/* GLEIPNIR · BIFROST — site styles
   Tokens first; light and dark are each chosen, not flipped. */

:root {
  color-scheme: light;
  --page: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --glass: rgba(255, 255, 255, 0.72);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #7a7873;
  --line: rgba(11, 11, 11, 0.09);
  --line-2: rgba(11, 11, 11, 0.16);
  --grid: #e7e6e0;
  --axis: #c3c2b7;
  --accent: #4a3aa7;
  --accent-ink: #3b2d8f;
  --accent-soft: rgba(74, 58, 167, 0.09);
  --aurora-1: #4a3aa7;
  --aurora-2: #2a78d6;
  --aurora-3: #1baf7a;
  --good: #0a7d0a;
  --bad: #c43434;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 32px rgba(20, 18, 40, 0.06);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.05), 0 24px 64px rgba(20, 18, 40, 0.10);
  /* chart series — validated categorical slots (light surface) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --band: rgba(42, 120, 214, 0.10);
  --code-bg: #111118;
  --code-ink: #e6e5f0;
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 1180px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0b0e;
    --surface: #141418;
    --surface-2: #1b1b21;
    --glass: rgba(16, 16, 20, 0.66);
    --ink: #f4f4f6;
    --ink-2: #c3c2cc;
    --ink-3: #8d8c97;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.16);
    --grid: #26262c;
    --axis: #3a3a42;
    --accent: #9085e9;
    --accent-ink: #b3abf2;
    --accent-soft: rgba(144, 133, 233, 0.12);
    --aurora-1: #9085e9;
    --aurora-2: #3987e5;
    --aurora-3: #199e70;
    --good: #2fbf4a;
    --bad: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 64px rgba(0, 0, 0, 0.5);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --band: rgba(57, 135, 229, 0.20);
    --code-bg: #0e0e13;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0e;
  --surface: #141418;
  --surface-2: #1b1b21;
  --glass: rgba(16, 16, 20, 0.66);
  --ink: #f4f4f6;
  --ink-2: #c3c2cc;
  --ink-3: #8d8c97;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --grid: #26262c;
  --axis: #3a3a42;
  --accent: #9085e9;
  --accent-ink: #b3abf2;
  --accent-soft: rgba(144, 133, 233, 0.12);
  --aurora-1: #9085e9;
  --aurora-2: #3987e5;
  --aurora-3: #199e70;
  --good: #2fbf4a;
  --bad: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 64px rgba(0, 0, 0, 0.5);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --band: rgba(57, 135, 229, 0.20);
  --code-bg: #0e0e13;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code {
  font-size: .86em; padding: .12em .4em; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* ------------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  background: var(--glass);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  color: var(--ink-2); font-size: 14px; font-weight: 500; padding: 8px 12px; border-radius: 999px;
  transition: color .2s, background-color .2s;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--ink); background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: transform .2s, border-color .2s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
.menu-btn { display: none; }
@media (max-width: 1120px) {
  .menu-btn { display: inline-grid; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
    display: none; box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; border-radius: 10px; }
  .nav .wrap { gap: 12px; }
  .nav-actions { margin-left: auto; }
}
.nav-actions { display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ hero */
.hero { position: relative; padding: 112px 0 88px; overflow: hidden; isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: -30% -10% auto -10%; height: 130%; z-index: -2;
  background:
    radial-gradient(40% 50% at 18% 30%, color-mix(in srgb, var(--aurora-1) 22%, transparent), transparent 70%),
    radial-gradient(35% 45% at 82% 20%, color-mix(in srgb, var(--aurora-2) 20%, transparent), transparent 70%),
    radial-gradient(30% 40% at 60% 85%, color-mix(in srgb, var(--aurora-3) 16%, transparent), transparent 70%);
  filter: blur(8px);
  animation: drift 18s ease-in-out infinite alternate;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
}
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(2%, 3%, 0) scale(1.06); } }

.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; gap: 40px; } .hero { padding: 72px 0 56px; } }
.notfound { min-height: 64vh; display: flex; align-items: center; }
.notfound h1 { margin: 18px 0 14px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--glass);
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 20%, transparent); }
h1 {
  font-size: clamp(44px, 7.2vw, 88px); line-height: .98; letter-spacing: -.035em; margin: 22px 0 18px; font-weight: 800;
}
.grad {
  background: linear-gradient(100deg, var(--aurora-1), var(--aurora-2) 50%, var(--aurora-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.acronym { font-size: 15px; color: var(--ink-3); letter-spacing: .01em; margin: 0 0 20px; }
.acronym b { color: var(--ink); font-weight: 700; }
.lead { font-size: clamp(17px, 1.6vw, 20px); color: var(--ink-2); max-width: 40ch; margin: 0 0 32px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 999px;
  font-weight: 600; font-size: 15px; border: 1px solid var(--line-2); color: var(--ink); background: var(--surface);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--page); border-color: transparent; }
.btn.primary:hover { box-shadow: var(--shadow-lg); }
.btn svg { width: 16px; height: 16px; }

/* hero visual: coaxial chamber cross-section */
.hero-visual {
  position: relative; aspect-ratio: 1; border-radius: 28px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2)); box-shadow: var(--shadow-lg); overflow: hidden;
}
.hero-visual svg { width: 100%; height: 100%; }
.hero-visual .caption {
  position: absolute; left: 16px; bottom: 14px; right: 16px; display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between;
  font-size: 12px; color: var(--ink-3); font-family: var(--mono);
}
.chamber-ring { fill: none; stroke: var(--line-2); }
.chamber-gas { fill: color-mix(in srgb, var(--aurora-2) 7%, transparent); }
.chamber-anode { fill: color-mix(in srgb, var(--aurora-3) 70%, var(--surface)); }
.chamber-coat { fill: none; stroke: var(--s2); stroke-width: 2; }
.track { stroke: var(--aurora-1); stroke-width: 2.4; stroke-linecap: round; fill: none; stroke-dasharray: 260; stroke-dashoffset: 260; animation: shoot 5.5s cubic-bezier(.2, .7, .2, 1) infinite; }
.track.t2 { stroke: var(--s2); }
.spark { fill: var(--aurora-2); opacity: 0; animation: pop 5.5s ease-out infinite; }
@keyframes shoot { 0% { stroke-dashoffset: 260; opacity: 0; } 6% { opacity: 1; } 40% { stroke-dashoffset: 0; opacity: 1; } 80% { opacity: .15; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes pop { 0%, 12% { opacity: 0; } 30% { opacity: .9; } 85% { opacity: .2; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hero::before, .track, .spark { animation: none; }
  .track { stroke-dashoffset: 0; }
  .spark { opacity: .6; }
  html { scroll-behavior: auto; }
}

/* ----------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 64px; box-shadow: var(--shadow); }
.stat { background: var(--surface); padding: 22px 22px 20px; }
.stat .v { font-size: clamp(26px, 3vw, 34px); font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.stat .v small { font-size: .5em; font-weight: 600; color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
.stat .k { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.stat .ref { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-family: var(--mono); }
@media (max-width: 800px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* -------------------------------------------------------------- sections */
section { padding: 104px 0; position: relative; }
section.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { section { padding: 72px 0; } }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 12px; }
h2 { font-size: clamp(32px, 4.4vw, 52px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 16px; font-weight: 780; }
h3 { font-size: 20px; letter-spacing: -.01em; margin: 0 0 8px; }
.sub { color: var(--ink-2); font-size: 18px; max-width: 62ch; margin: 0 0 48px; }
.muted { color: var(--ink-3); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* -------------------------------------------------------------- pipeline */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; position: relative; }
.pipeline::before {
  content: ""; position: absolute; left: 4%; right: 4%; top: 38px; height: 2px; z-index: 0;
  background: linear-gradient(90deg, var(--aurora-1), var(--aurora-2), var(--aurora-3));
  opacity: .5;
}
.stage {
  position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px 18px; box-shadow: var(--shadow); transition: transform .25s, border-color .25s, box-shadow .25s;
}
.stage:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--shadow-lg); }
.stage .num {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-size: 15px;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--line); margin-bottom: 16px;
}
.stage h3 { font-size: 17px; margin-bottom: 2px; }
.stage .tech { font-size: 12px; color: var(--ink-3); font-family: var(--mono); margin-bottom: 10px; }
.stage p { font-size: 14px; color: var(--ink-2); margin: 0 0 12px; }
.stage .out { font-size: 12px; font-family: var(--mono); color: var(--ink-3); border-top: 1px dashed var(--line-2); padding-top: 10px; }
@media (max-width: 1000px) {
  .pipeline { grid-template-columns: 1fr 1fr; }
  .pipeline::before { display: none; }
}
@media (max-width: 560px) { .pipeline { grid-template-columns: 1fr; } }

.config-strip {
  margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: center;
  font-size: 14px; color: var(--ink-2);
}
.config-strip code { font-size: 13px; }

/* ----------------------------------------------------------------- cards */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
section.alt .card { background: var(--page); }
.card h3 { margin-bottom: 4px; }
.card .desc { font-size: 14px; color: var(--ink-2); margin: 0 0 16px; }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) { .span-2 { grid-column: auto; } }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 12px; font-family: var(--font); }
.chart .lbl { fill: var(--ink-2); font-size: 13px; }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .zero { stroke: var(--ink-3); stroke-width: 1; }
.chart .band { fill: var(--band); }
.chart .row-hit { fill: transparent; }
.chart .row:hover .row-hit, .chart .row.focus .row-hit { fill: var(--accent-soft); }
.chart .mark-dev { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .stem { stroke: var(--s1); stroke-width: 2; stroke-linecap: round; }
.chart .dot-off { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .dot-on { fill: var(--s2); stroke: var(--surface); stroke-width: 2; }
.chart .link { stroke: var(--axis); stroke-width: 2; }
section.alt .chart .mark-dev, section.alt .chart .dot-off, section.alt .chart .dot-on { stroke: var(--page); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.bar { width: 14px; height: 10px; border-radius: 3px; }
.legend i.s1 { background: var(--s1); } .legend i.s2 { background: var(--s2); } .legend i.s3 { background: var(--s3); }
.legend i.band { background: var(--band); border: 1px solid color-mix(in srgb, var(--s1) 35%, transparent); }
.legend i.grey { background: var(--axis); }

.tip {
  position: fixed; z-index: 80; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s; max-width: 300px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 13px; line-height: 1.45;
}
.tip.show { opacity: 1; transform: none; }
.tip b { display: block; margin-bottom: 4px; font-size: 13px; }
.tip .r { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); }
.tip .r span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.tip .src { margin-top: 6px; color: var(--ink-3); font-size: 12px; }

details.table { margin-top: 14px; font-size: 13px; }
details.table summary { cursor: pointer; color: var(--ink-3); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.table summary::-webkit-details-marker { display: none; }
details.table summary::before { content: "▸"; transition: transform .2s; display: inline-block; }
details.table[open] summary::before { transform: rotate(90deg); }
.tbl-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
th.num { text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok::before { content: "✓"; color: var(--good); font-weight: 800; }
.pill.wip::before { content: "↗"; color: var(--s2); font-weight: 800; }

/* ------------------------------------------------------------- mini tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--surface-2); }
section.alt .tile { background: var(--surface); }
.tile .v { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.tile .k { font-size: 12px; color: var(--ink-3); }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* --------------------------------------------------------------- figures */
.figs { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.fig { grid-column: span 6; margin: 0; }
.fig.wide { grid-column: span 12; }
.fig.third { grid-column: span 4; }
@media (max-width: 900px) { .fig, .fig.third { grid-column: span 12; } }
.fig button {
  all: unset; cursor: zoom-in; display: block; width: 100%; box-sizing: border-box;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #ffffff; padding: 12px;
  box-shadow: var(--shadow); transition: transform .25s, box-shadow .25s;
}
.fig button:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.fig button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.fig img { width: 100%; height: auto; border-radius: 6px; }
.fig figcaption { font-size: 14px; color: var(--ink-2); margin-top: 12px; padding: 0 4px; }
.fig figcaption b { color: var(--ink); font-weight: 650; }

/* -------------------------------------------------------------- BIFROST */
.bifrost-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; margin-bottom: 56px; }
@media (max-width: 960px) { .bifrost-hero { grid-template-columns: 1fr; } }
.bifrost-word { font-size: clamp(44px, 6vw, 72px); font-weight: 800; letter-spacing: -.03em; line-height: 1; margin: 0 0 14px; }
.rainbow {
  background: linear-gradient(90deg, #e34948, #eb6834, #eda100, #1baf7a, #2a78d6, #4a3aa7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="dark"] .rainbow { background-image: linear-gradient(90deg, #e66767, #d95926, #c98500, #199e70, #3987e5, #9085e9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rainbow { background-image: linear-gradient(90deg, #e66767, #d95926, #c98500, #199e70, #3987e5, #9085e9); } }

.features { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.feature { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.feature svg { flex: none; width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.feature b { color: var(--ink); display: block; font-size: 15px; }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }

.shots { display: grid; gap: 28px; }
.shot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-radius: 22px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg);
}
.shot.stack { grid-template-columns: 1fr; }
.shot-media { position: relative; background: var(--surface-2); min-height: 280px; display: grid; }
.shot-media .frame { display: grid; grid-template-rows: auto 1fr; }
.shot-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.shot-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.shot-bar span { margin-left: 10px; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.shot-img { position: relative; display: grid; place-items: center; background: var(--surface-2); cursor: zoom-in; }
.shot-img img { width: 100%; height: 100%; object-fit: contain; transition: opacity .35s ease; }
.shot-img img[hidden] { display: none; }
.shot-img .missing {
  display: none; padding: 40px 24px; text-align: center; color: var(--ink-3); font-size: 14px; max-width: 42ch;
}
.shot-img.is-missing { cursor: default; min-height: 280px; }
.shot-img.is-missing img { display: none; }
.shot-img.is-missing .missing { display: block; }
.shot-img .missing code { display: inline-block; margin-top: 8px; }
.shot-copy { padding: 32px; display: flex; flex-direction: column; justify-content: center; }
.shot-copy .num { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); font-weight: 600; letter-spacing: .1em; margin-bottom: 10px; }
.shot-copy h3 { font-size: 24px; letter-spacing: -.02em; }
.shot-copy p { color: var(--ink-2); font-size: 15px; margin: 0 0 12px; }
.shot-copy ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.shot-copy li { margin: 4px 0; }
.shot.flip .shot-media { order: 2; }
@media (max-width: 900px) {
  .shot { grid-template-columns: 1fr; }
  .shot.flip .shot-media { order: 0; }
  .shot-copy { padding: 24px; }
}

/* ----------------------------------------------------------------- V & V */
.vv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .vv { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .vv { grid-template-columns: 1fr; } }
.vv .card { padding: 22px; }
.vv .q { font-size: 14px; color: var(--ink-2); margin: 6px 0 12px; font-style: italic; }
.vv .ev { font-size: 13px; color: var(--ink-3); }
.vv .state { margin-top: 14px; }
.callout {
  margin-top: 28px; padding: 22px 24px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft); display: flex; gap: 16px; align-items: flex-start;
}
.callout svg { flex: none; width: 22px; height: 22px; color: var(--accent-ink); margin-top: 2px; }
.callout p { margin: 0; color: var(--ink-2); }
.callout b { color: var(--ink); }

/* ----------------------------------------------------------------- footer */
footer { padding: 56px 0 64px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: center; }
footer nav { display: flex; gap: 20px; flex-wrap: wrap; }
footer .author { justify-content: flex-start; gap: 16px; margin-top: 32px; padding-top: 32px; border-top: 1px solid var(--line); }
footer .author img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); box-shadow: var(--shadow); }
footer .author small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
footer .author b { display: block; margin-top: 2px; font-size: 17px; font-weight: 600; color: var(--ink); }
footer a { color: var(--ink-2); }

/* ---------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 32px;
  background: rgba(8, 8, 12, .82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lightbox.open { display: grid; }
.lightbox img { max-width: min(1400px, 100%); max-height: 88vh; border-radius: 12px; background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.lightbox .close { position: absolute; top: 18px; right: 18px; }
.lightbox .cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #d8d7e2; font-size: 14px; padding: 0 24px; }

/* ------------------------------------------------------ language switch */
.lang { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; gap: 2px; background: var(--surface); }
.lang a { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--ink-3); padding: 5px 9px; border-radius: 999px; line-height: 1; }
.lang a:hover { color: var(--ink); text-decoration: none; background: var(--surface-2); }
.lang a[aria-current="page"] { background: var(--ink); color: var(--page); }
@media (max-width: 420px) { .lang a { padding: 5px 7px; } .nav-actions { gap: 6px; } .nav-actions .icon-btn { width: 34px; height: 34px; } }

/* ------------------------------------------------------ buttons & chips */
.linkish { all: unset; cursor: pointer; color: var(--ink-2); font: inherit; }
.linkish:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.callout .linkish { color: var(--accent-ink); font-weight: 600; }
.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
button.btn { cursor: pointer; font-family: inherit; }
.doc-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.doc-links.center { justify-content: center; }
.chip {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; background: var(--surface); transition: border-color .2s, color .2s;
}
.chip::before { content: ""; width: 14px; height: 14px; background: currentColor; opacity: .8;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4.5A2.5 2.5 0 0 1 6.5 2H20v17H6.5A2.5 2.5 0 0 0 4 21.5z'/%3E%3Cpath d='M4 21.5A2.5 2.5 0 0 1 6.5 19H20v3H6.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4.5A2.5 2.5 0 0 1 6.5 2H20v17H6.5A2.5 2.5 0 0 0 4 21.5z'/%3E%3Cpath d='M4 21.5A2.5 2.5 0 0 1 6.5 19H20v3H6.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
section.alt .chip { background: var(--page); }
footer nav .linkish { font-size: 14px; }

/* ------------------------------------------------------------ doc viewer */
dialog.docs {
  width: min(1180px, calc(100vw - 32px)); height: min(88vh, 960px); max-width: none; max-height: none; padding: 0; border: 1px solid var(--line-2);
  border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.docs::backdrop { background: rgba(8, 8, 12, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.docs-shell { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.docs-nav { border-right: 1px solid var(--line); padding: 20px 12px; overflow-y: auto; background: var(--surface-2); display: flex; flex-direction: column; gap: 2px; }
.docs-kicker { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); margin: 0 10px 10px; }
.docs-nav button { all: unset; cursor: pointer; font-size: 14px; color: var(--ink-2); padding: 8px 10px; border-radius: 10px; }
.docs-nav button:hover { background: var(--surface); color: var(--ink); }
.docs-nav button[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.docs-nav button:focus-visible { outline: 2px solid var(--accent); }
.docs-note { font-size: 12px; color: var(--ink-3); margin: 16px 10px 0; line-height: 1.5; }
.docs-main { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.docs-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 28px; border-bottom: 1px solid var(--line); }
.docs-head h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; flex: 1; }
.doc { overflow-y: auto; padding: 8px 40px 48px; font-size: 15px; line-height: 1.65; min-height: 0; }
.doc:focus { outline: none; }
.doc h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 28px 0 14px; }
.doc h2 { font-size: 22px; margin: 36px 0 10px; letter-spacing: -.01em; padding-top: 12px; border-top: 1px solid var(--line); }
.doc h3 { font-size: 17px; margin: 26px 0 8px; }
.doc h4 { font-size: 15px; margin: 20px 0 6px; }
.doc p, .doc li { color: var(--ink-2); }
.doc strong { color: var(--ink); }
.doc pre { background: var(--code-bg); color: var(--code-ink); border-radius: 12px; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
.doc pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.doc blockquote { margin: 16px 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.doc blockquote p { margin: 6px 0; }
.doc table { margin: 12px 0; font-size: 13.5px; }
.doc .tbl-wrap { margin: 12px 0; }
.doc th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.doc .xref { font-family: var(--mono); font-size: .9em; color: var(--ink-3); }
.doc-loading { color: var(--ink-3); padding: 40px 0; }
@media (max-width: 800px) {
  dialog.docs { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .docs-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .docs-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; gap: 4px; }
  .docs-kicker, .docs-note { display: none; }
  .docs-nav button { white-space: nowrap; font-size: 13px; padding: 7px 10px; }
  .docs-shell > .docs-nav { order: 2; }
  .docs-main { order: 1; }
  .doc { padding: 4px 16px 40px; }
  .docs-head { padding: 10px 10px 10px 16px; }
}

/* --------------------------------------------------------------- NIDHOGG */
.nid-hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: start; }
@media (max-width: 960px) { .nid-hero { grid-template-columns: 1fr; gap: 32px; } }
.nid-word { font-size: clamp(44px, 6vw, 72px); font-weight: 800; letter-spacing: -.03em; line-height: 1; margin: 0 0 14px; }
.serpent { background: linear-gradient(95deg, #1baf7a, #2a78d6 55%, #4a3aa7); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="dark"] .serpent { background-image: linear-gradient(95deg, #199e70, #3987e5 55%, #9085e9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .serpent { background-image: linear-gradient(95deg, #199e70, #3987e5 55%, #9085e9); } }
.nid-quote { margin: 0 0 14px; padding: 0; border: 0; }
.nid-quote p { font-size: clamp(22px, 2.6vw, 30px); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: 0; color: var(--ink); }
.nid-story { color: var(--ink-2); font-size: 16px; margin: 0; }
.snake-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 16px 18px; box-shadow: var(--shadow-lg); }
.snake-card figcaption { font-size: 13px; color: var(--ink-3); margin-top: 10px; line-height: 1.55; }
.snake-card .legend { margin-bottom: 8px; }
#chart-snake { min-height: 300px; }
.chart .snake-path { fill: none; stroke-width: 1.15; stroke-linejoin: round; stroke-linecap: round; opacity: .82; transition: opacity .2s, stroke-width .2s; }
.chart .snake:hover .snake-path { opacity: .35; }
.chart .snake .snake-path.hot { opacity: 1; stroke-width: 2.2; }
.chart .scalebar { stroke: var(--ink-2); stroke-width: 2; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; }
.chart .val.small { font-size: 11px; font-weight: 600; }
.chart .verdict.ok { fill: var(--good); }
.chart .verdict.wip { fill: var(--ink-2); }
.chart .verdict.wip .glyph { fill: var(--s2); }
.chart .verdict.ok .glyph { fill: var(--good); }

.myth { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 48px 0 56px; }
.myth-item { background: var(--surface); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.myth-item b { font-size: 18px; letter-spacing: -.01em; }
.myth-item span { font-size: 14px; color: var(--ink-2); }
@media (max-width: 760px) { .myth { grid-template-columns: 1fr; } }

.block-title { font-size: 24px; letter-spacing: -.02em; margin: 0 0 18px; }
.caps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1000px) { .caps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .caps { grid-template-columns: 1fr; } }
.cap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
section.alt .cap { background: var(--page); }
.cap b { font-size: 15px; }
.cap span { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; margin-top: 28px; }
.vs-col { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; background: var(--surface); }
.vs-col.accent { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
.vs-col h3 { font-size: 19px; margin-bottom: 10px; }
.vs-col ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14.5px; }
.vs-col li { margin: 5px 0; }
.vs-k { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px; }
.vs-mid { display: grid; place-items: center; font-size: 28px; color: var(--ink-3); }
@media (max-width: 800px) { .versus { grid-template-columns: 1fr; } .vs-mid { transform: rotate(90deg); } }

.tile-note { grid-column: 1 / -1; display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); margin: 4px 0 0; }
.tile-note span { display: inline-flex; align-items: center; gap: 6px; }
.tile-note i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tile-note i.s1 { background: var(--s1); } .tile-note i.s2 { background: var(--s2); }
.who { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.who li { margin: 6px 0; }

/* ------------------------------------------------------------- direction */
.chapter { display: flex; gap: 20px; align-items: flex-start; margin: 64px 0 24px; }
.chapter:first-of-type { margin-top: 8px; }
.chapter-n {
  flex: none; font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--accent-ink);
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid var(--line);
}
.chapter h3 { font-size: 26px; letter-spacing: -.02em; margin: 2px 0 8px; }
.chapter p { color: var(--ink-2); margin: 0; max-width: 72ch; font-size: 16.5px; }

table.matrix th[scope="row"] { min-width: 180px; }
table.matrix th[scope="row"] b { display: block; font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0; }
table.matrix th[scope="row"] span { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; text-transform: none; letter-spacing: 0; }
table.matrix td { vertical-align: middle; }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.state i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid var(--s1); }
.state.res i { background: var(--s1); }
.state.cfg i { background: linear-gradient(90deg, var(--s1) 50%, transparent 50%); }
.state.no { color: var(--ink-3); font-weight: 500; }
.state.no i { border-color: var(--axis); }

.timeline { list-style: none; padding: 0; margin: 0 0 28px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 24px; right: 24px; top: 22px; height: 2px; background: linear-gradient(90deg, var(--aurora-3), var(--aurora-2), var(--aurora-1)); opacity: .45; }
.timeline li { position: relative; background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 44px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.timeline li::before { content: ""; position: absolute; top: 15px; left: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.timeline li.tl-now::before { background: var(--accent); }
.timeline .tl-k { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.timeline b { font-size: 16px; }
.timeline span:last-child { font-size: 13.5px; color: var(--ink-2); }
@media (max-width: 900px) { .timeline { grid-template-columns: 1fr 1fr; } .timeline::before { display: none; } }
@media (max-width: 520px) { .timeline { grid-template-columns: 1fr; } }

.tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.track-card { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.track-card.wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .tracks { grid-template-columns: 1fr; } }
.track-card header { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.track-card h3 { font-size: 21px; letter-spacing: -.015em; margin: 0; }
.track-card p { color: var(--ink-2); font-size: 15px; margin: 0 0 12px; }
.track-card .doc-links { margin-top: auto; padding-top: 14px; }
.pill.next { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent-ink); }
.pill.next::before { content: "→"; color: var(--accent-ink); font-weight: 800; }
.pill.open::before { content: "○"; font-weight: 800; }
.pill.opp::before { content: "✦"; color: var(--s2); }
.pill.later::before { content: "…"; font-weight: 800; }
.pill.done::before { content: "✓"; color: var(--good); font-weight: 800; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 12px; }
.match > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.match ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
@media (max-width: 520px) { .match { grid-template-columns: 1fr; } }
.small { font-size: 13.5px; }
p.small { color: var(--ink-3); }
.muted.small { color: var(--ink-3); }
table.vplan th[scope="row"] { font-family: var(--mono); color: var(--accent-ink); font-size: 12.5px; text-transform: none; }
table.vplan td { font-size: 13.5px; color: var(--ink-2); }
.need { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.need::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--s1); }
.need.code::before { background: var(--s2); }
.need.config::before { background: var(--s3); }
.blockers { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.blockers b { font-family: var(--mono); color: var(--accent-ink); margin-right: 6px; font-size: 12.5px; }
.mini-title { font-size: 16px; margin: 0 0 4px; }
.ticks, .checks { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; color: var(--ink-2); }
.ticks li { padding-left: 18px; position: relative; }
.ticks li::before { content: ""; position: absolute; left: 2px; top: .6em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: .7; }
.ticks b { color: var(--ink); }
.checks li { padding-left: 24px; position: relative; }
.checks li::before { position: absolute; left: 0; font-weight: 800; }
.checks li.done::before { content: "✓"; color: var(--good); }
.checks li.todo::before { content: "○"; color: var(--ink-3); }
.sub-t { font-size: 15px; display: block; margin-bottom: 4px; }

/* ------------------------------------------------- theme-matched images */
.fig img.on-dark { display: none; }
:root[data-theme="dark"] .fig img.on-light { display: none; }
:root[data-theme="dark"] .fig img.on-dark { display: block; }
:root[data-theme="dark"] .fig button { background: #161616; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fig img.on-light { display: none; }
  :root:not([data-theme="light"]) .fig img.on-dark { display: block; }
  :root:not([data-theme="light"]) .fig button { background: #161616; }
}
.lightbox.dark img { background: #161616; }
.lightbox.tall { overflow-y: auto; place-items: start center; }
.lightbox.tall img { max-height: none; width: min(1200px, 100%); }

/* --------------------------------------------------------- dashboard frame */
.shot-img.tall { display: block; max-height: 720px; overflow-y: auto; cursor: default; overscroll-behavior: contain; }
.shot-img.tall img { height: auto; object-fit: initial; cursor: zoom-in; }
@media (max-width: 640px) { .shot-img.tall { max-height: 520px; } }

/* ------------------------------------------------------ two-way diagram */
.duplex {
  display: grid; grid-template-columns: 1fr 1.25fr 1fr; align-items: stretch; gap: 0; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.dx-node { border: 1px solid var(--line-2); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; justify-content: center; background: var(--page); }
.dx-node.accent { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.dx-node b { font-size: 17px; letter-spacing: .02em; }
.dx-node span { font-size: 13px; color: var(--ink-2); }
.dx-node .dx-k { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.dx-lanes { display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 0 10px; }
.dx-lane { display: flex; flex-direction: column; gap: 6px; }
.dx-label { font-size: 12.5px; color: var(--ink-2); text-align: center; line-height: 1.4; }
.dx-arrow { position: relative; height: 2px; border-radius: 2px; overflow: visible; }
.dx-lane.out .dx-arrow { background: linear-gradient(90deg, transparent, var(--s1)); }
.dx-lane.in .dx-arrow { background: linear-gradient(270deg, transparent, var(--s2)); }
.dx-arrow::after { content: ""; position: absolute; top: -5px; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.dx-lane.out .dx-arrow::after { right: -2px; border-left: 9px solid var(--s1); }
.dx-lane.in .dx-arrow::after { left: -2px; border-right: 9px solid var(--s2); }
.dx-arrow::before { content: ""; position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%; animation: travel 2.6s linear infinite; }
.dx-lane.out .dx-arrow::before { background: var(--s1); left: 0; }
.dx-lane.in .dx-arrow::before { background: var(--s2); right: 0; animation-name: travel-back; animation-delay: 1.3s; }
@keyframes travel { from { left: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } to { left: calc(100% - 8px); opacity: 0; } }
@keyframes travel-back { from { right: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } to { right: calc(100% - 8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dx-arrow::before { animation: none; display: none; } }
.dx-foot { grid-column: 1 / -1; margin: 16px 0 0; font-size: 13px; color: var(--ink-3); text-align: center; }
@media (max-width: 640px) {
  .duplex { grid-template-columns: 1fr; gap: 14px; }
  .dx-lanes { padding: 4px 0; gap: 16px; }
}

/* ------------------------------------------------ NIDHOGG input / output */
.io { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.io-col ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.io-col li { margin: 5px 0; }
.io-core { font-weight: 800; font-size: 15px; letter-spacing: .06em; padding: 14px 12px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--page); position: relative; }
.io-core::before, .io-core::after { content: "→"; position: absolute; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 400; }
.io-core::before { left: -14px; } .io-core::after { right: -14px; }
@media (max-width: 640px) { .io { grid-template-columns: 1fr; } .io-core { justify-self: center; } .io-core::before, .io-core::after { display: none; } }

/* grid children must be allowed to shrink below their content (tables scroll inside .tbl-wrap) */
.grid-2 > *, .grid-3 > *, .tracks > *, .nid-hero > *, .bifrost-hero > * { min-width: 0; }

/* ---------------------------------------------- area for improvement */
.improve {
  margin-top: 20px; display: grid; grid-template-columns: 1fr 1.1fr; gap: 32px; padding: 28px;
  border-radius: var(--radius); background: var(--page); box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--s2) 40%, var(--line));
}
.improve > * { min-width: 0; }
@media (max-width: 960px) { .improve { grid-template-columns: 1fr; padding: 22px; } }
.imp-text h3 { font-size: 23px; letter-spacing: -.015em; margin: 12px 0 10px; }
.imp-lead { color: var(--ink-2); font-size: 16px; margin: 0 0 16px; }
.imp-half { border-left: 3px solid var(--line-2); padding: 2px 0 2px 14px; margin: 0 0 14px; }
.imp-half b { display: block; font-size: 15px; margin-bottom: 4px; }
.imp-half p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.imp-working {
  margin: 18px 0 0; padding: 12px 16px; border-radius: 12px; font-weight: 650; font-size: 15px; color: var(--ink);
  background: color-mix(in srgb, var(--good) 12%, transparent); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent);
}
.imp-working::before { content: "↗ "; color: var(--good); font-weight: 800; }
.pill.improve-pill { border-color: color-mix(in srgb, var(--s2) 55%, transparent); color: var(--ink); }
.pill.improve-pill::before { content: "↗"; color: var(--s2); font-weight: 800; }
.pill.progress { border-color: color-mix(in srgb, var(--good) 55%, transparent); color: var(--ink); }
.pill.progress::before { content: "●"; color: var(--good); font-size: 9px; }
.improve .tiles .v { font-size: 19px; }
.improve .desc { font-size: 14px; color: var(--ink-2); margin: 0 0 14px; }

/* link from the Eₙ chart down to the improvement block */
.jump { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 14px; font-weight: 650; color: var(--accent-ink); }
.jump:hover { text-decoration: underline; text-underline-offset: 3px; }
.chart .row.linked { cursor: pointer; }
.improve:target { outline: 2px solid color-mix(in srgb, var(--s2) 60%, transparent); outline-offset: 4px; }
