/* WikiCartes Lab — feuille de style principale, sans dépendance externe.
   Direction : une encyclopédie de poche. Papier et encre, titres en serif,
   un seul accent (vermillon, comme un tampon de bibliothèque), filets fins
   plutôt qu'ombres et dégradés. */
:root {
  --bg: #f2eee5;
  --surface: #fbf9f4;
  --surface-2: #ece6da;
  --text: #1c1a16;
  --muted: #6b6457;
  --border: #dcd3c2;
  --rule: #c8bda8;
  --accent: #b23a1e;
  --accent-strong: #8f2c15;
  --accent-soft: #f3e2d9;
  --on-accent: #fff8f0;
  --ink: #1c1a16;
  --on-ink: #f6f2e9;
  --ok: #2d6a3e;
  --ok-soft: #e2ecdf;
  --ko: #a52a1f;
  --ko-soft: #f6e0db;
  --warn: #85580a;
  --warn-soft: #f3e6c6;
  --gold: #9a6b12;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgb(28 26 22 / .05);
  --shadow-lg: 0 1px 0 rgb(28 26 22 / .04), 0 24px 48px -16px rgb(28 26 22 / .28);
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Libertinus Serif", "Linux Libertine", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --nav-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --surface: #1c1915; --surface-2: #26221c; --text: #ece5d6; --muted: #a39a89; --border: #332d25; --rule: #4a4236;
    --accent: #e27b55; --accent-strong: #f09572; --accent-soft: #3a231a; --on-accent: #1a0e08; --ink: #ece5d6; --on-ink: #17140f;
    --ok: #8cc79a; --ok-soft: #1b2d20; --ko: #f08a78; --ko-soft: #3a1d18; --warn: #e3b85c; --warn-soft: #33290f; --gold: #d8a94a;
    --shadow: none; --shadow-lg: 0 24px 48px -16px rgb(0 0 0 / .65);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120f; --surface: #1c1915; --surface-2: #26221c; --text: #ece5d6; --muted: #a39a89; --border: #332d25; --rule: #4a4236;
  --accent: #e27b55; --accent-strong: #f09572; --accent-soft: #3a231a; --on-accent: #1a0e08; --ink: #ece5d6; --on-ink: #17140f;
  --ok: #8cc79a; --ok-soft: #1b2d20; --ko: #f08a78; --ko-soft: #3a1d18; --warn: #e3b85c; --warn-soft: #33290f; --gold: #d8a94a;
  --shadow: none; --shadow-lg: 0 24px 48px -16px rgb(0 0 0 / .65);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 106.25%; } /* 17 px : Source Sans 3 est plus petite que les polices système */
body {
  margin: 0; background: var(--bg) var(--grain); color: var(--text); font: 1rem/1.5 var(--font);
  min-height: 100vh; min-height: 100dvh; font-feature-settings: "kern", "liga";
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
main:focus, main:focus-visible { outline: none; } /* focus donné au changement de page, pour les lecteurs d'écran */
::selection { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 4.6vw, 2.6rem); letter-spacing: -0.01em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 1.32rem; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Icônes en ligne : <span class="i"><svg></span> */
.i { display: inline-flex; width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.i svg { width: 100%; height: 100%; }
.i.filled svg, .filled > svg { fill: currentColor; }
svg.ico { display: block; }

/* Petite étiquette de rubrique, en capitales espacées. */
.kicker {
  display: flex; align-items: center; gap: 10px; margin: 0 0 6px;
  font: 650 .7rem/1.2 var(--font); letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
}
.kicker::after { content: ""; flex: 1; height: 1px; background: var(--rule); max-width: 120px; }

/* --- Structure ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand > span:not(.logo):not(.lab) { font-family: var(--serif); font-weight: 700; font-size: 1.22rem; letter-spacing: -0.01em; }
.brand .logo { width: 32px; height: 32px; flex: none; }
.brand .logo svg { width: 100%; height: 100%; display: block; border-radius: 6px; box-shadow: 0 0 0 1px var(--rule); }
.brand .lab {
  font: 700 .62rem/1 var(--mono); letter-spacing: .12em; color: var(--accent); border: 1px solid currentColor;
  border-radius: 2px; padding: 3px 4px 2px; transform: rotate(-3deg);
}
.topnav { display: none; gap: 2px; margin-left: 20px; }
.topnav a { padding: 8px 12px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .94rem; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.chips { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 4px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); font-size: .85rem; font-weight: 650; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip svg { width: 16px; height: 16px; }
.chip .i { width: 16px; height: 16px; }
.chip.flame { color: var(--ko); }
.chip.level { color: var(--accent); }
a.chip:hover, button.chip:hover { border-color: var(--rule); background: var(--surface-2); }

main { max-width: 780px; margin: 0 auto; padding: 22px 16px calc(var(--nav-h) + 32px); }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--rule);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .02em; position: relative;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a[aria-current="page"] { color: var(--text); }
.bottomnav a[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 30%; right: 30%; height: 2px; background: var(--accent); }
.badge-dot {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font: 700 .66rem/17px var(--font); text-align: center;
}
/* La barre du haut n'a la place pour tous les liens qu'à partir de 1100 px. */
@media (min-width: 1100px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  main { padding-bottom: 48px; }
}
body.focus .bottomnav, body.focus .topbar { display: none; }
body.focus main { padding-top: 12px; padding-bottom: 32px; }

/* --- Panneaux & boutons --------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card > h2:first-child, .card > .row:first-child > h2 { margin-bottom: .55em; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface); font-weight: 600; cursor: pointer;
  text-decoration: none; color: var(--text); transition: background .15s ease, border-color .15s ease, transform .08s ease;
  font-size: .95rem; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn .i { width: 17px; height: 17px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.accent:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .86rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

/* --- En-têtes de page ------------------------------------------------------------- */
.hero { padding: 4px 0 16px; border-bottom: 1px solid var(--rule); }
.hero h1 { margin-bottom: .25em; }
.hero p { color: var(--muted); max-width: 56ch; margin-bottom: .4em; }
.hero.row { align-items: flex-end; }
.daily {
  display: flex; gap: 16px; align-items: center; text-decoration: none; color: var(--on-ink); background: var(--ink); border: none;
}
.daily .big { width: 44px; height: 44px; flex: none; }
.daily h2 { margin: 0 0 4px; color: inherit; }
.daily p { margin: 0; opacity: .85; font-size: .92rem; }
.daily .go { margin-left: auto; border: 1px solid currentColor; border-radius: var(--radius-sm); padding: 7px 12px; font-weight: 650; white-space: nowrap; }
.search { position: relative; margin: 12px 0 10px; }
.search input {
  width: 100%; min-height: 46px; padding-block: 11px; padding-inline: 42px 14px; border-radius: var(--radius-sm); border: 1px solid var(--rule);
  background: var(--surface); font-size: 1rem;
}
.search > span:first-child { position: absolute; inset-inline-start: 14px; top: 13px; width: 19px; height: 19px; color: var(--muted); display: flex; pointer-events: none; }
.search > span:first-child svg { width: 19px; height: 19px; }
.results {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.results button {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; text-align: start; border: 0;
  background: none; cursor: pointer; border-bottom: 1px solid var(--border);
}
.results button:last-child { border-bottom: 0; }
.results button:hover, .results button.active { background: var(--surface-2); }
.results img, .results .ph { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex: none; background: var(--surface-2); }
.results strong { display: block; }
.results span { font-size: .85rem; color: var(--muted); }
.decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.deck {
  display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius-sm); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); min-height: 108px; transition: border-color .15s;
}
.deck:hover { border-color: var(--text); }
.deck .ico { width: 26px; height: 26px; margin-bottom: 4px; color: var(--accent); }
.deck strong { font-size: 1rem; }
.deck span { font-size: .82rem; color: var(--muted); }
.deck.trending { background: var(--accent-soft); border-color: transparent; }
.proto-note { text-align: center; color: var(--muted); font-size: .84rem; margin-top: 28px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }

/* --- Article ---------------------------------------------------------------------- */
.article-hero { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); margin-bottom: 16px; max-height: 340px; }
.article-hero img { width: 100%; max-height: 340px; object-fit: cover; }
.article h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.article .desc { color: var(--muted); margin-top: -4px; }
.article .body { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; }
.article .body p { margin-bottom: 1em; }
.license { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 18px; }
.cta-bar {
  position: sticky; bottom: calc(var(--nav-h) + 12px); margin-top: 20px; z-index: 5;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 10px;
}
@media (min-width: 820px) { .cta-bar { bottom: 16px; } }
.cta-bar .status { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Questions ---------------------------------------------------------------------- */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--text); transition: width .35s ease; }
.counter { font: 650 .86rem var(--mono); color: var(--muted); min-width: 3.5em; text-align: end; }
.qcard { padding: 22px; }
.qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font: 650 .68rem/1.2 var(--font); padding: 3px 7px;
  border-radius: 3px; border: 1px solid var(--rule); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; background: transparent;
}
.tag .i { width: 12px; height: 12px; }
.tag.community { border-color: var(--warn); color: var(--warn); }
.qcontext { font: 650 .72rem/1.3 var(--font); color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.qprompt { font-family: var(--serif); font-size: clamp(1.3rem, 3.6vw, 1.6rem); font-weight: 600; margin: 6px 0 16px; line-height: 1.25; }
.qimage { border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); margin-bottom: 16px; display: grid; place-items: center; min-height: 120px; }
.qimage img { max-height: 280px; width: auto; max-width: 100%; object-fit: contain; }
.qimage.flag img { max-height: 170px; box-shadow: 0 0 0 1px var(--border); }
.quote {
  font-family: var(--serif); font-size: 1.08rem; line-height: 1.6; border-inline-start: 2px solid var(--accent);
  padding: 4px 16px; margin: 0 0 16px;
}
.options { display: grid; gap: 8px; }
.options.tf { grid-template-columns: 1fr 1fr; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 11px 14px; text-align: start;
  border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface); cursor: pointer; font-size: 1rem; font-weight: 500;
  transition: border-color .12s, background .12s;
}
.option:hover:not([disabled]) { border-color: var(--text); background: var(--surface-2); }
.option .key {
  flex: none; width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center; font: 700 .78rem var(--mono);
  border: 1px solid var(--rule); color: var(--muted);
}
.option .mark { margin-inline-start: auto; width: 20px; height: 20px; flex: none; }
.option[disabled] { cursor: default; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.correct .mark { color: var(--ok); }
.option.wrong { border-color: var(--ko); background: var(--ko-soft); }
.option.wrong .key { background: var(--ko); border-color: var(--ko); color: #fff; }
.option.wrong .mark { color: var(--ko); }
.option.dim { opacity: .5; }
.timer { height: 3px; background: var(--surface-2); margin: -6px 0 14px; overflow: hidden; }
.timer > div { height: 100%; background: var(--gold); width: 100%; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); border-inline-start: 3px solid; animation: rise .2s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.feedback.ok { background: var(--ok-soft); border-color: var(--ok); }
.feedback.ko { background: var(--ko-soft); border-color: var(--ko); }
.feedback h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 1rem; }
.feedback.ok h3 { color: var(--ok); }
.feedback.ko h3 { color: var(--ko); }
.feedback h3 svg { width: 20px; height: 20px; }
.evidence { font-family: var(--serif); font-size: 1rem; margin: 8px 0; font-style: italic; }
.evidence mark { background: color-mix(in srgb, var(--gold) 28%, transparent); color: inherit; padding: 0 2px; font-style: normal; }
.links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; align-items: center; }
.links a, .links button { display: inline-flex; align-items: center; gap: 4px; }
.links svg { width: 14px; height: 14px; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.next-row { display: flex; justify-content: flex-end; margin-top: 16px; }

/* --- Résultats ------------------------------------------------------------------- */
.result-head { text-align: center; padding: 28px 18px; }
.result-mark {
  width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--rule); color: var(--text); background: var(--surface-2);
}
.result-mark svg { width: 30px; height: 30px; }
.result-mark.win { color: var(--gold); border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.result-mark.lose { color: var(--ko); border-color: var(--ko); background: var(--ko-soft); }
.ring { width: 150px; height: 150px; margin: 0 auto 12px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
.ring .val small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.pills { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 650; font-size: .88rem; }
.pill .i { width: 15px; height: 15px; }
.pill.xp { background: color-mix(in srgb, var(--gold) 14%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--gold); }
.pill.badge { background: var(--warn-soft); color: var(--warn); }
.detail { list-style: none; padding: 0; margin: 0; }
.detail li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail li:last-child { border-bottom: 0; }
.detail .ic { flex: none; width: 22px; height: 22px; }
.detail .ic.ok { color: var(--ok); }
.detail .ic.ko { color: var(--ko); }
.detail p { margin: 0 0 2px; font-weight: 600; }
.detail .ans { font-size: .9rem; color: var(--muted); }

/* --- Profil, réglages ---------------------------------------------------------- */
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 140px; margin: 16px 0 6px; }
.boxes .bar { background: var(--text); border-radius: 2px; min-height: 4px; position: relative; opacity: .8; }
.boxes .bar.m { background: var(--ok); }
.boxes .bar span { position: absolute; top: -22px; left: 0; right: 0; text-align: center; font-size: .8rem; font-weight: 700; }
.box-labels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; font-size: .72rem; color: var(--muted); text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.stat { padding: 14px 10px; text-align: center; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.stat:nth-child(4n) { border-inline-end: 0; }
.stat:nth-last-child(-n+4) { border-bottom: 0; }
.stat b { display: block; font: 600 1.45rem/1.2 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.stat span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(4n) { border-inline-end: 1px solid var(--border); }
  .stat:nth-child(2n) { border-inline-end: 0; }
  .stat:nth-last-child(-n+4) { border-bottom: 1px solid var(--border); }
  .stat:nth-last-child(-n+2) { border-bottom: 0; }
}
.levelbar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.levelbar > div { height: 100%; background: var(--accent); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badgecell { text-align: center; padding: 12px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: .78rem; font-weight: 600; }
.badgecell .e { width: 28px; height: 28px; display: block; margin: 0 auto 6px; color: var(--accent); }
.badgecell.off { opacity: .35; filter: grayscale(1); }
.hbar { display: grid; grid-template-columns: 9em 1fr 3em; gap: 10px; align-items: center; font-size: .88rem; margin: 6px 0; }
.hbar .track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbar .track div { height: 100%; background: var(--text); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 650; font-size: .9rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field textarea { min-height: 84px; resize: vertical; font-family: var(--serif); }
.field .hint { font-size: .82rem; color: var(--muted); }
.field.ok input { border-color: var(--ok); }
select { border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface); padding: 6px 10px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { width: 42px; height: 24px; appearance: none; background: var(--rule); border-radius: 12px; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked { background: var(--text); }
.switch input:checked::after { transform: translateX(18px); }
.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* --- Création --------------------------------------------------------------------- */
.qa-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.qa-list li { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; padding: 8px 10px; border-radius: 4px; }
.qa-list li.error { background: var(--ko-soft); color: var(--ko); }
.qa-list li.warn { background: var(--warn-soft); color: var(--warn); }
.qa-list li.ok { background: var(--ok-soft); color: var(--ok); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter > div { height: 100%; transition: width .2s, background .2s; }
.suggestions { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; margin-top: 6px; }
.suggestions button {
  text-align: start; border: 1px dashed var(--rule); background: var(--surface-2); border-radius: 4px; padding: 8px 10px;
  font-family: var(--serif); font-size: .92rem; cursor: pointer;
}
.suggestions button:hover { border-color: var(--text); }
.mine { list-style: none; padding: 0; margin: 0; }
.mine li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.mine li > div { flex: 1; }
.picked { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.picked img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }

/* --- À propos ---------------------------------------------------------------------- */
.compare { width: 100%; border-collapse: collapse; font-size: .9rem; }
.compare th, .compare td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare th { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border-bottom-color: var(--rule); }
.compare td:first-child { font-weight: 650; width: 22%; font-family: var(--serif); font-size: .98rem; }
.compare td.new { color: var(--text); }
.compare td.old { color: var(--muted); }
@media (max-width: 600px) {
  .compare thead { display: none; }
  .compare tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .compare td { border: 0; padding: 4px 6px; }
  .compare td:first-child { grid-column: 1 / -1; width: auto; }
  .compare td.old::before { content: "WikiMasters"; display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; }
  .compare td.new::before { content: "Lab"; display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
}
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prose p, .prose li { max-width: 68ch; }
.prose ul { padding-inline-start: 1.2em; }
.prose li { margin-bottom: .4em; }

/* --- Divers ----------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
  box-shadow: var(--shadow-lg); animation: rise .2s ease; max-width: calc(100vw - 32px);
}
.banner { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 8px 16px; font-size: .9rem; font-weight: 600; border-bottom: 1px solid var(--rule); }
.banner button { margin-inline-start: 8px; }
dialog {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(20 18 15 / .5); }
.reasons { display: grid; gap: 8px; margin: 12px 0; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .e {
  width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--rule); color: var(--text); background: var(--surface-2);
}
.empty .e svg { width: 24px; height: 24px; }
.empty p { max-width: 42ch; margin-inline: auto; }
.error-box { background: var(--ko-soft); color: var(--ko); padding: 12px 14px; border-radius: var(--radius-sm); border-inline-start: 3px solid var(--ko); }

/* Médailles de classement : un chiffre dans un disque, pas d'emoji. */
.medal {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  font: 700 .74rem/1 var(--mono); color: #fff; background: var(--muted);
}
.medal.m1 { background: #b0832a; box-shadow: inset 0 0 0 2px #e2bd63; }
.medal.m2 { background: #7d8187; box-shadow: inset 0 0 0 2px #b9bdc2; }
.medal.m3 { background: #93582f; box-shadow: inset 0 0 0 2px #c98d5f; }

/* Montant en WikiCoins : icône de pièce + nombre. */
.coin-amt { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.coin-amt .i, .coins .i { color: var(--gold); width: 1.05em; height: 1.05em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Défi du jour sur téléphone : le bouton passe sous le texte. */
@media (max-width: 520px) {
  .daily { flex-wrap: wrap; gap: 12px 14px; }
  .daily > div { flex: 1; min-width: 0; }
  .daily .go { margin-left: 0; width: 100%; text-align: center; }
}

/* Téléphone : l'en-tête garde le logo et les compteurs, sans le nom ni le pseudo. */
@media (max-width: 520px) {
  .brand > span:not(.logo) { display: none; }
  .user-chip .uname { display: none; }
  .chips { gap: 4px; }
  .chip { padding: 5px 7px; }
}
