/* Clause & Effect — WIRXL Clay palette, Sunset Arcade shapes. */

:root {
  color-scheme: dark;
  --bg: #1A0D06;
  --surface: #3A2013;
  --surface-2: #4A2C1C;
  --border: #B46A45;
  --text: #FFE8D6;
  --muted: #D3A889;
  --accent: #F2703C;
  --accent-hover: #FF8A5C;
  --accent-text: #F2703C;
  --on-accent: #1A0D06;
  --focus: #F2703C;
  --shadow: #8B3A1A;
  --rust: #8B3A1A;

  --good: #8FD694;      --good-text: #8FD694;  --good-line: #8FD694;
  --bad: #FF7A8A;       --bad-text: #FF8F9C;   --bad-line: #FF7A8A;
  --gold: #FFC857;      --gold-text: #FFC857;
  --blue: #7CC6FE;      --blue-text: #7CC6FE;

  --good-tint: color-mix(in srgb, var(--good) 16%, var(--bg));
  --bad-tint: color-mix(in srgb, var(--bad) 16%, var(--bg));

  --bw: 3px;
  --bw-sm: 2px;
  --sh-card: 5px 5px 0 var(--shadow);
  --sh-btn: 4px 4px 0 var(--shadow);
  --sh-sm: 3px 3px 0 var(--shadow);
  --sh-text: 2px 2px 0 var(--shadow);

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --gutter: 16px;
  --maxw: 680px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #FBF3EC; --surface: #FFFFFF; --surface-2: #F3E6DB; --border: #BA7A50;
    --text: #1A0D06; --muted: #7D5240; --accent-text: #B84518; --focus: #B84518;
    --good-text: #1E6B34; --good-line: #3F9E55;
    --bad-text: #B3243A;  --bad-line: #D9435A;
    --gold-text: #7A5200; --blue-text: #1D5C8F;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FBF3EC; --surface: #FFFFFF; --surface-2: #F3E6DB; --border: #BA7A50;
  --text: #1A0D06; --muted: #7D5240; --accent-text: #B84518; --focus: #B84518;
  --good-text: #1E6B34; --good-line: #3F9E55;
  --bad-text: #B3243A;  --bad-line: #D9435A;
  --gold-text: #7A5200; --blue-text: #1D5C8F;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
strong { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: var(--maxw); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

/* ---------- Type helpers ---------- */
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.display { font-family: var(--font-display); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-shadow: var(--sh-text); }
.wordmark {
  font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .12em; line-height: 1;
  text-transform: uppercase; margin: 0;
  background: linear-gradient(180deg, #FFE8D6 0 46%, var(--accent) 50% 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(2px 2px 0 var(--shadow));
}
:root[data-theme="light"] .wordmark { background: none; color: var(--accent-text); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .wordmark { background: none; color: var(--accent-text); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .1em; text-transform: uppercase;
  padding: 14px 22px; min-height: 54px;
  background: var(--accent); color: var(--on-accent);
  border: var(--bw-sm) solid var(--accent); border-radius: 0;
  box-shadow: var(--sh-btn);
  transition: transform .06s, box-shadow .06s, background .15s;
  user-select: none;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
.btn:disabled { background: var(--surface-2); border-color: var(--border); color: var(--muted); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); }
.btn.good { background: var(--good); border-color: var(--good); color: var(--on-accent); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
.btn.block { width: 100%; }
.btn.small { font-size: 13px; min-height: 40px; padding: 8px 14px; box-shadow: var(--sh-sm); }
.btn.small:active:not(:disabled) { transform: translate(3px, 3px); }

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  background: transparent; border: var(--bw-sm) solid transparent; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--border); }
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: square; stroke-linejoin: miter; flex: none; }
.icon.fill { fill: currentColor; stroke: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 10px; border: var(--bw-sm) solid var(--border); background: var(--surface);
  color: var(--text); box-shadow: var(--sh-sm);
}
.chip .icon { width: 16px; height: 16px; }
.chip.gold { color: var(--gold-text); }
.chip.gold .icon { color: var(--gold); }

/* Skewed flag badge */
.flag { display: inline-block; background: var(--accent); transform: skewX(-12deg); padding: 3px 10px; }
.flag > span { display: block; transform: skewX(12deg); font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--on-accent); }
.flag.gold { background: var(--gold); }

/* Card with corner brackets */
.card {
  position: relative; background: var(--surface);
  border: var(--bw) solid var(--border); box-shadow: var(--sh-card); padding: 18px;
}
.card.brackets::before, .card.brackets::after {
  content: ''; position: absolute; width: 14px; height: 14px; border: var(--bw) solid var(--accent);
}
.card.brackets::before { top: calc(var(--bw) * -1); left: calc(var(--bw) * -1); border-right: 0; border-bottom: 0; }
.card.brackets::after { bottom: calc(var(--bw) * -1); right: calc(var(--bw) * -1); border-left: 0; border-top: 0; }

.rule { height: 4px; border-top: 3px solid var(--border); border-bottom: 1px solid var(--border); margin: 28px 0; }

/* ---------- Home ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 14px var(--gutter);
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: var(--bw-sm) solid var(--surface-2);
}
.topbar .wordmark { margin-right: auto; white-space: nowrap; font-size: clamp(19px, 5.6vw, 24px); }
.topbar .chip { box-shadow: none; }

.home { padding: 0 var(--gutter) 40px; }

.hero { margin-top: 22px; overflow: hidden; padding: 22px 18px 20px; }
.hero .sun {
  position: absolute; width: 150px; height: 150px; border-radius: 50%; top: -58px; right: -18px;
  background: linear-gradient(180deg, #FFE8D6 0%, var(--accent) 58%, var(--rust) 100%);
}
.hero .sun::after {
  content: ''; position: absolute; inset: 44% 0 0 0;
  background: repeating-linear-gradient(180deg, var(--surface) 0 4px, transparent 4px 11px);
}
.hero-row { position: relative; display: flex; align-items: flex-end; gap: 14px; }
.hero-text { flex: 1; min-width: 0; }
.hero h2 { font-size: 30px; line-height: 1.1; margin: 8px 0 6px; }
.hero p { margin: 0 0 16px; color: var(--muted); }
.hero .evi { width: 96px; flex: none; margin-bottom: 62px; }
.hero .btn { margin-top: 4px; }

.stage { margin-top: 38px; }
.stage-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stage-head h3 { font-size: 22px; margin: 0; }
.stage-head .mono { color: var(--accent-text); }
.stage-desc { color: var(--muted); margin: 6px 0 0; }

.unit { margin-top: 18px; }
.unit-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--accent); color: var(--on-accent); border: var(--bw-sm) solid var(--accent); box-shadow: var(--sh-btn);
}
.unit-banner h4 { margin: 2px 0 0; font-family: var(--font-display); font-size: 20px; letter-spacing: .08em; text-transform: uppercase; }
.unit-banner .mono { color: var(--on-accent); }
.unit-banner p { margin: 2px 0 0; font-size: 14px; }

.trail { position: relative; padding: 26px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(var(--x, 0)); position: relative; }
.node {
  width: 76px; height: 76px; display: grid; place-items: center; position: relative;
  background: var(--surface); color: var(--muted);
  border: var(--bw) solid var(--border); box-shadow: 5px 5px 0 var(--shadow);
  transition: transform .06s, box-shadow .06s;
}
.node .icon { width: 32px; height: 32px; }
.node:active { transform: translate(5px, 5px); box-shadow: none; }
.node.done { background: var(--gold); border-color: var(--gold); color: var(--on-accent); }
.node.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.node.current::after {
  content: ''; position: absolute; inset: -11px; border: var(--bw-sm) solid var(--accent);
  animation: pulse 1.6s ease-out infinite;
}
.node.soon { border-style: dashed; box-shadow: none; background: transparent; cursor: default; }
.node.soon:active { transform: none; }
.node.boss { width: 66px; height: 66px; transform: rotate(45deg); margin: 10px; border-color: var(--gold); }
.node.boss .icon { transform: rotate(-45deg); color: var(--gold-text); }
.node.boss:active { transform: rotate(45deg); }
.node-label { font-size: 14px; font-weight: 500; text-align: center; max-width: 180px; line-height: 1.3; }
.node-label.muted { color: var(--muted); font-weight: 400; }
.node-wrap .flag { position: absolute; top: -20px; z-index: 2; white-space: nowrap; }

.soon-card { margin-top: 14px; padding: 16px; border: var(--bw-sm) dashed var(--border); color: var(--muted); }
.soon-card strong { color: var(--text); }
.boss-row { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.boss-row .node.boss { flex: none; }

.grid-band { height: 70px; overflow: hidden; position: relative; border-top: var(--bw) solid var(--border); margin-top: 48px; }
.grid-band::before {
  content: ''; position: absolute; left: -60%; right: -60%; top: 0; height: 190px;
  background-image: linear-gradient(var(--border) 2px, transparent 2px), linear-gradient(90deg, var(--border) 2px, transparent 2px);
  background-size: 44px 26px; transform: perspective(110px) rotateX(50deg); transform-origin: top center; opacity: .5;
}
.footer { padding: 14px var(--gutter) 30px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer .badge { font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); text-decoration: none; }

/* Menu */

/* ---------- Lesson ---------- */
.lesson { display: flex; flex-direction: column; min-height: 100dvh; }
.lesson-top {
  display: flex; align-items: center; gap: 12px; padding: 12px var(--gutter);
  position: sticky; top: 0; z-index: 20; background: var(--bg);
}
.bar { flex: 1; height: 18px; border: var(--bw-sm) solid var(--border); background: var(--surface); position: relative; overflow: hidden; }
.bar > i {
  position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent);
  transition: width .35s cubic-bezier(.3, 1.4, .5, 1);
}
.bar > i::after { content: ''; position: absolute; left: 6px; right: 6px; top: 3px; height: 3px; background: rgba(255, 232, 214, .45); }
.combo { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .06em; color: var(--gold-text); display: inline-flex; align-items: center; gap: 4px; min-width: 52px; justify-content: flex-end; }
.combo .icon { color: var(--gold); width: 20px; height: 20px; }
.combo.on { animation: pop .3s; }

.lesson-body { flex: 1; padding: 8px var(--gutter) 28px; }
.ex { animation: enter .28s ease-out; }
.ex-kind { display: flex; align-items: center; gap: 8px; color: var(--accent-text); margin: 10px 0 8px; }
.ex-kind .icon { width: 18px; height: 18px; }
.ex-kind .retry { color: var(--gold-text); margin-left: auto; }
.prompt { font-size: 21px; font-weight: 500; line-height: 1.35; margin: 0 0 18px; }
.sub { color: var(--muted); margin: -8px 0 16px; }

.lesson-foot {
  position: sticky; bottom: 0; z-index: 10; background: var(--bg);
  border-top: var(--bw) solid var(--surface-2); padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.lesson-foot .btn { flex: 1; }
.foot-hint { flex-basis: 100%; margin: 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.foot-hint strong { color: var(--gold-text); }
@media (hover: none) and (pointer: coarse) { .kbd { display: none; } }
.pairs { list-style: none; margin: 4px 0 10px; padding: 0; display: grid; gap: 4px; }
.pairs li { display: flex; gap: 8px; align-items: baseline; }
.pairs .arrow { color: var(--muted); }
.sure {
  display: inline-flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 14px;
  background: var(--surface); border: var(--bw-sm) solid var(--border); color: var(--muted);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
}
.sure[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-text); background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
.sure .icon { width: 18px; height: 18px; }

.feedback { flex-direction: column; align-items: stretch; gap: 12px; animation: slideup .22s ease-out; }
.feedback.good { background: var(--good-tint); border-top-color: var(--good-line); }
.feedback.bad { background: var(--bad-tint); border-top-color: var(--bad-line); }
.fb-head { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; }
.feedback.good .fb-head { color: var(--good-text); }
.feedback.bad .fb-head { color: var(--bad-text); }
.fb-head .icon { width: 28px; height: 28px; stroke-width: 3; }
.fb-head .fb-xp { margin-left: auto; font-size: 16px; color: var(--gold-text); }
.fb-body { max-height: 38vh; overflow-y: auto; font-size: 15px; }
.fb-body p { margin: 0 0 8px; }
.fb-body .label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.fb-note { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; color: var(--gold-text); }
details.why-all { margin-top: 6px; }
details.why-all summary { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); cursor: pointer; }
details.why-all ul { margin: 8px 0 0; padding-left: 18px; }
details.why-all li { margin-bottom: 6px; }

/* Options */
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; background: var(--surface); border: var(--bw-sm) solid var(--border);
  box-shadow: var(--sh-sm); font-size: 16px; line-height: 1.4;
  transition: transform .06s, box-shadow .06s, border-color .12s, background .12s;
}
.opt:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.opt .key {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center; margin-top: -1px;
  font-family: var(--font-mono); font-size: 12px; border: var(--bw-sm) solid var(--border); color: var(--muted);
}
.opt .tick { flex: none; width: 24px; height: 24px; border: var(--bw-sm) solid var(--border); display: grid; place-items: center; margin-top: 0; }
.opt .tick .icon { width: 16px; height: 16px; stroke-width: 3.5; opacity: 0; }
.opt.sel { border-color: var(--accent); background: var(--surface-2); box-shadow: 3px 3px 0 var(--accent); }
.opt.sel .key { border-color: var(--accent); color: var(--accent-text); }
.opt.sel .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.opt.sel .tick .icon { opacity: 1; }
.opt.picked .tick { background: var(--text); border-color: var(--text); color: var(--bg); }
.opt.picked .tick .icon { opacity: 1; }
.opt.right { border-color: var(--good-line); background: var(--good-tint); box-shadow: 3px 3px 0 var(--good-line); }
.opt.wrong { border-color: var(--bad-line); background: var(--bad-tint); box-shadow: 3px 3px 0 var(--bad-line); }
.opt.missed { border-style: dashed; border-color: var(--good-line); }
.opt:disabled { cursor: default; }
.opt:disabled:not(.right):not(.wrong):not(.missed) { opacity: .6; }

/* Teach card */
.teach { padding: 22px 20px; }
.teach h2 { font-size: 26px; margin: 0 0 12px; line-height: 1.15; }
.teach .body { font-size: 18px; line-height: 1.55; }
.teach .body p { margin: 0 0 12px; }
.teach .example { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); font-size: 16px; }
.teach .example .mono { display: block; margin-bottom: 4px; color: var(--accent-text); }
.teach-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.teach-list { --kw: 54px; }
.teach-list li { display: grid; grid-template-columns: var(--kw) 1fr; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.teach-list:has(.k.long) { --kw: 76px; }
.teach-list li:last-child { border-bottom: 0; }
.teach-list .k { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: .04em; text-align: center; padding: 4px 0; background: var(--accent); color: var(--on-accent); }
.teach-list .k.long { font-size: 16px; padding: 6px 0; }
.teach-list .t { font-weight: 700; }
.teach-list .d { color: var(--muted); font-size: 15px; }
.teach-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.teach-head .evi { width: 58px; flex: none; }

/* Flashcard */
.flash { perspective: 1200px; }
.flash-inner { position: relative; min-height: 260px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, .8, .4, 1); cursor: pointer; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px;
  padding: 26px; background: var(--surface); border: var(--bw) solid var(--accent); box-shadow: var(--sh-card);
}
.flash-face.back { transform: rotateY(180deg); background: var(--surface-2); border-color: var(--border); }
.flash-face .front-text { font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.15; }
.flash-face .back-text { font-size: 18px; line-height: 1.5; }
.flash-rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.flash-rate .btn { font-size: 14px; padding: 10px 8px; }
.flash-hint { text-align: center; margin-top: 16px; }

/* Speaker / quotes */
.quote { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.avatar {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .04em;
  color: var(--on-accent); border: var(--bw-sm) solid var(--bg); box-shadow: 3px 3px 0 var(--shadow);
}
.bubble { flex: 1; padding: 12px 14px; background: var(--surface); border: var(--bw-sm) solid var(--border); position: relative; }
.bubble .who { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px; }
.bubble p { margin: 0; }
.evidence { padding: 14px 16px; background: var(--surface); border: var(--bw-sm) solid var(--border); border-left: 6px solid var(--accent); margin-bottom: 18px; font-size: 17px; }
.evidence .mono { display: block; margin-bottom: 6px; color: var(--accent-text); }
.evidence p { margin: 0; }

/* Document (spot the problem) */
.doc { background: var(--surface); border: var(--bw) solid var(--border); box-shadow: var(--sh-card); margin-bottom: 8px; }
.doc-head { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-bottom: var(--bw-sm) solid var(--border); }
.doc-lines { display: flex; flex-direction: column; }
.doc-line {
  display: grid; grid-template-columns: 34px 1fr; gap: 8px; text-align: left; width: 100%;
  padding: 12px 12px 12px 8px; background: transparent; border: 0; border-bottom: 1px solid var(--surface-2);
  border-left: 4px solid transparent; font-size: 15px; line-height: 1.45;
}
.doc-line:last-child { border-bottom: 0; }
.doc-line .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding-top: 2px; text-align: right; }
.doc-line:hover:not(:disabled) { background: var(--surface-2); }
.doc-line.sel { border-left-color: var(--accent); background: var(--surface-2); }
.doc-line.right { border-left-color: var(--good-line); background: var(--good-tint); }
.doc-line.wrong { border-left-color: var(--bad-line); background: var(--bad-tint); }

/* Tiles (gap, order, build) */
.bank { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.tile {
  padding: 10px 14px; background: var(--surface); border: var(--bw-sm) solid var(--border); box-shadow: var(--sh-sm);
  font-size: 15px; line-height: 1.35; text-align: left; transition: transform .06s, box-shadow .06s, opacity .15s;
}
.tile:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.tile.used { opacity: .25; box-shadow: none; pointer-events: none; }
.tile.right { border-color: var(--good-line); background: var(--good-tint); }
.tile.wrong { border-color: var(--bad-line); background: var(--bad-tint); }

.sentence { font-size: 20px; line-height: 2.3; }
.blank {
  display: inline-block; min-width: 96px; min-height: 40px; padding: 2px 12px; margin: 0 2px; vertical-align: middle; line-height: 1.6;
  border: 0; border-bottom: var(--bw) solid var(--border); background: transparent; font-size: 18px; text-align: center;
}
.blank.filled { background: var(--surface); border: var(--bw-sm) solid var(--accent); box-shadow: var(--sh-sm); }
.blank.active:not(.filled) { border-bottom-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.blank.right { border-color: var(--good-line); background: var(--good-tint); }
.blank.wrong { border-color: var(--bad-line); background: var(--bad-tint); }

.slots { display: flex; flex-direction: column; gap: 10px; }
.slot {
  display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; min-height: 52px; padding: 8px 12px;
  border: var(--bw-sm) dashed var(--border); background: transparent; text-align: left; width: 100%;
}
.slot .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.slot.filled { border-style: solid; background: var(--surface); box-shadow: var(--sh-sm); }
.slot.active { border-color: var(--accent); }
.slot.right { border-color: var(--good-line); background: var(--good-tint); }
.slot.wrong { border-color: var(--bad-line); background: var(--bad-tint); }
.slot .ph { color: var(--muted); font-size: 14px; }
.slot-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); display: block; }

/* Match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match .col { display: flex; flex-direction: column; gap: 12px; }
.match .opt { min-height: 64px; align-items: center; justify-content: center; text-align: center; padding: 10px; font-size: 15px; }
.match .opt.done { border-color: var(--good-line); background: var(--good-tint); box-shadow: none; opacity: .55; }
.match .opt.flash-bad { border-color: var(--bad-line); background: var(--bad-tint); animation: shake .3s; }

/* Sort */
.pips { display: flex; gap: 6px; justify-content: center; margin: -4px 0 14px; }
.pip { width: 22px; height: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.pip.now { background: var(--accent); border-color: var(--accent); }
.pip.good { background: var(--good); border-color: var(--good-line); }
.pip.bad { background: var(--bad); border-color: var(--bad-line); }
/* Fixed height, so the buckets never move under your thumb. */
.sort-stage { min-height: 196px; display: flex; flex-direction: column; margin-bottom: 12px; }
.sort-card {
  flex: none; min-height: 112px; display: grid; place-items: center; padding: 18px 18px; text-align: center;
  font-size: 18px; font-weight: 500; line-height: 1.4;
  background: var(--surface); border: var(--bw) solid var(--accent); box-shadow: var(--sh-card);
}
.sort-card.in { animation: enter .22s ease-out; }
.sort-card.good { border-color: var(--good-line); background: var(--good-tint); animation: pop .25s; cursor: pointer; }
.sort-card.bad { border-color: var(--bad-line); background: var(--bad-tint); animation: shake .3s; }
.sort-result { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 15px; line-height: 1.4; min-height: 64px; }
.sort-result .icon { width: 20px; height: 20px; stroke-width: 3; margin-top: 1px; }
.sort-result.good { color: var(--good-text); }
.sort-result.bad { color: var(--bad-text); }
.sort-result span { color: var(--text); }
.sort-result .sort-hint { color: var(--muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; width: 100%; text-align: center; padding-top: 10px; }
.sort-board { display: grid; gap: 10px; align-items: start; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.pile-label { display: none; }
@media (max-width: 560px) {
  .sort-board.four { grid-template-columns: 1fr 1fr; }
  .sort-board.four .sort-col { display: contents; }
  .sort-board.four .bucket { grid-row: var(--hr); grid-column: var(--hc); min-height: 64px; }
  .sort-board.four .sort-pile { grid-row: var(--pr); grid-column: var(--pc); }
  .sort-board.four .sort-pile:not(:has(.sort-chip)) { display: none; }
  .sort-board.four .pile-label { display: block; font-size: 11px; margin-top: 4px; }
}
.sort-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sort-pile { display: flex; flex-direction: column; gap: 6px; }
.sort-chip {
  display: flex; gap: 6px; align-items: flex-start; padding: 6px 8px; font-size: 13px; line-height: 1.3;
  background: var(--surface); border: var(--bw-sm) solid var(--good-line);
}
.sort-chip .icon { width: 14px; height: 14px; stroke-width: 3.5; margin-top: 1px; color: var(--good-text); }
.sort-chip.bad { border-color: var(--bad-line); border-style: dashed; }
.sort-chip.bad .icon { color: var(--bad-text); }
.sort-chip.new { animation: drop .35s cubic-bezier(.2, 1.4, .4, 1); box-shadow: 3px 3px 0 var(--good-line); }
.sort-chip.bad.new { box-shadow: 3px 3px 0 var(--bad-line); }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) scale(.9); } to { opacity: 1; transform: none; } }
.bucket {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 14px 6px; min-height: 92px;
  background: var(--surface-2); border: var(--bw-sm) solid var(--border); box-shadow: var(--sh-btn);
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .08em; text-transform: uppercase;
  transition: transform .06s, box-shadow .06s, background .15s, border-color .15s;
}
.bucket:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
.bucket:disabled { cursor: default; }
.bucket .bucket-sub { font-family: var(--font-body); font-weight: 500; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--muted); }
.bucket.is-answer { background: var(--good); border-color: var(--good); color: var(--on-accent); box-shadow: 4px 4px 0 var(--good-line); }
.bucket.is-answer .bucket-sub { color: var(--on-accent); }
.bucket.is-wrong { background: var(--bad-tint); border-color: var(--bad-line); color: var(--bad-text); box-shadow: none; transform: translate(4px, 4px); }

/* Blitz */
.blitz-timer { height: 10px; background: var(--surface); border: var(--bw-sm) solid var(--border); margin-bottom: 18px; position: relative; overflow: hidden; }
.blitz-timer > i { position: absolute; inset: 0; background: var(--gold); transform-origin: left; }
.blitz-timer.low > i { background: var(--bad); }
.blitz-meta { display: flex; justify-content: space-between; margin-bottom: 10px; }
.blitz-card { min-height: 170px; display: grid; place-items: center; text-align: center; padding: 24px; font-size: 20px; font-weight: 500; line-height: 1.4; background: var(--surface); border: var(--bw) solid var(--border); box-shadow: var(--sh-card); animation: enter .18s ease-out; }
.blitz-card.good { border-color: var(--good-line); }
.blitz-card.bad { border-color: var(--bad-line); animation: shake .3s; }
.blitz-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.blitz-btns .btn { min-height: 72px; font-size: 22px; }
.blitz-start { text-align: center; padding: 20px 0; }
.blitz-start .big { font-family: var(--font-display); font-size: 64px; font-weight: 700; color: var(--gold-text); line-height: 1; text-shadow: var(--sh-text); }

/* Clause picker */
.clauses { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.clause-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; min-height: 72px; text-align: left; background: var(--surface); border: var(--bw-sm) solid var(--border); box-shadow: var(--sh-sm); }
.clause-btn .num { font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1; color: var(--accent-text); }
.clause-btn .name { font-size: 14px; line-height: 1.25; }
.clause-btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.clause-btn.sel { border-color: var(--accent); background: var(--surface-2); box-shadow: 3px 3px 0 var(--accent); }
.clause-btn.right { border-color: var(--good-line); background: var(--good-tint); }
.clause-btn.wrong { border-color: var(--bad-line); background: var(--bad-tint); }

/* Grade stamps */
.stamps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp-btn {
  padding: 16px 10px; min-height: 64px; background: var(--surface); border: var(--bw) solid currentColor; box-shadow: var(--sh-btn);
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .12em; text-transform: uppercase;
}
.stamp-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
.stamp-btn[data-g="major"] { color: var(--bad-text); }
.stamp-btn[data-g="minor"] { color: var(--gold-text); }
.stamp-btn[data-g="ofi"] { color: var(--blue-text); }
.stamp-btn[data-g="conforming"] { color: var(--good-text); }
.stamp-btn.sel { background: currentColor; }
.stamp-btn.sel span { color: var(--on-accent); }
.stamped { position: relative; }
.stamp-mark {
  position: absolute; right: 10px; top: 50%; padding: 4px 12px; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: .14em; text-transform: uppercase;
  border: 4px solid currentColor; transform: translateY(-50%) rotate(-12deg); animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

/* Mission */
.mission-head { padding: 18px; margin-bottom: 18px; }
.mission-head h2 { margin: 6px 0 8px; font-size: 26px; line-height: 1.1; }
.mission-head p { margin: 0; color: var(--muted); }
.scene { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; color: var(--accent-text); }
.scene .icon { width: 16px; height: 16px; }
.mission-fb { padding: 12px 14px; margin: 14px 0; border: var(--bw-sm) solid; animation: enter .2s ease-out; }
.mission-fb.s2 { border-color: var(--good-line); background: var(--good-tint); }
.mission-fb.s1 { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--bg)); }
.mission-fb.s0 { border-color: var(--bad-line); background: var(--bad-tint); }
.mission-fb .mono { display: block; margin-bottom: 4px; }
.mission-fb.s2 .mono { color: var(--good-text); }
.mission-fb.s1 .mono { color: var(--gold-text); }
.mission-fb.s0 .mono { color: var(--bad-text); }
.mission-fb p { margin: 0; }
.notebook { margin-top: 22px; border: var(--bw-sm) solid var(--border); background: var(--surface); }
.notebook summary { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.notebook ol { margin: 0; padding: 0 14px 12px 36px; font-size: 14px; }
.notebook li { margin-bottom: 6px; }
.stars { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.stars .icon { width: 48px; height: 48px; color: var(--surface-2); }
.stars .icon.on { color: var(--gold); animation: pop .4s backwards; }
.stars .icon.on:nth-child(2) { animation-delay: .15s; }
.stars .icon.on:nth-child(3) { animation-delay: .3s; }
.debrief { margin-top: 16px; }
.debrief h3 { font-size: 18px; margin: 0 0 8px; }
.debrief ul { margin: 0; padding-left: 18px; }
.debrief li { margin-bottom: 8px; }

/* Written */
textarea.answer {
  width: 100%; min-height: 190px; padding: 14px; resize: vertical;
  font: 16px/1.5 var(--font-body); color: var(--text); background: var(--surface);
  border: var(--bw-sm) solid var(--border); box-shadow: var(--sh-sm); border-radius: 0;
}
textarea.answer:focus { outline: none; border-color: var(--accent); }
.wordcount { text-align: right; margin-top: 6px; }
.model { margin-top: 18px; }
.model p { margin: 0 0 8px; }
.checklist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* Complete screen */
.complete { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px var(--gutter) 24px; }
.complete .evi { width: 150px; animation: bob 2.4s ease-in-out infinite; }
.complete h1 { font-size: 38px; margin: 18px 0 4px; line-height: 1.05; color: var(--gold-text); }
.complete .quip { color: var(--muted); margin: 0 0 24px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; max-width: 440px; }
.stat { padding: 12px; border: var(--bw-sm) solid var(--border); background: var(--surface); box-shadow: var(--sh-sm); text-align: left; }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.1; }
.stat.xp .v { color: var(--gold-text); }
.stat.acc .v { color: var(--good-text); }
.stat.combo-s .v { color: var(--accent-text); }
.complete { padding-bottom: 32px; }
.complete-foot { justify-content: center; }
.complete-foot .btn { max-width: 440px; }
.stat .v.stars-inline { display: flex; gap: 4px; padding-top: 4px; }
.stars-inline .icon { width: 26px; height: 26px; color: var(--surface-2); }
.stars-inline .icon.on { color: var(--gold); }
.rankbar { width: 100%; max-width: 440px; margin-top: 18px; text-align: left; }
.rankbar .mono { margin-bottom: 6px; }
.rankbar .bar { height: 12px; }
.rankbar .bar > i { background: var(--gold); }
.moments { list-style: none; margin: 16px 0 0; padding: 0; width: 100%; max-width: 440px; display: grid; gap: 8px; text-align: left; }
.moments li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--surface); border: var(--bw-sm) solid var(--border); font-size: 15px; line-height: 1.4; animation: enter .3s ease-out backwards; }
.moments li:nth-child(2) { animation-delay: .1s; } .moments li:nth-child(3) { animation-delay: .2s; } .moments li:nth-child(4) { animation-delay: .3s; }
.moments li .icon { width: 20px; height: 20px; flex: none; color: var(--accent-text); margin-top: 1px; }
.moments li.gold { border-color: var(--gold); }
.moments li.gold .icon { color: var(--gold); }
.moments li.muted { color: var(--muted); border-style: dashed; }
.moments li.muted .icon { color: var(--muted); }

/* ---------- Home: review card ---------- */
.reviewcard { margin-top: 18px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; border-color: var(--blue); }
.reviewcard .rc-text { flex: 1; min-width: 0; }
.reviewcard .mono { color: var(--blue-text); }
.reviewcard p { margin: 4px 0 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.reviewcard .btn { flex: none; background: var(--blue); border-color: var(--blue); }
.reviewcard .btn .icon { width: 18px; height: 18px; }
.reviewcard .btn:hover:not(:disabled) { background: #A3D5FF; border-color: #A3D5FF; }
.flag.quiet { background: var(--surface-2); }
.flag.quiet > span { color: var(--text); }

/* ---------- Home: today card ---------- */
.todaycard { margin-top: 18px; padding: 14px 16px; display: grid; gap: 12px; }
.todaycard .row { display: flex; align-items: center; gap: 12px; }
.todaycard .row .icon { width: 22px; height: 22px; flex: none; }
.todaycard .goal .bar { flex: 1; height: 14px; }
.todaycard .goal .bar > i { background: var(--good); }
.todaycard .goal.done .bar > i { background: var(--gold); }
.todaycard .goal .mono { white-space: nowrap; color: var(--text); }
.todaycard .streakline { font-size: 15px; line-height: 1.4; }
.todaycard .streakline .icon { color: var(--accent-text); }
.todaycard .streakline.cold .icon { color: var(--muted); }
.todaycard .streakline.done .icon { color: var(--gold); }
.chip.streak .icon { color: var(--accent); }
.chip.streak.cold { color: var(--muted); }
.chip.streak.cold .icon { color: var(--muted); }
button.chip { cursor: pointer; }

/* ---------- Profile ---------- */
.profile { padding: 0 var(--gutter) 40px; }
.profile section { margin-top: 26px; }
.profile h2 { font-size: 20px; margin: 0 0 10px; }
.rankcard { margin-top: 20px; }
.rankcard .rname { font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; color: var(--gold-text); text-shadow: var(--sh-text); margin: 4px 0 12px; }
.rankcard .bar { height: 14px; margin: 6px 0; }
.rankcard .bar > i { background: var(--gold); }
.rankladder { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rankladder li { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 8px; border: 1px solid var(--border); color: var(--muted); }
.rankladder li.got { color: var(--on-accent); background: var(--gold); border-color: var(--gold); }
.freezes { display: flex; gap: 6px; }
.freezes .icon { width: 22px; height: 22px; color: var(--blue); }
.freezes .icon.empty { color: var(--surface-2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg button { padding: 12px 8px; background: var(--surface); border: var(--bw-sm) solid var(--border); box-shadow: var(--sh-sm); font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .06em; }
.seg button small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 12px; letter-spacing: 0; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.seg button[aria-pressed="true"] small { color: var(--on-accent); }
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ach { padding: 12px; border: var(--bw-sm) solid var(--border); background: var(--surface); display: grid; gap: 4px; align-content: start; }
.ach .icon { width: 26px; height: 26px; color: var(--gold); }
.ach strong { font-size: 15px; }
.ach span { font-size: 13px; color: var(--muted); line-height: 1.35; }
.ach.locked { border-style: dashed; background: transparent; }
.ach.locked .icon { color: var(--muted); }
.ach.locked strong { color: var(--muted); }
.settings { display: grid; gap: 10px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: var(--bw-sm) solid var(--border); width: 100%; text-align: left; }
.setting .val { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); }
.setting.danger { border-color: var(--bad-line); color: var(--bad-text); }

/* Toasts: combo flag + XP float */
.toast { position: fixed; left: 50%; top: 74px; z-index: 50; transform: translateX(-50%); pointer-events: none; animation: toast 1.4s ease-out forwards; }
.toast .flag { padding: 6px 16px; }
.toast .flag > span { font-size: 15px; }
.xpfloat {
  position: fixed; z-index: 55; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: .06em; color: var(--gold);
  text-shadow: 2px 2px 0 var(--shadow); animation: floatup 1s ease-out forwards;
}

/* Evi */
.evi svg { width: 100%; height: auto; display: block; overflow: visible; }
.evi.bob svg { animation: bob 2.6s ease-in-out infinite; }

/* ---------- Motion ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes pulse { 0% { opacity: .9; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.18); } }
@keyframes stamp { from { opacity: 0; transform: translateY(-50%) rotate(-12deg) scale(2.4); } to { opacity: 1; transform: translateY(-50%) rotate(-12deg) scale(1); } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -14px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 25% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -70px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .node.current::after { display: none; }
}

@media (min-width: 700px) {
  .hero h2 { font-size: 36px; }
  .prompt { font-size: 23px; }
  .lesson-body { padding-top: 16px; }
}

/* ---------- Boss levels: exam page ---------- */
.exam-page { padding: 0 var(--gutter) 40px; }
.exam-page > section { margin-top: 26px; }
.exam-page h2.display { font-size: 20px; margin: 0 0 10px; }
.exam-page .sub { margin: -4px 0 12px; }
.boss-card { margin-top: 20px; }
.boss-top { display: flex; gap: 16px; align-items: center; }
.boss-top .node.boss { flex: none; width: 58px; height: 58px; margin: 8px 12px 8px 6px; box-shadow: 4px 4px 0 var(--shadow); cursor: default; }
.boss-top h2 { font-size: 26px; line-height: 1.1; margin: 4px 0 6px; }
.boss-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.boss-status .mono.ok { color: var(--good-text); }
.boss-card .format { font-size: 15px; color: var(--muted); margin: 14px 0 16px; line-height: 1.45; }
.boss-card .format strong { color: var(--text); }
.exam-actions { display: grid; gap: 12px; }
.btn.two-line { flex-direction: column; gap: 2px; padding-top: 10px; padding-bottom: 10px; }
.btn.two-line > span { display: inline-flex; align-items: center; gap: 10px; }
.btn.two-line small { font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: .1em; opacity: .9; }
.linkish { background: none; border: 0; padding: 10px 0; min-height: 44px; font-size: 14px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; justify-self: center; }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.check-row { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 14px; background: var(--surface); border: var(--bw-sm) solid var(--border); }
.check-row.ok { border-color: var(--good-line); }
.check-mark { width: 34px; height: 34px; display: grid; place-items: center; border: var(--bw-sm) solid var(--border); color: var(--muted); }
.check-mark .icon { width: 20px; height: 20px; }
.check-row.ok .check-mark { background: var(--good); border-color: var(--good); color: var(--on-accent); }
.check-row.ok .check-mark .icon { stroke-width: 3; }
.check-text strong { display: block; font-size: 16px; }
.check-text p { margin: 2px 0 8px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.check-text p strong { display: inline; color: var(--text); font-size: 14px; }

.meter { position: relative; height: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.meter > i { position: absolute; inset: 0 auto 0 0; width: var(--v); background: var(--accent); }
.meter.ok > i { background: var(--good); }
.meter.low > i { background: var(--bad); }
.meter > b { position: absolute; top: -4px; bottom: -4px; left: var(--t); width: 3px; margin-left: -1px; background: var(--text); }

.weakcard { padding: 14px 16px; }
.weakcard .sub { margin: 0 0 10px; }
.weaklist { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.weaklist li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--surface-2); font-size: 15px; }
.weaklist li:last-child { border-bottom: 0; }
.weaklist .mono { flex: none; font-size: 11px; }

.unitrows, .pastrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.unitrows li { padding: 10px 12px; background: var(--surface); border: var(--bw-sm) solid var(--border); display: grid; gap: 6px; }
.unitrows li.soon { background: transparent; border-style: dashed; color: var(--muted); }
.u-title { display: flex; gap: 10px; align-items: baseline; font-weight: 500; line-height: 1.3; }
.u-title .mono { flex: none; font-size: 11px; }
.u-meta { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.u-meta .mono { font-size: 11px; letter-spacing: .08em; }
.unitrows li.soon .u-meta { grid-template-columns: 1fr; }
.pastrows li { display: grid; grid-template-columns: 58px 1fr auto auto; gap: 2px 10px; align-items: center; padding: 8px 12px; background: var(--surface); border: var(--bw-sm) solid var(--border); }
.pastrows .mono { grid-row: 1 / span 2; font-size: 11px; }
.pastrows .p-kind { grid-column: 2; grid-row: 1; font-weight: 500; }
.pastrows .p-score { grid-column: 2; grid-row: 2; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.pastrows .chip { grid-column: 3; grid-row: 1 / span 2; box-shadow: none; }
.pastrows .btn { grid-column: 4; grid-row: 1 / span 2; }
.chip.pass, .chip.right { color: var(--good-text); border-color: var(--good-line); }
.chip.fail, .chip.wrong { color: var(--bad-text); border-color: var(--bad-line); }
.chip.blank { color: var(--muted); border-style: dashed; }

/* Boss node on the path, now tappable */
button.boss-row { width: 100%; text-align: left; background: var(--surface); border: var(--bw-sm) solid var(--gold); box-shadow: var(--sh-sm); padding: 8px 14px 8px 4px; }
button.boss-row:active { transform: translate(3px, 3px); box-shadow: none; }
button.boss-row .node.boss { margin: 12px 8px 12px 14px; width: 56px; height: 56px; box-shadow: 4px 4px 0 var(--shadow); background: var(--gold); }
button.boss-row .node.boss .icon { color: var(--on-accent); }
.boss-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.boss-text .mono { color: var(--gold-text); }
.boss-text .display { font-size: 18px; text-shadow: none; }
.boss-sub { font-size: 13px; color: var(--muted); }
button.boss-row > .icon { color: var(--gold-text); }
.setting small.muted { color: var(--muted); font-size: 13px; }

/* ---------- The mock ---------- */
.exam-top { gap: 10px; }
.exam-count {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  background: var(--surface); border: var(--bw-sm) solid var(--border); font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em;
}
.exam-count .icon { width: 16px; height: 16px; color: var(--accent-text); }
.exam-top .bar { height: 12px; }
.exam-top .bar > i { background: var(--blue); }
.exam-clock { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .06em; min-width: 72px; justify-content: flex-end; color: var(--text); }
.exam-clock .icon { width: 18px; height: 18px; color: var(--muted); }
.exam-clock.low { color: var(--bad-text); }
.exam-clock.low .icon { color: var(--bad-text); }
.exam-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.exam-head .ex-kind { min-width: 0; }
.flag-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; background: transparent; border: var(--bw-sm) solid var(--border); font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.flag-btn .icon { width: 16px; height: 16px; }
.flag-btn.on { border-color: var(--gold); color: var(--gold-text); background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
.exam-foot .btn.ghost:disabled { opacity: .45; }

.sheet h2 { font-size: 24px; margin: 4px 0 8px; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin: 4px 0 14px; }
.qcell { position: relative; min-height: 48px; display: grid; place-items: center; background: transparent; border: var(--bw-sm) dashed var(--border); font-family: var(--font-mono); font-size: 14px; }
.qcell.done { background: var(--surface); border-style: solid; box-shadow: var(--sh-sm); }
.qcell.here { outline: 2px solid var(--accent); outline-offset: 2px; }
.qcell .icon { position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; color: var(--gold); }
.qcell.flagged { border-color: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .icon { width: 14px; height: 14px; color: var(--gold); }
.lg { display: inline-block; width: 14px; height: 14px; border: var(--bw-sm) dashed var(--border); }
.lg.done { background: var(--surface); border-style: solid; }
.timeup { text-align: center; padding-top: 30px; }
.timeup .evi { width: 120px; margin: 0 auto; }
.timeup h2 { font-size: 34px; margin: 16px 0 8px; color: var(--gold-text); }
.timeup p { color: var(--muted); max-width: 420px; margin: 0 auto; }

/* Results */
.score-big { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 0 0 20px; }
.sb-num { font-family: var(--font-display); font-weight: 700; font-size: 54px; line-height: 1; text-shadow: var(--sh-text); }
.sb-num small { font-size: 26px; color: var(--muted); text-shadow: none; }
.sb-pct { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--accent-text); }
.sb-stamp { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .14em; text-transform: uppercase; padding: 4px 12px; border: 4px solid currentColor; transform: rotate(-10deg); animation: stamp2 .35s cubic-bezier(.2, 1.6, .4, 1); }
.sb-stamp.pass { color: var(--good-text); }
.sb-stamp.fail { color: var(--bad-text); }
@keyframes stamp2 { from { opacity: 0; transform: rotate(-10deg) scale(2.2); } to { opacity: 1; transform: rotate(-10deg) scale(1); } }
.areas { list-style: none; margin: 18px 0 0; padding: 0; width: 100%; max-width: 440px; display: grid; gap: 12px; text-align: left; }
.a-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; margin-bottom: 4px; }
.gate-line { width: 100%; max-width: 440px; margin: 16px 0 0; padding: 10px 12px; font-size: 14px; line-height: 1.45; text-align: left; border: var(--bw-sm) dashed var(--border); color: var(--muted); }

/* Review after a mock */
.review-page .review-sum { margin: 16px 0 12px; }
.review-page .seg { margin-bottom: 16px; }
.review-page .seg button:disabled { opacity: .45; }
.rq-list { display: grid; gap: 18px; }
.rq { padding: 14px; }
.rq.wrong { border-color: var(--bad-line); }
.rq.blank { border-style: dashed; }
.rq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.rq-head .mono { flex: 1; min-width: 0; font-size: 11px; letter-spacing: .1em; }
.rq-head > .icon { width: 16px; height: 16px; color: var(--gold); }
.rq-head .chip { box-shadow: none; }
.rq .prompt { font-size: 18px; }
.exam-why { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); font-size: 15px; }
.exam-why p { margin: 0 0 8px; }
.exam-why .label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.exam-why .unanswered { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; color: var(--gold-text); }
.stamp-btn.struck { opacity: .55; text-decoration: line-through; text-decoration-thickness: 3px; }
.stamp-mark.still { animation: none; }
.exam-q .opt:disabled:not(.right):not(.wrong):not(.missed) { opacity: .7; }

@media (max-width: 420px) {
  .exam-count { padding: 0 8px; }
  .sb-num { font-size: 46px; }
  .pastrows li { grid-template-columns: 50px 1fr auto; }
  .pastrows .btn { grid-column: 2 / span 2; grid-row: 3; justify-self: start; }
}

/* Sign-in (cloud mode) */
.gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 28px var(--gutter) 24px; gap: 18px; }
.gate .wordmark { margin: 0; }
.gate .evi { width: 110px; margin-top: 8px; }
.gate-msg { color: var(--muted); text-align: center; margin: 0; }
.gate-form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.gate-form label { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.gate-form input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: 16px/1.4 var(--font-body); color: var(--text); background: var(--bg);
  border: var(--bw-sm) solid var(--border); border-radius: 0;
}
.gate-form input:focus { outline: none; border-color: var(--accent); }
.gate-form .btn { margin-top: 12px; }
.gate-form p { margin: 0 0 8px; }
.gate-error { min-height: 1.4em; margin: 6px 0 0 !important; font-size: 14px; color: var(--bad-text); }
.gate-error.ok { color: var(--good-text); }
.gate-form .linkish { align-self: center; margin-top: 10px; min-height: 40px; padding: 8px; color: var(--accent-text); font: 14px var(--font-body); cursor: pointer; }
.gate-foot { margin-top: auto; color: var(--muted); font-size: 11px; text-align: center; }

/* Written answers sent for review */
.send-review { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 6px; }
.send-review .btn .icon { width: 16px; height: 16px; }
.feedbackcard { border-color: var(--gold); }
.feedbackcard .mono { color: var(--gold-text); }
.feedbackcard .btn { background: var(--gold); border-color: var(--gold); }
.feedbackcard .btn:hover:not(:disabled) { background: #FFD77F; border-color: #FFD77F; }
.written-card { margin-top: 18px; display: grid; gap: 12px; }
.written-card.done { border-color: var(--good-line); }
.wc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wc-head .mono { color: var(--muted); }
.wc-prompt p { margin: 0 0 8px; }
.wc-answer summary { cursor: pointer; font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); min-height: 40px; display: flex; align-items: center; }
.wc-text { white-space: pre-wrap; margin: 6px 0 0; padding: 12px; background: var(--bg); border: var(--bw-sm) solid var(--surface-2); }
.wc-review { display: grid; gap: 8px; border-top: var(--bw-sm) solid var(--surface-2); padding-top: 12px; }
.wc-review p { margin: 0 0 6px; }
.wc-mark { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.wc-mark strong { font-size: 18px; }
.wc-mark .chip { margin-left: auto; }
.wc-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wc-points li { display: flex; gap: 8px; align-items: flex-start; }
.wc-points .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.wc-points li.ok .icon { color: var(--good-text); }
.wc-points li.miss .icon { color: var(--bad-text); }
.wc-next .mono { color: var(--gold-text); }
.wc-wait { display: flex; align-items: center; gap: 6px; margin: 0; }
.wc-wait .icon { width: 16px; height: 16px; }
.gate-form .muted, .written-card .muted { color: var(--muted); }

/* Switches and in-page confirmations */
.setting.toggle .toggle-label { display: inline-flex; align-items: center; gap: 10px; }
.setting.toggle .toggle-label .icon { width: 18px; height: 18px; color: var(--accent-text); }
.switch { position: relative; flex: none; width: 50px; height: 28px; background: var(--bg); border: var(--bw-sm) solid var(--border); transition: background .15s, border-color .15s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; background: var(--muted); transition: transform .15s, background .15s; }
.setting.toggle[aria-checked="true"] .switch { background: var(--accent); border-color: var(--accent); }
.setting.toggle[aria-checked="true"] .switch::after { transform: translateX(22px); background: var(--on-accent); }
.confirm-inline { display: grid; gap: 10px; padding: 12px 14px; background: var(--bad-tint); border: var(--bw-sm) solid var(--bad-line); }
.confirm-inline p { margin: 0; color: var(--text); }
.confirm-inline .row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
.btn.danger:hover:not(:disabled) { background: var(--bad-line); border-color: var(--bad-line); }
.setting-note { margin: 0; padding: 12px 14px; border: var(--bw-sm) dashed var(--good-line); color: var(--good-text); }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
