/* Layout : barre du haut collante, sommaire latéral collant, colonne de lecture de ~70 caractères ; écrans Telegram en maquette */
:root {
  --bg: #0f0c0d; --surface: #181314; --surface-2: #211a1b; --line: #2f2627;
  --fg: #f4eeee; --muted: #a8999b; --accent: #ec2a33; --accent-soft: rgba(236,42,51,.14);
  --live: #2fd36a; --test: #4c84ff; --warn: #f5b13d;
  --tg-bg: #17212b; --tg-msg: #182533; --tg-btn: #2b5278; --tg-fg: #f5f5f5;
  --display: "Jost", "Futura", "Avenir Next", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --bg: #faf7f7; --surface: #ffffff; --surface-2: #f3eded; --line: #e6dcdc;
  --fg: #1b1315; --muted: #6c5f61; --accent: #cf1720; --accent-soft: rgba(207,23,32,.09);
  --live: #128a43; --test: #2357d6; --warn: #a96a00;
  --tg-bg: #e9eef3; --tg-msg: #ffffff; --tg-btn: #d6e4f2; --tg-fg: #1b1f24;
  color-scheme: light; } }
:root[data-theme="light"] {
  --bg: #faf7f7; --surface: #ffffff; --surface-2: #f3eded; --line: #e6dcdc;
  --fg: #1b1315; --muted: #6c5f61; --accent: #cf1720; --accent-soft: rgba(207,23,32,.09);
  --live: #128a43; --test: #2357d6; --warn: #a96a00;
  --tg-bg: #e9eef3; --tg-msg: #ffffff; --tg-btn: #d6e4f2; --tg-fg: #1b1f24;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { background: var(--bg); color: var(--fg); font: 400 15.5px/1.65 var(--body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }

/* Barre du haut */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); min-width: 0; }
.brand img { width: 44px; height: auto; }
.brand b { font: italic 800 17px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.brand span { font: 500 13px/1 var(--display); color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.search { margin-left: auto; position: relative; flex: 0 1 280px; min-width: 0; }
.search input { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 8px 12px; font: 14px var(--body); }
.search input::placeholder { color: var(--muted); }

/* Grille */
.wrap { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 32px 80px; }
nav.side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 6px; }
.side h4 { font: 700 11px/1 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.side h4:first-child { margin-top: 0; }
.side a { display: block; color: var(--fg); text-decoration: none; font-size: 14px; padding: 5px 10px; border-left: 2px solid var(--line); }
.side a:hover { border-left-color: var(--muted); }
.side a.on { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.side a[hidden] { display: none; }
.side .none { font-size: 13px; color: var(--muted); padding: 5px 10px; }
.mobile-toc { display: none; }
main { min-width: 0; max-width: 780px; }

/* Typo */
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.15; }
h1 { font-weight: 800; font-style: italic; text-transform: uppercase; font-size: clamp(34px, 6vw, 56px); letter-spacing: -.01em; margin: 0 0 14px; }
h1 em { color: var(--accent); font-style: italic; }
h2 { font-size: 30px; font-weight: 700; margin: 0 0 6px; }
h3 { font-size: 19px; font-weight: 700; margin: 30px 0 8px; }
.eyebrow { font: 700 11px/1 var(--display); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.lead { font-size: 17.5px; color: var(--muted); max-width: 62ch; margin: 0 0 8px; }
p, li { max-width: 68ch; }
section { padding-top: 56px; margin-top: 56px; border-top: 1px solid var(--line); }
section.hero { border-top: 0; margin-top: 0; padding-top: 8px; }
ul, ol { padding-left: 22px; }
.muted-note { font-size: 13.5px; color: var(--muted); }
section.hero p:not(.lead) { font-size: 16.5px; }
li { margin: 4px 0; }

/* Démarrage en étapes */
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; max-width: none; display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 14px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0; }
.steps li::before { content: counter(s); font: italic 800 22px/40px var(--display); color: #fff; background: var(--accent); width: 40px; height: 40px; text-align: center; border-radius: 8px; transform: skewX(-8deg); }
.steps b { display: block; font-family: var(--display); font-size: 16.5px; }
.steps span { color: var(--muted); font-size: 14.5px; }

/* Cartes de section sur l'accueil */
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 18px; }
.map a { display: grid; gap: 4px; text-decoration: none; color: var(--fg); padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.map a:hover { border-color: var(--accent); }
.map b { font-family: var(--display); font-size: 16px; }
.map span { color: var(--muted); font-size: 13.5px; line-height: 1.45; }

/* Encadrés */
.note { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 16px; margin: 18px 0; font-size: 14.5px; }
.note p { margin: 4px 0; }
.note > strong:first-child { display: block; font: 700 11px/1.4 var(--display); letter-spacing: .14em; text-transform: uppercase; margin-bottom: 4px; }
.note.tip > strong:first-child { color: var(--live); }
.note.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.note.warn > strong:first-child { color: var(--warn); }
.note.key { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.note.key > strong:first-child { color: var(--accent); }

/* Tableaux */
.tbl { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.2px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 700 11px/1.3 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; font-weight: 600; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Pastilles de mode */
.pill { display: inline-block; font: 600 12px/1 var(--body); padding: 4px 8px; border-radius: 999px; white-space: nowrap; vertical-align: 1px; }
.pill.live { color: var(--live); background: color-mix(in srgb, var(--live) 14%, transparent); }
.pill.test { color: var(--test); background: color-mix(in srgb, var(--test) 14%, transparent); }

/* Écran Telegram */
.tg { background: var(--tg-bg); color: var(--tg-fg); border-radius: 14px; padding: 14px; margin: 20px 0; max-width: 460px; border: 1px solid var(--line); }
.tg .cap { font: 600 11px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 2px; }
.tg .msg { background: var(--tg-msg); border-radius: 12px 12px 12px 4px; padding: 10px 12px; font-size: 13.6px; line-height: 1.5; white-space: pre-line; }
.tg .msg i { opacity: .7; }
.tg .kb { display: grid; gap: 4px; margin-top: 4px; }
.tg .row { display: flex; gap: 4px; }
.tg .row span { flex: 1 1 0; min-width: 0; text-align: center; background: var(--tg-btn); border-radius: 8px; padding: 8px 4px; font-size: 12.6px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

figure { margin: 20px 0; }
figure img { width: 100%; height: auto; border-radius: 10px; display: block; border: 1px solid var(--line); }
figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }

.cmd { display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; font: 13px/1.6 var(--mono); }
dl.lex { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 8px 18px; margin: 16px 0; }
dl.lex dt { font-weight: 600; font-family: var(--display); font-size: 15.5px; }
dl.lex dd { margin: 0; color: var(--muted); }
details.faq { border-bottom: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 600; font-family: var(--display); font-size: 16.5px; }
details.faq p { margin: 8px 0 0; color: var(--muted); }
footer { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

@media (max-width: 880px) {
  .wrap { grid-template-columns: minmax(0,1fr); gap: 0; padding-block: 20px 60px; }
  nav.side { display: none; }
  .mobile-toc { display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; margin-bottom: 20px; }
  .mobile-toc summary { cursor: pointer; font: 700 13px/1.4 var(--display); letter-spacing: .12em; text-transform: uppercase; }
  .mobile-toc nav { columns: 2; column-gap: 16px; margin-top: 10px; }
  .mobile-toc a { display: block; font-size: 14px; padding: 4px 0; text-decoration: none; color: var(--fg); break-inside: avoid; }
  .brand span { display: none; }
  .search { flex-basis: 170px; }
  dl.lex { grid-template-columns: minmax(0,1fr); gap: 2px; }
  dl.lex dd { margin-bottom: 10px; }
  td:first-child { white-space: normal; }
}
@media (max-width: 520px) { .brand b { display: none; } .search { flex: 1 1 auto; } }
@media (max-width: 420px) { .mobile-toc nav { columns: 1; } }

/* Sélecteur de langue */
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.lang a { font: 700 12px/1 var(--display); letter-spacing: .1em; padding: 9px 10px; color: var(--muted); text-decoration: none; }
.lang a[aria-current="page"] { background: var(--accent); color: #fff; }
.lang a:not([aria-current]):hover { color: var(--fg); }
