:root {
  --paper: #EEF2EF;
  --card: #FFFFFF;
  --ink: #12282A;
  --ink-2: #4B6163;
  --line: #CBD6D2;
  --line-strong: #9DB0AC;
  --deep: #0C5A5C;
  --mark: #F2A900;
  --mark-soft: #FFF1CC;
  --alert: #C2412D;
  --good: #1E7B52;
  --fig-tint: #9FB4B1;
  --display: "Bricolage Grotesque", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 var(--body);
}
.app { max-width: 780px; margin: 0 auto; padding: 20px 16px 72px; }
h1, h2 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(34px, 7vw, 52px); }
h2 { font-size: 22px; margin: 40px 0 14px; }
p { margin: 0 0 12px; }
b { font-weight: 700; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

.eyebrow { font: 500 13px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 14px; }
.lede { font-size: 19px; max-width: 34em; margin: 16px 0 0; }
.fine { font-size: 14.5px; color: var(--ink-2); margin: 12px 0 0; max-width: 40em; }
.meta { display: flex; gap: 10px; margin: 20px 0 0; font: 500 14px/1 var(--mono); }
.meta span { border: 1.5px solid var(--ink); border-radius: 999px; padding: 7px 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 22px;
  border: 1.5px solid var(--ink); border-radius: 10px; background: transparent; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--card); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn-primary { background: var(--deep); border-color: var(--deep); color: #fff; }
.btn-primary:hover { background: #094648; }
.btn-danger { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn-danger:hover { background: #a23423; }
.btn-quiet { border-color: transparent; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.actions { margin-top: 28px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------------------------------------ intro */
.hero { padding: 28px 0 8px; }
.wordmark { font-size: clamp(84px, 24vw, 176px); letter-spacing: -0.055em; line-height: 0.82; margin-left: -0.04em; }
.hero .lede { margin-top: 22px; }
.rule { margin-top: 26px; }
.rule svg { display: block; width: 100%; height: auto; }
.rule line { stroke: var(--ink); stroke-width: 1.2; }
.rule text { font: 500 10px var(--mono); fill: var(--ink-2); text-anchor: middle; }
.intro-grid { display: grid; gap: 0 40px; }
@media (min-width: 700px) { .intro-grid { grid-template-columns: 5fr 6fr; } }
.plan { list-style: none; margin: 0; padding: 0; counter-reset: part; border-top: 1.5px solid var(--ink); }
.plan li { counter-increment: part; display: grid; grid-template-columns: 26px 1fr auto; gap: 2px 8px; padding: 11px 0; border-bottom: 1px solid var(--line-strong); align-items: baseline; }
.plan li::before { content: counter(part); font: 500 13px var(--mono); color: var(--ink-2); grid-row: span 2; }
.plan-name { font-weight: 700; }
.plan-time { font: 500 13px var(--mono); grid-column: 3; grid-row: 1; }
.plan-what { color: var(--ink-2); font-size: 15px; grid-column: 2 / 4; }
.terms { list-style: none; margin: 0; padding: 0; }
.terms li { padding: 0 0 14px 18px; position: relative; }
.terms li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 8px; height: 8px; border-radius: 50%; background: var(--mark); }

/* ------------------------------------------------------------ part intro, practice */
.part-intro, .res, .review, .mem { padding-top: 24px; }
.practice { margin-top: 32px; padding: 20px 16px 22px; background: var(--card); border: 1.5px dashed var(--line-strong); border-radius: 14px; }
.practice-tag { font: 500 12.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 14px; }
.feedback { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; border-left: 5px solid var(--good); background: #E6F3EC; }
.feedback.is-bad { border-left-color: var(--alert); background: #FBEAE6; }

/* ------------------------------------------------------------ question screen */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0 14px; }
.bar-part { display: flex; flex-direction: column; line-height: 1.2; }
.bar-part b { font-family: var(--display); font-size: 21px; letter-spacing: -0.01em; }
.bar-part span { font: 500 12.5px var(--mono); color: var(--ink-2); margin-top: 3px; }
.bar-timer { font: 500 22px/1 var(--mono); padding: 9px 13px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--card); font-variant-numeric: tabular-nums; }
.bar-timer.is-low { color: #fff; background: var(--alert); border-color: var(--alert); }
.bar-untimed { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }

.ruler { display: flex; border-top: 1.5px solid var(--ink); margin-bottom: 22px; }
.tick { flex: 1; min-width: 0; height: 46px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tick i { display: block; width: 1.5px; height: 9px; background: var(--ink); }
.tick span { font: 500 12px/1 var(--mono); color: var(--ink-2); padding: 3px 6px; border-radius: 6px; }
.tick.is-done i { width: 5px; height: 16px; background: var(--deep); }
.tick.is-here span { background: var(--mark); color: var(--ink); }

.q-count { font: 500 12.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 10px; }
.q-prompt { font-size: 19px; line-height: 1.4; max-width: 36em; margin-bottom: 18px; }
.q-stem:empty { display: none; }
.q-stem { margin-bottom: 22px; }

.matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 348px); margin: 0 auto; }
.cell { aspect-ratio: 1; background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 8px; padding: 5%; }
.cell-q { display: grid; place-items: center; border-style: dashed; border-color: var(--ink); background: transparent; font: 700 44px/1 var(--display); color: var(--ink-2); }

.stem-fig { display: flex; justify-content: center; }
.figbox { width: 150px; background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 8px; padding: 8px; }
.figbox-wide { width: min(100%, 300px); padding: 18px; }
.fold-steps { list-style: none; margin: 0 auto; padding: 0; display: flex; justify-content: center; gap: 12px; counter-reset: step; }
.fold-steps { flex-wrap: nowrap; }
.fold-steps li { counter-increment: step; flex: 1 1 0; min-width: 0; max-width: 132px; font-size: 14px; line-height: 1.3; color: var(--ink-2); }
.fold-steps li .figbox { width: 100%; margin-bottom: 6px; padding: 4px; }
.fold-steps li span::before { content: counter(step) ". "; font-family: var(--mono); color: var(--ink); }

.series { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.series span { min-width: 58px; padding: 12px 10px; text-align: center; font: 500 24px/1 var(--mono); background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 8px; }
.series .series-q { background: transparent; border-style: dashed; border-color: var(--ink); color: var(--ink-2); }
.pairs { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 8px; }
.pairs span { padding: 11px 16px; text-align: center; font: 500 20px/1 var(--mono); background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 8px; white-space: nowrap; }
.pairs span:last-child { border-style: dashed; border-color: var(--ink); background: transparent; }
.labels { list-style: none; margin: 0 auto; padding: 0; max-width: 420px; display: grid; gap: 8px; }
.labels li { padding: 11px 14px; background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 8px; }
.labels b { font-family: var(--mono); font-weight: 500; font-size: 14px; margin-right: 8px; }

.opts { display: grid; gap: 10px; }
.opts-fig { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 640px) { .opts-n6 { grid-template-columns: repeat(6, 1fr); } .opts-n5 { grid-template-columns: repeat(5, 1fr); } }
.opts-short { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.opts-text { grid-template-columns: 1fr; max-width: 560px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 9px 12px; text-align: left;
  background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 10px; cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:disabled { cursor: default; }
.opt-key { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; font: 500 12px/1 var(--mono); background: var(--card); }
.opt-body { flex: 1; min-width: 0; }
.opts-fig .opt { flex-direction: column; align-items: stretch; gap: 0; padding: 26px 8px 8px; }
.opts-fig .opt-key { position: absolute; top: 6px; left: 6px; width: 21px; height: 21px; font-size: 11px; }
.opts-short .opt { flex-direction: column; gap: 6px; padding: 9px 4px 11px; text-align: center; }
.opts-short .opt-text { font: 500 18px/1 var(--mono); }
.opt.is-picked { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); background: var(--mark-soft); }
.opt.is-picked .opt-key { background: var(--mark); }
.opt.is-right { border-color: var(--good); box-shadow: inset 0 0 0 1.5px var(--good); background: #E6F3EC; }
.opt.is-right .opt-key { background: var(--good); border-color: var(--good); color: #fff; }
.opt.is-wrong { border-color: var(--alert); box-shadow: inset 0 0 0 1.5px var(--alert); background: #FBEAE6; }
.opt.is-wrong .opt-key { background: var(--alert); border-color: var(--alert); color: #fff; }

@media (min-width: 760px) {
  .q-matrix { display: grid; grid-template-columns: 330px 1fr; gap: 36px; align-items: center; }
  .q-matrix .q-stem { margin-bottom: 0; }
  .q-matrix .opts-fig { grid-template-columns: repeat(3, 1fr); }
}

.q-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.confirm { margin-top: 24px; padding: 16px; background: var(--card); border: 1.5px solid var(--ink); border-radius: 12px; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ------------------------------------------------------------ figures */
.fig { display: block; width: 100%; height: auto; color: var(--ink); overflow: visible; }
.fg-shape { stroke: currentColor; stroke-width: 4; stroke-linejoin: round; }
.fg-none { fill: none; }
.fg-tint { fill: var(--fig-tint); }
.fg-solid { fill: currentColor; }
.fg-seg { stroke: currentColor; stroke-width: 5.5; stroke-linecap: round; }
.fg-anchor { fill: var(--line-strong); }
.fg-cell { fill: currentColor; stroke: var(--card); stroke-width: 1.5; }
.fg-ghost { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 3 3; }
.fg-paper { fill: #F6F8F7; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }
.fg-fold { stroke: currentColor; stroke-width: 1.8; stroke-dasharray: 5 4; }
.fg-arrow { fill: none; stroke: var(--deep); stroke-width: 2.8; stroke-linecap: round; }
.fg-arrowhead { fill: var(--deep); }
.fg-hole { fill: currentColor; }
.fg-cube-t, .fg-cube-l, .fg-cube-r { stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.fg-cube-t { fill: #FFFFFF; }
.fg-cube-l { fill: #C6D3CF; }
.fg-cube-r { fill: #8AA29F; }

/* ------------------------------------------------------------ memory */
.mem { text-align: center; }
.mem h1 { margin-top: 20px; }
.mem .lede { margin-left: auto; margin-right: auto; }
.mem .actions-row { justify-content: center; }
.mem .fine { margin-left: auto; margin-right: auto; }
.mem-note { font: 500 13px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin: 36px 0 0; }
.mem-next { font-size: 22px; margin: 18px 0 0; }
.digit { font: 700 clamp(120px, 38vw, 220px)/1.1 var(--display); height: 1.1em; user-select: none; -webkit-user-select: none; }
.recall { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-top: 26px; }
.recall input { width: min(100%, 360px); padding: 10px 0 8px 0.3em; text-align: center; font: 500 34px/1.2 var(--mono); letter-spacing: 0.3em; color: var(--ink); background: transparent; border: 0; border-bottom: 3px solid var(--ink); border-radius: 0; }
.recall input:focus { outline: none; border-bottom-color: var(--mark); }

/* ------------------------------------------------------------ results */
.res-range { display: flex; align-items: baseline; gap: 0.12em; font-size: clamp(76px, 22vw, 168px); letter-spacing: -0.05em; line-height: 0.9; margin-left: -0.03em; }
.res-range i { font: italic 400 0.17em/1 var(--body); letter-spacing: 0; color: var(--ink-2); padding: 0 0.5em; }
.res-sub { font-size: 19px; max-width: 34em; margin-top: 20px; }
.curve { margin: 26px 0 0; }
.curve svg { display: block; width: 100%; height: auto; }
.cv-pop { fill: #D5DFDB; }
.cv-band { fill: var(--mark); }
.cv-post { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.cv-axis, .cv-tick { stroke: var(--ink); stroke-width: 1.4; }
.cv-mark { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 3 4; }
.cv-num { font: 500 13px var(--mono); fill: var(--ink); text-anchor: middle; }
.curve figcaption { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14.5px; color: var(--ink-2); margin-top: 6px; }
.curve figcaption span { display: inline-flex; align-items: center; gap: 7px; }
.curve figcaption i { flex: none; width: 14px; height: 14px; border-radius: 3px; }
.key-pop { background: #D5DFDB; }
.key-you { background: var(--mark); }

.profile { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.profile li { display: grid; grid-template-columns: 132px 1fr 62px; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line-strong); }
.pf-name { font-weight: 700; }
.pf-bar { position: relative; height: 12px; background: var(--line); border-radius: 2px; }
.pf-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--deep); border-radius: 2px; }
.pf-bar em, .pf-keymark { position: absolute; top: -5px; width: 3px; height: 22px; background: var(--mark); outline: 1.5px solid var(--ink); }
.pf-score { font: 500 13px var(--mono); text-align: right; white-space: nowrap; }
.pf-spans { font-size: 15.5px; }
.pf-key { position: relative; padding-left: 16px; }
.pf-keymark { left: 2px; top: 2px; height: 16px; }
@media (max-width: 480px) { .profile li { grid-template-columns: 1fr auto; } .pf-bar, .pf-spans { grid-column: 1 / 3; grid-row: 2; } .pf-score { grid-column: 2; grid-row: 1; } }
.trust p { max-width: 40em; }

/* ------------------------------------------------------------ review */
.rv { margin: 0 0 18px; padding: 18px 16px 16px; background: var(--card); border: 1.5px solid var(--line-strong); border-radius: 14px; }
.rv-head { font: 500 13px/1 var(--mono); color: var(--ink-2); display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.rv-tag { padding: 5px 9px; border-radius: 999px; color: #fff; background: var(--good); }
.rv-tag.is-bad { background: var(--alert); }
.rv-why { margin: 16px 0 0; max-width: 40em; }
.rv .opt { background: var(--paper); }

/* ------------------------------------------------------------ phones: keep figure and options on one screen */
@media (max-width: 520px) {
  .app { padding-top: 12px; }
  .bar { padding-bottom: 10px; }
  .bar-part b { font-size: 18px; }
  .bar-timer { font-size: 18px; padding: 7px 10px; }
  .ruler { margin-bottom: 12px; }
  .tick { height: 40px; }
  .q-count { display: none; }
  .q-prompt { font-size: 17px; margin-bottom: 12px; }
  .q-stem { margin-bottom: 14px; }
  .matrix { width: min(100%, 240px); gap: 6px; }
  .opts { gap: 8px; }
  .opts-fig .opt { padding: 7px; }
  .opts-fig .opt-key { top: 4px; left: 4px; width: 19px; height: 19px; font-size: 10.5px; }
  .opts-fig.opts-n6 .opt, .q-rotation .opt, .q-fold .opt { padding: 16px 12px 6px; }
  .figbox { width: 124px; }
  .figbox-wide { width: min(100%, 240px); padding: 12px; }
  .fold-steps { gap: 8px; }
  .fold-steps li { font-size: 12.5px; }
  .q-nav { margin-top: 18px; }
  .cv-num { font-size: 22px; }
  .series span { min-width: 46px; font-size: 21px; padding: 10px 6px; }
}

@media (prefers-reduced-motion: no-preference) {
  .opt, .btn { transition: background-color 0.12s, border-color 0.12s; }
}
@media print {
  body { background: #fff; }
  .actions, .confirm, .btn { display: none !important; }
  .rv { break-inside: avoid; }
}
