/* Polices servies par le site (SIL Open Font License 1.1, voir fonts/OFL-*.txt), sous-ensemble latin. */
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url(/fonts/barlow-condensed-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(/fonts/barlow-condensed-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(/fonts/barlow-condensed-700.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(/fonts/atkinson-400.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url(/fonts/atkinson-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(/fonts/atkinson-700.woff2) format("woff2"); }
/* Mise en page : une colonne, comme une planchette de vol. Un seul élément sombre, le tableau de bord ;
   le reste en feuilles de lignes sur la brume. */
:root {
  --sky: #e9f1f4;        /* brume sur la vallée */
  --panel: #ffffff;
  --ink: #14232e;        /* ardoise */
  --muted: #5a6e7a;
  --line: #cfdde3;
  --vert: #1f8a4c;       /* vert du brevet initial */
  --vert-soft: #d9f0e2;
  --manche: #e4572e;     /* manche à air : série et seuil des 75 % */
  --manche-soft: #fbe2d9;
  --good: #1f8a4c;
  --bad: #c0392b;
  --bad-soft: #f8dcd8;
  --cockpit: #14232e; --cockpit-ink: #eef4f6; --cockpit-muted: #9fb4bf; --gauge-fill: #cfe3ea; --gauge-pass: #4cc283;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #0e171d; --panel: #16232c; --ink: #e6eef2; --muted: #93a8b4;
    --line: #263945; --vert: #4cc283; --vert-soft: #173a29; --manche: #f27a52; --manche-soft: #3d2219;
    --good: #4cc283; --bad: #ef7a6c; --bad-soft: #3e1f1b; color-scheme: dark;
    --cockpit: #1d2f3b; --cockpit-ink: #eef4f6; --cockpit-muted: #9fb4bf;
  }
}
:root[data-theme="dark"] {
  --sky: #0e171d; --panel: #16232c; --ink: #e6eef2; --muted: #93a8b4;
  --line: #263945; --vert: #4cc283; --vert-soft: #173a29; --manche: #f27a52; --manche-soft: #3d2219;
  --good: #4cc283; --bad: #ef7a6c; --bad-soft: #3e1f1b; color-scheme: dark;
  --cockpit: #1d2f3b; --cockpit-ink: #eef4f6; --cockpit-muted: #9fb4bf;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--sky); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(12px, env(safe-area-inset-top, 0px)) 40px;
}
main { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
#view { gap: 24px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; font-weight: 600; }
.page-title { font-size: 1.9rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, label:focus-within, summary:focus-visible { outline: 3px solid var(--manche); outline-offset: 2px; }

/* Barre du haut : marque, niveau, pilote (ouvre les réglages). Cachée pendant le quiz. */
.topbar { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.6rem; margin-right: auto; }
.brand svg { width: 28px; height: 28px; color: var(--vert); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--panel); }
.seg button { border: 0; background: none; border-radius: 999px; padding: 4px 12px; font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.me { border: 0; background: none; padding: 0; border-radius: 50%; display: grid; }
body[data-view="quiz"] .topbar, body[data-view="quiz"] footer { display: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; color: #fff; font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1; }
.lvl { display: inline-block; font-family: var(--display); font-weight: 600; font-size: .8rem; padding: 0 6px; border-radius: 4px; color: #fff; vertical-align: 2px; }
.lvl.V { background: #1f8a4c; } .lvl.B { background: #2563a8; }

/* Tableau de bord : le pronostic sur une jauge graduée, avec le plancher des 75 %, et le vol du jour. */
.cockpit { background: var(--cockpit); color: var(--cockpit-ink); border-radius: 14px; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.readout { display: flex; align-items: flex-end; gap: 14px; }
.readout .big { font-family: var(--display); font-weight: 700; font-size: 4.4rem; line-height: .8; letter-spacing: -.01em; }
.readout .big small { font-size: 1.7rem; margin-left: 2px; color: var(--cockpit-muted); }
.cockpit .label { font-family: var(--display); font-weight: 600; font-size: 1.25rem; line-height: 1.15; }
.cockpit .hint { font-size: .875rem; color: var(--cockpit-muted); }
.gauge { position: relative; height: 20px; border-radius: 4px; margin-bottom: 16px;
  background: repeating-linear-gradient(to right, transparent 0 calc(10% - 1px), rgb(255 255 255 / .25) calc(10% - 1px) 10%), rgb(255 255 255 / .08); }
.gauge .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px 0 0 4px; background: var(--gauge-fill); }
.gauge .fill.pass { background: var(--gauge-pass); }
.gauge .floor { position: absolute; left: 75%; top: -5px; bottom: -5px; border-left: 2px dashed var(--manche); }
.gauge .floor span { position: absolute; top: 100%; left: 0; transform: translateX(-50%); margin-top: 1px; font-family: var(--display); font-weight: 600; font-size: .85rem; color: var(--manche); white-space: nowrap; }
.takeoff { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; background: var(--vert); color: #fff; border: 0; border-radius: 10px; padding: 14px 16px; }
.takeoff .t { font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1; }
.takeoff .s { font-size: .9rem; }
:root[data-theme="dark"] .takeoff { color: #08150e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .takeoff { color: #08150e; } }

/* Équipage : série, semaine nommée, pilotes. Un anneau orange autour de ceux qui ont volé aujourd'hui. */
.crewbox { display: flex; flex-direction: column; gap: 10px; }
.crew-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.streak { color: var(--muted); font-size: .95rem; }
.streak b { font-family: var(--display); font-size: 1.7rem; line-height: 1; color: var(--manche); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .day { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.week i { display: block; width: 100%; height: 10px; border-radius: 3px; background: var(--line); }
.week i.both { background: var(--manche); }
.week i.half { background: linear-gradient(to right, var(--manche) 50%, var(--line) 50%); }
.week small { font-size: .75rem; color: var(--muted); }
.pilots { list-style: none; margin: 0; padding: 0; }
.pilots li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.pilots li:last-child { border-bottom: 1px solid var(--line); }
.pilots li.flew .avatar { box-shadow: 0 0 0 2px var(--sky), 0 0 0 4px var(--manche); }
.pilots .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; overflow-wrap: anywhere; }
.grade { font-family: var(--display); font-weight: 600; font-size: 1rem; color: var(--vert); }

/* Feuilles de lignes : entraînement, matières, duels, choix du duel */
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 13px 16px; }
.line:first-child { border-top: 0; }
.line:hover:not(:disabled) { background: color-mix(in srgb, var(--sky) 60%, var(--panel)); }
.line:disabled { cursor: default; opacity: .5; }
.line .t { font-weight: 700; }
.line .aside { font-size: .875rem; color: var(--muted); }
.line .d { grid-column: 1 / -1; font-size: .875rem; color: var(--muted); }
.line.subject .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.line.subject .bar i { display: block; height: 100%; background: var(--vert); }
.duel { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.duel:first-child { border-top: 0; }
.duel .vs { font-weight: 700; }
.back { align-self: flex-start; background: none; border: 0; padding: 6px 0; font-weight: 700; color: var(--muted); }
.back::before { content: "‹ "; }
.btn { background: var(--vert); color: #fff; border: 0; border-radius: 8px; padding: 12px 18px; font-weight: 700; }
:root[data-theme="dark"] .btn { color: #08150e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #08150e; } }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { width: 100%; padding: 15px; font-size: 1.05rem; }

/* Quiz : barre compacte, méta discrète, action fixée en bas, sous le pouce */
.quizbar { display: flex; align-items: center; gap: 12px; }
.qmeta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-family: var(--display); font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.actionbar { position: sticky; bottom: 0; margin-top: -12px; padding: 16px 0 max(12px, env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--sky) 40%); }
.progress { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--manche); transition: width .3s; }
.code { font-family: var(--display); font-weight: 600; color: var(--muted); font-size: .95rem; }
.question { font-size: 1.15rem; font-weight: 700; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.answer { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start; padding: 12px; border: 2px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.answer input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--vert); }
.answer.checked { border-color: var(--ink); }
.answer .pts { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.answer.ok { border-color: var(--good); background: var(--vert-soft); }
.answer.ko { border-color: var(--bad); background: var(--bad-soft); }
.answer.miss { border-style: dashed; border-color: var(--good); }
.verdict { font-family: var(--display); font-size: 1.4rem; font-weight: 700; }
.verdict.ok { color: var(--good); } .verdict.ko { color: var(--bad); }
.result-big { font-family: var(--display); font-size: 4rem; font-weight: 700; line-height: 1; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--vert-soft); color: var(--vert); }
.pill.warn { background: var(--manche-soft); color: var(--manche); }
.review { display: flex; flex-direction: column; gap: 10px; }
.review li { margin-left: 1.1em; }
footer { font-size: .8rem; color: var(--muted); text-align: center; }
a { color: var(--vert); }
footer a { color: inherit; }
@media (prefers-reduced-motion: reduce) { .progress i { transition: none; } }

/* Version installée et avis de mise à jour */
.version { margin: 6px 0 0; }
.toast { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom, 0px)); max-width: 528px; margin: 0 auto; display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--ink); color: var(--panel); border-radius: var(--r); padding: 12px 16px; box-shadow: 0 6px 24px rgb(0 0 0 / .25); }

/* Champs de saisie (compte, équipage) */
.field { flex: 1; min-width: 0; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }

/* Favori : étoile dans l'en-tête de la question */
.fav { background: none; border: 0; font-size: 1.4rem; line-height: 1; padding: 2px 4px; color: var(--muted); }
.fav[aria-pressed="true"] { color: var(--manche); }
textarea.field { display: block; width: 100%; margin-top: 6px; resize: vertical; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; align-self: flex-start; }

/* Explication après la correction */
.why { display: flex; flex-direction: column; gap: 4px; background: var(--sky); border-left: 3px solid var(--vert); border-radius: 0 8px 8px 0; padding: 10px 12px; }
