/* ---------- tokens ---------- */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eceef8;
  --text: #12142a;
  --muted: #565b7a;
  --border: #dcdfef;
  --accent: #5b4cf0;
  --accent-2: #0b9e90;
  --btn-bg: #5b4cf0;
  --btn-bg-hover: #4a3bdc;
  --btn-text: #ffffff;
  --ok: #0f7a52;
  --ok-bg: #dff5ea;
  --bad: #c42450;
  --bad-bg: #fde4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf0d2;
  --info: #3a46b8;
  --info-bg: #e5e8fc;
  --ring: #5b4cf0;
  --shadow: 0 1px 2px rgba(18, 20, 42, .06), 0 8px 28px rgba(18, 20, 42, .07);
  --shadow-lg: 0 2px 4px rgba(18, 20, 42, .06), 0 24px 60px rgba(40, 30, 120, .16);
  --blob-1: rgba(91, 76, 240, .16);
  --blob-2: rgba(15, 181, 165, .14);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14; --surface: #141726; --surface-2: #1b1f33; --text: #eef0fb; --muted: #a0a6c6;
    --border: #272c47; --accent: #8b7dff; --accent-2: #2dd4bf; --btn-bg: #8b7dff; --btn-bg-hover: #a094ff; --btn-text: #0b0d14;
    --ok: #4ade9c; --ok-bg: rgba(52, 211, 153, .14); --bad: #ff7b96; --bad-bg: rgba(251, 113, 133, .15);
    --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .14); --info: #a5b0ff; --info-bg: rgba(139, 125, 255, .17);
    --ring: #a094ff; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 30px 70px rgba(0, 0, 0, .5);
    --blob-1: rgba(139, 125, 255, .16); --blob-2: rgba(45, 212, 191, .10);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0d14; --surface: #141726; --surface-2: #1b1f33; --text: #eef0fb; --muted: #a0a6c6;
  --border: #272c47; --accent: #8b7dff; --accent-2: #2dd4bf; --btn-bg: #8b7dff; --btn-bg-hover: #a094ff; --btn-text: #0b0d14;
  --ok: #4ade9c; --ok-bg: rgba(52, 211, 153, .14); --bad: #ff7b96; --bad-bg: rgba(251, 113, 133, .15);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .14); --info: #a5b0ff; --info-bg: rgba(139, 125, 255, .17);
  --ring: #a094ff; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 30px 70px rgba(0, 0, 0, .5);
  --blob-1: rgba(139, 125, 255, .16); --blob-2: rgba(45, 212, 191, .10);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  font: 400 1rem/1.55 var(--font); color: var(--text); background: var(--bg);
  position: relative; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60rem 36rem at 90% -10%, var(--blob-1), transparent 60%),
    radial-gradient(50rem 34rem at -10% 110%, var(--blob-2), transparent 60%);
}
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 5.2vw, 3.4rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
h4 { font-size: .95rem; font-weight: 700; margin-bottom: .4em; }
p { margin: 0 0 .9em; }
a { color: var(--accent); }
img { max-width: 100%; }
ul, ol { padding-left: 1.2em; }
kbd {
  font: 600 .72em var(--mono); padding: .12em .45em; border-radius: 6px; margin: 0 .1em;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--muted);
}
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sr-copy { position: fixed; left: -9999px; top: 0; opacity: 0; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--btn-bg); color: var(--btn-text);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, calc((100vw - 1080px) / 2)); padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: .92rem; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--info-bg); color: var(--info); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer; transition: transform .15s, background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#theme-btn .i-sun { display: none; }
#theme-btn[data-eff="dark"] .i-sun { display: block; }
#theme-btn[data-eff="dark"] .i-moon { display: none; }

.banner { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 8px 16px; font-size: .9rem; font-weight: 600; }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; }
.page { max-width: 1080px; margin: 0 auto; padding: 28px 16px 64px; animation: rise .35s ease both; }
.page.narrow { max-width: 560px; padding-top: 80px; }
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.8em; }
.prose li { margin-bottom: .45em; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.footer { max-width: 1080px; width: 100%; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.footer p { margin-bottom: .4em; }
.footer strong { color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 .95rem var(--font);
  text-decoration: none; cursor: pointer; transition: transform .12s, background .15s, box-shadow .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--btn-bg); color: var(--btn-text); border-color: transparent; box-shadow: 0 6px 20px color-mix(in srgb, var(--btn-bg) 40%, transparent); }
.btn.primary:hover { background: var(--btn-bg-hover); }
.btn.big { min-height: 52px; padding: 0 28px; font-size: 1.02rem; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.danger-ghost { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.danger-ghost:hover { background: var(--bad-bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-row, .cta-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cta-row { margin-top: 20px; }

/* ---------- cards, pills ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.link { font-weight: 600; font-size: .9rem; }
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.tiny { margin-left: 8px; padding: 1px 7px; font-size: .68rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 40px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; align-items: start; }
.page > .card, .page > section.card { margin-bottom: 18px; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 28px 0 44px; }
.eyebrow { text-transform: uppercase; font-size: .78rem; letter-spacing: .12em; font-weight: 700; color: var(--accent); margin-bottom: .8em; }
.grad { background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 38em; }
.hero-visual { position: relative; aspect-ratio: 1; width: min(100%, 400px); justify-self: center; }
.demo { position: absolute; inset: 14%; width: 72%; height: 72%; object-fit: cover; border-radius: 50%; box-shadow: var(--shadow-lg); border: 4px solid var(--surface); }
.orbit { position: absolute; border-radius: 50%; border: 1.5px dashed var(--border); inset: 0; animation: spin 40s linear infinite; }
.orbit.o2 { inset: 7%; border-style: solid; border-color: color-mix(in srgb, var(--accent) 35%, transparent); animation-duration: 60s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-chip {
  position: absolute; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); animation: float 6s ease-in-out infinite;
}
.hero-chip.c1 { top: 6%; left: -2%; color: var(--ok); }
.hero-chip.c2 { bottom: 10%; right: -4%; color: var(--bad); animation-delay: -2s; }
.hero-chip.c3 { bottom: 2%; left: 8%; color: var(--info); animation-delay: -4s; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------- dots / stats ---------- */
.dots { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 14px; }
.dot { width: 34px; height: 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.dot.ok { background: var(--ok); border-color: var(--ok); }
.dot.bad { background: var(--bad); border-color: var(--bad); }
.dot.now { background: var(--accent); border-color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.streak { display: flex; gap: 18px; align-items: center; }
.streak h2 { font-size: 2rem; margin-bottom: .1em; }
.streak p { margin-bottom: .3em; }
.streak-flame { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.streak-flame .ico { width: 34px; height: 34px; }
.streak-flame.lit { background: linear-gradient(145deg, #ff9a3c, #ff4d6d); color: #fff; box-shadow: 0 8px 24px rgba(255, 90, 80, .4); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: .72rem; color: var(--muted); }
.stats-card .stat-row { grid-template-columns: repeat(3, 1fr); }
.verdict-line { font-weight: 600; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info); margin: 0 0 18px; }
.verdict-line.over { background: var(--warn-bg); color: var(--warn); }
.verdict-line.under { background: var(--info-bg); color: var(--info); }
.verdict-line.well { background: var(--ok-bg); color: var(--ok); }

.how { margin-top: 8px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.step-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--info-bg); color: var(--info); margin-bottom: 12px; }
.step p { margin: 0; font-size: .93rem; }

/* ---------- play ---------- */
.play-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 18px; }
.play-progress { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.play-progress .dots { margin: 0; justify-content: center; }
.play-progress .dot { width: 30px; }
.case-label, .practice-count { margin: 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.running { display: flex; align-items: baseline; gap: 4px; min-width: 56px; justify-content: flex-end; }
.running-num { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.case-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.viewer {
  position: sticky; top: 76px; aspect-ratio: 4 / 3; max-height: 76vh; width: 100%; border-radius: var(--radius); overflow: hidden;
  background: #05060a; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.lesion { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; }
.viewer.loading .lesion { opacity: 0; }
.skeleton { position: absolute; inset: 0; background: linear-gradient(100deg, #0b0d14 30%, #1a1e30 50%, #0b0d14 70%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; display: none; }
.viewer.loading .skeleton { display: block; }
@keyframes shimmer { to { background-position: -200% 0; } }
.img-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: #fff; background: rgba(5, 6, 10, .9); text-align: center; }
.zoom-btn {
  position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px 8px 10px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(10, 12, 20, .65); color: #fff;
  backdrop-filter: blur(8px); font: 600 .85rem var(--font); cursor: pointer;
}
.zoom-btn:hover { background: rgba(10, 12, 20, .85); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.field { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.field.flat { margin: 12px 0 0; }
.field legend, .legend { display: block; font-weight: 700; font-size: 1rem; padding: 0; margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-body {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius-sm); border: 2px solid var(--border);
  background: var(--surface); transition: border-color .15s, background .15s, transform .12s;
}
.choice:hover .choice-body { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.choice:active .choice-body { transform: scale(.98); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--info-bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--ring); outline-offset: 2px; }
.choice-title { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 1.05rem; }
.choice-sub { font-size: .82rem; color: var(--muted); }
.choice.benign .choice-title, .choice.malignant .choice-title { font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice.chip .choice-body { padding: 7px 14px; border-radius: 999px; border-width: 1.5px; font-weight: 600; font-size: .88rem; flex-direction: row; }
.choice.chip .choice-title { font-size: .88rem; font-weight: 600; }

.conf-out { display: block; margin-bottom: 8px; color: var(--muted); font-size: .95rem; }
.conf-out strong { color: var(--text); font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-right: 4px; }
input[type="range"] {
  --fill: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--accent) var(--fill), var(--surface-2) var(--fill)); border: 1px solid var(--border); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
input[type="range"]::-moz-range-progress { height: 10px; border-radius: 99px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; background: var(--surface); border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.ticks { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); padding: 0 6px; font-variant-numeric: tabular-nums; }
.stakes { margin: 10px 0 0; font-size: .92rem; color: var(--muted); }
.stakes strong { font-variant-numeric: tabular-nums; }
.bonus { margin-bottom: 20px; border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.bonus summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
.hint { min-height: 1.4em; margin: 8px 0 0; }
.kbd-hint { margin: 6px 0 0; }

/* reveal */
.verdict { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict h2 { margin: 0; font-size: 1.35rem; outline: none; }
.verdict p { margin: 0; color: var(--text); font-size: .92rem; }
.verdict-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: currentColor; }
.verdict-icon .ico { color: var(--surface); stroke-width: 2.6; }
.pts { text-align: right; line-height: 1; }
.pts-num { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pts-unit { display: block; font-size: .75rem; font-weight: 700; }
.pts.pos, .pts.neg { color: inherit; }
.dxline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; margin: 0 0 14px; }
.dxline.ok { color: var(--ok); } .dxline.bad { color: var(--muted); }
.dxline .ico { width: 18px; height: 18px; }
.truth { margin-bottom: 14px; }
.truth-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.truth-head h3 { margin: 0; font-size: 1.4rem; }
.learn { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; }
.learn ul { margin: 0 0 10px; padding-left: 1.1em; }
.learn li { margin-bottom: .25em; font-size: .93rem; }
.tip { font-size: .9rem; margin: 0; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 0 0 12px; }
.meta div { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.meta dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.meta dd { margin: 0; font-weight: 600; font-size: .92rem; }
.credit { margin-bottom: 16px; word-break: break-word; }

/* ---------- results ---------- */
.results-head { margin-bottom: 18px; }
.big-score { display: flex; align-items: baseline; gap: 10px; }
.big-num { font-size: clamp(3.4rem, 12vw, 5.5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.rlist { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 10px; }
.rrow { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 10px 14px 10px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--border); }
.rrow.ok { border-left-color: var(--ok); } .rrow.bad { border-left-color: var(--bad); }
.rrow img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: #05060a; }
.rrow-main { display: flex; flex-direction: column; min-width: 0; }
.rrow-pts { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.share-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 8px; }
.share-canvas { display: block; width: 100%; max-width: 380px; aspect-ratio: 1; border-radius: 16px; margin: 14px 0; box-shadow: var(--shadow-lg); }
.share-text { white-space: pre-wrap; font: .82rem/1.5 var(--mono); background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin: 14px 0 0; overflow-x: auto; }

/* ---------- profile ---------- */
.chart { width: 100%; height: auto; display: block; margin-bottom: 8px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--font); }
.chart .axis-title { fill: var(--muted); font: 600 12px var(--font); }
.chart .ideal { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart .curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .pt { fill: var(--accent); fill-opacity: .85; stroke: var(--surface); stroke-width: 2; }
.table-wrap { overflow-x: auto; }
.narrow-tbl { max-width: 420px; margin-bottom: 1em; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tbl tbody th { font-weight: 600; white-space: nowrap; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.data-details summary { cursor: pointer; font-weight: 600; font-size: .9rem; margin: 6px 0; }
.empty { text-align: center; padding: 24px 0; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist li strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.mini-dots { display: inline-flex; gap: 4px; }
.mini-dots i { width: 14px; height: 14px; border-radius: 4px; background: var(--ok); }
.mini-dots i.bad { background: var(--bad); }

.glossary { display: grid; gap: 10px; margin: 0 0 1em; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; color: var(--muted); }
.card, .panel { min-width: 0; }

/* ---------- toast, dialogs ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 90;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-lg);
  transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 1px solid var(--border); border-radius: 24px; background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(5, 6, 14, .62); backdrop-filter: blur(6px); }
.dialog-body { padding: 26px; }
.dialog-body h2 { font-size: 1.5rem; }
.dialog-body li { margin-bottom: .5em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.viewer-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; background: #000; inset: 0; }
.viewer-dialog[open] { display: flex; flex-direction: column; }
.vd-stage { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: zoom-in; }
.vd-stage.zoomed { cursor: grab; }
.vd-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.vd-bar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: #0b0d14; color: #fff; flex-wrap: wrap; }
.vd-bar #vd-level { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.vd-bar .btn:not(.primary) { background: #1b1f33; color: #fff; border-color: #333a5c; }
.noscript { padding: 40px 16px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid3 { grid-template-columns: minmax(0, 1fr); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
  .hero-visual { width: min(70%, 300px); order: -1; }
  .case-grid { grid-template-columns: 1fr; }
  .viewer { position: relative; top: 0; max-height: 60vh; }
}
@media (max-width: 720px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0; gap: 0; justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border-top: 1px solid var(--border);
  }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 14px; font-size: .72rem; min-width: 64px; }
  .nav a svg { width: 22px; height: 22px; }
  .icon-btn { margin-left: auto; }
  .page { padding-bottom: 110px; }
  .footer { padding-bottom: 100px; }
  .play-head { grid-template-columns: auto 1fr auto; }
  .play-head .btn.small { padding: 0 10px; }
  .stats-card .stat-row { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.35rem; }
  .verdict { grid-template-columns: auto 1fr; }
  .verdict .pts { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 6px; }
  .panel, .card, .share-block { padding: 18px; }
  .btn.big { width: 100%; }
  .cta-row .btn.big { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .play-progress .dot { width: 22px; }
  .rrow { grid-template-columns: 48px 1fr auto; gap: 10px; }
  .rrow img { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  .topbar, .nav, .footer, .btn, .icon-btn { display: none !important; }
}

/* ---------- round 2: contrast, mobile reflow, touch targets ---------- */
:root {
  --border-strong: #868cae;
  --danger-bg: #c42450;
  --danger-text: #ffffff;
  --accent-2-text: #067d72;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --border-strong: #5f6894; --danger-bg: #ff7b96; --danger-text: #0b0d14; --accent-2-text: #2dd4bf; }
}
:root[data-theme="dark"] { --border-strong: #5f6894; --danger-bg: #ff7b96; --danger-text: #0b0d14; --accent-2-text: #2dd4bf; }

.grad, .big-num { background-image: linear-gradient(100deg, var(--accent), var(--accent-2-text)); }
.btn.danger { background: var(--danger-bg); color: var(--danger-text); }
.choice-body { border-color: var(--border-strong); }
.choice input:checked + .choice-body { border-color: var(--accent); }
.streak-flame.lit { background: linear-gradient(145deg, #e8590c, #c92a4d); }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn[aria-disabled="true"]:active { transform: none; }

.panel, .card, .step, .stat, .viewer, .case-grid > *, .hero > *, .grid3 > *, .grid2 > * { min-width: 0; }
.seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-row { grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr)); }
.stats-card .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.tbl th, .tbl td { overflow-wrap: anywhere; }
.tbl tbody th { white-space: normal; }
.panel { scroll-margin-top: 72px; }

/* text never below 12px */
.nav a { font-size: .8rem; }
.pill, .pill.tiny, .pts-unit, .stat-sub, .meta dt, .tbl thead th, .ticks { font-size: .75rem; }
kbd { font-size: .78em; }
.chart .axis { font-size: 12px; }

/* correct / wrong are never colour-only */
.dot.bad { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .55) 0 3px, transparent 3px 6px); }
.mini-dots i { display: inline-grid; place-items: center; width: 20px; height: 20px; font: 700 .72rem/1 var(--font); font-style: normal; color: #fff; background: var(--ok); }
.mini-dots i.bad { background: var(--bad); }
.toggle { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; min-height: 44px; cursor: pointer; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.actionbar { margin-top: 4px; }
.toast { width: max-content; }
.hero-chip { animation-iteration-count: 3; }
.orbit { animation: none; }

@media (hover: none) {
  .choice-title kbd, .kbd-hint { display: none; }
}
@media (pointer: coarse) {
  .btn.small, .zoom-btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .brand { min-height: 44px; }
  input[type="range"] { height: 44px; }
  summary { min-height: 44px; display: flex; align-items: center; gap: 8px; }
  .link { display: inline-flex; align-items: center; min-height: 44px; }
  .footer a { display: inline-block; padding: 8px 2px; }
}

@media (max-width: 720px) {
  /* backdrop-filter on the header would trap the fixed bottom nav inside it */
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
  .actionbar {
    position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5; margin: 0 -18px -18px; padding: 12px 18px;
    background: linear-gradient(to bottom, transparent, var(--surface) 22%); border-radius: 0 0 var(--radius) var(--radius);
  }
  .hero { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
}

.dot { border-color: var(--border-strong); }
.dot.ok, .dot.bad, .dot.now { border-color: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mini-dots i { color: #0b0d14; }
}
:root[data-theme="dark"] .mini-dots i { color: #0b0d14; }
.table-wrap:focus-visible { outline-offset: 0; }

/* ---------- round 3: touch widths beyond 720px, sticky bar, sizes ---------- */
html { scroll-padding-bottom: 170px; scroll-padding-top: 76px; }
kbd { font-size: 12px; }
.mini-dots i { font-size: 12px; }
.hint:empty { display: none; }
.hint { min-height: 0; }
.vd-bar .btn { min-width: 44px; }

@media (max-width: 900px), (max-height: 520px) {
  .actionbar {
    position: sticky; bottom: env(safe-area-inset-bottom); z-index: 5; margin: 0 -22px -22px; padding: 12px 22px;
    background: linear-gradient(to bottom, transparent, var(--surface) 22%); border-radius: 0 0 var(--radius) var(--radius);
  }
}
@media (pointer: coarse), (max-width: 1024px), (max-height: 520px) {
  .btn.small, .zoom-btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .brand { min-height: 44px; }
  .nav a { min-height: 44px; }
  input[type="range"] { height: 44px; }
  summary { min-height: 44px; display: flex; align-items: center; gap: 8px; }
  .link { display: inline-flex; align-items: center; min-height: 44px; }
  .footer a, .prose a:not(.btn) { display: inline-block; padding: 12px 4px; }
}
@media (hover: none), (pointer: coarse) {
  .kbd-toggle { display: none; }
}
@media (max-width: 720px) {
  .actionbar { bottom: calc(var(--nav-h, 72px) + env(safe-area-inset-bottom) - 2px); margin: 0 -18px -18px; padding: 10px 18px; }
  .toast { bottom: calc(var(--nav-h, 72px) + 16px + env(safe-area-inset-bottom)); }
  .page { padding-bottom: calc(var(--nav-h, 72px) + 40px); }
}

.hero-chip { animation: float 4s ease-in-out 1; }

.tbl thead th { white-space: nowrap; overflow-wrap: normal; }

.chart { max-width: 360px; margin-inline: auto; }
.chart .axis, .chart .axis-title { font-size: 14px; }
@media (pointer: coarse), (max-width: 1024px), (max-height: 520px) {
  .choice.chip .choice-body { min-height: 44px; align-items: center; }
}

/* ---------- round 5 polish ---------- */
.footer a, .prose a:not(.btn) { padding-left: 0; padding-right: 0; }
.dot.now { animation-iteration-count: 3; }
.hero-chip.c1 { animation-delay: 0s; }
.hero-chip.c2 { animation-delay: .4s; }
.hero-chip.c3 { animation-delay: .8s; }
.chart .axis, .chart .axis-title { font-size: 15px; }
.hist a.mono { text-decoration: none; font-weight: 600; }
.hist a.mono:hover { text-decoration: underline; }
@media (max-width: 360px) {
  .choice-body { padding: 12px 12px; }
  .choice.benign .choice-title, .choice.malignant .choice-title { font-size: 1.02rem; }
  .stat { padding: 12px 10px; }
  .stat-label { font-size: .75rem; overflow-wrap: anywhere; }
  .stats-card .stat-row { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
  .play-head { gap: 8px; }
  .running { min-width: 0; }
}

/* ---------- round 5b ---------- */
.nowrap, .mono { white-space: nowrap; }
.tbl tbody th { overflow-wrap: normal; word-break: normal; min-width: 9em; }
.swipe-hint { display: none; }
@media (max-width: 600px) { .swipe-hint { display: inline; } }
.actionbar:not(.ready) { position: static !important; margin: 4px 0 0 !important; padding: 0 !important; background: none !important; }
.choice input:checked + .choice-body {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}
.choice input:checked + .choice-body .choice-title::before { content: "\2713\a0"; font-weight: 800; color: var(--accent); }
.choice.chip input:checked + .choice-body .choice-title::before { margin-right: 2px; }
.footer a, .prose a:not(.btn) { display: inline; padding: 0; }
.footer p { line-height: 1.6; }
