:root {
  --fg: #1a2330;
  --muted: #5b6675;
  --accent: #15607a;
  --accent-dark: #0e455a;
  --ok: #1c7c3f;
  --ok-bg: #e6f4ea;
  --bad: #b3261e;
  --bad-bg: #fbeae9;
  --line: #d8dee6;
  --card: #fff;
  --bg: #f4f6f8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}
#app { max-width: 720px; margin: 0 auto; padding: 24px 18px 48px; }

/* Language switcher — top bar, current language highlighted. */
#langbar {
  max-width: 720px; margin: 0 auto; padding: 12px 18px 0;
  display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap;
}
/* Country / option switcher (Switzerland ↔ France). */
.countrybar {
  max-width: 720px; margin: 0 auto; padding: 12px 18px 0;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  font-size: .82rem; color: var(--muted);
}
.countrybar a { color: var(--accent-dark); text-decoration: none; }
.countrybar a:hover { text-decoration: underline; }
.countrybar .on { font-weight: 600; color: var(--ink, #222); }
.langbtn {
  padding: 5px 11px; font-size: .82rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.langbtn:hover { border-color: var(--accent); color: var(--accent-dark); }
.langbtn.on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.screen { animation: fade .2s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

h1 { font-size: 1.6rem; margin: .2em 0 .1em; }
h2 { font-size: 1.4rem; }
.sub { color: var(--muted); margin-top: 0; }
.fine { color: var(--muted); font-size: .85rem; }

.banner {
  background: #fff7e6; border: 1px solid #f0d089; border-radius: 8px;
  padding: 12px 14px; margin: 16px 0; font-size: .92rem;
}
/* Softer notice for fallback / unofficial-translation banners. */
.banner.soft {
  background: #eef5f8; border-color: #bcd6e0; color: var(--accent-dark);
  font-size: .88rem;
}
.config {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin: 16px 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: .92rem;
}
.config b { color: var(--accent-dark); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
button {
  font: inherit; padding: 11px 18px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: .5; cursor: default; }

.quizbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; color: var(--muted); font-size: .9rem;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent-dark); }
.timer.low { color: var(--bad); }

/* Figure box — identical size/background for every image, so resolution or
   crop differences can never leak the answer. */
.figure {
  width: 100%; height: 220px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; overflow: hidden;
}
.figure img { max-width: 90%; max-height: 90%; object-fit: contain; }

.stem { font-size: 1.12rem; font-weight: 600; margin: 6px 0 14px; }
.hint { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }

.choice {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 9px;
  background: var(--card); cursor: pointer; transition: border-color .12s;
}
.choice:hover { border-color: var(--accent); }
.choice input { width: 18px; height: 18px; flex: 0 0 auto; }
/* Digit badge = the keyboard shortcut for the choice (press 1/2/3…). */
.keyhint {
  flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 5px; background: var(--bg);
  color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums;
}
.choice.correct .keyhint { border-color: var(--ok); color: var(--ok); }
.choice.wrong .keyhint { border-color: var(--bad); color: var(--bad); }
.choice.correct { background: var(--ok-bg); border-color: var(--ok); }
.choice.wrong { background: var(--bad-bg); border-color: var(--bad); }
.choice.locked { cursor: default; }

.explain {
  margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--accent);
  background: #eef5f8; border-radius: 0 8px 8px 0; font-size: .94rem;
}
.explain .src { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.explain a { color: var(--accent-dark); }

#score { font-size: 1.05rem; }
.badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  font-weight: 700; margin: 8px 0;
}
.badge.pass { background: var(--ok-bg); color: var(--ok); }
.badge.fail { background: var(--bad-bg); color: var(--bad); }
.scoreline { margin: 4px 0; }
.scoreline b { font-variant-numeric: tabular-nums; }

.review-item {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  margin-bottom: 10px; background: var(--card); font-size: .92rem;
}
.review-item .q { font-weight: 600; }
.review-item .mark { float: right; font-weight: 700; }
.review-item .mark.ok { color: var(--ok); }
.review-item .mark.no { color: var(--bad); }
.review-item ul { margin: 8px 0 0; padding-left: 18px; }
.review-item li.c { color: var(--ok); }
.review-item li.x { color: var(--bad); text-decoration: line-through; }

.sitefoot {
  max-width: 720px; margin: 0 auto; padding: 16px 18px 40px;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line);
}

/* Domain (theme) picker on the start screen — chips that toggle which themes a
   practice/exam run draws from. */
.domains-block { margin: 14px 0 4px; }
.domains-label { font-size: .9rem; color: var(--muted); }
.domains { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--muted); font-size: .9rem; cursor: pointer; transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip .chipn {
  font-size: .78rem; font-variant-numeric: tabular-nums; opacity: .8;
  padding: 0 6px; border-radius: 999px; background: rgba(0,0,0,.08);
}
.chip.on .chipn { background: rgba(255,255,255,.22); }
.chip.allbtn { border-style: dashed; }

/* Anki download row under the start actions. */
.anki-dl {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.anki-dl .anki-label { font-weight: 600; color: var(--accent-dark); width: 100%; }
.dlbtn {
  display: inline-block; padding: 7px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: .9rem;
  border: 1px solid var(--accent);
}
.dlbtn:hover { background: var(--accent-dark); }
.dlbtn.ghost { background: var(--card); color: var(--accent-dark); }
.dlbtn.ghost:hover { background: #eef5f8; }
.anki-dl .fine { width: 100%; margin: 2px 0 0; }

/* Per-domain score breakdown on the results screen. */
.breakdown { margin: 6px 0 18px; }
.dom-h { font-size: 1rem; margin: 0 0 8px; }
.dom-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: .9rem; }
.dom-name { flex: 0 0 40%; }
.dom-bar { flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.dom-bar i { display: block; height: 100%; background: var(--ok); }
.dom-score { flex: 0 0 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* --- Practice learning aids (recall-first, diagnostics, spacing, confidence) -
 * Practice-only UI; exam mode never shows these. */

/* Toggle pills for the practice options (on the start screen). */
.study-settings .toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; font-size: .85rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  cursor: pointer;
}
.study-settings .toggle:hover { border-color: var(--accent); color: var(--accent-dark); }
.study-settings .toggle .tsw {
  width: 26px; height: 15px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .15s;
}
.study-settings .toggle .tsw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: left .15s;
}
.study-settings .toggle.on {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.study-settings .toggle.on .tsw { background: rgba(255, 255, 255, .55); }
.study-settings .toggle.on .tsw::after { left: 13px; }

/* Recall-first: keep the options unreadable until the learner commits. */
#choices.veiled { filter: blur(7px); opacity: .5; pointer-events: none; user-select: none; }
.recall-gate {
  margin: 12px 0; padding: 12px 14px; border-left: 4px solid var(--accent);
  background: #eef5f8; border-radius: 0 8px 8px 0;
}
.recall-gate p { margin: 0 0 8px; font-size: .92rem; }
.recall-gate textarea {
  width: 100%; resize: vertical; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px;
}
.recall-gate.done { opacity: .7; }
.recall-gate.done p { color: var(--muted); }

/* Confidence picker. */
.confidence { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; }
.confidence .conf-q { color: var(--muted); font-size: .88rem; }
.conf {
  padding: 5px 14px; font-size: .85rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
}
.conf:hover { border-color: var(--accent); }
.conf.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.conf:disabled { cursor: default; opacity: .8; }

/* Diagnostic distractor feedback. */
.diag {
  margin-top: 14px; padding: 10px 14px; border-radius: 8px;
  background: var(--bad-bg); border: 1px solid #e9c4c1; font-size: .92rem;
}
.diag b { color: var(--bad); }
.diag div + div { margin-top: 3px; }
.choice-why {
  margin: 6px 0 2px; padding: 6px 10px; border-radius: 6px;
  font-size: .85rem; line-height: 1.4;
}
.choice-why.ok { background: var(--ok-bg); color: var(--ok); }
.choice-why.no { background: var(--bad-bg); color: var(--bad); }
.review-item .choice-why { margin-left: 0; }

/* Hypercorrection flag in the results review. */
.hc-flag {
  margin: 8px 0; padding: 6px 10px; border-radius: 6px;
  background: #fff3cd; border: 1px solid #f0d089; color: #7a5b00; font-size: .85rem; font-weight: 600;
}

/* Path-to-permit panel: the non-theory steps (medical / practical / application /
   fees / validity) rendered from MANIFEST.path under a collapsible <details>. */
.permit-path {
  margin-top: 16px; padding: 4px 14px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.permit-path > summary {
  cursor: pointer; padding: 8px 2px; font-weight: 600; color: var(--accent-dark);
}
.permit-path[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.path-step { padding: 8px 0; border-top: 1px solid var(--line); }
.path-step:first-child { border-top: none; }
.path-step-h b { color: var(--fg); }
.path-step-b { margin: 3px 0; line-height: 1.45; }
.path-step-src a { color: var(--accent-dark); }
.path-vol { cursor: help; color: #7a5b00; }
