/* Layout: eye-chart title band → dark slit-lamp "instrument" holding the 3D eye → condition card grid → test-image lab. */
:root {
  --paper: #eef1f0;
  --paper-2: #e2e7e5;
  --card: #f8faf9;
  --ink: #111a21;
  --ink-2: #33414b;
  --muted: #5f6d76;
  --line: #cdd6d4;
  --cobalt: #2536c4;
  --cobalt-ink: #ffffff;
  --fundus: #d65a24;
  --chart-red: #c8322a;
  --chart-green: #1d8549;
  --focus: #2536c4;

  /* instrument surfaces stay dark in both themes, like a darkened exam room */
  --stage: #0a0f14;
  --stage-2: #121b23;
  --stage-3: #18232c;
  --stage-ink: #e3e9ec;
  --stage-muted: #8d9aa4;
  --stage-line: #243039;
  --glow: rgba(214, 90, 36, 0.18);
  --hud-bg: rgba(12, 17, 22, 0.94);

  --display: "Hepta Slab", Rockwell, "Roboto Slab", Georgia, serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.3125rem;
  --fs-xl: 1.75rem;
  --fs-2xl: clamp(2rem, 4.2vw, 3rem);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1216; --paper-2: #141b20; --card: #131a1f; --ink: #e6ecee; --ink-2: #bcc6cb; --muted: #8b98a0; --line: #26323a;
    --cobalt: #8a98ff; --cobalt-ink: #0a0e24; --fundus: #ff8a4c; --chart-red: #ff6f62; --chart-green: #4fd08a; --focus: #a7b2ff;
    --stage: #070b0f; --stage-2: #0e161c; --stage-3: #141e26; --stage-line: #1f2a33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1216; --paper-2: #141b20; --card: #131a1f; --ink: #e6ecee; --ink-2: #bcc6cb; --muted: #8b98a0; --line: #26323a;
  --cobalt: #8a98ff; --cobalt-ink: #0a0e24; --fundus: #ff8a4c; --chart-red: #ff6f62; --chart-green: #4fd08a; --focus: #a7b2ff;
  --stage: #070b0f; --stage-2: #0e161c; --stage-3: #141e26; --stage-line: #1f2a33;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-md)/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
body.has-hud { padding-bottom: 200px; }
#world { background: var(--paper); min-height: 100vh; }
img, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
kbd {
  font: 600 0.78em/1 var(--mono);
  padding: 0.2em 0.45em; border-radius: 5px;
  border: 1px solid currentColor; opacity: 0.8;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.wrap { width: min(1320px, 100%); margin-inline: auto; padding-inline: clamp(16px, 3.5vw, 40px); }
.section { padding-block: clamp(48px, 7vw, 96px); }
.eyebrow {
  margin: 0 0 10px;
  font: 600 var(--fs-xs)/1.2 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fundus);
}
.sec-head { max-width: 760px; margin-bottom: clamp(24px, 3vw, 36px); }
.sec-head h2 {
  margin: 0 0 12px;
  font: 800 var(--fs-2xl)/1.05 var(--display);
  letter-spacing: -0.01em; text-wrap: balance;
}
.lede { margin: 0; color: var(--ink-2); font-size: var(--fs-md); max-width: 65ch; }
.panel-label {
  margin: 0; font: 600 var(--fs-xs)/1.2 var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--stage-muted);
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.panel-note { letter-spacing: 0.02em; text-transform: none; font-weight: 400; opacity: 0.8; }

/* ---------- masthead ---------- */
.masthead { border-bottom: 1px solid var(--line); }
.masthead-in { display: flex; align-items: center; gap: 24px; padding-block: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 800 1.125rem/1 var(--display); }
.brand-mark { width: 34px; height: 34px; color: var(--ink); }
.nav { display: flex; gap: 22px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm); }
.nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.vision-pill {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: 0.02em;
}
.vp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chart-green); }
.vision-pill.is-on .vp-dot { background: var(--fundus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fundus) 25%, transparent); }
@media (max-width: 720px) { .nav { display: none; } .vision-pill { margin-left: auto; } }

/* ---------- hero: an eye chart ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(24px, 4vw, 64px);
  align-items: end; padding-block: clamp(32px, 6vw, 72px) clamp(24px, 4vw, 40px);
}
.chart { min-width: 0; }
.chart-title { margin: 0; font-weight: inherit; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin: 0; }
.row .opt { min-width: 0; }
.acu { flex: none; font: 600 var(--fs-xs)/1 var(--mono); color: var(--muted); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.r1 .opt { font: 800 clamp(2.6rem, 8.6vw, 7rem)/0.92 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.r2 .opt { font: 800 clamp(1.7rem, 5vw, 4rem)/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; }
.r2 { margin-top: 10px; }
.r3 { margin-top: 26px; }
.r3 .opt { font: 600 clamp(1.2rem, 2.5vw, 1.9rem)/1.2 var(--display); text-wrap: balance; }
.r4 .opt { font-size: var(--fs-md); color: var(--ink-2); max-width: 62ch; }
.r5 .opt { font-size: 0.72rem; color: var(--muted); }
.chart-rule { border: 0; height: 3px; margin: 14px 0; border-radius: 2px; }
.chart-rule.is-red { background: var(--chart-red); }
.chart-rule.is-green { background: var(--chart-green); }

.hero-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.hero-steps li { counter-increment: step; }
.hero-steps a {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; text-decoration: none;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  transition: border-color 0.2s, transform 0.2s;
}
.hero-steps a::before {
  content: counter(step); grid-row: span 2; align-self: center;
  font: 800 1.6rem/1 var(--display); color: var(--fundus);
}
.hero-steps a:hover { border-color: var(--ink-2); transform: translateX(3px); }
.hs-k { font-weight: 700; }
.hs-t { font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; align-items: start; } .hero-steps { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }

/* ---------- instrument (3D) ---------- */
.instrument {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr) 340px;
  grid-template-areas: "parts stage info";
  background: var(--stage); color: var(--stage-ink);
  border: 1px solid var(--stage-line); border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 80px -40px rgba(4, 10, 16, 0.6);
}
.parts { grid-area: parts; padding: 20px 12px 20px 18px; border-right: 1px solid var(--stage-line); min-width: 0; }
.part-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 2px; }
.part-list li { display: flex; align-items: center; gap: 2px; }
.part-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 8px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font-size: var(--fs-sm); color: var(--stage-ink);
}
.part-btn:hover, .part-btn.is-hover { background: var(--stage-3); }
.part-btn[aria-pressed="true"] { background: var(--stage-3); box-shadow: inset 2px 0 0 var(--c); }
.part-btn .sw { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.part-btn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-btn {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; color: var(--stage-muted); cursor: pointer;
}
.vis-btn:hover { background: var(--stage-3); color: var(--stage-ink); }
.vis-btn svg { width: 16px; height: 16px; }
.vis-btn[aria-pressed="false"] { color: #56636c; }
.part-list li.is-hidden .part-btn { opacity: 0.45; }

.stage {
  grid-area: stage; position: relative; min-width: 0; overflow: hidden;
  height: clamp(460px, 72vh, 740px);
  background:
    radial-gradient(55% 50% at 50% 48%, var(--glow), transparent 72%),
    radial-gradient(circle at 50% 50%, var(--stage-2), var(--stage) 78%);
}
#eye-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.leaders, .labels { position: absolute; inset: 0; pointer-events: none; }
.leaders { width: 100%; height: 100%; overflow: visible; }
.leaders line { stroke: rgba(227, 233, 236, 0.32); stroke-width: 1; }
.leaders line.is-on { stroke: rgba(255, 170, 120, 0.9); }
.leaders circle { fill: #fff; }
.lbl {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 5px 9px 5px 7px; border-radius: 999px;
  font: 600 12px/1 var(--body); color: var(--stage-ink);
  background: rgba(8, 12, 16, 0.72); border: 1px solid rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s;
}
.lbl::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.lbl:hover, .lbl.is-on { background: rgba(30, 20, 14, 0.92); border-color: var(--c); }

.stage-tools { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool {
  border: 1px solid var(--stage-line); background: rgba(10, 15, 20, 0.7); color: var(--stage-ink);
  padding: 6px 12px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tool:hover { border-color: #3b4a55; }
.tool[aria-pressed="true"] { background: var(--stage-ink); color: var(--stage); border-color: var(--stage-ink); }
.tool.icon { width: 30px; padding: 6px 0; font-size: 1rem; line-height: 1; }
.tool-sep { width: 1px; height: 20px; background: var(--stage-line); margin-inline: 4px; }

.focus-picker {
  position: absolute; top: 58px; left: 14px; max-width: min(360px, calc(100% - 28px));
  background: rgba(10, 15, 20, 0.86); border: 1px solid var(--stage-line); border-radius: 14px; padding: 10px;
  display: grid; gap: 8px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.seg { display: flex; background: var(--stage-3); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; color: var(--stage-muted); }
.seg button[aria-checked="true"] { background: #ffc56b; color: #1c1206; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: var(--fs-xs); color: var(--stage-ink); cursor: pointer; }
.check input { accent-color: #ffc56b; width: 16px; height: 16px; }
.focus-note { margin: 0; font-size: var(--fs-xs); color: var(--stage-muted); line-height: 1.4; }

.scalebar { position: absolute; left: 18px; bottom: 92px; display: grid; gap: 4px; font: 400 11px/1 var(--mono); color: var(--stage-muted); }
.scalebar span { display: block; width: var(--w, 60px); height: 6px; border: 1px solid var(--stage-muted); border-top: 0; }
.scalebar em { font-style: normal; }

.explode {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px 10px 10px; border-radius: 999px;
  background: rgba(10, 15, 20, 0.82); border: 1px solid var(--stage-line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.explode-btn {
  flex: none; border: 0; cursor: pointer; border-radius: 999px; padding: 9px 18px;
  background: var(--fundus); color: #1b0c04; font: 800 var(--fs-sm)/1 var(--display); letter-spacing: 0.04em;
}
.explode-btn:hover { filter: brightness(1.08); }
.explode-track { flex: 1; min-width: 0; }
.explode-ticks { display: flex; justify-content: space-between; font: 400 10px/1 var(--mono); color: var(--stage-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.stage-hint { position: absolute; right: 18px; bottom: 92px; margin: 0; font-size: 11px; color: var(--stage-muted); }
.gl-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--stage-muted); }

/* sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: none; cursor: pointer; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--track-fill, #ffc56b) var(--p, 0%), var(--track, #33414b) var(--p, 0%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track, #33414b); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--track-fill, #ffc56b); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; border: 3px solid var(--track-fill, #ffc56b); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--track-fill, #ffc56b); }

.info { grid-area: info; padding: 22px 22px 24px; border-left: 1px solid var(--stage-line); overflow-y: auto; max-height: clamp(460px, 72vh, 740px); min-width: 0; }
.info h3 { margin: 4px 0 2px; font: 800 var(--fs-xl)/1.1 var(--display); }
.info-tag { margin: 0 0 14px; font: 600 var(--fs-xs)/1.2 var(--mono); color: var(--c, #ffc56b); letter-spacing: 0.06em; text-transform: uppercase; }
.info-body { margin: 0 0 18px; color: #c9d2d7; font-size: var(--fs-sm); line-height: 1.6; }
.facts { margin: 0 0 18px; display: grid; gap: 0; border-top: 1px solid var(--stage-line); }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--stage-line); font-size: var(--fs-xs); }
.facts dt { color: var(--stage-muted); }
.facts dd { margin: 0; font-family: var(--mono); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.info-sub { margin: 18px 0 8px; font: 600 11px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--stage-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--stage-line); background: var(--stage-3); color: var(--stage-ink); cursor: pointer;
  border-radius: 999px; padding: 6px 12px; font-size: var(--fs-xs); font-weight: 600;
}
.chip:hover { border-color: var(--fundus); }
.chip::after { content: " →"; color: var(--fundus); }
.info-none { font-size: var(--fs-xs); color: var(--stage-muted); margin: 0; }
.info-ctrl { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--stage-3); margin-bottom: 6px; }
.info-ctrl label { font-size: var(--fs-xs); color: var(--stage-muted); display: flex; justify-content: space-between; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: radial-gradient(circle, #0b0806 28%, var(--s) 30%, var(--s) 62%, #120c08 70%); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: #fff; }
.info-back { margin-top: 20px; border: 0; background: none; color: var(--stage-muted); cursor: pointer; padding: 0; font-size: var(--fs-xs); text-decoration: underline; text-underline-offset: 3px; }
.info-back:hover { color: var(--stage-ink); }

@media (max-width: 1120px) {
  .instrument { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "parts" "info"; }
  .parts { border-right: 0; border-top: 1px solid var(--stage-line); padding: 14px 16px; }
  .part-list { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 6px; scrollbar-width: thin; }
  .part-list li { flex: none; }
  .part-btn { white-space: nowrap; }
  .info { border-left: 0; border-top: 1px solid var(--stage-line); max-height: none; }
}
@media (max-width: 640px) {
  .stage { height: 460px; }
  .stage-hint, .scalebar { display: none; }
  .tool { padding: 6px 10px; }
  #t-spin, .tool-sep { display: none; }
  .explode { gap: 10px; padding: 8px 12px 8px 8px; }
  .explode-btn { padding: 8px 12px; }
}

/* ---------- blind spot ---------- */
.blindspot {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(20px, 4vw, 56px); align-items: center;
  padding-block: clamp(8px, 2vw, 24px) 0;
}
.bs-text h3 { margin: 0 0 10px; font: 800 var(--fs-xl)/1.1 var(--display); }
.bs-text p:last-child { margin: 0; color: var(--ink-2); max-width: 60ch; }
.bs-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 44px clamp(24px, 4vw, 48px); background: #fbfbf7; color: #111;
  border-radius: 16px; border: 1px solid var(--line); min-height: 160px;
}
.bs-card { max-width: 100%; }
.bs-cross { font: 400 44px/1 var(--mono); }
.bs-dot { width: 26px; height: 26px; border-radius: 50%; background: #111; }
@media (max-width: 800px) { .blindspot { grid-template-columns: 1fr; } }

/* ---------- condition cards ---------- */
.cond-groups { display: grid; gap: clamp(28px, 4vw, 44px); }
.cond-group-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.cond-group-head h3 { margin: 0; font: 800 var(--fs-lg)/1.2 var(--display); }
.cond-group-head p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.cond-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .cond-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .cond-grid { grid-template-columns: minmax(0, 1fr); } }
.cond-card {
  display: grid; grid-template-rows: auto 1fr; text-align: left; padding: 0; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s;
}
.cond-card:hover { transform: translateY(-3px); border-color: var(--ink-2); box-shadow: 0 14px 30px -18px rgba(10, 20, 30, 0.45); }
.cond-card[aria-pressed="true"] { border-color: var(--fundus); box-shadow: 0 0 0 2px var(--fundus); }
.thumb { position: relative; aspect-ratio: 3 / 2; max-width: 100%; overflow: hidden; background: var(--paper-2); isolation: isolate; }
.thumb .t-fx, .thumb .t-fx img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.thumb .t-fx img { object-fit: cover; }
.thumb .ov-blur, .thumb .ov-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.thumb .ov-blur { display: none; }
.thumb-badge {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  font: 600 10px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 7px; border-radius: 6px; background: rgba(10, 14, 18, 0.72); color: #e3e9ec;
}
.cond-card[aria-pressed="true"] .thumb-badge { background: var(--fundus); color: #1b0c04; }
.cc-body { padding: 14px 16px 16px; display: grid; gap: 4px; align-content: start; }
.cc-body h4 { margin: 0; font: 800 var(--fs-md)/1.2 var(--display); }
.cc-aka { margin: 0; font: 600 11px/1.3 var(--mono); color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.cc-line { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }
.cc-stat { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 6px; align-items: baseline; }
.cc-stat::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--fundus); transform: translateY(-1px); }

/* ---------- lab ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.lab-main { min-width: 0; display: grid; gap: 14px; }
.viewer {
  --split: 50%;
  position: relative; aspect-ratio: 3 / 2; max-width: 100%; border-radius: 16px; overflow: hidden;
  background: #0b0f12; isolation: isolate; user-select: none; -webkit-user-select: none;
}
.v-layer, .v-fx { position: absolute; inset: 0; }
.v-layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.v-affected { clip-path: inset(0 0 0 var(--split)); }
.viewer.no-split .v-affected { clip-path: none; }
.v-affected .ov-blur, .v-affected .ov-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.v-affected .ov-blur { display: none; }
.v-split {
  position: absolute; top: 0; bottom: 0; left: var(--split); width: 44px; margin-left: -22px;
  cursor: ew-resize; touch-action: none; z-index: 3; display: grid; place-items: center;
}
.v-split::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 10px rgba(0,0,0,.5); }
.v-knob {
  position: relative; width: 38px; height: 38px; border-radius: 50%; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.45);
  display: grid; place-items: center;
}
.v-knob::before { content: "‹ ›"; font: 800 15px/1 var(--display); color: #111; letter-spacing: 2px; }
.viewer.no-split .v-split, .viewer.no-split .v-tag-l { display: none; }
.v-tag {
  position: absolute; top: 12px; z-index: 2; pointer-events: none;
  font: 600 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 9px; border-radius: 7px; background: rgba(8, 12, 16, 0.78); color: #e8eef0;
}
.v-tag-l { left: 12px; }
.v-tag-r { right: 12px; background: var(--fundus); color: #1b0c04; }

.thumbs { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.tbtn {
  display: grid; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; min-width: 0;
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2);
}
.tbtn .tim { aspect-ratio: 3 / 2; max-width: 100%; border-radius: 9px; overflow: hidden; background: var(--paper-2); border: 2px solid transparent; transition: border-color 0.15s; display: grid; place-items: center; }
.tbtn .tim img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tbtn:hover .tim { border-color: var(--line); }
.tbtn[aria-checked="true"] .tim { border-color: var(--fundus); }
.tbtn[aria-checked="true"] { color: var(--ink); }
.tbtn .tnm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbtn.upload .tim { border: 2px dashed var(--line); color: var(--muted); font: 800 1.4rem/1 var(--display); }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tbtn.upload:focus-within .tim { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 900px) { .thumbs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.lab-side {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  display: grid; gap: 14px; position: sticky; top: 16px;
}
.lab-side .panel-label { color: var(--muted); }
.lab-side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.switch input { accent-color: var(--fundus); width: 16px; height: 16px; }
.lab-conds { display: grid; gap: 12px; max-height: 470px; overflow-y: auto; padding-right: 4px; margin-right: -4px; }
.lab-g { display: grid; gap: 2px; }
.lab-g-name { margin: 0 0 4px; font: 600 10px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lab-c {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left;
  border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: var(--fs-sm); color: var(--ink);
}
.lab-c small { font-size: 11px; color: var(--muted); text-align: right; }
.lab-c:hover { background: var(--paper-2); }
.lab-c[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.lab-c[aria-checked="true"] small { color: inherit; opacity: 0.75; }
.lab-sev label { display: flex; justify-content: space-between; font-size: var(--fs-xs); font-weight: 600; margin-bottom: 4px; }
.lab-sev output { font-family: var(--mono); color: var(--fundus); }
.lab-sev input { --track: var(--line); --track-fill: var(--fundus); }
.lab-note { margin: 0; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
.lab-note button { border: 0; background: none; padding: 0; color: var(--cobalt); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 1000px) {
  .lab { grid-template-columns: 1fr; }
  .lab-side { position: static; }
  .lab-conds { max-height: none; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 36px 48px; }
.footer-in { display: grid; gap: 10px; max-width: 900px; }
.footer p { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); }
.footer-small { color: var(--muted) !important; font-size: var(--fs-xs) !important; }

/* ---------- page simulation overlay + HUD ---------- */
.page-ov { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.page-ov .ov-blur, .page-ov .ov-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page-ov .ov-blur { display: none; }

.hud {
  position: fixed; z-index: 60; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(1160px, calc(100% - 24px));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px 22px; align-items: center;
  padding: 14px 18px; border-radius: 18px;
  background: var(--hud-bg); color: var(--stage-ink); border: 1px solid #2a3740;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: hud-in 0.35s cubic-bezier(.2,.8,.2,1);
}
@keyframes hud-in { from { transform: translate(-50%, 24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hud { animation: none; } .cond-card, .hero-steps a { transition: none; } }
.hud-id { min-width: 0; }
.hud-kicker { margin: 0; font: 600 10px/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: #ffb08a; }
.hud-name { margin: 2px 0 0; font: 800 1.25rem/1.15 var(--display); }
.hud-aka { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--stage-muted); }
.hud-sev label { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-xs); color: var(--stage-muted); margin-bottom: 2px; }
.hud-sev output { font-family: var(--mono); font-weight: 600; color: #ffc56b; text-align: right; }
.hud-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hbtn {
  border: 1px solid #33424c; background: #16212a; color: var(--stage-ink); cursor: pointer;
  padding: 9px 14px; border-radius: 10px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  display: inline-flex; gap: 8px; align-items: center; user-select: none; -webkit-user-select: none; touch-action: none;
}
.hbtn:hover { border-color: #52636e; }
.hbtn.is-active { background: var(--stage-ink); color: var(--stage); }
.hbtn.is-fix { background: #ffc56b; color: #1c1206; border-color: #ffc56b; }
.hbtn.is-fix.is-active { background: #16212a; color: #ffc56b; }
.hbtn.is-clear { background: var(--stage-ink); color: var(--stage); border-color: var(--stage-ink); }
.hud-sees { grid-column: 1 / 3; margin: 0; font-size: var(--fs-sm); color: #c9d2d7; line-height: 1.45; }
.hud-more { justify-self: end; border: 0; background: none; color: var(--stage-muted); font-size: var(--fs-xs); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.hud-more:hover { color: var(--stage-ink); }
.hud-detail { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 12px; border-top: 1px solid #26323a; }
.hud-detail h5 { margin: 0 0 4px; font: 600 10px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--stage-muted); }
.hud-detail p { margin: 0; font-size: var(--fs-xs); line-height: 1.5; color: #d4dce0; }
.hud-detail .hud-link { margin-top: 8px; border: 0; background: none; padding: 0; color: #ffc56b; cursor: pointer; font-size: var(--fs-xs); font-weight: 700; }
@media (max-width: 860px) {
  .hud { grid-template-columns: 1fr; gap: 10px; padding: 12px 14px; }
  .hud-actions { justify-content: flex-start; }
  .hud-sees { grid-column: 1; font-size: var(--fs-xs); }
  .hud-more { justify-self: start; }
  .hud-detail { grid-template-columns: 1fr; }
  .hbtn kbd { display: none; }
  body.has-hud { padding-bottom: 300px; }
}
