:root {
  --paper: #F3F5FA;
  --surface: #FFFFFF;
  --ink: #1B2130;
  --ink-2: #4C566B;
  --line: #D6DCE9;
  --form: #2B4BCB;
  --on-form: #FFFFFF;
  --form-tint: #E4E9FB;
  --ok: #17794A;
  --ok-tint: #E0F3E8;
  --bad: #B8342A;
  --bad-tint: #FBE7E4;
  --flag: #9A5B00;
  --flag-tint: #FBEFD6;
  --lift: 0 1px 2px rgba(27, 33, 48, .06), 0 10px 28px rgba(27, 33, 48, .10);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11141B;
    --surface: #1A1F2A;
    --ink: #E9EDF5;
    --ink-2: #A6B0C5;
    --line: #2D3546;
    --form: #93A6FF;
    --on-form: #10131A;
    --form-tint: #232C4D;
    --ok: #62D096;
    --ok-tint: #16372A;
    --bad: #FF8E80;
    --bad-tint: #45211D;
    --flag: #F2B552;
    --flag-tint: #3E3013;
    --lift: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--form);
  overflow-wrap: break-word;
}

::selection { background: var(--form-tint); color: var(--ink); }

:focus-visible { outline: 2px solid var(--form); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3, p, ul, fieldset, legend { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: var(--form); text-underline-offset: 3px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

code {
  font: 0.9em/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--form-tint);
  border-radius: 5px;
  padding: 1px 5px;
}

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
}

body.in-session #app { padding-top: 0; padding-bottom: calc(108px + env(safe-area-inset-bottom)); }

/* ---------- page furniture ---------- */

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.page-head .lede { margin-top: 8px; color: var(--ink-2); max-width: 60ch; }

.back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin: -10px 0 4px -6px; padding-right: 10px;
  text-decoration: none; font-weight: 500;
}

h2.sec { font-size: 1.0625rem; line-height: 1.3; font-weight: 650; margin: 32px 0 10px; }

.muted { color: var(--ink-2); }
.fine { color: var(--ink-2); font-size: 0.875rem; line-height: 1.5; margin-top: 16px; max-width: 62ch; }

.cta-stack { display: grid; gap: 10px; margin-top: 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; text-align: center;
  transition: transform .12s var(--ease), background-color .12s, border-color .12s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--form); border-color: var(--form); color: var(--on-form); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--form); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
}
.icon-btn:active { background: var(--form-tint); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px; padding: 14px 16px; border-radius: 14px;
  background: var(--form-tint); color: var(--ink); text-decoration: none; font-weight: 600;
}
.banner .timer { color: var(--form); }

/* ---------- home: progress sheet ---------- */

.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet-head h2 { font-size: 1.0625rem; font-weight: 650; }
.sheet-head p { font-size: 0.875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.sheet { border-top: 1px solid var(--line); }
.sheet-row {
  display: block; padding: 12px 0 14px; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.sheet-row:active { background: var(--form-tint); }
.sheet-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sheet-name { font-weight: 550; line-height: 1.3; }
.sheet-count { flex: none; font-size: 0.875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.dot { width: 15px; height: 10px; border-radius: 999px; border: 1.25px solid var(--form); opacity: .55; }
.dot.ok { background: var(--ink); border-color: var(--ink); opacity: 1; }
.dot.bad { background: var(--bad-tint); border-color: var(--bad); opacity: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 0.8125rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.settings { margin-top: 36px; border-top: 1px solid var(--line); }
.settings summary { min-height: 48px; display: flex; align-items: center; color: var(--ink-2); cursor: pointer; }
.settings-body { display: grid; gap: 16px; padding-bottom: 8px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.875rem; color: var(--ink-2); }
.field input, .field select {
  min-height: 48px; width: 100%; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
}

/* ---------- lists ---------- */

.list { border-top: 1px solid var(--line); }
.list-row {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 0;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
}
.list-row:active { background: var(--form-tint); }
.list-row > .ic { color: var(--ink-2); }
.list-num {
  flex: none; display: grid; place-items: center; width: 34px; height: 24px;
  border: 1.5px solid var(--form); border-radius: 999px; color: var(--form);
  font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.list-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list-title { font-weight: 550; line-height: 1.3; }
.list-sub { font-size: 0.875rem; color: var(--ink-2); }
.list-score { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.list-score.ok { color: var(--ok); }
.list-score.bad { color: var(--bad); }

/* ---------- notes ---------- */

.notes { max-width: 68ch; }
.notes-intro { color: var(--ink-2); }
.notes h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 650; margin: 30px 0 10px; }
.notes ul { display: grid; gap: 10px; }
.notes li { position: relative; padding-left: 24px; }
.notes li::before {
  content: ""; position: absolute; left: 0; top: .58em;
  width: 13px; height: 8px; border: 1.25px solid var(--form); border-radius: 999px;
}
.notes .traps li::before { background: var(--ink); border-color: var(--ink); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pager a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; text-decoration: none; font-weight: 500; }

/* ---------- choices and segmented controls ---------- */

.choice { display: grid; gap: 10px; }
.choice legend { font-size: 0.875rem; color: var(--ink-2); margin-bottom: 8px; }
.choice-row {
  display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer;
}
.choice-row:has(input:checked) { border-color: var(--form); background: var(--form-tint); }
.choice-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--form); flex: none; }
.choice-main { display: grid; gap: 1px; }
.choice-title { font-weight: 600; }
.choice-sub { font-size: 0.875rem; color: var(--ink-2); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--form-tint); }
.seg label {
  display: grid; place-items: center; min-height: 44px; padding: 4px 6px; border-radius: 10px;
  font-size: 0.9375rem; font-weight: 550; text-align: center; line-height: 1.2; cursor: pointer; color: var(--ink-2);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(27, 33, 48, .14); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--form); outline-offset: 2px; }

.setup { display: grid; gap: 22px; }
.setup .field > span, .setup legend { font-size: 0.875rem; color: var(--ink-2); margin-bottom: 8px; display: block; }
.pool-note { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- session chrome ---------- */

.session-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; margin: 0 -16px; padding: env(safe-area-inset-top) 16px 0;
  background: var(--paper);
}
.session-bar .icon-btn { margin-left: -10px; }
.session-pos { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.session-pos strong { color: var(--ink); font-weight: 650; }
.timer { font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.timer.is-low { color: var(--bad); }

.progress { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; height: 3px; margin: 0 -16px; background: var(--line); }
.progress span { display: block; height: 100%; background: var(--form); transition: width .3s var(--ease); }

.q-wrap { padding-top: 22px; }
.q-text { font-size: 1.125rem; line-height: 1.5; max-width: 68ch; }
.q-hint { margin-top: 10px; color: var(--form); font-weight: 600; font-size: 0.9375rem; }

.opts { display: grid; gap: 10px; margin-top: 20px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
  text-align: left; line-height: 1.45;
  transition: border-color .12s, background-color .12s;
}
.opt:disabled { color: inherit; opacity: 1; cursor: default; }
.bubble {
  flex: none; display: grid; place-items: center; width: 34px; height: 24px; margin-top: 0;
  border: 1.5px solid var(--form); border-radius: 999px; color: var(--form);
  font-size: 0.8125rem; font-weight: 650; line-height: 1;
  transition: background-color .12s, color .12s, border-color .12s;
}
.opt-body { display: grid; gap: 6px; min-width: 0; }
.opt.is-picked { border-color: var(--ink); }
.opt.is-picked .bubble { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.opt.is-right { border-color: var(--ok); background: var(--ok-tint); }
.opt.is-right .bubble { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-tint); }
.opt.is-wrong .bubble { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.opt-note { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; font-weight: 650; }
.opt-note .ic { width: 16px; height: 16px; stroke-width: 2.25; }
.is-right .opt-note { color: var(--ok); }
.is-wrong .opt-note { color: var(--bad); }

.verdict { margin-top: 22px; font-size: 1.125rem; font-weight: 700; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

.why { margin-top: 10px; max-width: 68ch; }
.rev-body .why { margin-top: 18px; }
.why h3 { font-size: 0.9375rem; font-weight: 650; margin-bottom: 4px; }
.why-dom { margin-top: 10px; font-size: 0.875rem; color: var(--ink-2); }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.action-bar > .inner { max-width: 608px; margin: 0 auto; display: grid; gap: 8px; }
.test-bar > .inner { grid-template-columns: 50px 1fr 1fr 1.15fr; }
.test-bar .btn { padding: 0 8px; }
.test-bar .btn.is-on { border-color: var(--flag); background: var(--flag-tint); color: var(--flag); }

/* ---------- answer sheet (bottom sheet) ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(10, 13, 22, .5); animation: fade .2s both; }
.sheet-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 640px; max-height: 88dvh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--lift);
  animation: rise .28s var(--ease) both;
}
.sheet-panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.sheet-panel-head h2 { font-size: 1.125rem; font-weight: 650; }
.sheet-panel-head .icon-btn { margin-right: -10px; }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; margin: 14px 0 4px; }
.cell {
  position: relative; display: grid; place-items: center; height: 38px;
  border: 1.5px solid var(--form); border-radius: 999px; background: transparent; color: var(--form);
  font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.cell.is-done { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cell.is-flag::after {
  content: ""; position: absolute; top: -4px; right: -2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--flag); border: 2px solid var(--surface);
}
.cell.is-current { outline: 2px solid var(--form); outline-offset: 2px; }
.key { display: inline-block; width: 22px; height: 14px; border-radius: 999px; border: 1.5px solid var(--form); }
.key.done { background: var(--ink); border-color: var(--ink); }
.key.flag { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--flag); }
.confirm { margin-top: 18px; font-weight: 550; }
.sheet-panel .cta-stack { margin-top: 14px; }
.btn.danger { border-color: transparent; background: transparent; color: var(--bad); }

@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- results and review ---------- */

.dom-rows { display: grid; gap: 14px; }
.dom-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dom-name { line-height: 1.3; }
.dom-score { flex: none; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.875rem; }
.dom-score b { color: var(--ink); font-weight: 650; font-size: 1rem; margin-left: 8px; }
.bar { position: relative; height: 8px; margin-top: 6px; border-radius: 999px; background: var(--line); }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--ink); }
.bar.ok span { background: var(--ok); }
.bar.bad span { background: var(--bad); }
.bar::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 80%; width: 2px; background: var(--ink-2); border-radius: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 40px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 999px;
  background: transparent; font-size: 0.875rem; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.rev-list { border-top: 1px solid var(--line); }
.rev { border-bottom: 1px solid var(--line); }
.rev summary { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; cursor: pointer; list-style: none; }
.rev summary::-webkit-details-marker { display: none; }
.rev-n { flex: none; width: 2ch; padding-top: 1px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.rev-q { flex: 1; min-width: 0; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.rev[open] .rev-q { display: block; font-size: 1.0625rem; line-height: 1.5; }
.rev-state { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.rev-state .ic { width: 15px; height: 15px; stroke-width: 2.5; }
.rev-ok .rev-state { background: var(--ok-tint); color: var(--ok); }
.rev-bad .rev-state { background: var(--bad-tint); color: var(--bad); }
.rev-skip .rev-state { background: var(--line); color: var(--ink-2); }
.rev-body { padding: 0 0 20px; }
.rev-body .opts { margin-top: 2px; }
.empty { padding: 18px 0; color: var(--ink-2); }

/* ---------- tabs ---------- */

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px max(8px, calc((100vw - 640px) / 2)) calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
#tabs a {
  display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 7px 4px 4px;
  border-radius: 12px; color: var(--ink-2); text-decoration: none; font-size: 0.75rem; font-weight: 550;
}
#tabs a .ic { width: 22px; height: 22px; }
#tabs a[aria-current="page"] { color: var(--form); }
#tabs a:active { background: var(--form-tint); }

@media (min-width: 700px) {
  #app { padding-top: 48px; }
  .page-head h1 { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
