/* ============================================================
   PASSO — Minimal Brutalism
   Hard borders, hard shadows, high contrast, sans-serif type.
   ============================================================ */

/* Токены дизайн-системы (docs/design-system/tokens.json).
   Имена переменных = имена токенов; светлая тема в :root, тёмная в
   [data-theme="dark"]. Старые имена ниже — алиасы, удаляем, когда ни
   один экран их не использует. */

/* ---------- Fonts (self-hosted, SIL OFL 1.1 — see /fonts/OFL-*.txt) ----------
   Onest (variable 100–900): latin, latin-ext (Italian accents), cyrillic.
   IBM Plex Mono 500/600: numerals, timer, counters. No external requests. */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/onest-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/onest-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/onest-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  --paper: #f4f1ea;
  --surface: #ffffff;
  --surface-sunken: #ebe7dd;
  --ink: #000000;
  --ink-muted: #55514a;
  --line-soft: #d8d2c4;
  --on-ink: #f4f1ea;
  --accent: #ff4d00;
  --on-accent: #000000;
  --accent-ink: #b83a00;
  --accent-soft: #ffe3d6;
  --ok: #006b7a;
  --ok-soft: #d9f1f4;
  --on-ok: #ffffff; /* light theme: --ok is dark teal, text on it must be white (6:1) */
  --bad: #b3002c;
  --bad-soft: #ffe0e6;
  --warn: #ffd000;
  --on-warn: #000000;
  --warn-ink: #6b5000;
  --warn-soft: #fff3bf;
  --focus: #0044cc;
  /* activity heat map, low to high */
  --heat-0: #eceae3;
  --heat-1: #ffd9c2;
  --heat-2: #ffb380;
  --heat-3: #ff8138;
  --heat-4: #ff4d00;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-none: 0;
  --radius-xs: 2px;
  --radius-full: 999px;

  --shadow-sm: 3px 3px 0 #000000;
  --shadow-md: 6px 6px 0 #000000;

  --border-2: 2px;
  --border-3: 3px;

  --tap-min: 48px;
  --nav-h: 64px;
  --content-max: 720px;

  --z-nav: 100;
  --z-overlay: 200;

  /* Стек из tokens.json без "Onest" — он self-hostится только в S2.13. */
  --font-sans: "Onest", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* --- алиасы старых имён (пока их используют экраны) --- */
  --muted: var(--ink-muted);
  --border: var(--border-3) solid var(--ink);
  --border-thin: var(--border-2) solid var(--ink);
  --shadow: var(--shadow-md);
  --shadow-small: var(--shadow-sm);
  --font: var(--font-sans);
}

[data-theme="dark"] {
  --paper: #0c0c0c;
  --surface: #1a1a1a;
  --surface-sunken: #121212;
  --ink: #f4f1ea;
  --ink-muted: #b5b0a5;
  --line-soft: #2e2e2e;
  --on-ink: #0c0c0c;
  --accent-ink: #ff7a3d;
  --accent-soft: #3a1a0d;
  --ok: #4fd0e0;
  --ok-soft: #0c2f35;
  --on-ok: #002b31;
  --bad: #ff7b96;
  --bad-soft: #3a0f1a;
  --warn-ink: #ffd000;
  --warn-soft: #3a3000;
  --focus: #7aa2ff;
  /* activity heat map, low to high */
  --heat-0: #262626;
  --heat-1: #5c2c14;
  --heat-2: #93431c;
  --heat-3: #c25a20;
  --heat-4: #ff4d00;

  --shadow-sm: 3px 3px 0 #f4f1ea;
  --shadow-md: 6px 6px 0 #f4f1ea;
}

/* S3.3: 'auto' theme — follow the OS. Light by default (the :root values
   apply); in dark mode use exactly the [data-theme="dark"] variables. Kept
   1:1 with the dark block on purpose — do not hand-edit one without the
   other. */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --paper: #0c0c0c;
    --surface: #1a1a1a;
    --surface-sunken: #121212;
    --ink: #f4f1ea;
    --ink-muted: #b5b0a5;
    --line-soft: #2e2e2e;
    --on-ink: #0c0c0c;
    --accent-ink: #ff7a3d;
    --accent-soft: #3a1a0d;
    --ok: #4fd0e0;
    --ok-soft: #0c2f35;
    --on-ok: #002b31;
    --bad: #ff7b96;
    --bad-soft: #3a0f1a;
    --warn-ink: #ffd000;
    --warn-soft: #3a3000;
    --focus: #7aa2ff;
    /* activity heat map, low to high */
    --heat-0: #262626;
    --heat-1: #5c2c14;
    --heat-2: #93431c;
    --heat-3: #c25a20;
    --heat-4: #ff4d00;

    --shadow-sm: 3px 3px 0 #f4f1ea;
    --shadow-md: 6px 6px 0 #f4f1ea;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  /* iOS: 100vh ignores the browser's collapsing toolbar, which makes a
     fixed bottom bar drift. dvh tracks the viewport that is really there. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Masthead & nav ---------- */

.masthead {
  border-bottom: var(--border);
  background: var(--surface);
  padding: 16px 24px;
  /* viewport-fit=cover lets content sit under the status bar/notch. */
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Wordmark: name in ink (never accent — 2.9:1 on paper), accent square
   follows the last letter, tagline in ink-muted mono. */
.brand {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1;
}

.brand__name {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font: 900 32px/1 var(--font-sans);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand__dot {
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  background: var(--accent);
  border: 0.07em solid var(--ink);
}

.brand__tag {
  font: 600 12px/16px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.accent { color: var(--accent-ink); }

/* S2.7: Settings gear in the masthead -- phones only (bar has five tabs) */
.settings-gear {
  display: none;
  align-self: flex-start;
  color: var(--ink);
  border: var(--border);
  width: 44px;
  height: 44px;
  padding: 10px;
  box-sizing: border-box;
}
.settings-gear svg { width: 24px; height: 24px; display: block; }
.settings-gear:hover { background: var(--surface-sunken); }
.settings-gear.active { background: var(--ink); color: var(--on-ink); }

.nav {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border: var(--border-thin);
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-right: var(--border-thin);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav svg { width: 22px; height: 22px; display: block; }

.nav a:last-child { border-right: none; }
.nav a { position: relative; }

/* S2.7: count of open mistakes on the Mistakes tab */
.nav-badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 2px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bad);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  border-radius: 9px;
}
.nav a:hover { background: var(--surface-sunken); }
.nav a.active { background: var(--ink); color: var(--on-ink); }

main {
  flex: 1;
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- Type & layout helpers ---------- */

h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.lede { color: var(--muted); font-weight: 500; margin-bottom: 28px; font-size: 0.875rem; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 760px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Cards & panels ---------- */

.panel {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow-small);
  padding: 20px;
}

.card h2, .panel h2 {
  /* heading token (tokens.json): card and panel titles, sentence case */
  font-size: 1.25rem;
  line-height: 1.5rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 12px;
}

a.card {
  display: block;
  color: var(--ink);
  text-decoration: none;
  transition: transform 60ms ease, box-shadow 60ms ease;
}

a.card:hover { background: var(--warn); color: #000; }
a.card:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.stat-value {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
}

.stat-value.ok { color: var(--ok); }
.stat-value.accent { color: var(--accent-ink); }

.stat-sub { font-size: 0.875rem; font-weight: 500; color: var(--muted); margin-top: 6px; }

.bar {
  height: 12px;
  border: var(--border-thin);
  background: var(--surface);
  margin-top: 12px;
}

.bar > div { height: 100%; background: var(--ok); }

/* ---------- Buttons & forms ---------- */

.btn {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--ink);
  border: var(--border-thin);
  border-radius: 0;
  padding: 12px 22px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  box-shadow: var(--shadow-small);
  transition: transform 60ms ease, box-shadow 60ms ease, background-color 60ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* hover — подъём на 1px + surface-sunken (не жёлтый: жёлтый = warning) */
.btn:hover { background: var(--surface-sunken); transform: translate(-1px, -1px); }
/* press — провал на 3px, тень убирается */
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--surface-sunken);
  border-color: var(--ink-muted);
  color: var(--ink-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
/* primary hover — остаётся accent, только подъём */
.btn-primary:hover { background: var(--accent); }
.btn-big { font-size: 1rem; padding: 16px 32px; }
/* S2.8: answer buttons now use .ds-answer (design system). They stay neutral at rest (no colour hint); the old solid ok/bad fills were intentionally removed. The .btn-true/.btn-false classes are kept only as stable QA/test selectors. */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

input, select {
  font-family: var(--font);
  font-size: 1rem;
  padding: 12px;
  border: var(--border-thin);
  background: var(--surface);
  color: var(--ink);
  border-radius: 0;
  appearance: none;
}

input:focus-visible, select:focus-visible, .nav a:focus-visible, a.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* фокус кнопки — синий --focus 3px (дизайн-система) */
.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Quiz ---------- */

.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.quiz-progress { font-weight: 900; font-size: 0.9rem; letter-spacing: 0.1em; }

.timer {
  font: 600 1.4rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  border: var(--border-thin);
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
}

.timer.low { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

.question-card { text-align: left; }

.question-img {
  display: block;
  max-height: 160px;
  margin-bottom: 16px;
  border: var(--border-thin);
  padding: 8px;
  background: #fff;
}

.question-text { font-size: 1.25rem; font-weight: 700; line-height: 1.45; }

.question-translation {
  margin-top: 12px;
  padding: 12px;
  border-left: 6px solid var(--accent);
  background: var(--paper);
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.btn-translate {
  margin-top: 14px;
  background: var(--paper);
  border-style: dashed;
}

.answers { display: flex; gap: 16px; margin-top: 24px; flex-wrap: wrap; }
.ds-answers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: 24px; }
.ds-answer {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  padding: 0 16px;
  border: var(--border-3) solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: 900 24px/28px var(--font-sans);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.08s ease;
}
.ds-answer svg.ic { width: 28px; height: 28px; stroke-width: 3; }
.ds-answer:hover { background: var(--surface-sunken); }
.ds-answer:active { transform: translate(3px, 3px); box-shadow: none; }
.ds-answer:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ds-answer__state { display: none; font: 800 12px/16px var(--font-sans); letter-spacing: 0.7px; }
.ds-answer--ok,
.ds-answer--bad,
.ds-answer--reveal { flex-direction: column; gap: 2px; pointer-events: none; box-shadow: none; }
.ds-answer--ok { background: var(--ok-soft); border-color: var(--ok); }
.ds-answer--ok svg.ic,
.ds-answer--ok .ds-answer__state { color: var(--ok); }
.ds-answer--bad { background: var(--bad-soft); border-color: var(--bad); }
.ds-answer--bad svg.ic,
.ds-answer--bad .ds-answer__state { color: var(--bad); }
.ds-answer--bad::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 14px;
  background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 7px);
  opacity: 1;
}
.ds-answer--reveal { border-style: dashed; border-color: var(--ok); background: var(--surface); }
.ds-answer--reveal svg.ic,
.ds-answer--reveal .ds-answer__state { color: var(--ok); }
.ds-answer--ok .ds-answer__state,
.ds-answer--bad .ds-answer__state,
.ds-answer--reveal .ds-answer__state { display: block; }
/* the answer is locked: untouched buttons drop to ink-muted */
.ds-answer:disabled:not(.ds-answer--ok):not(.ds-answer--bad):not(.ds-answer--reveal) {
  color: var(--ink-muted);
  cursor: default;
}
.ds-answer:disabled:not(.ds-answer--ok):not(.ds-answer--bad):not(.ds-answer--reveal) svg.ic {
  color: var(--ink-muted);
}

/* S2.9 (components/Feedback): post-answer panel */
.ds-feedback {
  margin-top: 20px;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: var(--border-3) solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}
.ds-feedback--ok { border-color: var(--ok); background: var(--ok-soft); }
.ds-feedback--bad { border-color: var(--bad); background: var(--bad-soft); }
.ds-feedback__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 900 20px/24px var(--font-sans);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.ds-feedback__head svg.ic { width: 22px; height: 22px; stroke-width: 3; }
.ds-feedback--ok .ds-feedback__head { color: var(--ok); }
.ds-feedback--bad .ds-feedback__head { color: var(--bad); }
.ds-feedback__answer {
  font: 700 14px/20px var(--font-sans);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.ds-feedback .why-objective,
.ds-feedback .why-fact { background: var(--paper); }
.ds-feedback .why-fact:last-of-type { margin-bottom: 0; }
/* Q3: the chapter facts are collapsed — specific content comes first. */
.ds-feedback .why-details { margin-top: var(--space-2); }
.ds-feedback .why-details summary {
  cursor: pointer;
  font: 600 0.85rem/1.4 var(--font-sans);
  color: var(--muted);
  padding: 6px 0;
}
.ds-feedback .why-block { margin-top: var(--space-1); }
.ds-feedback__actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }

.kbd-hint { margin-top: 16px; font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; }

kbd {
  border: 2px solid var(--ink);
  padding: 1px 6px;
  font-family: var(--font);
  font-weight: 900;
  background: var(--surface);
  color: var(--ink);
}

/* ---------- Exam navigator ---------- */

.exam-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }

.exam-nav button {
  width: 44px;
  height: 44px;
  border: var(--border-thin);
  background: var(--surface);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.exam-nav button.answered { background: var(--ink); color: var(--paper); }
.exam-nav button.current { outline: 3px solid var(--accent); }

/* ---------- Lists ---------- */

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: var(--border-thin);
}

.row:last-child { border-bottom: none; }
/* S2.8a: icon + word status line (no color coding). */
.row .ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* S2.8a: "What erases it" list in the Your progress block. */
.progress-erases { margin: 0 0 8px; }
.progress-erases dt { font-weight: 700; margin-bottom: 4px; }
.progress-erases dd { margin: 0 0 6px 0; padding-left: 20px; position: relative; font-size: 0.875rem; color: var(--ink-muted); }
.progress-erases dd::before { content: "\2013"; position: absolute; left: 4px; }

.tag {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  border: 2px solid var(--ink);
  padding: 3px 8px;
  white-space: nowrap;
}

.tag.ok { background: var(--ok); color: var(--on-ok); }
.tag.bad { background: var(--bad); color: #fff; }
.tag.warn { background: var(--warn); color: #000; }

/* ---------- Theory reader ---------- */

.chapter-body { font-size: 1.05rem; line-height: 1.7; }
.chapter-body p { margin-bottom: 16px; }

.translation-block {
  border-left: 6px solid var(--accent);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--paper);
  color: var(--muted);
  font-weight: 600;
}

.simple-block {
  border: var(--border-thin);
  border-left: 6px solid var(--ok);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--paper);
}

/* ---------- Onboarding ---------- */

.onboard { max-width: 480px; margin: 40px auto; }

.onboard .lede { margin-bottom: 12px; }
.onboard .stat-sub { margin-bottom: 20px; }
.onboard .btn { white-space: nowrap; }

.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps span { flex: 1; height: 10px; border: var(--border-thin); background: var(--surface); }
.steps span.done { background: var(--accent); }

/* ---------- Misc ---------- */

.error-banner {
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  background: var(--bad);
  border: var(--border-thin);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.empty-note { color: var(--muted); font-weight: 400; letter-spacing: 0; font-size: 0.875rem; padding: 20px 0; }

.footer {
  border-top: var(--border);
  background: var(--ink);
  color: var(--paper);
  padding: 14px 24px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.footer code { background: var(--accent); color: var(--on-accent); padding: 1px 6px; }

/* ---------- Privacy notice (ds-notice, S2.5) ---------- */

.ds-notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  margin: 0 24px 16px;
  background: var(--surface-sunken);
  color: var(--ink);
  border: var(--border-2) solid var(--ink);
  font: 400 14px/20px var(--font-sans);
}

.ds-notice .ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.ds-notice__btn {
  margin-left: auto;
  flex: none;
  white-space: nowrap;
  min-height: 44px;
  padding: 8px 16px;
  border: var(--border-2) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}

.ds-notice__btn:hover { background: var(--surface-sunken); }
.ds-notice__btn:active { transform: translateY(1px); }
.ds-notice__btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* S3.1: "New version available" strip — same shape as the privacy notice,
   but in accent colour so it reads as actionable, not informational. */
.ds-notice--new { background: var(--accent); color: var(--on-accent); border-color: var(--ink); }
.ds-notice--new .ds-notice__btn { background: var(--paper); color: var(--ink); border-color: var(--ink); }

@media (max-width: 760px) {
  .ds-notice { margin: 0 16px 12px; padding: var(--space-2) var(--space-3); }
}

/* ---------- Callout (ds-callout, S2.8a3) ---------- */

.ds-callout {
  display: flex;
  background: var(--surface);
  color: var(--ink);
  border: var(--border-3) solid var(--ink);
  box-shadow: var(--shadow-sm);
}

.ds-callout__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  background: var(--warn);
  color: var(--on-warn);
  border-right: var(--border-3) solid var(--ink);
}

.ds-callout__icon .ic { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Alert tone (S2.8a4): bad-soft block with a triangle, per Callout spec. */
.ds-callout__icon--bad { background: var(--bad-soft); color: var(--bad); }

.ds-callout__body { flex: 1; display: grid; gap: 2px; padding: var(--space-3) var(--space-4); }

.ds-callout__title { font: 800 13px/16px var(--font-sans); letter-spacing: .8px; text-transform: uppercase; }

.ds-callout__text { margin: 0; font: 400 16px/24px var(--font-sans); }

.ds-callout__action {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: var(--space-3);
}

/* S3.6 — the daily nudge's close control: a square icon button (44x44 for
 * the touch target) that sits to the right of the primary action. */
.ds-callout__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: var(--border-3) solid var(--ink);
  cursor: pointer;
}
.ds-callout__close .ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 760px) {
  .ds-callout { flex-wrap: wrap; }
  .ds-callout__body { flex: 1 1 calc(100% - 56px - 24px); }
  .ds-callout__action {
    flex: 1 1 100%;
    flex-direction: row;
    justify-content: flex-end;
    padding: 0 var(--space-3) var(--space-3);
  }
}

/* Q5 — dashboard is one column; the flex gap is the only spacing between
   sections, so per-child bottom margins would double it. */
.dashboard-stack { display: flex; flex-direction: column; gap: 24px; }
.dashboard-stack > * { margin-bottom: 0; }

/* Q5 — secondary actions as a 2x3 tile grid instead of a button row. */
.action-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }

/* Q6 — exam result actions: one full-width button per line, so «DASHBOARD»
   and the long «РАЗБРАТЬ ОШИБКИ» never overflow at 375px. */
.exam-result-actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: 20px; }
.exam-result-actions .btn { width: 100%; }

/* Q6 — «what went wrong» row: statement + student's vs. right answer tags,
   with a «Why?» link that appears once the chapter explanation is found. */
.ex-wrong-row { flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ex-wrong-row:last-child { border-bottom: none; }
.ex-wrong-text { flex: 1 1 100%; font-weight: 600; }
.ex-wrong-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ex-wrong-why { flex: 0 0 auto; }
.ex-wrong-why__link {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
  display: inline-block;
}
.action-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap-min);
  padding: 10px 12px;
  background: var(--surface);
  border: var(--border-3) solid var(--ink);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font: 700 13px/16px var(--font-sans);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 80ms ease;
}
.action-tile:hover { background: var(--surface-sunken); transform: translate(-1px, -1px); }
.action-tile:active { transform: translate(3px, 3px); box-shadow: none; }
.action-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.action-tile__icon { flex: none; width: 20px; height: 20px; }
.action-tile__icon .ic { width: 20px; height: 20px; }
.action-tile__label { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
  /* Room for the fixed bar AND the home indicator below it. */
  main { padding: 20px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }

  .masthead {
    /* S2.7: brand left, Settings gear right (nav is a fixed bottom bar) */
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  /* S2.7: 44px touch target without growing the 64px masthead —
     negative margins keep the box at 40px while the hit area stays 44px */
  .settings-gear { display: block; margin: -12px 0; }

  .brand__name { font-size: 22px; line-height: 1; } /* wordmark --sm */


  /* Navigation becomes a fixed, thumb-reachable bottom bar */
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    border: none;
    border-top: var(--border);
    background: var(--surface);
    display: grid;
    /* S2.7: five tabs on phones -- Settings sits behind the masthead gear */
    grid-template-columns: repeat(5, 1fr);
    /* The bar must reach the physical bottom edge: without these insets
       iOS leaves a strip below it where the page shows through. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .nav .nav-settings { display: none; }

  .nav a {
    /* S2.7: 64px bar (design system --nav-h), >= 72px targets */
    min-height: var(--nav-h);
    justify-content: center;
    padding: 8px 2px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
  }
  .nav-badge { top: 6px; }

  /* S2.7: quiz/exam session owns the bottom of the screen */
  body.in-session .nav { display: none; }

  .footer { margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); text-align: center; }

  .panel { padding: 16px; }
  .card { padding: 16px; }

  h1 { font-size: 1.6rem; }

  /* Big thumb targets for answering */
  .ds-answers { gap: var(--space-3); }
  .ds-answer { min-height: 64px; font: 900 20px/40px var(--font-sans); }

  .quiz-head { gap: 8px; }
  .quiz-head .btn { padding: 8px 12px; }


  .kbd-hint { display: none; } /* no keyboard on phones */

  .onboard { margin: 8px auto; }

  .stat-value { font-size: 2rem; }
}

/* ---------- Theory: signs gallery & chapter nav ---------- */

.signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}

.signs-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 2px solid var(--ink);
  background: #fff;
  padding: 6px;
  box-sizing: border-box;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

/* ---------- Sign modal & clickable tiles ---------- */

.sign-tile {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.sign-tile:hover img { background: var(--warn); }
.sign-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--surface);
  overscroll-behavior: contain;
  border: var(--border);
  box-shadow: var(--shadow);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-sign {
  display: block;
  max-height: 180px;
  margin: 0 auto 16px;
  border: var(--border-thin);
  background: #fff;
  padding: 10px;
}

.fact {
  border-left: 6px solid var(--ok);
  background: var(--paper);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-weight: 600;
}

.fact-translation {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 2px dashed var(--ink);
  padding-top: 6px;
}

/* ---------- Dictionary ---------- */

.term-row { cursor: default; }
.term-row .term-it { flex: 1; }
.term-row .term-tr { color: var(--muted); font-weight: 700; text-align: right; }

.term-row.is-hidden { cursor: pointer; }

.term-veil {
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 10px;
}

.term-row.is-hidden:hover .term-veil { background: var(--accent); }

/* ---------- Statistics: exam trend chart ---------- */

.exam-trend {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  border-bottom: var(--border);
  padding-bottom: 0;
}

.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.trend-bar {
  width: 100%;
  min-height: 6px;
  border: 2px solid var(--ink);
  border-bottom: none;
}

.trend-bar.ok { background: var(--ok); }
.trend-bar.bad { background: var(--bad); }

.trend-label {
  font-size: 0.75rem;
  font-weight: 900;
}

@media (max-width: 760px) {
  .row { flex-wrap: wrap; row-gap: 6px; }
}

/* ---------- Theory lessons ---------- */

.lesson-objective {
  border-left: 10px solid var(--accent);
}

.key-idea {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: var(--border-thin);
}

.key-idea:last-child { border-bottom: none; padding-bottom: 0; }

.key-idea-num {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--border-thin);
  background: var(--warn);
  color: #000;
  font-weight: 900;
  font-size: 1rem;
}

.key-idea-title {
  display: block;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.key-idea-text { line-height: 1.55; font-weight: 500; }

.must-value {
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.traps-panel { border-left: 10px solid var(--bad); }

.trap {
  padding: 14px 0;
  border-bottom: var(--border-thin);
}

.trap:last-of-type { border-bottom: none; }

.trap-img {
  display: block;
  max-height: 90px;
  border: var(--border-thin);
  background: #fff;
  padding: 4px;
  margin-bottom: 10px;
}

.trap-text {
  font-size: 1.05rem;
  font-weight: 700;
  font-style: italic;
  margin-bottom: 10px;
}

.trap-answer { display: flex; gap: 12px; align-items: flex-start; }
.trap-why { flex: 1; line-height: 1.5; font-weight: 500; }

.exam-italian-banner {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border-left: 10px solid var(--ok);
  background: var(--ok-soft);
}

.exam-italian-banner:hover { background: var(--ok); color: #fff; }
.exam-italian-banner:hover .stat-sub { color: #e8f7f9; }

.section-explain { line-height: 1.55; font-weight: 500; margin-bottom: 16px; }

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.word-card {
  border: var(--border-thin);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--paper);
}

.word-it { font-size: 1rem; }
.word-gloss { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

/* L1b — bank data under an absolute word */
.word-stat {
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-ink, #8a6100);
}
details.word-true { margin-top: 6px; overscroll-behavior: contain; }
details.word-true summary {
  list-style: none;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
details.word-true summary::-webkit-details-marker { display: none; }
details.word-true[open] summary { color: var(--muted); }
.word-true-q {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  margin: 4px 0 8px;
}
.word-takeaway {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 600;
  margin: 8px 0 0;
}

.tag.accent-tag { background: var(--accent); color: var(--on-accent); }

/* L1c — signal-word drill: highlighted word + post-answer note */
mark.ds-signal {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0 2px;
  border-bottom: 3px solid var(--accent);
}
.signal-notes { margin-top: 12px; display: grid; gap: 4px; }
.signal-ratio {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-ink, #8a6100);
}
.signal-true {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 600;
}

/* ---------- L4: Numbers list (chapter → fact cards; a table cannot fit a phone) ---------- */

.numbers-chapter { margin-top: var(--space-6); }
.numbers-chapter__title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-ink, #8a6100);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--ink);
  margin-bottom: var(--space-2);
}
.numbers-fact { padding: var(--space-3) 0; border-bottom: 1px solid var(--line-soft, rgba(0,0,0,.15)); }
.numbers-fact:last-child { border-bottom: 0; }
.numbers-fact__head { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: baseline; }
.numbers-fact__name { font-weight: 700; }
.numbers-fact__value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--surface-sunken, transparent);
  padding: 0 var(--space-2);
}
.numbers-fact__sub {
  margin: 2px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.numbers-fact__note {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-muted);
}

/* ---------- Search ---------- */

.search-sign {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: var(--border-thin);
  background: #fff;
  padding: 2px;
  flex: none;
}

/* ---------- Answer feedback animation ---------- */

.ds-feedback { animation: feedback-pop 140ms ease-out; }

@keyframes feedback-pop {
  from { transform: scale(0.96); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-feedback { animation: none; }
}

/* U3: убирает ~300 мс задержку двойного тапа на iOS */
a, button, [role="button"], .ds-answer, input, select {
  touch-action: manipulation;
}

/* ---------- Accessibility ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--warn);
  color: #000;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 10px 16px;
  border: var(--border);
}

.skip-link:focus { left: 8px; top: 8px; }

main:focus { outline: none; }

/** S3.5 — transient "COPIED" toast after the share fallback (clipboard). */
.share-copied {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ok);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 100;
}

.offline-note {
  border: var(--border-thin);
  border-left: 10px solid var(--warn);
  background: var(--surface);
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ---------- "Why was I wrong" block ---------- */

.why-box { margin-top: 14px; }

.why-objective {
  font-weight: 600;
  line-height: 1.5;
  padding: 10px 12px;
  border-left: 6px solid var(--warn);
  background: var(--paper);
  margin-bottom: 10px;
}

.why-fact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: var(--border-thin);
}

.why-fact:last-of-type { border-bottom: none; margin-bottom: 10px; }

/* L9a: AI-drafted explanation, shown in the mistake breakdown from the
   2nd wrong answer onward. Visually distinct from the chapter facts above. */
.explanation { margin-top: var(--space-2); }
.explanation__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.explanation__link {
  font: 700 12px/16px var(--font-sans);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.explanation__key { font-size: 14px; line-height: 1.5; }
.explanation__why { font-size: 14px; line-height: 1.55; color: var(--ink); margin: 6px 0 0; }
.ds-feedback .explanation {
  padding: 10px 12px;
  border-left: 4px solid var(--warn);
  background: var(--paper);
}
.ds-feedback .explanation .why-fact { padding: 0; }

/* ---------- Design system (S2.11): Card, Tag, Button, Stat, WeekStrip, GoalRing ----------
   Source of truth: docs/design-system/components/bundle.css. The app ships
   its own copy of the rules so the public/ build stays dependency-free;
   keep the two in sync when a component changes. */

.ds-card {
  display: block;
  position: relative;
  background: var(--surface);
  color: var(--ink);
  border: var(--border-3) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  text-decoration: none;
  text-align: left;
  font: inherit;
}

.ds-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: var(--space-3);
}

.ds-card__eyebrow {
  font: 800 13px/16px var(--font-sans);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.ds-card__title { margin: 0 0 4px; font: 800 20px/24px var(--font-sans); }
.ds-card__sub { margin: 0 0 var(--space-3); font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }

.ds-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border: var(--border-2) solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font: 800 12px/16px var(--font-sans);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.ds-tag svg.ic { width: 14px; height: 14px; stroke-width: 3; }
.ds-tag--accent { background: var(--accent); color: var(--on-accent); }
.ds-tag--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 20px;
  border: var(--border-3) solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: 800 16px/20px var(--font-sans);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 80ms ease;
}

.ds-btn:hover { background: var(--surface-sunken); transform: translate(-1px, -1px); }
.ds-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.ds-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ds-btn--primary { background: var(--accent); color: var(--on-accent); }
.ds-btn--primary:hover { background: var(--accent); }
.ds-btn--lg { min-height: 56px; padding: 0 28px; font-size: 18px; line-height: 22px; font-weight: 900; }
.ds-btn--block { display: flex; width: 100%; }
.ds-btn[disabled], .ds-btn[aria-disabled="true"] {
  background: var(--surface-sunken);
  border-color: var(--ink-muted);
  color: var(--ink-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Stat: label, one big number, one sub line. Friendly zeros, no third line. */
.ds-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
/* The records screen shows 4 cards — 2×2 on desktop (S3.9b). */
.ds-stat-row--records { grid-template-columns: repeat(2, 1fr); }
.ds-stat {
  display: grid;
  gap: 4px;
  align-content: start;
  background: var(--surface);
  border: var(--border-3) solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.ds-stat__label {
  font: 800 13px/16px var(--font-sans);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.ds-stat__value {
  font: 900 44px/44px var(--font-sans);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.ds-stat__value--streak { color: var(--accent-ink); }
.ds-stat__value--ok { color: var(--ok); }
/* S3.7b: value + streak-shield badge on one baseline-aligned row. */
.ds-stat__valrow { display: flex; align-items: center; gap: 8px; }
.ds-stat__shield { display: grid; place-items: center; flex: none; color: var(--accent-ink); }
.ds-stat__shield svg.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ds-stat__sub { margin: 0; font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }

/* WeekStrip: 7 cells, 44px tall, accent fill = goal met, today outlined. */
.ds-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-2); }
.ds-week__day { display: grid; gap: 6px; justify-items: center; }
.ds-week__cell {
  display: grid;
  place-items: center;
  width: 100%;
  height: 44px;
  border: var(--border-2) solid var(--ink);
  background: var(--surface);
  color: var(--on-accent);
}

.ds-week__cell svg.ic { width: 20px; height: 20px; stroke-width: 3; }
.ds-week__cell--done { background: var(--accent); }
.ds-week__cell--today { border-width: 3px; box-shadow: var(--shadow-sm); }
.ds-week__label {
  font: 800 12px/16px var(--font-sans);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.ds-week__day--today .ds-week__label { color: var(--accent-ink); }

/* GoalRing: ink outline as the 3:1 boundary, sunken track, accent arc
   from twelve o'clock (the svg is rotated -90deg). */
.ds-ring { position: relative; display: inline-grid; place-items: center; width: 112px; height: 112px; }
.ds-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ds-ring__edge { fill: none; stroke: var(--ink); stroke-width: 16; }
.ds-ring__track { fill: none; stroke: var(--surface-sunken); stroke-width: 10; }
.ds-ring__value { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: butt; transition: stroke-dashoffset 400ms ease-out; }
.ds-ring__centre { position: relative; display: grid; justify-items: center; text-align: center; }
.ds-ring__num { font: 900 28px/28px var(--font-sans); font-variant-numeric: tabular-nums; }
.ds-ring__sub {
  font: 800 12px/16px var(--font-sans);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Dashboard: week strip and the daily-goal ring sit side by side. */
.week-panel { margin-bottom: 24px; }
.week-row { display: flex; align-items: center; gap: 20px; }
.week-row .ds-week { flex: 1; }

.today-goal {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Activity heat map: last 90 days, weeks as columns (Monday-first, as in
   Italy). The grid itself is decorative — the numbers live in the text
   line above and in the aria-label, the title attributes serve hover. */
.heat-months { display: flex; gap: 3px; margin-bottom: 4px; }
.heat-month {
  width: 12px;
  overflow: visible;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.heat-grid { display: flex; gap: 3px; }
.heat-col { display: flex; flex-direction: column; gap: 3px; }
.heat-cell { width: 12px; height: 12px; background: var(--heat-0); }
.heat-cell.l1 { background: var(--heat-1); }
.heat-cell.l2 { background: var(--heat-2); }
.heat-cell.l3 { background: var(--heat-3); }
.heat-cell.l4 { background: var(--heat-4); }
.heat-cell.empty { visibility: hidden; }
.heat-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* On a phone the 13 heat columns must fit: slightly smaller cells. */
@media (max-width: 420px) {
  .heat-month, .heat-cell { width: 10px; height: 10px; }
}



@media (max-width: 480px) {
  /* S2.4: подзаголовок wordmark скрыт на <= 480px */
  .brand__tag { display: none; }
}

/* S2.11: Stat cards stack to one column under 480px (Stat README), the
   week+ring panel tightens so the ring stays first-screen on a phone. */
@media (max-width: 480px) {
  .ds-stat-row { grid-template-columns: 1fr; }
  .ds-stat__value { font-size: 40px; line-height: 40px; }
  .week-row { gap: 14px; }
  .ds-ring { width: 96px; height: 96px; }
  .ds-ring__num { font-size: 24px; line-height: 24px; }
  .today-goal .ds-ring__sub { display: none; }
}

/* S2.14b: the newcomer next-steps panel must fit in the first 812px at 375px -
   compress its internal spacing on a phone (it is the last content card before
   the fixed bar, so it is the piece that overflows). */
@media (max-width: 480px) {
  #dashboard-next-steps { padding: 8px 12px; }
  #dashboard-next-steps .ds-card__top { margin-bottom: 4px; }
  #dashboard-next-steps .ds-card__title { margin-bottom: 2px; }
  #dashboard-next-steps .ds-card__sub { margin-bottom: 8px; }
  #dashboard-next-steps .ds-btn--lg { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-ring__value { transition: none; }
  .ds-btn, .ds-card { transition: none; }
}

/* The nav badge sets display; [hidden] must still win (bug: «0» showed on MISTAKES). */
.nav-badge[hidden] { display: none !important; }

/* Report a problem — quiet link under the after-answer actions. */
.report-link { display: inline-block; margin-top: 8px; font-size: 14px; line-height: 20px; color: var(--ink-muted); text-decoration: underline; text-underline-offset: 3px; }


/* L1c — тренажёр «Язык экзамена»: подсветка слова-сигнала + заметки в Feedback */
mark.ds-signal {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 800;
}
.signal-notes { margin-top: var(--space-2); }

/* L2 — подсветка сигнала в вопросе (практика/повторение): тappable mark + callout */
mark.ds-signal[role='button'] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
mark.ds-signal[role='button']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ds-signal-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 10px 0 2px;
  padding: var(--space-2) var(--space-3);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font: 400 14px/20px var(--font-sans);
  color: var(--accent-ink);
}
.ds-signal-callout__gloss { opacity: .9; }
.ds-signal-callout .tag { margin: 0; }

/* L8 — «Слово по тапу»: tap any dictionary word in text_it → translation
   callout. Teal palette so it stays distinct from the orange L2 signal mark. */
mark.ds-term {
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 700;
}
mark.ds-term[role='button'] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
mark.ds-term[role='button']:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}
.ds-term-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--ok-soft);
  border-left: 3px solid var(--ok);
  border-radius: 6px;
  font: 400 14px/20px var(--font-sans);
  color: var(--ok);
}
.ds-term-callout__gloss { opacity: .9; }
.signal-ratio {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-ink);
  margin: 0 0 4px;
}
.signal-true {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ok);
  margin: 0;
}

/* L5b — learning path screen (#/path) + dashboard link card.
   Reuses .ds-card/.ds-tag/.ds-btn; only the Read → Check → Practice
   pipeline strip and the step list need their own styles. */
.path-pipeline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 4px;
  margin: 10px 0;
}
.path-part-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1.5px solid var(--line-soft);
  background: var(--surface-sunken);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-muted);
}
.path-part-wrap .path-part__icon { width: 13px; height: 13px; }
.path-part__icon--done { color: var(--ok); }
.path-part-wrap:has(.path-part__icon--done) {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}
.path-part__label--active { color: var(--ink); }
.path-part-wrap:has(.path-part__label--active) {
  border-color: var(--ink);
  background: var(--surface);
}
.path-part__sep {
  width: 14px;
  height: 2px;
  background: var(--line-soft);
  display: inline-block;
}
.path-card { margin-bottom: 10px; }
.path-card .ds-btn { margin-top: 10px; width: 100%; }
.path-list { margin-top: 16px; }

/* #/numbers: learner-language row + Italian exam term underneath */
.numbers-chapter__it { display: block; margin-top: 2px; font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); letter-spacing: 0; }
.numbers-fact__it { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.numbers-fact__it span { font-weight: 700; color: var(--ink); }
