/* =========================================================================
   Einstufungstest Deutsch — stylesheet
   Direction (§11.1): a well-set exam paper. Warm paper, ink, one accent.
   ========================================================================= */

/* --- 1. Tokens ---------------------------------------------------------- */

:root {
  /* Light palette — the complete set lives here (§11.3). */
  --paper:        #faf7f2;
  --paper-sunk:   #f0ebe1;
  --surface:      #fffdf9;
  --surface-2:    #f6f2ea;
  --ink:          #1b1917;
  --ink-2:        #4a453d;
  --muted:        #6d675d;
  --line:         #e0d9cc;
  --line-strong:  #cfc6b5;
  --accent:       #145b58;
  --accent-ink:   #0e4442;
  --accent-soft:  #dbeceb;
  --accent-on:    #ffffff;
  --ok:           #2c6a3f;
  --ok-soft:      #dfeee2;
  --err:          #9c3327;
  --err-soft:     #f6e3df;
  --flag:         #8a5a12;
  --flag-soft:    #f6ebd7;
  --ring:         #145b58;
  --shadow-1:     0 1px 2px rgb(28 22 12 / .05), 0 2px 8px rgb(28 22 12 / .05);
  --shadow-2:     0 8px 30px rgb(28 22 12 / .12), 0 2px 6px rgb(28 22 12 / .07);
  --backdrop:     rgb(30 26 20 / .38);

  /* Type */
  --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-text: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Space + shape */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 16px;  --r-full: 999px;
  --tap: 44px;

  /* Motion (§10) */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-nav: 260ms;
  --t-fill: 180ms;
  --t-select: 140ms;
  --t-drawer: 220ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #14161a;
    --paper-sunk:   #1a1d23;
    --surface:      #1b1e24;
    --surface-2:    #22262d;
    --ink:          #eceae5;
    --ink-2:        #c7c3bb;
    --muted:        #a2a8ae;
    --line:         #2d323a;
    --line-strong:  #3d434d;
    --accent:       #6fd3c6;
    --accent-ink:   #a9e7de;
    --accent-soft:  #1d3733;
    --accent-on:    #08211f;
    --ok:           #7fca90;
    --ok-soft:      #1c2e21;
    --err:          #f0958a;
    --err-soft:     #33201d;
    --flag:         #e0b567;
    --flag-soft:    #2f2718;
    --ring:         #6fd3c6;
    --shadow-1:     0 1px 2px rgb(0 0 0 / .3), 0 2px 8px rgb(0 0 0 / .25);
    --shadow-2:     0 10px 34px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .35);
    --backdrop:     rgb(6 8 10 / .6);
  }
}

:root[data-theme="dark"] {
  --paper:        #14161a;
  --paper-sunk:   #1a1d23;
  --surface:      #1b1e24;
  --surface-2:    #22262d;
  --ink:          #eceae5;
  --ink-2:        #c7c3bb;
  --muted:        #a2a8ae;
  --line:         #2d323a;
  --line-strong:  #3d434d;
  --accent:       #6fd3c6;
  --accent-ink:   #a9e7de;
  --accent-soft:  #1d3733;
  --accent-on:    #08211f;
  --ok:           #7fca90;
  --ok-soft:      #1c2e21;
  --err:          #f0958a;
  --err-soft:     #33201d;
  --flag:         #e0b567;
  --flag-soft:    #2f2718;
  --ring:         #6fd3c6;
  --shadow-1:     0 1px 2px rgb(0 0 0 / .3), 0 2px 8px rgb(0 0 0 / .25);
  --shadow-2:     0 10px 34px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .35);
  --backdrop:     rgb(6 8 10 / .6);
}

/* --- 2. Base ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--accent); }

:where(a, button, [tabindex], input, summary):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

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

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-on);
  padding: 10px 16px; border-radius: var(--r-md); text-decoration: none;
  transition: top 120ms var(--ease);
}
.skip:focus { top: 8px; }

.app { min-height: 100svh; display: flex; flex-direction: column; }
.main { flex: 1; display: flex; flex-direction: column; outline: none; }

.boot { margin: auto; text-align: center; color: var(--muted); }
.boot__mark {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border-radius: var(--r-md); background: var(--accent); color: var(--accent-on);
  font-family: var(--font-mono); font-weight: 700; letter-spacing: .02em;
}
.boot__text { margin-top: 12px; font-size: .9rem; }

.noscript { max-width: 34rem; margin: 12vh auto; padding: 0 24px; }
.noscript h1 { font-family: var(--font-text); font-size: 1.6rem; margin-bottom: 8px; }

/* --- 3. Shared atoms ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: .95rem; font-weight: 500;
  transition: background var(--t-select) var(--ease), border-color var(--t-select) var(--ease),
              transform var(--t-select) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-on); font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost { background: none; border-color: transparent; color: var(--muted); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn--lg { min-height: 52px; padding: 0 28px; font-size: 1.05rem; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn--wide { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: .78rem; color: var(--ink-2); white-space: nowrap;
}
.chip--mono { font-family: var(--font-mono); letter-spacing: .02em; }
.chip--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip--ok  { background: var(--ok-soft);  border-color: transparent; color: var(--ok); font-weight: 600; }
.chip--err { background: var(--err-soft); border-color: transparent; color: var(--err); font-weight: 600; }
.chip--warn{ background: var(--flag-soft);border-color: transparent; color: var(--flag); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}

.rule-line { height: 1px; background: var(--line); border: 0; margin: 0; }

/* Banners (storage warning, offline chip, shared-result notice) */
.banners { position: sticky; top: 0; z-index: 40; }
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; font-size: .85rem;
  background: var(--flag-soft); color: var(--flag);
  border-bottom: 1px solid var(--line);
}
.banner--info { background: var(--accent-soft); color: var(--accent-ink); }
.banner__x { margin-left: auto; color: inherit; opacity: .7; padding: 4px 8px; }

/* Toasts */
.toasts {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 30rem);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--paper);
  padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-2);
  font-size: .88rem;
  animation: toast-in 240ms var(--ease) both;
}
.toast button { color: var(--paper); text-decoration: underline; font-size: .85rem; opacity: .9; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* --- 4. Intro screen ---------------------------------------------------- */

.intro { max-width: 44rem; margin: 0 auto; padding: clamp(28px, 7vh, 72px) 20px 64px; width: 100%; }
.intro__eyebrow {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.intro__title {
  font-family: var(--font-text); font-size: clamp(2rem, 6vw, 3rem); line-height: 1.08;
  letter-spacing: -0.015em; margin-bottom: 10px;
}
.intro__sub { font-size: 1.05rem; color: var(--muted); max-width: 32rem; }

.facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0; }
.fact {
  flex: 1 1 8rem; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.fact__n { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 600; }
.fact__l { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.how { margin: 26px 0; display: grid; gap: 10px; }
.how li { display: flex; gap: 12px; align-items: flex-start; font-size: .95rem; color: var(--ink-2); }
.how li::before {
  content: ""; flex: none; width: 6px; height: 6px; margin-top: 9px;
  border-radius: 50%; background: var(--accent);
}

.intro__actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 30px; }
.intro__note { font-size: .85rem; color: var(--muted); margin-top: 14px; }

.history { margin-top: 44px; }
.history h2 { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.history__row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); margin-bottom: 8px;
}
.history__row:hover { background: var(--surface-2); }
.history__score { font-family: var(--font-mono); font-weight: 600; }
.history__date { color: var(--muted); font-size: .85rem; margin-left: auto; }

/* --- 5. Test chrome ----------------------------------------------------- */

.test { display: flex; flex-direction: column; min-height: 100svh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(12px, 3vw, 24px);
}
.rail {
  display: flex; gap: 1px; height: 22px; align-items: flex-end; padding: 6px 0 4px;
  width: 100%;
}
.rail__seg {
  flex: 1 1 0; height: 8px; min-width: 0; padding: 0;
  background: var(--line); border-radius: 1px;
  transition: background var(--t-fill) var(--ease), height var(--t-fill) var(--ease);
  position: relative;
}
.rail__seg[data-state="answered"] { background: var(--accent); }
.rail__seg[data-state="flagged"]  { background: var(--flag); }
.rail__seg[data-current="true"]   { height: 16px; background: var(--accent); box-shadow: 0 0 0 1px var(--paper); }
.rail__seg:hover { height: 14px; }

.rail-bar { height: 4px; background: var(--paper-sunk); border-radius: var(--r-full); overflow: hidden; margin: 10px 0 6px; }
.rail-bar__fill {
  display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit;
  transform: scaleX(0); transform-origin: left center;
  transition: transform var(--t-fill) var(--ease);
}

.topmeta {
  display: flex; align-items: center; gap: 10px; padding: 2px 0 8px;
  font-size: .82rem; color: var(--muted); white-space: nowrap; min-width: 0;
}
.topmeta__count { font-family: var(--font-mono); font-weight: 600; color: var(--ink); flex: none; }
.topmeta__level { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topmeta__right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.timer { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r-md); color: var(--muted);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

/* Stage — outgoing and incoming share one grid cell so they can overlap (§6.3) */
.stage {
  flex: 1; display: grid; align-items: center; justify-items: center;
  padding: clamp(16px, 4vh, 40px) clamp(16px, 4vw, 24px);
  min-height: clamp(360px, 52vh, 460px);
}
.stage > * { grid-area: 1 / 1; width: 100%; }

.qcard { max-width: 40rem; margin: 0 auto; }
.qcard__tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; min-height: 26px; }

.prompt {
  font-family: var(--font-text);
  font-size: clamp(1.25rem, 1rem + 1.6vw, 1.7rem);
  line-height: 1.55; letter-spacing: -0.005em;
  margin-bottom: clamp(20px, 4vh, 34px);
}
/* Focus lands on the heading when the question changes (§12). A full ring
   around a whole sentence is visually loud, so the indicator is a margin bar. */
.prompt:focus-visible {
  outline: none;
  box-shadow: -14px 0 0 -11px var(--accent);
}

.blank {
  display: inline-block; min-width: 4.5ch; padding: 0 .25ch;
  border-bottom: 2px solid var(--line-strong);
  text-align: center; vertical-align: baseline;
  transition: border-color var(--t-select) var(--ease), color var(--t-select) var(--ease);
}
.blank--filled { border-bottom-color: var(--accent); color: var(--accent); }
.blank__ph { visibility: hidden; }

.options { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 52px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  transition: border-color var(--t-select) var(--ease), background var(--t-select) var(--ease),
              box-shadow var(--t-select) var(--ease);
}
.option:hover { border-color: var(--line-strong); background: var(--surface-2); }
.option__key {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: var(--r-sm); background: var(--paper-sunk); color: var(--muted);
  font-family: var(--font-mono); font-size: .82rem; text-transform: lowercase;
  transition: background var(--t-select) var(--ease), color var(--t-select) var(--ease);
}
.option__text { font-family: var(--font-text); font-size: 1.05rem; }
.option[aria-checked="true"] {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.option[aria-checked="true"] .option__key { background: var(--accent); color: var(--accent-on); }

.bottombar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(12px, 3vw, 24px) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.bottombar__mid { margin-inline: auto; display: flex; gap: 8px; }
.flagbtn[aria-pressed="true"] { color: var(--flag); background: var(--flag-soft); }

.hint {
  text-align: center; font-size: .8rem; color: var(--muted);
  padding: 0 16px 10px;
}
.hint kbd {
  font-family: var(--font-mono); font-size: .75rem;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
}

/* --- 6. Motion (§6.3, §10) --------------------------------------------- */

@keyframes q-in-fwd  { from { opacity: 0; transform: translateX(24px) }  to { opacity: 1; transform: none } }
@keyframes q-out-fwd { from { opacity: 1; transform: none } to { opacity: 0; transform: translateX(-24px) } }
@keyframes q-in-back  { from { opacity: 0; transform: translateX(-24px) } to { opacity: 1; transform: none } }
@keyframes q-out-back { from { opacity: 1; transform: none } to { opacity: 0; transform: translateX(24px) } }
@keyframes opt-in { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

.anim-in-fwd   { animation: q-in-fwd   var(--t-nav) var(--ease) both; }
.anim-out-fwd  { animation: q-out-fwd  var(--t-nav) var(--ease) both; pointer-events: none; }
.anim-in-back  { animation: q-in-back  var(--t-nav) var(--ease) both; }
.anim-out-back { animation: q-out-back var(--t-nav) var(--ease) both; pointer-events: none; }
.anim-in-fwd .option, .anim-in-back .option { animation: opt-in 220ms var(--ease) both; }
.anim-in-fwd .option:nth-child(1), .anim-in-back .option:nth-child(1) { animation-delay: 40ms; }
.anim-in-fwd .option:nth-child(2), .anim-in-back .option:nth-child(2) { animation-delay: 65ms; }
.anim-in-fwd .option:nth-child(3), .anim-in-back .option:nth-child(3) { animation-delay: 90ms; }
.anim-in-fwd .option:nth-child(4), .anim-in-back .option:nth-child(4) { animation-delay: 115ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 120ms !important;
    animation-delay: 0ms !important;
    transition-duration: 120ms !important;
  }
  .anim-in-fwd, .anim-in-back   { animation-name: fade-in; }
  .anim-out-fwd, .anim-out-back { animation-name: fade-out; }
  .anim-in-fwd .option, .anim-in-back .option { animation-name: fade-in; }
  .rise { animation-name: fade-in !important; }
}
@keyframes fade-out { from { opacity: 1 } to { opacity: 0 } }

/* --- 7. Overlay layer: overview drawer, sheets, shortcuts --------------- */

.layer { position: fixed; inset: 0; z-index: 50; }
.layer[hidden] { display: none; }
.backdrop {
  position: absolute; inset: 0; background: var(--backdrop);
  animation: fade-in var(--t-drawer) var(--ease) both;
}
.sheet {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(94vw, 34rem); max-height: 86svh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 24px;
  animation: sheet-in var(--t-drawer) var(--ease) both;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)) }
  to   { opacity: 1; transform: translate(-50%, -50%) }
}
.sheet__title { font-family: var(--font-text); font-size: 1.35rem; margin-bottom: 8px; }
.sheet__body { color: var(--ink-2); font-size: .95rem; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.sheet__actions .btn { flex: 1 1 12rem; }

.drawer {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(94vw, 30rem); overflow: auto;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2); padding: 20px;
  animation: drawer-in var(--t-drawer) var(--ease) both;
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px) } to { opacity: 1; transform: none } }
.drawer__head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.drawer__head h2 { font-family: var(--font-text); font-size: 1.25rem; }
.drawer__head .iconbtn { margin-left: auto; }
.drawer__summary { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter {
  padding: 6px 12px; border-radius: var(--r-full); font-size: .82rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }

.grid100 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.grid100 .cell {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-family: var(--font-mono); font-size: .78rem;
}
.grid100 .cell[data-answered="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.grid100 .cell[data-flagged="true"]::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--flag);
}
.grid100 .cell[data-current="true"] { box-shadow: 0 0 0 2px var(--ring); }
.grid100 .cell[hidden] { display: none; }
.grid100 .cell[data-correct="true"]  { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.grid100 .cell[data-correct="false"] { background: var(--err-soft); color: var(--err); border-color: transparent; }

.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.qchip {
  font-family: var(--font-mono); font-size: .78rem; padding: 4px 9px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
}
.qchip:hover { border-color: var(--accent); color: var(--accent); }

.keys { display: grid; gap: 8px; }
.keys li { display: flex; align-items: baseline; gap: 12px; font-size: .9rem; color: var(--ink-2); }
.keys kbd {
  font-family: var(--font-mono); font-size: .78rem; min-width: 2.2rem; text-align: center;
  padding: 2px 6px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--line); border-bottom-width: 2px;
}

.popover {
  position: absolute; right: clamp(12px, 3vw, 24px); top: 64px;
  width: min(92vw, 20rem); padding: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: rise-in 160ms var(--ease) both;
}
.setting { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.setting__label { font-size: .9rem; }
.setting__hint { font-size: .78rem; color: var(--muted); }
.setting > :last-child { margin-left: auto; }
.switch {
  width: 44px; height: 26px; border-radius: var(--r-full);
  background: var(--line-strong); position: relative; flex: none;
  transition: background var(--t-select) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--surface);
  transition: transform var(--t-select) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.seg button { padding: 6px 10px; font-size: .8rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-on); }

/* --- 8. Results --------------------------------------------------------- */

.results { max-width: 52rem; margin: 0 auto; padding: clamp(20px, 4vh, 40px) 20px 80px; width: 100%; }
.results__head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.results__head h1 { font-family: var(--font-text); font-size: 1.5rem; }
.results__head .spacer { margin-left: auto; }

.section { margin-bottom: clamp(28px, 5vh, 48px); }
.section > h2 {
  font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.rise { animation: rise-in 420ms var(--ease) both; }

.verdict { padding: clamp(20px, 4vw, 32px); }
.verdict__row { display: flex; align-items: baseline; gap: clamp(16px, 4vw, 32px); flex-wrap: wrap; }
.verdict__score {
  font-family: var(--font-mono); font-size: clamp(3rem, 12vw, 4.6rem); font-weight: 700;
  line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.verdict__of { font-size: .9rem; color: var(--muted); font-family: var(--font-ui); font-weight: 400; }
.verdict__band {
  font-family: var(--font-text); font-size: clamp(2rem, 8vw, 3rem); color: var(--accent);
  line-height: 1;
}
.verdict__levels { font-size: .85rem; color: var(--muted); margin-top: 6px; }

.ruler { margin-top: 28px; }
.ruler__track { display: flex; gap: 2px; height: 40px; }
.ruler__band {
  position: relative; display: grid; place-items: center;
  background: var(--paper-sunk); border-radius: 3px;
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
  overflow: hidden;
}
.ruler__band[data-hit="true"] { background: var(--accent); color: var(--accent-on); font-weight: 700; }
.ruler__marker {
  position: relative; height: 22px; margin-top: 4px;
}
.ruler__pin {
  position: absolute; top: 0;
  display: grid; justify-items: center; gap: 2px;
  transform: translateX(-50%) translateX(-16px);
  opacity: 0;
  transition: transform 700ms var(--ease), opacity 400ms var(--ease);
}
.ruler__pin[data-settled="true"] { transform: translateX(-50%); opacity: 1; }
.ruler__pin span { font-family: var(--font-mono); font-size: .72rem; color: var(--ink); }
.ruler__pin::before {
  content: ""; width: 2px; height: 8px; background: var(--ink); border-radius: 1px;
}
.ruler__scale { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: .7rem; color: var(--muted); margin-top: 2px; }

.headline {
  font-family: var(--font-text); font-size: clamp(1.05rem, .95rem + .6vw, 1.3rem);
  line-height: 1.6; color: var(--ink); max-width: 44rem;
}
.headline em { font-style: normal; color: var(--accent); font-weight: 600; }

.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 3rem 1fr auto; align-items: center; gap: 12px; }
.bar__label { font-family: var(--font-mono); font-size: .85rem; color: var(--ink-2); }
.bar__track { height: 12px; background: var(--paper-sunk); border-radius: var(--r-full); overflow: hidden; }
.bar__fill {
  display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit;
  transform: scaleX(0); transform-origin: left center;
  transition: transform 700ms var(--ease);
}
.bar__fill[data-weak="true"] { background: var(--err); }
.bar__val { font-family: var(--font-mono); font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table__meter { width: 7rem; height: 8px; background: var(--paper-sunk); border-radius: var(--r-full); overflow: hidden; }
.table__meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.table__num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.table__wrong { color: var(--err); font-weight: 600; }

.group { margin-bottom: 22px; }
.group__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.group__head h3 { font-family: var(--font-text); font-size: 1.1rem; }
.group__blurb { font-size: .85rem; color: var(--muted); margin-bottom: 10px; max-width: 44rem; }

.miss { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 6px; overflow: hidden; }
.miss__btn { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 12px 14px; }
.miss__btn:hover { background: var(--surface-2); }
.miss__n { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); flex: none; padding-top: 3px; min-width: 2.4rem; }
.miss__body { min-width: 0; }
.miss__sentence { font-family: var(--font-text); font-size: 1.02rem; line-height: 1.5; }
.miss__sentence b { color: var(--ok); font-weight: 600; }
.miss__swap { font-size: .84rem; color: var(--muted); margin-top: 4px; }
.miss__swap del { color: var(--err); text-decoration-thickness: 1px; }
.miss__swap ins { color: var(--ok); text-decoration: none; font-weight: 600; }
.miss__caret { margin-left: auto; color: var(--muted); flex: none; transition: transform var(--t-select) var(--ease); }
.miss[open] .miss__caret { transform: rotate(180deg); }
.miss__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 200ms var(--ease); }
.miss[open] .miss__panel { grid-template-rows: 1fr; }
.miss__panel > div { overflow: hidden; }
.miss__panel .inner { padding: 0 14px 14px 3.6rem; display: grid; gap: 10px; }

.why { font-size: .95rem; line-height: 1.6; color: var(--ink-2); }
.traps { display: grid; gap: 6px; }
.trap { display: flex; gap: 8px; font-size: .88rem; color: var(--muted); line-height: 1.5; }
.trap__key { font-family: var(--font-mono); color: var(--ink-2); flex: none; }
.trap--yours { color: var(--err); }
.trap--yours .trap__key { color: var(--err); }

.study { display: grid; gap: 12px; }
.study__item { padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.study__item h3 { font-family: var(--font-text); font-size: 1.05rem; margin-bottom: 4px; }
.study__item p { font-size: .88rem; color: var(--muted); }
.study__rules { display: grid; gap: 4px; margin-top: 10px; }
.study__rules li { font-size: .85rem; color: var(--ink-2); display: flex; gap: 8px; }
.study__rules li::before { content: "→"; color: var(--accent); flex: none; }
.study__qs { margin-top: 10px; font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* --- 9. Review ---------------------------------------------------------- */

.review__bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px);
}
.review__pos { font-family: var(--font-mono); font-size: .82rem; color: var(--muted); margin-left: auto; }
.rcard { max-width: 42rem; margin: 0 auto; width: 100%; }
.rcard__verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.rcard__solution {
  font-family: var(--font-text); font-size: clamp(1.2rem, 1rem + 1.2vw, 1.55rem);
  line-height: 1.55; margin-bottom: 14px;
}
.rcard__solution b { color: var(--ok); font-weight: 600; }
.rcard__swap {
  display: grid; gap: 4px; font-size: .95rem; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--surface-2); margin-bottom: 16px;
}
.rcard__swap .yours { color: var(--err); }
.rcard__swap .yours del { text-decoration-thickness: 1px; }
.rcard__swap .right { color: var(--ok); font-weight: 600; }
.rcard__prompt { font-family: var(--font-text); color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.rcard__section { margin-top: 16px; }
.rcard__section > h3 {
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
details.disclosure > summary {
  cursor: pointer; font-size: .85rem; color: var(--accent); padding: 6px 0; list-style: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸ "; }
details.disclosure[open] > summary::before { content: "▾ "; }

/* --- 10. Responsive ----------------------------------------------------- */

@media (max-width: 640px) {
  .rail { display: none; }
  .topmeta { font-size: .78rem; gap: 6px; }
  .topmeta__right { gap: 2px; }
  .option { min-height: 52px; }
  .stage { min-height: auto; padding-top: 20px; }
  .grid100 { grid-template-columns: repeat(8, 1fr); }
  .verdict__row { gap: 14px; }
  .bar { grid-template-columns: 2.4rem 1fr auto; }
  .sheet { width: 96vw; padding: 20px; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (min-width: 641px) { .rail-bar { display: none; } }
@media (min-width: 1024px) {
  .test { max-height: 100svh; }
  .stage { overflow: auto; }
}

/* --- 11. Print (§6.9) --------------------------------------------------- */

@media print {
  :root {
    --paper: #fff; --surface: #fff; --surface-2: #fff; --paper-sunk: #eee;
    --ink: #000; --ink-2: #222; --muted: #555; --line: #bbb; --line-strong: #999;
    --accent: #0b4340; --accent-ink: #0b4340; --accent-soft: #eef4f3; --accent-on: #fff;
    --ok: #14532d; --err: #7f1d1d; --ok-soft: #f0f6f1; --err-soft: #fbf0ef;
    --shadow-1: none; --shadow-2: none;
  }
  body { background: #fff; font-size: 11pt; }
  .topbar, .bottombar, .banners, .toasts, .layer, .skip, .actions,
  .review__bar, .results__head .spacer, .no-print { display: none !important; }
  .results { max-width: none; padding: 0; }
  .card, .miss, .study__item { border: 1px solid #bbb; box-shadow: none; }
  .miss__panel { grid-template-rows: 1fr !important; }
  .miss__panel > div { overflow: visible; }
  .miss__caret { display: none; }
  .miss, .study__item, .group, .bar { break-inside: avoid; page-break-inside: avoid; }
  .section { break-inside: avoid-page; margin-bottom: 18pt; }
  .rise, .anim-in-fwd, .anim-in-back { animation: none !important; opacity: 1 !important; transform: none !important; }
  details.disclosure > summary { display: none; }
  details.disclosure { display: block; }
  a[href]::after { content: ""; }
  @page { margin: 16mm; }
}
