/* =========================================================
   WorldMemArena — Academic light theme
   ========================================================= */
:root {
  --bg: #fbfcff;
  --bg-2: #f3f6fb;
  --bg-hero: #f6f8fd;
  --panel: #ffffff;
  --ink: #172033;
  --ink-2: #46506a;
  --muted: #78829b;
  --line: #e2e7f1;
  --line-2: #cbd4e4;
  --accent: #2557a7;
  --accent-2: #357abd;
  --accent-light: #eef5ff;
  --teal: #16837a;
  --rose: #bf496d;
  --amber: #b66a14;
  --green: #059669;
  --violet: #5d55a3;
  --grad: linear-gradient(115deg, #2557a7 0%, #357abd 52%, #16837a 100%);
  --grad-2: linear-gradient(135deg, #bf496d 0%, #2557a7 55%, #16837a 100%);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 18px rgba(30, 43, 70, 0.07);
  --shadow-hover: 0 8px 28px rgba(37, 87, 167, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: rgba(67,97,238,0.2); color: var(--ink); }

#bgCanvas {
  display: none;
}

/* ====================== NAV ====================== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
  transition: background .3s ease, box-shadow .3s ease;
}
.nav.scrolled {
  background: rgba(255,255,255,0.95);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 9px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px;
  width: 24px; height: 24px;
}
.brand-dot {
  display: block; border-radius: 3px;
  background: var(--accent);
}
.brand-dot:nth-child(2){ background: var(--teal); }
.brand-dot:nth-child(3){ background: var(--rose); }
.brand-dot:nth-child(4){ background: var(--amber); }
.brand-name {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; color: var(--ink);
}
.brand.small .brand-mark { width: 20px; height: 20px; }
.brand.small .brand-name { font-size: .96rem; }

.nav-links { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav-links a {
  padding: 7px 12px; border-radius: 8px;
  color: var(--ink-2); font-size: 0.9rem; font-weight: 600;
  transition: color .2s ease, background .2s ease;
}
.nav-links a:hover { color: var(--accent); background: var(--accent-light); }
.nav-cta {
  background: var(--accent) !important;
  color: #fff !important; padding: 8px 14px !important;
  border-radius: 8px; font-weight: 700;
  transition: transform .2s ease, box-shadow .2s ease;
}
.nav-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(67,97,238,0.28); }

/* ====================== HERO ====================== */
.hero {
  position: relative; isolation: isolate;
  padding: 78px 28px 30px;
  background: var(--bg-hero);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero-orb {
  display: none;
}
.hero-orb-a { width: 500px; height: 500px; background: var(--accent); top: -150px; left: -100px; }
.hero-orb-b { width: 450px; height: 450px; background: var(--teal); top: 60px; right: -120px; }
.hero-orb-c { width: 350px; height: 350px; background: var(--rose); bottom: -100px; left: 40%; opacity: 0.15; }
.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(37,87,167,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,87,167,0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 2;
  max-width: 1160px; margin: 0 auto;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border: 1px solid var(--line-2);
  border-radius: 999px; background: #fff;
  font-size: .76rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px rgba(67,97,238,0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1;} 50%{transform:scale(1.3);opacity:.5;} }

.hero-title {
  margin: 10px 0 6px;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: clamp(1.8rem, 4.2vw, 3.15rem);
  font-weight: 700; line-height: .98; letter-spacing: -.04em;
}
.hero-title .grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}
.hero-sub {
  display: block; margin-top: 6px;
  font-family: "Inter", sans-serif;
  font-size: clamp(0.88rem, 1.4vw, 1.14rem);
  font-weight: 500; letter-spacing: -.01em; color: var(--ink-2);
  line-height: 1.3;
}
.hero-lede {
  max-width: 720px;
  margin: 10px 0 14px;
  color: var(--ink-2);
  font-size: clamp(0.84rem, 1.1vw, .94rem);
}
.hero-lede b { color: var(--ink); }

.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 8px;
  font-family: "Inter", sans-serif; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); }
.btn.lg { height: 44px; padding: 0 20px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(67,97,238,0.25);
}
.btn-primary:hover { background: #3651d4; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(67,97,238,0.35); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-light:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; }

/* Teaser figure in hero */
.hero-teaser {
  margin: 16px auto 0;
  max-width: 660px;
  position: relative;
  z-index: 2;
}
.hero-teaser img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 6px;
}

/* authors */
.authors { margin-top: 10px; }
.author-row { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--ink); font-size: .82rem; font-weight: 600; max-width: 980px; }
.author-row sup { color: var(--accent); font-weight: 700; }
.affils { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .76rem; }
.affils sup { color: var(--accent); font-weight: 700; }

/* stat strip */
.stat-strip {
  position: relative; z-index: 3;
  max-width: 1100px; margin: 16px auto -20px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.stat-num {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.16rem, 1.9vw, 1.55rem);
  font-weight: 700; letter-spacing: -.02em; line-height: 1;
  color: var(--accent);
}
.stat-label { margin-top: 3px; color: var(--muted); font-size: .74rem; font-weight: 600; }

/* ====================== SECTIONS ====================== */
.section { position: relative; max-width: 1160px; margin: 0 auto; padding: 38px 28px 22px; }
.section-head { max-width: 820px; margin-bottom: 14px; }
.kicker {
  display: inline-block; font-size: .72rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
  padding: 4px 10px; border: 1px solid rgba(67,97,238,0.25);
  border-radius: 999px; background: var(--accent-light);
}
.kicker.light { color: var(--accent); border-color: rgba(67,97,238,0.3); background: rgba(67,97,238,0.08); }
h2 {
  margin: 8px 0 6px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.24rem, 2.1vw, 1.7rem);
  font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
  color: var(--ink);
}
.hl {
  background: var(--grad-2);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lede { color: var(--ink-2); font-size: .86rem; max-width: 700px; }
.muted { color: var(--muted); }

/* Overview cards */
.overview-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.o-card {
  position: relative;
  padding: 13px;
  background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .2s ease, box-shadow .2s ease;
}
.o-card::after { display: none; }
.o-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.o-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-light);
  color: var(--accent);
  margin-bottom: 8px;
}
.o-icon svg { width: 18px; height: 18px; }
.o-card h3 { margin: 0 0 3px; font-size: .88rem; font-weight: 700; }
.o-card p { margin: 0; color: var(--muted); font-size: .79rem; }

/* Loop */
.section-loop .loop-wrap {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  gap: 8px; align-items: stretch;
  margin: 10px 0 12px;
}
.loop-stage {
  position: relative;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px;
  background: #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.loop-stage:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.loop-num {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem; line-height: 1; font-weight: 700;
  color: var(--accent);
}
.loop-spade { position: absolute; right: 10px; top: 8px; color: var(--accent); opacity: .35; font-size: 1rem; }
.loop-stage h3 { margin: 3px 0 3px; font-size: .88rem; font-weight: 700; color: var(--ink); }
.loop-stage p { margin: 0; color: var(--muted); font-size: .76rem; }
.loop-arrow {
  align-self: center; width: 22px; height: 12px; position: relative;
}
.loop-arrow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--teal), transparent);
  transform: translateY(-50%);
}
.loop-arrow::after { display: none; }

.loop-figure {
  margin-top: 16px;
}
.loop-figure img {
  width: 100%;
  max-width: 500px;
  max-height: 300px;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 6px;
}

/* Benchmark */
.bench-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: stretch;
}
.bench-card {
  position: relative;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.bench-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.bench-a::before, .bench-b::before {
  content: ""; position: absolute; inset: -1px -1px auto -1px; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--grad);
}
.bench-b::before { background: var(--grad-2); }
.bench-tag {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-light); color: var(--accent);
  font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: 10px;
}
.bench-b .bench-tag { background: rgba(224,69,123,0.1); color: var(--rose); }
.bench-card h3 { margin: 0 0 5px; font-family: "Space Grotesk", sans-serif; font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; }
.bench-card > p { margin: 0 0 8px; color: var(--ink-2); font-size: .86rem; }
.bench-list { margin: 0 0 10px; padding: 0; list-style: none; color: var(--muted); font-size: .82rem; }
.bench-list li { padding: 5px 0; border-top: 1px solid var(--line); }
.bench-list li:first-child { border-top: 0; }
.bench-list b { color: var(--ink); font-weight: 700; }
.bench-foot { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .82rem; }
.bench-foot b { color: var(--accent); font-weight: 800; font-size: .95rem; }

.bench-cta {
  background: var(--accent-light);
  border-color: rgba(67,97,238,0.2);
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
}
.bench-cta h3 { font-family: "Space Grotesk", sans-serif; }
.bench-cta p { color: var(--ink-2); margin: 0; }

.pipeline-fig {
  margin: 16px 0 0;
}
.pipeline-fig img {
  width: 100%;
  max-width: 760px;
  max-height: 260px;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 6px;
}
.pipeline-fig figcaption {
  padding: 10px 16px;
  color: var(--muted); font-size: .86rem; text-align: center;
}

/* Findings */
.findings-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.finding {
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.finding:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.finding-num {
  font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: .75rem;
  color: var(--rose); letter-spacing: .1em;
}
.finding h3 { margin: 4px 0 4px; font-family: "Space Grotesk", sans-serif; font-size: .94rem; }
.finding p { margin: 0 0 8px; color: var(--muted); font-size: .82rem; }
.finding-bar { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.finding-bar span {
  display: block; height: 100%; width: var(--w, 50%);
  background: linear-gradient(90deg, var(--accent), var(--teal));
  animation: growBar 1s cubic-bezier(.2,.8,.2,1) both;
  transform-origin: left;
}
@keyframes growBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.figure-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-width: 900px;
  margin: 14px auto 0;
}
.fig-card {
  margin: 0;
  background: transparent;
  display: grid;
  grid-template-columns: minmax(260px, .95fr) minmax(220px, .55fr);
  gap: 16px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.fig-card:first-child { border-top: 0; }
.fig-card:hover { transform: none; }
.fig-card img {
  width: 100%;
  max-width: 430px;
  max-height: 210px;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 4px;
}
.fig-card:nth-child(2) img {
  max-width: 520px;
  max-height: 150px;
}
.fig-card figcaption {
  padding: 0;
  color: var(--muted);
  font-size: .82rem;
  text-align: left;
}
.fig-card figcaption b { color: var(--ink); }

/* CTA */
.section-cta { padding-bottom: 28px; }
.cta-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--accent-light);
  padding: 22px 26px;
}
.cta-glow {
  position: absolute; inset: -100px -100px auto auto;
  width: 350px; height: 350px; border-radius: 50%;
  background: radial-gradient(circle, rgba(67,97,238,0.15), transparent 60%);
  pointer-events: none;
}
.cta-body { position: relative; z-index: 1; max-width: 640px; }
.cta-body h2 { margin: 10px 0 8px; }
.cta-body p { color: var(--ink-2); font-size: .92rem; }
.cta-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 28px 16px;
  margin-top: 20px;
  background: var(--bg-2);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start;
}
.footer-inner p { margin: 6px 0 0; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--ink-2); font-size: .88rem; font-weight: 600; }
.footer-links a:hover { color: var(--accent); }
.footer-tail { max-width: 1100px; margin: 14px auto 0; font-size: .78rem; }

/* reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ====================== RESPONSIVE ====================== */
@media (max-width: 1080px) {
  .overview-cards { grid-template-columns: repeat(2, 1fr); }
  .bench-grid { grid-template-columns: 1fr 1fr; }
  .bench-cta { grid-column: span 2; }
  .findings-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-strip { grid-template-columns: repeat(3, 1fr); }
  .section-loop .loop-wrap { grid-template-columns: 1fr 1fr; }
  .loop-arrow { display: none; }
}
@media (max-width: 720px) {
  .nav-inner { padding: 10px 18px; }
  .hero { padding: 72px 18px 28px; }
  .btn { height: 38px; padding: 0 12px; font-size: .84rem; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .overview-cards, .bench-grid, .findings-grid, .section-loop .loop-wrap { grid-template-columns: 1fr; }
  .bench-cta { grid-column: auto; }
  .cta-card { padding: 20px 18px; }
  .footer-inner { grid-template-columns: 1fr; }
  .section { padding: 32px 18px 20px; }
  .fig-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .fig-card figcaption { text-align: center; }
}

/* ====================== DATA EXPLORER ====================== */
.exp-hero {
  position: relative; isolation: isolate;
  padding: 76px 28px 28px;
  background: var(--bg-hero);
  overflow: hidden;
}
.exp-hero .hero-orb-a { width: 400px; height: 400px; top: -80px; left: -60px; }
.exp-hero .hero-orb-b { width: 400px; height: 400px; right: -120px; }
.exp-hero-inner { position: relative; z-index: 2; max-width: 1200px; margin: 0 auto; }
.exp-hero h1 {
  margin: 10px 0 6px; max-width: 900px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.45rem, 3.1vw, 2.35rem);
  line-height: 1.05; letter-spacing: -.04em;
}
.exp-hero h1 .grad { background: var(--grad-2); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.exp-hero p.lede { max-width: 700px; }

.exp-wrap { max-width: 1200px; margin: 0 auto; padding: 18px 28px 42px; position: relative; z-index: 2; }

.exp-toolbar {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  margin-bottom: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: #fff; color: var(--ink-2);
  padding: 7px 12px; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: .84rem;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.chip:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(67,97,238,0.25);
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.active .chip-dot { background: #fff; }

.metric-toggle {
  display: inline-flex; padding: 3px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px;
}
.metric-toggle button {
  appearance: none; border: 0; cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .82rem;
  transition: background .15s ease, color .15s ease;
}
.metric-toggle button.active {
  background: #fff; color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.exp-grid {
  display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(0, 2fr); gap: 14px;
  align-items: stretch;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s ease;
}
.panel:hover { box-shadow: var(--shadow); }
.panel.pad { padding: 14px; }
.panel-head {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h2 { margin: 0; font-size: .98rem; font-family: "Space Grotesk", sans-serif; }
.panel-head p { margin: 0; color: var(--muted); font-size: .8rem; }

.domain-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.domain-title h2 {
  margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 1.3rem; letter-spacing: -.02em;
}
.domain-pill {
  padding: 4px 8px; border-radius: 999px;
  color: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.domain-blurb { color: var(--ink-2); margin: 0 0 10px; font-size: .84rem; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  background: var(--bg-2);
}
.mini strong {
  display: block; font-family: "Space Grotesk", sans-serif;
  font-size: 1.18rem; font-weight: 700; letter-spacing: -.02em;
  color: var(--accent);
}
.mini span { color: var(--muted); font-size: .76rem; font-weight: 600; }

.caption { margin: 10px 0 0; color: var(--muted); font-size: .8rem; }

.chart-host {
  position: relative; padding: 10px 14px;
  min-height: 280px;
}
.chart-host canvas { width: 100% !important; max-width: 100%; }

.matrix-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 12px; margin-top: 12px;
}
.cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cell {
  border-radius: 10px; padding: 10px; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 76px;
  transition: transform .2s ease;
}
.cell:hover { transform: translateY(-2px); }
.cell b { font-size: 1.3rem; font-family: "Space Grotesk", sans-serif; }
.cell span { font-size: .76rem; opacity: .92; font-weight: 700; }
.cell .meta { font-size: .68rem; opacity: .8; }

.sub-domain-wrap { padding: 10px 14px; }
.sub-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 14px; align-items: center; }
.legend { display: grid; gap: 6px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: .84rem; }
.legend-item .left { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-item .val { color: var(--ink); font-family: "JetBrains Mono", monospace; font-size: .78rem; font-weight: 700; }

.viz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.viz-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.viz-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.viz-card .thumb {
  background: #fff;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
}
.viz-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  transition: transform .4s ease;
}
.viz-card:hover .thumb img { transform: scale(1.02); }
.viz-card .body { padding: 8px 12px; }
.viz-card h3 { margin: 0 0 3px; font-size: .92rem; font-family: "Space Grotesk", sans-serif; }
.viz-card p { margin: 0; color: var(--muted); font-size: .8rem; }

.profile-row {
  display: grid; grid-template-columns: 80px 1fr 42px; gap: 8px; align-items: center;
  font-size: .82rem;
}
.profile-row + .profile-row { margin-top: 6px; }
.profile-label { color: var(--ink-2); font-weight: 600; }
.profile-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.profile-fill { height: 100%; border-radius: 999px; transform-origin: left; animation: growBar .8s cubic-bezier(.2,.8,.2,1) both; }
.profile-val { color: var(--ink); text-align: right; font-family: "JetBrains Mono", monospace; font-size: .8rem; }

.heatmap-grid {
  display: grid; grid-template-columns: 140px repeat(4, 1fr); gap: 5px;
  padding: 14px 16px;
}
.heatmap-grid-wide {
  grid-template-columns: 140px repeat(11, minmax(0, 1fr));
}
.heat-head, .heat-row-label {
  font-size: .74rem; color: var(--muted); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.heat-row-label { justify-content: flex-start; color: var(--ink-2); }
.heat-cell {
  height: 34px; border-radius: 5px;
  display: grid; place-items: center;
  font-size: .74rem; font-weight: 700; color: #fff;
  font-family: "JetBrains Mono", monospace;
  transition: transform .15s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.heat-cell:hover { transform: scale(1.06); z-index: 1; }

.qa-type-legend {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px;
}
.qa-type-legend .legend-item { font-size: .78rem; }
.qa-type-legend .legend-item .left b { color: var(--ink); margin-right: 4px; }

@media (max-width: 720px) {
  .qa-type-legend { grid-template-columns: 1fr; }
}

.dgroup-label {
  display: inline-block; padding: 2px 7px;
  background: var(--accent-light); border-radius: 5px;
  font-family: "JetBrains Mono", monospace; font-size: .68rem; color: var(--accent); font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}

@media (max-width: 1080px) {
  .exp-grid { grid-template-columns: 1fr; }
  .sub-grid { grid-template-columns: 1fr; }
  .matrix-row { grid-template-columns: 1fr; }
  .cells { grid-template-columns: repeat(2, 1fr); }
  .heatmap-grid-wide { grid-template-columns: 110px repeat(11, minmax(28px, 1fr)); }
  .heatmap-grid-wide .heat-cell { font-size: .68rem; }
}
@media (max-width: 720px) {
  .exp-toolbar { grid-template-columns: 1fr; }
  .cells { grid-template-columns: 1fr 1fr; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .heatmap-grid-wide { font-size: .62rem; }
}

/* ====================================================================
   Case Viewer (Data Browser)
   ==================================================================== */

/* ---- 3-tier navigation (Domain → Subcategory → Sample) ---- */
.browser-nav {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.nav-tier {
  display: grid; grid-template-columns: 110px 1fr; gap: 16px;
  align-items: flex-start;
}
.nav-tier-label {
  font-size: .72rem; letter-spacing: .14em; font-weight: 800;
  color: var(--muted); text-transform: uppercase;
  padding-top: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-tier-label .small {
  font-size: .68rem; letter-spacing: .04em; text-transform: none;
  font-weight: 600; color: var(--muted);
}

.dom-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.dom-tab {
  appearance: none; cursor: pointer; font: inherit; font-weight: 700;
  background: #fff; border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: .88rem;
  transition: transform .15s ease, border-color .15s ease;
}
.dom-tab:hover { transform: translateY(-1px); border-color: var(--accent); }
.dom-tab-dot { width: 8px; height: 8px; border-radius: 50%; }
.dom-tab-count {
  font-family: "JetBrains Mono", monospace; font-size: .7rem;
  font-weight: 700; opacity: .7;
}
.dom-tab.active .dom-tab-count { opacity: .85; }

.subcat-strip {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.subcat-pill {
  appearance: none; cursor: pointer; font: inherit; font-weight: 700;
  background: #fff; border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px;
  font-size: .82rem; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform .15s ease, border-color .15s ease;
}
.subcat-pill:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.subcat-pill-count {
  background: var(--bg-2); color: var(--muted);
  font-family: "JetBrains Mono", monospace; font-size: .68rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
.subcat-pill.active .subcat-pill-count { background: rgba(255,255,255,0.7); }

.sample-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.sample-card {
  appearance: none; cursor: pointer; font: inherit; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.sample-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.sample-card.active {
  background: linear-gradient(180deg, #fff, #f7faff);
}
.sample-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sample-id {
  font-family: "JetBrains Mono", monospace; font-weight: 700;
  font-size: .92rem; color: var(--ink);
}
.sample-tag {
  font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 7px; border-radius: 4px; color: #fff;
}
.sample-blurb {
  margin: 0; font-size: .82rem; color: var(--ink-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sample-stats {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: .72rem; color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  border-top: 1px dashed var(--line); padding-top: 6px;
}
.sample-stats b { color: var(--ink); font-weight: 700; }

.viewer-empty {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 30px; text-align: center; color: var(--muted);
}
.viewer-empty h3 { margin: 0 0 6px; color: var(--ink); font-family: "Space Grotesk", sans-serif; }

.case-viewer {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden;
}
.case-head {
  display: grid; grid-template-columns: 1fr auto; gap: 16px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.case-title-row { display: flex; align-items: center; gap: 10px; }
.case-title {
  margin: 0; font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem; letter-spacing: -.02em;
}
.case-title code {
  font-family: "JetBrains Mono", monospace; font-size: 1rem;
  color: var(--ink);
}
.case-blurb { margin: 8px 0 0; color: var(--ink-2); font-size: .9rem; max-width: 720px; }
.case-stats { display: flex; gap: 8px; align-items: stretch; }
.case-mini {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; min-width: 64px; text-align: center;
}
.case-mini strong {
  display: block; font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem; color: var(--accent); font-weight: 800;
}
.case-mini span { color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.sess-nav {
  padding: 10px 18px; background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
}
.sess-switch {
  display: inline-flex; align-items: stretch; gap: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; overflow: hidden;
}
.sess-arrow {
  appearance: none; cursor: pointer; background: #fff; border: 0;
  padding: 7px 10px; color: var(--ink-2);
  display: inline-grid; place-items: center;
  transition: background .15s ease, color .15s ease;
}
.sess-arrow:hover:not(:disabled) { background: var(--accent-light); color: var(--accent); }
.sess-arrow:disabled { color: var(--line-2); cursor: not-allowed; }
.sess-select {
  appearance: none; -webkit-appearance: none;
  border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  background: #fff; cursor: pointer;
  font: inherit; font-weight: 700; font-size: .84rem;
  color: var(--ink); padding: 6px 28px 6px 12px;
  font-family: "JetBrains Mono", monospace;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378829b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
  min-width: 280px; max-width: 480px;
}
.sess-select:hover { background-color: var(--accent-light); }
.sess-meta {
  color: var(--ink-2); font-size: .85rem;
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.sess-now b { font-family: "JetBrains Mono", monospace; color: var(--ink); }
.sess-now-dot { color: var(--line-2); }

.case-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 0;
}
.case-left { padding: 18px; border-right: 1px solid var(--line); min-width: 0; }
.case-right { padding: 16px 14px; background: #fafbff; }

/* ---- Step images strip ---- */
.step-imgs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 18px;
}
.step-imgs.single { grid-template-columns: 1fr; }
.step-img {
  margin: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.step-img img { width: 100%; height: auto; display: block; }
.step-img figcaption {
  padding: 8px 10px; font-size: .76rem; color: var(--ink-2);
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
}
.step-img .step-tag {
  background: var(--accent); color: #fff;
  padding: 1px 7px; border-radius: 5px;
  font-family: "JetBrains Mono", monospace; font-size: .68rem; font-weight: 700;
}
.step-img .img-id {
  font-family: "JetBrains Mono", monospace; font-size: .72rem; color: var(--muted);
}
.step-img .img-cap { color: var(--ink-2); flex: 1; min-width: 100%; line-height: 1.4; }

/* ---- Step blocks (Obs / Act / Action) ---- */
.step-block {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}
.step-hdr { margin-bottom: 8px; }
.step-num {
  font-family: "Space Grotesk", sans-serif; font-weight: 800;
  font-size: .92rem; color: var(--ink);
  border-left: 3px solid var(--accent); padding-left: 8px;
}
.step-obs, .step-act, .step-action {
  display: grid; grid-template-columns: 70px 1fr; gap: 12px;
  align-items: baseline; margin-top: 8px;
  padding-top: 8px; border-top: 1px dashed var(--line);
}
.step-label {
  font-family: "JetBrains Mono", monospace; font-size: .72rem;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.step-body { font-size: .86rem; color: var(--ink); line-height: 1.55; }
.step-body code {
  background: var(--bg-2); padding: 2px 6px; border-radius: 4px;
  font-family: "JetBrains Mono", monospace; font-size: .82rem; color: var(--accent);
}
.obs-row { margin-bottom: 2px; }
.obs-row b { color: var(--ink-2); }

/* ---- Chat view (lifelong) ---- */
.chat-stream { display: flex; flex-direction: column; gap: 14px; }
.chat-turn { display: flex; flex-direction: column; gap: 4px; }
.chat-turn.user { align-items: flex-start; }
.chat-turn.asst { align-items: flex-start; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: .74rem; }
.chat-role {
  font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 7px; border-radius: 4px;
}
.chat-turn.user .chat-role { background: var(--accent-light); color: var(--accent); }
.chat-turn.asst .chat-role { background: #ecfaf6; color: var(--teal); }
.chat-time {
  font-family: "JetBrains Mono", monospace; color: var(--muted); font-size: .7rem;
}
.chat-bubble {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; max-width: 100%;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-turn.user .chat-bubble { border-color: #d9e4f7; background: #f8fbff; }
.chat-turn.asst .chat-bubble { border-color: #dceee8; background: #f6fcfa; }
.chat-text { font-size: .88rem; color: var(--ink); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-img {
  margin: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; overflow: hidden;
}
.chat-img img { width: 100%; height: auto; max-height: 320px; object-fit: cover; display: block; }
.chat-img figcaption {
  padding: 6px 9px; font-size: .74rem; color: var(--ink-2); border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chat-img .img-id {
  font-family: "JetBrains Mono", monospace; font-size: .7rem; color: var(--muted); font-weight: 700;
}

/* ---- Memory points sidebar ---- */
.mp-head {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.mp-title {
  font-family: "Space Grotesk", sans-serif; font-weight: 800;
  font-size: 1rem; color: var(--ink);
}
.mp-sub {
  font-size: .74rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.ev-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  background: #ffd966;
}
.ev-inline {
  background: #fff3c4; padding: 0 4px; border-radius: 3px;
  color: #8b6b1b; font-weight: 700;
}
.mp-list { display: flex; flex-direction: column; gap: 8px; max-height: 980px; overflow-y: auto; padding-right: 4px; }
.mp-list::-webkit-scrollbar { width: 6px; }
.mp-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.mp-card {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.mp-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,43,70,0.06); }
.mp-card.evidence {
  background: #fffbe8;
  border-color: #f0d98a;
  box-shadow: 0 1px 0 rgba(240,217,138,0.4);
}
.mp-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: .76rem; margin-bottom: 4px;
}
.mp-icon { font-size: .96rem; }
.mp-id {
  font-family: "JetBrains Mono", monospace; font-weight: 700; color: var(--ink);
}
.mp-imp {
  font-family: "JetBrains Mono", monospace; font-size: .72rem;
  color: var(--muted); font-weight: 700;
}
.mp-ev-tag {
  background: #ffd966; color: #6b521b;
  padding: 1px 6px; border-radius: 4px;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
.mp-upd-tag {
  padding: 1px 6px; border-radius: 4px;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
.mp-content { font-size: .82rem; line-height: 1.5; color: var(--ink); }
.mp-meta {
  font-size: .68rem; margin-top: 4px;
  font-family: "JetBrains Mono", monospace; text-transform: lowercase;
}
.mp-empty { padding: 14px; text-align: center; font-size: .82rem; }

/* ---- Sample QA ---- */
.case-qa { margin-top: 22px; }
.qa-head { margin-bottom: 12px; }
.qa-head h2 { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 1.15rem; }
.qa-head .small { font-size: .8rem; margin-top: 4px; }

.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qa-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px;
}
.qa-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.qa-tag {
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 5px;
  background: var(--bg-2); color: var(--ink-2);
}
.qa-tag.muted { background: transparent; color: var(--muted); font-weight: 700; }
.qa-tag.muted code { font-family: "JetBrains Mono", monospace; color: var(--ink-2); }
.qa-tag.diff-easy { background: #dff7e9; color: var(--green); }
.qa-tag.diff-medium { background: #fdeed1; color: var(--amber); }
.qa-tag.diff-hard { background: #fae0e5; color: var(--rose); }

.qa-q, .qa-a { font-size: .9rem; line-height: 1.55; margin-bottom: 8px; }
.qa-q b, .qa-a b { font-family: "Space Grotesk", sans-serif; }
.qa-q b { color: var(--accent); }
.qa-a b { color: var(--teal); }
.qa-ev {
  border-top: 1px dashed var(--line); padding-top: 8px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: .78rem;
}
.ev-chip {
  font-family: "JetBrains Mono", monospace; font-size: .72rem; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
}
.ev-chip.mp { background: #fff3c4; color: #8b6b1b; }
.ev-chip.img { background: var(--accent-light); color: var(--accent); }

/* ---- About section ---- */
.about-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.about-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px;
}
.about-card h3 { margin: 0 0 8px; font-family: "Space Grotesk", sans-serif; font-size: 1rem; }
.about-card ul { margin: 0; padding-left: 18px; }
.about-card li { font-size: .85rem; color: var(--ink-2); line-height: 1.6; margin-bottom: 4px; }
.about-card code {
  background: var(--bg-2); padding: 1px 5px; border-radius: 3px;
  font-family: "JetBrains Mono", monospace; font-size: .8rem;
}

/* ---- Subcat label in case head ---- */
.subcat-label { font-size: .9rem; }

/* ---- Responsive ---- */
@media (max-width: 1080px) {
  .case-grid { grid-template-columns: 1fr; }
  .case-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-head { grid-template-columns: 1fr; }
  .case-stats { flex-wrap: wrap; }
  .qa-grid { grid-template-columns: 1fr; }
  .about-row { grid-template-columns: 1fr; }
  .nav-tier { grid-template-columns: 1fr; gap: 6px; }
  .nav-tier-label { padding-top: 0; }
  .sample-cards { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .step-imgs { grid-template-columns: 1fr; }
  .step-obs, .step-act, .step-action { grid-template-columns: 1fr; }
  .step-label { font-size: .68rem; }
  .case-stats .case-mini { min-width: 0; flex: 1 1 calc(50% - 4px); }
}
