/* ==========================================================================
   VCA на български: course app.
   Same visual language as the landing page (navy, bright blue accent, regular-weight Arial headings, 15px radius),
   tuned for reading and one-handed use on a phone in a canteen or on the bus: light surfaces, high contrast,
   grouped lists instead of loose cards, colour plus an icon for every state. No web fonts, no decorative rules.
   Fonts stay as approved: Arial for headings and buttons, the system font for body text (28 Oct 2026).
   ========================================================================== */
:root {
  /* Brand, from the landing page */
  --navy: #001f3c;
  --navy-2: #0b2c50;
  --blue: #3b7cff;
  --blue-btn: #2f6beb;
  --blue-btn-hover: #2559c9;
  --blue-ink: #2350b8;
  --blue-soft: #ebf2ff;
  --blue-line: #cddcff;
  /* Neutrals, tinted toward the navy hue */
  --bg: #f2f4f8;
  --surface: #fdfdfe;
  --surface-2: #f5f7fa;
  --surface-3: #e9edf3;
  --line: #e0e5ec;
  --line-strong: #c6cfdb;
  --ink: #0b1626;
  --ink-2: #445163;
  --ink-3: #5c6879;
  --on-dark: #fdfdfe;
  --on-dark-2: rgba(253, 253, 254, 0.78);
  /* States */
  --ok: #157a40;
  --ok-ink: #0f5c30;
  --ok-soft: #e7f5ed;
  --ok-line: #b5dfc5;
  --bad: #c42f2f;
  --bad-ink: #9e2222;
  --bad-soft: #fdeeee;
  --bad-line: #f2c4c4;
  --amber: #8f5300;
  --amber-soft: #fff3d6;
  --flag: #e19a00;
  --focus: #3b7cff;
  /* Shape and depth */
  --radius: 0.9375rem;
  --radius-sm: 0.625rem;
  --radius-xs: 0.4375rem;
  --shadow-1: 0 1px 2px rgba(0, 31, 60, 0.05), 0 1px 1px rgba(0, 31, 60, 0.03);
  --shadow-2: 0 0.5rem 1.5rem rgba(0, 31, 60, 0.08), 0 1px 3px rgba(0, 31, 60, 0.05);
  /* Type and motion */
  --font-head: Arial, "Helvetica Neue", Helvetica, Roboto, "Liberation Sans", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --header-h: 3.5rem;
  --tabbar-h: 4rem;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.55; color: var(--ink);
  background: var(--bg); overflow-wrap: break-word; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { display: block; }
h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.2; text-wrap: balance; }
h1, h2 { font-family: var(--font-head); font-weight: 400; color: var(--navy); letter-spacing: -0.005em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3125rem; }
h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
p { margin: 0 0 1em; }
a { color: var(--blue-btn); text-underline-offset: 0.15em; }
a:hover { color: var(--blue-btn-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--blue-line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 0.5rem; top: -3rem; z-index: 100; padding: 0.5rem 0.875rem; background: var(--surface); border-radius: var(--radius-sm); }
.skip:focus { top: 0.5rem; }

.wrap {
  width: 100%; max-width: 44rem; margin: 0 auto;
  padding-left: max(1rem, env(safe-area-inset-left, 0px)); padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

/* ---------- Header and bottom tabs ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30; background: var(--navy); color: var(--on-dark);
  padding-top: env(safe-area-inset-top, 0px);
}
.app-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--on-dark); text-decoration: none; font-family: var(--font-head); font-size: 1.0625rem; }
.brand:hover { color: var(--on-dark); }
.brand svg { width: 2rem; height: 2rem; flex: none; }
.header-back {
  display: inline-flex; align-items: center; gap: 0.25rem; min-width: 0; min-height: 2.75rem; margin-left: -0.375rem; padding: 0 0.75rem 0 0.25rem;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--on-dark); font: inherit; font-size: 0.9375rem;
  cursor: pointer; text-decoration: none; transition: background-color 0.15s var(--ease);
}
.header-back:hover { background: rgba(253, 253, 254, 0.08); color: var(--on-dark); }
.header-back svg { width: 1.375rem; height: 1.375rem; flex: none; }
.header-timer {
  flex: none; padding: 0.25rem 0.625rem; border-radius: 999px; background: rgba(253, 253, 254, 0.1);
  font-family: var(--font-head); font-variant-numeric: tabular-nums; font-size: 1.0625rem; letter-spacing: 0.02em;
}
.header-timer.is-low { background: #ffd9d9; color: var(--bad-ink); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -0.25rem 1rem rgba(0, 31, 60, 0.05);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar ul { display: grid; grid-template-columns: repeat(5, 1fr); max-width: 44rem; margin: 0 auto; padding: 0 max(0.25rem, env(safe-area-inset-left, 0px)) 0 max(0.25rem, env(safe-area-inset-right, 0px)); list-style: none; }
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1875rem;
  min-height: var(--tabbar-h); color: var(--ink-3); font-size: 0.75rem; line-height: 1.1; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a svg {
  width: 1.5rem; height: 1.5rem; padding: 0.1875rem 0.875rem; border-radius: 999px; box-sizing: content-box;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.tabbar a:hover { color: var(--ink); }
.tabbar a[aria-current="page"] { color: var(--blue-ink); font-weight: 600; }
.tabbar a[aria-current="page"] svg { background: var(--blue-soft); color: var(--blue-btn); }
.tabbar a:focus-visible { outline-offset: -3px; border-radius: var(--radius-sm); }
.tab-badge {
  position: absolute; top: 0.3125rem; left: calc(50% + 0.5rem); min-width: 1.125rem; height: 1.125rem; padding: 0 0.3rem;
  border-radius: 999px; background: var(--bad); color: var(--on-dark); box-shadow: 0 0 0 2px var(--surface);
  font-size: 0.6875rem; font-weight: 700; line-height: 1.125rem; text-align: center;
}
body.no-tabs .tabbar { display: none; }
main { padding: 1.25rem 0 calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
body.no-tabs main { padding-bottom: 1.5rem; }
main:focus { outline: none; }

/* ---------- Text helpers (spacing helpers are at the end, so they win over component margins) ---------- */
.ic-sm { width: 1.125rem; height: 1.125rem; flex: none; }
.eyebrow { margin: 0 0 0.375rem; color: var(--blue-ink); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.lead { max-width: 38rem; font-size: 1.0625rem; line-height: 1.55; }
.stack { display: grid; gap: 0.75rem; }
.section-title {
  margin: 2rem 0 0.625rem; padding: 0 0.25rem; color: var(--ink-3);
  font-family: var(--font-body); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.draft-badge {
  display: inline-block; margin-left: 0.375rem; padding: 0.05rem 0.4rem; border-radius: 0.3rem;
  background: var(--amber-soft); color: var(--amber); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; vertical-align: middle;
}

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.125rem; box-shadow: var(--shadow-1); }
.card > :last-child { margin-bottom: 0; }
.card-navy { background: var(--navy); border-color: var(--navy); color: var(--on-dark); box-shadow: none; }
.card-navy h1, .card-navy h2 { color: var(--on-dark); }
.card-navy .muted { color: var(--on-dark-2); }

/* Grouped list: one surface, rows split by hairlines (topics, lessons, exams, glossary, profile) */
.list { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.list > li + li, .list > div + div { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 0.875rem; width: 100%; min-height: 4rem; padding: 0.75rem 1rem;
  color: var(--ink); text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s var(--ease);
}
a.row:hover, button.row:hover { color: var(--ink); }
.row:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.row > svg { width: 1.25rem; height: 1.25rem; flex: none; margin-left: auto; color: var(--ink-3); }
.row-body { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; line-height: 1.3; }
.row-meta { display: block; margin-top: 0.1875rem; color: var(--ink-3); font-size: 0.8125rem; line-height: 1.35; }
.row.is-locked .row-title { color: var(--ink-2); }
.row.is-locked .ico-box { background: var(--surface-3); color: var(--ink-3); }
.row-btn { border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.row-btn.is-danger .row-title { color: var(--bad-ink); }
.row-static .row-meta a { font-size: 0.875rem; }
@media (hover: hover) {
  a.row:hover, button.row:hover { background: var(--surface-2); }
}
a.row:active, button.row:active { background: var(--surface-3); }

.ico-box {
  display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem;
  background: var(--blue-soft); color: var(--blue-btn);
}
.ico-box svg { width: 1.375rem; height: 1.375rem; }
.ico-box.ico-bad { background: var(--bad-soft); color: var(--bad); }
.ico-box.ico-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0 1.25rem; border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-family: var(--font-head); font-size: 1rem; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.btn-primary { background: var(--blue-btn); color: var(--on-dark); }
.btn-primary:hover { background: var(--blue-btn-hover); color: var(--on-dark); }
.btn-primary:disabled { background: var(--surface-3); color: #6f7988; cursor: not-allowed; }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-3); background: var(--surface-2); color: var(--ink); }
.btn-outline:disabled { color: #8a93a0; border-color: var(--line); background: var(--surface); cursor: not-allowed; }
.btn-light { background: var(--surface); color: var(--navy); }
.btn-light:hover { background: #e6eeff; color: var(--navy); }
.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad-ink); }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.625rem; }
.btn-row > .btn { flex: 1 1 10rem; }
.link-btn { padding: 0; border: 0; background: none; color: var(--blue-btn); font: inherit; text-decoration: underline; cursor: pointer; }

.bar { height: 0.375rem; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--blue); }
.card-navy .bar { background: rgba(253, 253, 254, 0.16); }

/* ---------- Home ---------- */
.hero-panel { padding: 1.25rem 1.25rem 1.125rem; }
.hero-panel h2 { margin-bottom: 1rem; font-size: 1.25rem; }
.progress-grid { display: grid; gap: 0.875rem; }
.progress-row { display: grid; gap: 0.4375rem; }
.progress-row p { margin: 0; font-size: 0.9375rem; }
.hero-panel .bar { height: 0.5rem; }
.hero-note { margin: 1rem 0 0; color: var(--on-dark-2); font-size: 0.875rem; }
.continue { margin-top: 1.125rem; }
.btn.continue { justify-content: space-between; min-height: 3.25rem; padding: 0.75rem 1rem 0.75rem 1.125rem; text-align: left; }
p.continue { color: var(--on-dark); }

.nudge { margin-top: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.nudge-head { display: flex; align-items: center; gap: 0.875rem; margin-bottom: 0.875rem; }
.nudge-head p { margin: 0; font-weight: 600; line-height: 1.35; }
.empty-state { display: flex; align-items: center; gap: 0.875rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }

/* Topic ring: the number inside a ring that fills with the lessons read */
.ring { position: relative; display: block; flex: none; width: 2.75rem; height: 2.75rem; }
.ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--blue); }
.ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--navy); font-family: var(--font-head); font-size: 1rem; font-variant-numeric: tabular-nums;
}
.ring.is-done .ring-fill { stroke: var(--ok); }
.ring.is-done .ring-label { inset: 0.4375rem; border-radius: 50%; background: var(--ok); color: var(--on-dark); }
.ring.is-done .ring-label svg { width: 1.125rem; height: 1.125rem; }

/* ---------- Topic and lesson ---------- */
.chapter-progress { max-width: 24rem; margin: 0.25rem 0 0; }
.chapter-progress p { margin: 0 0 0.5rem; color: var(--ink-3); font-size: 0.875rem; }
.lesson-link { min-height: 3.75rem; }
.step {
  display: grid; place-items: center; flex: none; width: 1.875rem; height: 1.875rem; border: 1.5px solid var(--line-strong); border-radius: 50%;
  color: var(--ink-2); font-family: var(--font-head); font-size: 0.875rem; font-variant-numeric: tabular-nums;
}
.step svg { width: 1rem; height: 1rem; }
.is-read .step { background: var(--ok); border-color: var(--ok); color: var(--on-dark); }
.lesson-link .row-title { font-weight: 500; }
.lesson-link small { flex: none; color: var(--ink-3); font-size: 0.8125rem; white-space: nowrap; }
.practice-card { margin-top: 1.5rem; padding: 1.125rem 1.125rem 1.25rem; background: var(--blue-soft); border: 1px solid var(--blue-line); border-radius: var(--radius); }
.practice-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.625rem; }
.practice-head h2 { margin: 0; font-size: 1.25rem; }
.practice-card .ico-box { background: var(--surface); }
.practice-card .muted { color: var(--ink-2); }
.practice-card .btn { margin-top: 0.375rem; }
.next-topic .row-title { color: var(--blue-ink); font-weight: 600; }

.lesson { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.125rem; box-shadow: var(--shadow-1); }
.lesson h1 { margin-bottom: 1rem; }
.lesson-body { max-width: 38rem; }
.lesson-body p { font-size: 1.0625rem; line-height: 1.7; }
.lesson-body ul, .lesson-body ol { margin: 0 0 1.25em; padding-left: 1.375rem; display: grid; gap: 0.5rem; line-height: 1.6; }
.lesson-body ol li::marker { color: var(--blue-btn); font-family: var(--font-head); font-weight: 700; }
.lesson-body ul li::marker { color: var(--blue); }
.lesson-body li { padding-left: 0.125rem; }
.keybox { margin: 1.5rem 0; padding: 0.875rem 1rem 1rem; border-radius: var(--radius-sm); background: var(--blue-soft); border: 1px solid var(--blue-line); }
.keybox h3 { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; color: var(--blue-ink); font-size: 0.9375rem; }
.keybox h3 svg { width: 1.25rem; height: 1.25rem; flex: none; }
.keybox p { margin: 0; line-height: 1.6; }
.terms { margin: 1.5rem 0; padding: 0.875rem 1rem 0.375rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.terms h3 { margin-bottom: 0.25rem; color: var(--ink-2); font-size: 0.8125rem; letter-spacing: 0.05em; text-transform: uppercase; }
.terms dl { margin: 0; display: grid; }
.terms div { padding: 0.625rem 0; }
.terms div + div { border-top: 1px solid var(--line); }
.terms dt { font-weight: 600; }
.terms dd { margin: 0.125rem 0 0; color: var(--ink-2); font-size: 0.9375rem; }
.terms .foreign { color: var(--ink); font-style: italic; }
.country { margin: 1.5rem 0; display: grid; gap: 0.625rem; }
.country div { padding: 0.75rem 0.875rem 0.875rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); line-height: 1.55; }
.country b { display: block; margin-bottom: 0.25rem; color: var(--blue-ink); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.verify { margin-top: 1rem; padding: 0.625rem 0.875rem; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--amber); font-size: 0.875rem; }
.lesson-nav { display: grid; gap: 0.625rem; margin-top: 1.75rem; }
.prose h2 { margin-bottom: 0.75rem; }

/* ---------- Questions (practice and exam) ---------- */
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.625rem; color: var(--ink-3); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.q-head .chip {
  min-width: 0; padding: 0.25rem 0.75rem; border-radius: 999px; background: var(--blue-soft); color: var(--blue-ink);
  font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.q-head > span:last-child { flex: none; }
.q-bar { margin-bottom: 1.25rem; }
.q-text { margin: 0 0 1.125rem; color: var(--navy); font-family: var(--font-head); font-size: 1.375rem; line-height: 1.32; text-wrap: pretty; }
.options { display: grid; gap: 0.625rem; margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }
.opt {
  position: relative; display: grid; grid-template-columns: 2.25rem 1fr auto; align-items: center; gap: 0.75rem;
  min-height: 3.5rem; padding: 0.6875rem 0.875rem 0.6875rem 0.75rem;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-1);
  line-height: 1.38; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), box-shadow 0.15s var(--ease), opacity 0.2s var(--ease);
}
.opt input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.opt-letter {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 1.5px solid var(--line-strong); border-radius: 50%;
  color: var(--ink-2); font-family: var(--font-head); font-size: 0.9375rem;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
@media (hover: hover) {
  .opt:not(.is-locked):hover { border-color: var(--blue); }
}
.opt:not(.is-locked):active { background: var(--surface-2); }
.opt.is-selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.opt.is-selected .opt-letter { background: var(--blue-btn); border-color: var(--blue-btn); color: var(--on-dark); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt.is-right { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.opt.is-right .opt-letter { background: var(--ok); border-color: var(--ok); color: var(--on-dark); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.opt.is-wrong .opt-letter { background: var(--bad); border-color: var(--bad); color: var(--on-dark); }
.opt.is-locked { cursor: default; }
.opt.is-locked:not(.is-right):not(.is-wrong) { opacity: 0.62; box-shadow: none; }
.opt-mark svg { width: 1.5rem; height: 1.5rem; }
.is-right .opt-mark { color: var(--ok); }
.is-wrong .opt-mark { color: var(--bad); }
.feedback {
  display: grid; grid-template-columns: 2rem 1fr; gap: 0.75rem; align-items: start;
  margin: 0 0 1rem; padding: 1rem; border: 1px solid transparent; border-radius: var(--radius);
}
.feedback.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.fb-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; color: var(--on-dark); }
.fb-icon svg { width: 1.125rem; height: 1.125rem; }
.feedback.ok .fb-icon { background: var(--ok); }
.feedback.bad .fb-icon { background: var(--bad); }
.feedback h3 { margin: 0.25rem 0 0.375rem; }
.feedback.ok h3 { color: var(--ok-ink); }
.feedback.bad h3 { color: var(--bad-ink); }
.feedback p { margin: 0; line-height: 1.55; }
.feedback p + p { margin-top: 0.5rem; }
.q-nav {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); z-index: 5;
  display: flex; gap: 0.625rem; margin: 1.25rem -1rem 0; padding: 0.75rem 1rem;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -0.375rem 1rem rgba(0, 31, 60, 0.06);
}
/* Practice and exams have no tabs: the actions sit fixed at the bottom edge, in thumb reach, on every question */
body.no-tabs .q-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
  padding: 0.75rem max(1rem, env(safe-area-inset-right, 0px), calc(50% - 21rem)) calc(0.75rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px), calc(50% - 21rem));
}
.q-screen { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
.q-screen [aria-live] { scroll-margin-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); }
.q-nav .btn { flex: 0 0 auto; }
.q-nav .btn-primary { flex: 1; }

/* ---------- Results ---------- */
.score { margin: 0.25rem 0 0.5rem; font-family: var(--font-head); font-size: 3rem; line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.result-pass { background: var(--ok); border-color: var(--ok); color: var(--on-dark); box-shadow: none; }
.result-fail { background: var(--navy); border-color: var(--navy); color: var(--on-dark); box-shadow: none; }
.result-pass h1, .result-fail h1 { margin-bottom: 0.25rem; color: var(--on-dark); }
.result-pass .muted, .result-fail .muted { color: rgba(253, 253, 254, 0.85); }
.result-pass, .result-fail { padding: 1.375rem 1.25rem 1.25rem; }
.meter { position: relative; margin: 0.875rem 0 0.75rem; }
.meter .bar { height: 0.5rem; background: rgba(253, 253, 254, 0.22); }
.meter .bar span { background: var(--on-dark); }
.meter-mark { position: absolute; top: -0.3rem; width: 3px; height: 1.1rem; margin-left: -1px; border-radius: 2px; background: #ffd34d; }
.topic-scores { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.875rem; }
.topic-scores li { display: grid; grid-template-columns: 1fr auto; gap: 0.375rem 0.75rem; align-items: center; }
.topic-scores a { font-size: 0.9375rem; line-height: 1.35; }
.topic-scores .bar { grid-column: 1 / -1; height: 0.3125rem; }
.topic-scores .bar span.low { background: var(--bad); }
.topic-scores b { font-variant-numeric: tabular-nums; font-weight: 600; }
.review-item { display: grid; gap: 0.5rem; }
.review-item .q-text { margin: 0; color: var(--ink); font-family: var(--font-body); font-size: 1.0625rem; font-weight: 600; line-height: 1.4; text-wrap: wrap; }
.ans { margin: 0; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.9375rem; }
.ans.bad { background: var(--bad-soft); }
.ans.ok { background: var(--ok-soft); }
.ans b { font-weight: 700; }
.ans.bad b { color: var(--bad-ink); }
.ans.ok b { color: var(--ok-ink); }
.filters { display: flex; gap: 0.25rem; margin-bottom: 0.875rem; padding: 0.25rem; border-radius: 999px; background: var(--surface-3); }
.filters button {
  flex: 1; min-height: 2.5rem; padding: 0 0.875rem; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-2); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.filters button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* ---------- Exams ---------- */
.exam-no {
  display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem;
  background: var(--surface-3); color: var(--navy); font-family: var(--font-head); font-size: 1.0625rem; font-variant-numeric: tabular-nums;
}
.exam-item.is-locked .exam-no { background: var(--surface-2); color: var(--ink-3); }
.exam-item.is-running .exam-no { background: var(--amber-soft); color: var(--amber); }
.exam-item.is-running .row-meta { color: var(--amber); font-weight: 600; }
.pill { flex: none; margin-left: auto; padding: 0.25rem 0.625rem; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 0.75rem; font-weight: 700; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.rules { margin: 0.25rem 0 1.25rem; padding: 0; list-style: none; display: grid; gap: 0.75rem; }
.rules li { display: flex; gap: 0.625rem; align-items: flex-start; line-height: 1.5; }
.rules svg { width: 1.25rem; height: 1.25rem; flex: none; margin-top: 0.125rem; color: var(--ok); }
.grid-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: 0.375rem; margin: 0.75rem 0 1rem; padding: 0; list-style: none; }
.grid-nav button {
  position: relative; width: 100%; min-height: 2.75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.9375rem; font-variant-numeric: tabular-nums; cursor: pointer;
}
.grid-nav button.answered { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-ink); }
.grid-nav button.current { box-shadow: inset 0 0 0 2px var(--navy); }
.grid-nav button.flagged::after { content: ""; position: absolute; top: 0.3rem; right: 0.3rem; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--flag); }
.exam-tools { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0.25rem 0 0; }
.exam-tools .btn { min-height: 2.75rem; padding: 0 0.875rem; font-size: 0.9375rem; }
.btn-flag[aria-pressed="true"] { border-color: var(--flag); background: var(--amber-soft); color: var(--amber); }

/* ---------- Dialog (in-page, never window.confirm) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; align-items: end; background: rgba(0, 16, 36, 0.5); animation: fade-in 0.18s var(--ease); }
.sheet {
  max-height: 85vh; overflow-y: auto; padding: 1.5rem 0 calc(1.25rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-radius: 1.25rem 1.25rem 0 0; box-shadow: 0 -0.5rem 2rem rgba(0, 16, 36, 0.22);
  animation: sheet-in 0.24s var(--ease);
}
.sheet h2 { font-size: 1.3125rem; }
.sheet h2:focus { outline: none; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(1.5rem); opacity: 0.4; } }
@media (min-width: 40rem) { .sheet-backdrop { align-items: center; } .sheet { max-width: 30rem; margin: 0 auto; border-radius: var(--radius); } }

/* ---------- Glossary ---------- */
.search-bar {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); z-index: 10;
  margin: 0 -1rem; padding: 0.625rem 1rem 0.5rem; background: var(--bg);
}
.search-field { position: relative; display: block; }
.search-field svg { position: absolute; left: 0.875rem; top: 50%; width: 1.25rem; height: 1.25rem; margin-top: -0.625rem; color: var(--ink-3); pointer-events: none; }
.search {
  width: 100%; min-height: 3rem; padding: 0 1rem 0 2.75rem; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; box-shadow: var(--shadow-1);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-line); }
.gloss-count { margin: 0.375rem 0.25rem 0; }
.gloss-letter { margin: 1.25rem 0.25rem 0.5rem; color: var(--blue-ink); font-size: 1.25rem; }
.gloss > .gloss-letter:first-child { margin-top: 0.75rem; }
.gloss-list > div { padding: 0.75rem 1rem 0.8125rem; }
.gloss dt { font-weight: 700; line-height: 1.35; }
.gloss .foreign { display: block; margin-top: 0.125rem; color: var(--ink-2); font-style: italic; font-weight: 400; font-size: 0.9375rem; }
.gloss dd { margin: 0.3125rem 0 0; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.5; }

/* ---------- Guide, summaries ---------- */
.summary { break-inside: avoid; }
.summary h2 { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 0.875rem; font-size: 1.1875rem; }
.summary .num {
  display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue-btn); font-size: 0.9375rem; font-variant-numeric: tabular-nums;
}
.summary ul { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.5rem; line-height: 1.55; }
.summary li::marker { color: var(--blue); }

/* ---------- Profile ---------- */
.package { padding: 1.125rem 1.125rem 1rem; }
.package-head { display: flex; align-items: center; gap: 0.875rem; margin-bottom: 0.875rem; }
.package-name { margin: 0 0 0.125rem; font-size: 1.0625rem; font-weight: 700; }
.move { margin-top: 1rem; padding: 0; overflow: hidden; }
.move summary {
  display: flex; align-items: center; gap: 0.875rem; min-height: 4rem; padding: 0.75rem 1rem;
  list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color 0.15s var(--ease);
}
.move summary::-webkit-details-marker { display: none; }
.move summary:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.move summary > svg { width: 1.25rem; height: 1.25rem; flex: none; margin-left: auto; color: var(--ink-3); transition: transform 0.2s var(--ease); }
.move[open] summary > svg { transform: rotate(180deg); }
@media (hover: hover) { .move summary:hover { background: var(--surface-2); } }
.move-body { padding: 1rem; border-top: 1px solid var(--line); }
.code-box {
  display: block; width: 100%; min-height: 5.5rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); font: 0.8125rem/1.45 var(--font-mono); word-break: break-all; resize: vertical;
}
#import-code { background: var(--surface); border-color: var(--line-strong); }
.code-box:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-line); }
.field { display: grid; gap: 0.375rem; margin-top: 0.75rem; }
.field label { font-weight: 600; font-size: 0.9375rem; }
.field input {
  min-height: 3rem; padding: 0 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-line); }
.msg { margin: 0.5rem 0 0; font-size: 0.9375rem; }
.msg:empty { display: none; }
.msg.ok { color: var(--ok-ink); }
.msg.bad { color: var(--bad-ink); }

/* ---------- Sign-in, empty and loading screens ---------- */
.signin { max-width: 32rem; padding-top: 0.75rem; }
.signin-mark { display: block; }
.signin-mark svg { width: 3.25rem; height: 3.25rem; margin-bottom: 1.25rem; }
.signin .lead { color: var(--ink-2); }
.center-screen { min-height: 60vh; display: grid; place-content: center; text-align: center; gap: 0.75rem; }
.spinner { width: 2rem; height: 2rem; margin: 0 auto; border: 3px solid var(--surface-3); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .sheet, .sheet-backdrop { animation: none; }
  * { transition: none !important; }
}

/* ---------- Phones: lessons read edge to edge ---------- */
@media (max-width: 47.99rem) {
  .lesson { margin: -1.25rem -1rem 0; padding: 1.5rem 1rem 1.75rem; border-width: 0 0 1px; border-radius: 0; box-shadow: none; }
}

/* ---------- Wider screens ---------- */
@media (min-width: 40rem) {
  .country { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 48rem) {
  main { padding-top: 2rem; }
  h1 { font-size: 2.125rem; }
  .progress-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .lesson { padding: 2rem 2.25rem 2.25rem; }
  .q-text { font-size: 1.5rem; }
  .lesson-nav { grid-template-columns: 1fr 1fr; }
  .search-bar { margin: 0; padding-left: 0; padding-right: 0; }
}

/* ---------- Spacing helpers ---------- */
.mb-0 { margin-bottom: 0; }
.mt-s { margin-top: 0.75rem; }
.mt-m { margin-top: 1.25rem; }

/* ---------- Print (glossary and summaries as PDF) ---------- */
@media print {
  .app-header, .tabbar, .no-print, .skip { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; }
  .card, .list, .gloss-list > div { border: 0; box-shadow: none; padding: 0.25rem 0; break-inside: avoid; }
  .list > div + div { border-top: 0; }
  .gloss-letter { margin-top: 0.75rem; }
  a { color: inherit; text-decoration: none; }
}
