/*
  Deal (tasteskill 2.5.1, kind: software / study app)
  palette cool-grey-cobalt: a cool, quiet ground for long study sessions; cobalt marks the one action
  type instrument: Instrument Sans + DM Mono (figures, timer, keys)
  radius soft · buttons solid · mark wordmark
  motion: home entrance once on load; hover/press layer; tab indicator slides; nothing moves on scroll
*/

/* ---------- Tokens ---------- */
:root {
  --bg: #eef0f3;
  --card: #f9fafb;
  --track: #e2e5ea;
  --ink: #0b0c0e;
  --muted: #4d535d;
  --line: color-mix(in oklab, var(--ink) 13%, transparent);
  --line-strong: color-mix(in oklab, var(--ink) 30%, transparent);
  --action: #1f2de6;
  --action-ink: #ffffff;
  --action-soft: color-mix(in oklab, var(--action) 8%, var(--card));
  --ok: #0d7a3a;
  --ok-bg: #e5f3ea;
  --bad: #b8242b;
  --bad-bg: #fbe9ea;
  --warn: #9a5200;

  --font-text: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 500;
  --display-tracking: -0.028em;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-btn: 8px;
  --btn-h: 48px;
  --nav: 64px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --m-in: 150ms; --m-out: 120ms; --m-press: 90ms; --m-slide: 240ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e; --card: #141518; --track: #1d1f23; --ink: #eef0f3; --muted: #a9abb0;
    --action: #eef0f3; --action-ink: #0b0c0e;
    --action-soft: color-mix(in oklab, var(--ink) 9%, var(--card));
    --ok: #4cd483; --ok-bg: rgba(76, 212, 131, .12); --bad: #ff7a7a; --bad-bg: rgba(255, 122, 122, .12); --warn: #f2b84b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0e; --card: #141518; --track: #1d1f23; --ink: #eef0f3; --muted: #a9abb0;
  --action: #eef0f3; --action-ink: #0b0c0e;
  --action-soft: color-mix(in oklab, var(--ink) 9%, var(--card));
  --ok: #4cd483; --ok-bg: rgba(76, 212, 131, .12); --bad: #ff7a7a; --bad-bg: rgba(255, 122, 122, .12); --warn: #f2b84b;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; transition: none !important; }
h1, h2, h3 { margin: 0; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.2; }
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--s-6) max(var(--s-5), env(safe-area-inset-right)) calc(var(--s-7) + env(safe-area-inset-bottom)) max(var(--s-5), env(safe-area-inset-left));
}
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto; height: var(--nav);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(var(--s-5), env(safe-area-inset-right)) 0 max(var(--s-5), env(safe-area-inset-left));
}
.brand {
  background: none; border: 0; padding: var(--s-2) 0; min-height: 44px;
  font-size: 20px; font-weight: var(--display-weight); letter-spacing: -0.02em;
  position: relative;
}
.brand::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform var(--m-out) var(--ease);
}
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-btn);
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line);
  transition: background-color var(--m-out) var(--ease), border-color var(--m-out) var(--ease), transform var(--m-press) var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-moon { fill: currentColor !important; stroke: none !important; }
.icon-sun { display: none; }
.is-dark .icon-sun { display: block; }
.is-dark .icon-moon { display: none; }

/* ---------- Buttons (solid look) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--btn-h); padding: 0 var(--s-5);
  border-radius: var(--r-btn); border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink);
  font-size: 16px; font-weight: 500; white-space: nowrap;
  touch-action: manipulation;
  transition: background-color var(--m-out) var(--ease), border-color var(--m-out) var(--ease), color var(--m-out) var(--ease), transform var(--m-out) var(--ease);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn-block { width: 100%; }
.btn-sm { height: 44px; padding: 0 var(--s-4); font-size: 15px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
kbd {
  font: 500 13px/1 var(--font-mono);
  padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); color: var(--muted);
}
@media (hover: none) { .kbd-hint, kbd { display: none !important; } }

/* Hover and press: fine pointer only (motion layer numbers) */
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover { transform: translateY(-1px); transition-duration: var(--m-in); }
  .btn-primary:not(:disabled):hover { background: color-mix(in oklab, var(--action) 84%, var(--ink)); border-color: color-mix(in oklab, var(--action) 84%, var(--ink)); }
  .btn:not(.btn-primary):not(:disabled):hover { background: color-mix(in oklab, var(--card) 92%, var(--ink)); border-color: color-mix(in oklab, var(--ink) 50%, transparent); }
  .btn-ghost:not(:disabled):hover { color: var(--ink); }
  .icon-btn:hover { background: color-mix(in oklab, var(--bg) 90%, var(--ink)); border-color: var(--line-strong); transition-duration: var(--m-in); }
  .brand:hover::after { transform: scaleX(1); transform-origin: left; transition-duration: var(--m-in); }
}
.btn:not(:disabled):active { transform: translateY(1px) scale(.985); transition-duration: var(--m-press); }
.icon-btn:active { transform: scale(.985); }

/* ---------- Home ---------- */
.hero { margin: var(--s-2) 0 var(--s-6); }
.hero h1 { font-size: clamp(32px, 6.2vw, 48px); letter-spacing: -0.036em; line-height: 1.08; max-width: 16ch; }
.hero p { margin: var(--s-4) 0 0; font-size: 18px; color: var(--muted); max-width: 46ch; }
.hero p strong { color: var(--ink); font-weight: 500; }

/* Mode tabs: one ink pill slides to the clicked tab */
.tabs {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-1);
  padding: var(--s-1); border-radius: var(--r-md);
  background: var(--track);
}
.marker {
  position: absolute; top: 0; left: 0; z-index: 0;
  border-radius: var(--r-sm); pointer-events: none;
  transform-origin: left center;
  transition: transform var(--m-slide) var(--ease);
}
.tab-ind { background: var(--ink); }
.tab {
  position: relative; z-index: 1;
  border: 0; background: transparent; border-radius: var(--r-sm);
  min-height: 56px; padding: var(--s-2) var(--s-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-size: 16px; font-weight: 500; color: var(--ink);
  transition: color var(--m-slide) var(--ease);
}
.tab small { font-size: 13px; font-weight: 400; color: var(--muted); transition: color var(--m-slide) var(--ease); }
.tab[aria-selected="true"] { color: var(--bg); }
.tab[aria-selected="true"] small { color: color-mix(in oklab, var(--bg) 72%, var(--ink)); }
@media (hover: hover) and (pointer: fine) {
  .tab[aria-selected="false"]:hover { background: color-mix(in oklab, var(--track) 80%, var(--ink)); }
}

.panel {
  margin-top: var(--s-4); padding: var(--s-6);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel-lead { margin: 0 0 var(--s-5); font-size: 16px; color: var(--ink); max-width: 56ch; }
.field { margin-bottom: var(--s-5); }
.field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: var(--s-2); }
.field-hint { font-size: 14px; color: var(--muted); margin-top: var(--s-2); }

/* Segmented choice: a raised tile on a grey track */
.seg {
  position: relative;
  display: flex; flex-wrap: wrap; gap: var(--s-1);
  padding: var(--s-1); border-radius: var(--r-md); background: var(--track);
}
.seg button {
  position: relative; z-index: 1;
  flex: 1 1 0; min-width: 52px; min-height: 44px; padding: 0 var(--s-3);
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  font-size: 15px; font-weight: 500; color: var(--muted); white-space: nowrap;
  transition: background-color var(--m-out) var(--ease), color var(--m-out) var(--ease), transform var(--m-press) var(--ease);
}
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg > .marker { background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 2px color-mix(in oklab, var(--ink) 10%, transparent); }
@media (hover: hover) and (pointer: fine) {
  .seg button[aria-pressed="false"]:hover { color: var(--ink); transition-duration: var(--m-in); }
}
.seg button:active { transform: scale(.985); }

.row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
.num {
  width: 96px; height: 48px; padding: 0 var(--s-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--card);
  font: 400 16px var(--font-mono);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.num:focus { border-color: var(--action); box-shadow: 0 0 0 3px color-mix(in oklab, var(--action) 22%, transparent); outline: none; }
.range-label { display: flex; flex-direction: column; gap: var(--s-1); font-size: 14px; color: var(--muted); }
.check { display: flex; gap: var(--s-3); align-items: flex-start; cursor: pointer; min-height: 44px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--action); flex: none; }
.check-text { font-size: 16px; }
.check-text .field-hint { margin-top: 2px; }
.error { color: var(--bad); font-size: 14px; margin-top: var(--s-2); }
.start-row { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.shortcuts { margin-top: var(--s-4); font-size: 13px; color: var(--muted); }
.shortcuts kbd { margin: 0 2px; }

/* Home entrance, once on load: the h1 rises out of its mask, then the rest fades up 12px */
@media (prefers-reduced-motion: no-preference) {
  .enter .h1-mask { display: block; overflow: clip; padding-bottom: .08em; margin-bottom: -.08em; }
  .enter .h1-mask > span { display: block; animation: rise 700ms var(--ease-enter) both; }
  .enter .enter-up { animation: fade-up 520ms var(--ease-enter) both; }
  .enter .enter-d1 { animation-delay: 350ms; }
  .enter .enter-d2 { animation-delay: 410ms; }
  .enter .enter-d3 { animation-delay: 470ms; }
}
@keyframes rise { from { transform: translateY(105%); } to { transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Session header ---------- */
.session-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.session-title { font-size: 14px; font-weight: 500; color: var(--muted); }
.session-stats { display: flex; align-items: center; gap: var(--s-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 var(--s-3); border-radius: 999px;
  font: 500 14px/1 var(--font-mono); font-variant-numeric: tabular-nums;
  background: var(--card); border: 1px solid var(--line);
}
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }
.pill.text { font-family: var(--font-text); }
.timer { font-size: 15px; min-width: 72px; justify-content: center; }
.timer.low { color: var(--warn); border-color: currentColor; }
.timer.critical { color: var(--bad); border-color: currentColor; background: var(--bad-bg); }
.progress { height: 4px; border-radius: 99px; background: var(--track); overflow: hidden; margin-bottom: var(--s-5); }
.progress > span {
  display: block; height: 100%; width: 100%; background: var(--ink); border-radius: inherit;
  transform-origin: left; transition: transform var(--m-slide) var(--ease);
}

/* ---------- Question card ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  transition: border-color var(--m-out) var(--ease);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.q-meta { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: var(--s-3); }
.q-meta .mono { font-weight: 400; }
.q-prompt { font-size: clamp(20px, 3.6vw, 24px); margin: 0 0 var(--s-5); line-height: 1.32; letter-spacing: -0.018em; text-wrap: pretty; }
.choices { display: grid; gap: var(--s-2); list-style: none; margin: 0; padding: 0; }
.choice {
  width: 100%; text-align: left;
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); min-height: 56px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); font-size: 16px; line-height: 1.5;
  touch-action: manipulation;
  transition: border-color var(--m-out) var(--ease), background-color var(--m-out) var(--ease), transform var(--m-out) var(--ease);
}
.choice:disabled { cursor: default; }
.choice .letter {
  flex: none; width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  font: 500 13px/1 var(--font-mono);
  border: 1px solid var(--line-strong); color: var(--muted);
  transition: background-color var(--m-out) var(--ease), color var(--m-out) var(--ease), border-color var(--m-out) var(--ease);
}
.choice .text { padding-top: 2px; }
.choice .mark { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; padding-top: 4px; }
.review-mark { font-size: 13px; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .choice:not(:disabled):hover { transform: translateY(-2px); border-color: var(--line-strong); transition-duration: 180ms; }
}
.choice:not(:disabled):active { transform: scale(.985); transition-duration: var(--m-press); }
.choice.selected { border-color: var(--action); background: var(--action-soft); }
.choice.selected .letter { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.correct .letter { background: var(--ok); border-color: var(--ok); color: var(--card); }
.choice.correct .mark { color: var(--ok); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice.wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--card); }
.choice.wrong .mark { color: var(--bad); }
.choice.dim { color: var(--muted); }

.feedback {
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  font-size: 16px; font-weight: 500;
  display: flex; gap: var(--s-3); align-items: flex-start;
}
.feedback .glyph { margin-top: 4px; }
.feedback b { font-weight: 500; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback span { color: var(--ink); font-weight: 400; }

.actions { display: flex; gap: var(--s-3); margin-top: var(--s-4); align-items: center; }
.actions .spacer { flex: 1; }
.actions .btn { flex: 0 0 auto; }
.hint-text { font-size: 14px; color: var(--muted); }

/* Question overview (end-feedback quiz and exam) */
.overview { margin-top: var(--s-5); }
.overview summary { cursor: pointer; font-size: 15px; font-weight: 500; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.overview summary { list-style: none; gap: var(--s-2); }
.overview summary::-webkit-details-marker { display: none; }
.overview summary::before {
  content: ""; width: 8px; height: 8px; margin-left: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--m-out) var(--ease);
}
.overview[open] summary::before { transform: rotate(45deg); }
.overview summary:hover { color: var(--ink); }
.grid-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: var(--s-2); margin-top: var(--s-2); }
.grid-nav button {
  height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--card); font: 500 14px/1 var(--font-mono); color: var(--muted);
  transition: border-color var(--m-out) var(--ease), transform var(--m-press) var(--ease);
}
.grid-nav button.answered { background: var(--action-soft); border-color: color-mix(in oklab, var(--action) 45%, transparent); color: var(--ink); }
.grid-nav button.current { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
@media (hover: hover) and (pointer: fine) { .grid-nav button:hover { border-color: var(--line-strong); color: var(--ink); } }
.grid-nav button:active { transform: scale(.985); }
.submit-early { margin-top: var(--s-4); }

/* ---------- Flashcards: the answer swaps in place ---------- */
.flash {
  display: grid; cursor: pointer; min-height: 320px;
  -webkit-tap-highlight-color: transparent;
}
.flash-face { grid-area: 1 / 1; display: flex; flex-direction: column; }
.flash-face[hidden] { display: none; }
.flash-face.swap-in { animation: fade-up 260ms var(--ease) both; }
.flash-choices { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--s-2); color: var(--muted); }
.flash-choices li { display: flex; gap: var(--s-3); }
.flash-choices b { flex: none; font: 500 14px/1.6 var(--font-mono); }
.flash-hint { margin-top: auto; padding-top: var(--s-5); text-align: center; font-size: 14px; color: var(--muted); }
.answer-label { font-size: 13px; font-weight: 500; color: var(--ok); margin-bottom: var(--s-2); }
.answer-text { font-size: clamp(22px, 4.2vw, 28px); font-weight: var(--display-weight); letter-spacing: -0.022em; line-height: 1.25; margin: 0 0 var(--s-5); }
.answer-q { font-size: 16px; color: var(--muted); border-top: 1px solid var(--line); padding-top: var(--s-4); margin: 0; }
.flash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-4); }
.btn-miss { color: var(--bad); }
.btn-got { color: var(--ok); }

/* ---------- Results ---------- */
.score { text-align: center; padding: var(--s-6) var(--s-5); }
.score-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.score-big { font-size: clamp(44px, 11vw, 56px); font-weight: var(--display-weight); letter-spacing: -0.04em; line-height: 1.05; margin-top: 2px; font-variant-numeric: tabular-nums; }
.score-sub { color: var(--muted); margin-top: 2px; font-size: 14px; }
.score-notes { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }
.time-up { display: inline-block; margin-bottom: var(--s-4); padding: var(--s-1) var(--s-3); border-radius: 999px; background: var(--bad-bg); color: var(--bad); font-size: 14px; font-weight: 500; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin: var(--s-4) 0 var(--s-7); }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.review-head h2 { font-size: 24px; }
.review-head .seg { flex: 0 1 auto; }
.review-list { display: grid; gap: var(--s-3); }
.review-item { padding: var(--s-5); }
.review-item .q-prompt { font-size: 18px; margin-bottom: var(--s-3); }
.review-item .choices { gap: 6px; }
.review-item .choice { padding: 10px var(--s-3); min-height: 0; font-size: 16px; }
.review-item .choice .letter { width: 24px; height: 24px; font-size: 13px; }
.status { font-size: 13px; font-weight: 500; padding: 2px var(--s-2); border-radius: 999px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.status.skip { background: var(--track); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: var(--s-6); }

/* ---------- Motion: every action answers ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in-r { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-in-l { from { opacity: 0; transform: translateX(-28px); } }
@keyframes leave-r { to { opacity: 0; transform: translateX(44px); } }
@keyframes leave-l { to { opacity: 0; transform: translateX(-44px); } }
@keyframes pop { from { transform: scale(.7); } }
@keyframes bump { 40% { transform: scale(1.14); } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes fill-ok { from { background-color: var(--card); border-color: var(--line); } }
@keyframes fill-bad { from { background-color: var(--card); border-color: var(--line); } }
@keyframes dim-out { from { color: var(--ink); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes ready { from { opacity: .4; } }

/* Screens: a new screen fades up; the next question slides in from the side you moved to */
.view-in-fade { animation: fade-up 320ms var(--ease-enter) both; }
.slide-forward { animation: slide-in-r 300ms var(--ease-enter) both; }
.slide-back { animation: slide-in-l 300ms var(--ease-enter) both; }
.panel-swap > * { animation: fade-up 260ms var(--ease-enter) both; }
.list-swap { animation: fade-in 200ms var(--ease) both; }

/* Drawn check and cross */
.glyph { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.glyph path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.choices.just .glyph path, .feedback.just .glyph path { animation: draw 340ms var(--ease) 140ms both; }

/* Picking an answer: the pick pops; a right answer fills in green; a wrong one shakes,
   then the right one fills in a beat later; the rest step back */
.choices.just .choice.picked .letter { animation: pop 240ms var(--ease-enter) both; }
.choices.just .choice.correct { animation: fill-ok 360ms var(--ease) both; }
.choices.just .choice.correct:not(.picked) { animation-delay: 160ms; }
.choices.just .choice.correct:not(.picked) .letter { animation: pop 260ms var(--ease-enter) 160ms both; }
.choices.just .choice.wrong { animation: fill-bad 300ms var(--ease) both, shake 380ms var(--ease) both; }
.choices.just .choice.dim { animation: dim-out 300ms var(--ease) both; }
.feedback.just { animation: fade-up 280ms var(--ease-enter) 120ms both; }
.btn.ready { animation: ready 280ms var(--ease) both; }
.grid-nav button.just { animation: pop 240ms var(--ease-enter) both; }
@media (hover: hover) and (pointer: fine) {
  .choice:not(:disabled):hover .letter { border-color: var(--ink); color: var(--ink); }
  .choice.selected:not(:disabled):hover .letter { color: var(--action-ink); border-color: var(--action); }
}

/* Counters bump when they change; the last ten seconds tick */
.pill.bump { animation: bump 280ms var(--ease); }
.timer.tick { animation: bump 300ms var(--ease); }

/* Flashcards: a marked card leaves to its side, tinted by the mark */
.flash.leave-got { animation: leave-r 200ms var(--ease) forwards; }
.flash.leave-miss { animation: leave-l 200ms var(--ease) forwards; }
.flash.leave-got .card { border-color: var(--ok); }
.flash.leave-miss .card { border-color: var(--bad); }

/* Results: the ring draws to the score while the number counts up; the rest follows */
.ring-wrap { position: relative; width: 208px; height: 208px; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 7; }
.ring-track { stroke: var(--track); }
.ring-arc { stroke-linecap: round; stroke-dasharray: 100; transition: stroke-dashoffset 900ms var(--ease-enter); }
.ring-arc.ok { stroke: var(--ok); }
.ring-arc.bad { stroke: var(--bad); }
.ring-arc.mid { stroke: var(--ink); }
.ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.results-first .score-notes > *, .results-first .result-actions > * { animation: fade-up 420ms var(--ease-enter) both; animation-delay: 520ms; }
.results-first .score-notes > :nth-child(2), .results-first .result-actions > :nth-child(2) { animation-delay: 580ms; }
.results-first .score-notes > :nth-child(3) { animation-delay: 640ms; }
.results-first .score-notes > :nth-child(4) { animation-delay: 700ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .btn, .choice, .seg button, .grid-nav button, .icon-btn, .marker, .progress > span, .ring-arc { transition-property: background-color, border-color, color !important; }
  .btn:active, .choice:active, .seg button:active { transform: none !important; }
}

/* ---------- Phone ---------- */
@media (max-width: 639px) {
  :root { --nav: 56px; }
  .container { padding-top: var(--s-5); }
  .hero { margin-bottom: var(--s-5); }
  .hero p { font-size: 17px; }
  .card, .panel { padding: var(--s-5) var(--s-4); border-radius: var(--r-md); }
  .tab { min-height: 48px; font-size: 15px; }
  .tab small { display: none; }
  .seg button { padding: 0 var(--s-2); }
  .actions {
    position: sticky; bottom: 0; z-index: 5;
    margin: var(--s-4) calc(-1 * var(--s-5)) 0; padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .actions .btn { flex: 1 1 0; padding: 0 var(--s-3); }
  .actions .spacer, .actions .hint-text { display: none; }
  .flash { min-height: 280px; }
  .result-actions { grid-template-columns: 1fr; }
  .review-head .seg { flex: 1 1 100%; }
  .review-item { padding: var(--s-4); }
  .review-item .choice { flex-wrap: wrap; row-gap: 2px; }
  .review-item .choice .text { flex: 1 1 0; }
  .review-item .choice .mark { flex-basis: 100%; margin-left: 36px; padding-top: 0; }
}

@media (max-width: 400px) {
  .wide-only { display: none; }
  .brand { font-size: 18px; white-space: nowrap; }
  .session-title, .session-head .btn { white-space: nowrap; }
  .session-head .btn-sm { padding: 0 var(--s-2); }
  .container { padding-left: var(--s-4); padding-right: var(--s-4); }
  .topbar-inner { padding-left: var(--s-4); padding-right: var(--s-4); }
  .actions { margin-left: calc(-1 * var(--s-4)); margin-right: calc(-1 * var(--s-4)); padding-left: var(--s-4); padding-right: var(--s-4); }
  .seg button { min-width: 44px; font-size: 14px; }
}

@media (max-width: 400px) {
  .wide-only { display: none; }
  .brand { font-size: 18px; white-space: nowrap; }
  .session-title, .session-head .btn { white-space: nowrap; }
  .session-head .btn-sm { padding: 0 var(--s-2); }
  .container { padding-left: var(--s-4); padding-right: var(--s-4); }
  .topbar-inner { padding-left: var(--s-4); padding-right: var(--s-4); }
  .actions { margin-left: calc(-1 * var(--s-4)); margin-right: calc(-1 * var(--s-4)); padding-left: var(--s-4); padding-right: var(--s-4); }
  .seg button { min-width: 44px; font-size: 14px; }
}
