/* ============================================================
   UNCODE — project page styles
   ============================================================ */
:root {
  --ink:        #1d2230;
  --ink-soft:   #515b71;
  --ink-faint:  #6b7385;
  --line:       #e6e8ef;
  --bg:         #ffffff;
  --bg-alt:     #f6f7fb;
  --bg-tint:    #f1f0fb;

  --primary:    #4f46e5;   /* indigo */
  --primary-d:  #4338ca;
  --violet:     #7c3aed;
  --rose:       #e11d6f;
  --rose-bg:    #fdf0f5;
  --amber:      #a85d00;
  --amber-bg:   #fdf6e7;

  --uncode-bg:  #efeafe;   /* lavender row shade */
  --best:       #3b2f9e;

  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 1px 2px rgba(20,24,40,.05), 0 8px 30px rgba(20,24,40,.06);
  --shadow-lg:  0 20px 60px rgba(30,24,80,.16);
  --maxw:       980px;
  --font:       'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --serif:      'Newsreader', Georgia, 'Times New Roman', 'Noto Sans SC', serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 820px; }

/* ---------------- NAV ---------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.nav-brand:hover { text-decoration: none; }
.brand-badge {
  width: 30px; height: 30px; display: block; flex: none;
}
.brand-badge svg { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 18px; }

/* small-caps brand wordmark: "Uncode" -> Uɴᴄᴏᴅᴇ */
.uncode { font-variant: small-caps; font-feature-settings: "smcp" 1; letter-spacing: .015em; }
.nav-links { display: flex; gap: 6px; margin-left: auto; }
.nav-links a {
  color: var(--ink-soft); font-weight: 500; font-size: 14.5px;
  padding: 7px 12px; border-radius: 8px; transition: .15s;
}
.nav-links a:hover { color: var(--ink); background: var(--bg-alt); text-decoration: none; }
.nav-links a.active { color: var(--primary); background: var(--bg-tint); }
.lang-toggle {
  flex: none; margin-left: 12px; cursor: pointer; line-height: 1;
  font-family: var(--font); font-weight: 700; font-size: 13px; letter-spacing: .01em;
  color: var(--ink-soft); background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  transition: .15s;
}
.lang-toggle:hover { color: var(--primary); border-color: #d3d6e2; background: var(--bg-tint); }
.lang-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; transition: .2s; }

/* ---------------- HERO ---------------- */
.hero { position: relative; overflow: hidden; padding: 64px 0 46px; text-align: center; background: var(--bg); }
.hero-glow {
  position: absolute; inset: -40% 0 auto 0; height: 540px; z-index: 0; pointer-events: none;
  background:
    radial-gradient(600px 300px at 30% 20%, rgba(124,58,237,.14), transparent 60%),
    radial-gradient(620px 320px at 72% 8%, rgba(79,70,229,.16), transparent 62%);
}
.hero .container { position: relative; z-index: 1; }
.venue-badge {
  display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .02em;
  color: var(--primary-d); background: var(--bg-tint);
  border: 1px solid #ddd8fb; padding: 6px 14px; border-radius: 999px; margin-bottom: 20px;
}
.hero-title {
  font-size: clamp(25px, 4vw, 39px); line-height: 1.12; letter-spacing: -.022em;
  font-weight: 800; margin: 0 auto 18px; max-width: 860px; color: var(--ink);
}
.hero-subtitle {
  font-size: clamp(16px, 2.2vw, 19px); color: var(--ink-soft);
  max-width: 760px; margin: 0 auto 26px;
}
.hero-subtitle strong { color: var(--ink); }

.authors { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 0 auto 8px; max-width: 820px; }
.author { font-size: 17px; font-weight: 600; color: var(--ink); }
.author a { color: var(--ink); text-decoration: none; transition: color .15s; }
.author a:hover { color: var(--primary); text-decoration: underline; }
.author sup { color: var(--primary); font-weight: 700; }
.affils { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; color: var(--ink-soft); font-size: 14.5px; margin-bottom: 4px; }
.affils sup { color: var(--primary); }
.corr { color: var(--ink-faint); font-size: 13px; margin-bottom: 26px; }
.corr sup { color: var(--primary); }

.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 16px; transition: .16s; box-shadow: var(--shadow);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); border-color: #d3d6e2; box-shadow: var(--shadow-lg); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff; border-color: transparent; }
.btn-primary:hover { color: #fff; }

/* ---------------- SECTIONS ---------------- */
.section { padding: 64px 0; }
.section-tight { padding: 30px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mt { margin-top: 56px; }

.kicker {
  font-size: clamp(22px, 3vw, 30px); font-weight: 800; letter-spacing: -.02em;
  margin: 0 0 14px; color: var(--ink);
}
.kicker.center { text-align: left; }
.kicker::after {
  content: ""; display: block; width: 46px; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--violet)); margin: 14px 0 0;
}
.lead { font-size: 17px; color: var(--ink-soft); }
.lead.center { text-align: left; margin: 0 0 30px; }
.subhead { font-size: 18.5px; font-weight: 700; margin: 42px 0 16px; color: var(--ink); }
.subhead:first-of-type { margin-top: 8px; }

/* ---------------- STATS ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 20px; text-align: center; box-shadow: var(--shadow);
}
.stat-num {
  font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: var(--primary); line-height: 1.1;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .stat-num { color: transparent; }
}
.stat-num .u { -webkit-text-fill-color: var(--violet); }
.stat-num .approx { -webkit-text-fill-color: var(--ink-faint); font-weight: 600; }
.stat-cap { margin-top: 10px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }

/* ---------------- FIGURES ---------------- */
.figure { margin: 0; }
.figure img {
  width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; box-shadow: var(--shadow); cursor: zoom-in;
}
.figure.inset img { box-shadow: none; }
.figure figcaption { margin-top: 14px; font-size: 14.5px; color: var(--ink-soft); text-align: left; line-height: 1.5; }
.figure.narrow-fig { max-width: 720px; margin: 0 auto; }
#trajectory .figure { max-width: 720px; margin: 0 auto; }
.teaser-fig { max-width: 680px; margin: 0 auto 32px; }
.narrow .figure img { box-shadow: var(--shadow-lg); }
.hl-rose { color: var(--rose); font-weight: 600; }
.hl-amber { color: var(--amber); font-weight: 600; }

/* ---------------- BIAS CARDS ---------------- */
.bias-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.bias-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 24px; box-shadow: var(--shadow); border-top: 4px solid var(--line);
  display: flex; flex-direction: column;
}
.bias-card.rose  { border-top-color: var(--rose); }
.bias-card.amber { border-top-color: #e8a33d; }
.bias-tag { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.bias-card.rose  .bias-tag { color: var(--rose); }
.bias-card.amber .bias-tag { color: var(--amber); }
.bias-card h3 { font-size: 21px; font-weight: 800; margin: 4px 0 10px; letter-spacing: -.01em; }
.bias-card p { color: var(--ink-soft); font-size: 15.5px; margin: 0 0 18px; }
.figure.inset { background: var(--bg-alt); border-radius: var(--radius-sm); padding: 14px; margin-top: auto; }
.figure.inset img { border-radius: 8px; }
.figure.inset figcaption { font-size: 13.5px; margin-top: 10px; }

/* ---------------- METHOD ---------------- */
.eq-hero {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px; margin: 6px auto 30px; max-width: 760px;
  overflow-x: auto;
}
.eq-hero mjx-container { margin: 0 !important; }
.prior-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.prior-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.prior-card h3 { font-size: 18px; font-weight: 700; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.prior-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.prior-dot.indigo { background: var(--primary); }
.prior-dot.violet { background: var(--violet); }
.prior-card .eq { overflow-x: auto; margin: 4px 0 8px; }
.prior-card p { color: var(--ink-soft); font-size: 15px; margin: 6px 0 0; }

/* ---------------- TABLES ---------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; }
.rtab { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 14px; }
.rtab th, .rtab td { padding: 9px 10px; text-align: center; white-space: nowrap; }
.rtab thead th {
  position: sticky; top: 0; background: #fbfbfe; color: var(--ink);
  font-weight: 700; font-size: 13px; border-bottom: 2px solid var(--line);
}
.rtab .lcol { text-align: left; font-weight: 600; color: var(--ink); position: sticky; left: 0; background: #fff; }
.rtab thead .lcol { background: #fbfbfe; z-index: 2; }
.rtab tbody tr { border-bottom: 1px solid #f0f1f6; }
.rtab td.avg { font-weight: 700; background: #fafaff; }
.rtab th.avg { background: #f4f3fc; }
.rtab td.best { color: var(--best); font-weight: 800; }
.rtab .grouprow td {
  text-align: left; font-style: italic; font-weight: 700; color: var(--ink-soft);
  background: var(--bg-alt); font-size: 12.5px; letter-spacing: .02em; padding: 7px 12px;
}
.rtab .uncode-row td { background: var(--uncode-bg); }
.rtab .uncode-row td.lcol { background: #e7e0fd; font-weight: 800; color: var(--primary-d); }
.rtab .uncode-row td.avg { background: #e3dcfb; }
.rtab .uncode-row td.best { color: var(--primary-d); }
.ref-tag { font-style: normal; font-weight: 600; font-size: 11px; color: var(--ink-faint); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; margin-left: 8px; }
.rtab .sp { color: var(--violet); font-weight: 700; }
.rtab.compact { min-width: 760px; }

.tnote { font-size: 13.5px; color: var(--ink-soft); margin: 12px 2px 0; }
.chip { display: inline-block; font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 6px; }
.best-chip { color: var(--best); background: #efedfb; }
.uncode-chip { color: var(--primary-d); background: var(--uncode-bg); }

/* ---------------- TAKEAWAYS ---------------- */
.takeaways { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.takeaways li {
  display: flex; gap: 16px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.takeaways li div { color: var(--ink-soft); font-size: 15.5px; }
.takeaways li strong { color: var(--ink); }
.tk-num {
  flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), var(--violet)); font-size: 15px;
}

/* ---------------- ABSTRACT ---------------- */
.abstract {
  font-family: var(--serif); font-size: 19px; line-height: 1.7; color: #2b3142;
  border-left: 3px solid var(--primary); padding: 2px 0 2px 24px;
}
.abstract strong { font-family: var(--font); font-weight: 600; color: var(--ink); }

/* ---------------- POSTER ---------------- */
.poster-fig img { box-shadow: var(--shadow-lg); }
.poster-fig a { display: block; }

/* ---------------- BIBTEX ---------------- */
.bib-wrap { position: relative; }
.bib-wrap pre {
  background: #1b1f2e; color: #e7e9f3; border-radius: var(--radius);
  padding: 22px 22px; overflow-x: auto; font-size: 13.5px; line-height: 1.6;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; margin: 0;
  box-shadow: var(--shadow);
}
.copy-btn {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.copy-btn:hover { background: rgba(255,255,255,.2); }
.copy-btn.done { background: #2ecc71; border-color: #2ecc71; }

/* ---------------- FOOTER ---------------- */
.footer { padding: 44px 0 56px; text-align: left; border-top: 1px solid var(--line); background: var(--bg-alt); }
.foot-links { font-weight: 600; color: var(--ink-soft); margin: 0 0 14px; }
.foot-links a { color: var(--ink-soft); }
.foot-meta { color: var(--ink-soft); font-size: 14px; margin: 0 0 10px; }
.foot-fine { color: #646b7d; font-size: 12.5px; margin: 0; }

/* ---------------- LIGHTBOX ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(13,15,24,.9); padding: 4vh 4vw; cursor: zoom-out;
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.5); cursor: zoom-out; }

/* ---------------- REVEAL ANIM ---------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .bias-grid, .prior-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .nav-links {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; gap: 2px; background: #fff; border-bottom: 1px solid var(--line);
    padding: 8px 16px 14px; box-shadow: var(--shadow); display: none;
    max-height: calc(100vh - 60px); overflow-y: auto; overscroll-behavior: contain;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 12px; }
  .lang-toggle { margin-left: auto; margin-right: 4px; }
  .nav-toggle { display: block; }
}
@media (max-width: 680px) {
  .hero { padding: 44px 0 36px; }
  .section { padding: 48px 0; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .abstract { font-size: 17px; padding-left: 18px; }
  .author { font-size: 15.5px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}

/* ---------------- SKIP LINK (a11y) ---------------- */
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 0 0 10px 10px; transition: top .18s ease;
}
.skip-link:focus { top: 0; text-decoration: none; outline: 2px solid #fff; outline-offset: 2px; }

/* ---------------- BACK TO TOP ---------------- */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px); box-shadow: var(--shadow-lg);
  display: grid; place-items: center; color: var(--primary);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { border-color: #d3d6e2; color: var(--primary-d); }
.to-top svg { width: 20px; height: 20px; }
@media (max-width: 680px) { .to-top { right: 14px; bottom: 14px; } }
@media (prefers-reduced-motion: reduce) { .to-top { transition: opacity .2s ease; transform: none; } }

/* ---------------- PRINT ---------------- */
@media print {
  .nav, .to-top, .skip-link, .copy-btn, .hero-glow { display: none !important; }
  .nav { position: static; }
  html { scroll-behavior: auto; }
  body { color: #000; }
  .section, .hero { padding: 18px 0; }
  .section-alt { background: #fff !important; border: 0; }
  .hero-links, .lightbox { display: none !important; }
  .stat, .bias-card, .prior-card, .eq-hero, .takeaways li, .table-scroll, .figure img {
    box-shadow: none !important; break-inside: avoid;
  }
  .figure, .bias-card, .prior-card, table { break-inside: avoid; }
  a[href]:not(.btn)::after { content: ""; }
  .bib-wrap pre { background: #f4f4f7 !important; color: #1b1f2e !important; border: 1px solid var(--line); }
}
