:root {
  --ink: #1c2321; --ink-soft: #4a4f49; --paper: #f5f3ee; --surface: #eae6dc;
  --surface-2: #ded9cb; --accent: #b8481f; --accent-soft: #e7d3c6;
  --done: #2f5d52; --done-soft: #d6e3de; --off: #8a8579; --off-soft: #e3e0d6;
  --line: #d9d4c6; --code-bg: #21201b; --code-ink: #eae4d4; --code-accent: #e0a56a;
  --shadow: 0 1px 0 rgba(28,35,33,.06);
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece8e0; --ink-soft: #b7b2a6; --paper: #17181a; --surface: #202220;
    --surface-2: #2b2d29; --accent: #e08a5b; --accent-soft: #3a2a20;
    --done: #7fb3a3; --done-soft: #1f2f2a; --off: #7a7669; --off-soft: #262722;
    --line: #34352e; --code-bg: #0f0f0d; --code-ink: #e7e2d2; --code-accent: #e0a56a;
    --shadow: 0 1px 0 rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --ink: #ece8e0; --ink-soft: #b7b2a6; --paper: #17181a; --surface: #202220;
  --surface-2: #2b2d29; --accent: #e08a5b; --accent-soft: #3a2a20;
  --done: #7fb3a3; --done-soft: #1f2f2a; --off: #7a7669; --off-soft: #262722;
  --line: #34352e; --code-bg: #0f0f0d; --code-ink: #e7e2d2; --code-accent: #e0a56a;
  --shadow: 0 1px 0 rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--paper); color: var(--ink);
  font-family: Charter, "Iowan Old Style", Georgia, "Noto Serif", serif;
  font-size: 17px; line-height: 1.6; margin: 0; padding: 0;
}

h1, h2, h3, .eyebrow, .pill, .board-title, .step-title, th, .back-link, .why-name, .site-header a, .mobile-menu a {
  font-family: Bahnschrift, "DejaVu Sans Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
}
code, pre, .cmd, .cmd * {
  font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}
code { background: var(--surface); padding: 1px 5px; border-radius: 3px; }
pre code { background: none; padding: 0; }

a { color: var(--accent); }
[id] { scroll-margin-top: calc(var(--header-h) + 12px); }

/* =========================================================
   HEADER — fond volontairement fixe (ne s'inverse pas avec
   le thème) pour garder un contraste garanti dans tous les cas.
   ========================================================= */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--code-bg); box-shadow: var(--shadow);
}
.site-header .bar {
  max-width: 1000px; margin: 0 auto; padding: 0 20px; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  font-size: 15px; font-weight: 700; letter-spacing: .02em;
  color: var(--code-ink); text-decoration: none; white-space: nowrap;
}

.nav-desktop { display: flex; gap: 2px; }
.nav-desktop a {
  font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap;
  color: rgba(231,226,210,.68); padding: 8px 12px; border-radius: 20px;
  transition: background .15s, color .15s;
}
.nav-desktop a:hover { color: var(--code-ink); background: rgba(255,255,255,.09); }
.nav-desktop a.current { color: var(--ink); background: var(--code-accent); }

/* burger — masqué sur grand écran */
.burger {
  display: none; flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 42px; height: 42px; border: none; background: transparent;
  cursor: pointer; padding: 0; border-radius: 8px; flex-shrink: 0;
}
.burger:hover { background: rgba(255,255,255,.08); }
.burger span {
  display: block; width: 21px; height: 2px; border-radius: 2px;
  background: var(--code-ink); transition: transform .28s ease, opacity .2s ease;
}
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.menu-overlay {
  position: fixed; inset: 0; background: rgba(10,10,8,.45);
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity .32s ease;
}
.menu-overlay.show { opacity: 1; pointer-events: auto; }

.mobile-menu {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(80vw, 320px);
  background: var(--code-bg); z-index: 70;
  display: flex; flex-direction: column; gap: 2px; padding: 76px 20px 24px;
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.22, 1, .36, 1);
  box-shadow: -12px 0 40px rgba(0,0,0,.35);
}
.mobile-menu.open { transform: translateX(0); }
.mobile-menu a {
  color: rgba(231,226,210,.85); text-decoration: none; font-size: 16px; font-weight: 700;
  padding: 13px 12px; border-radius: 8px; border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.mobile-menu a:hover { background: rgba(255,255,255,.07); color: var(--code-ink); }
.mobile-menu a.current { background: rgba(224,165,91,.12); color: var(--code-accent); border-left-color: var(--code-accent); }
.menu-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
  border: none; background: transparent; color: var(--code-ink); font-size: 20px;
  cursor: pointer; border-radius: 8px;
}
.menu-close:hover { background: rgba(255,255,255,.08); }

@media (max-width: 780px) {
  .nav-desktop { display: none; }
  .burger { display: flex; }
}

/* =========================================================
   Contenu (repris à l'identique du gabarit précédent)
   ========================================================= */

main.sheet, .sheet { max-width: 780px; margin: 0 auto; padding: 44px 28px 96px; }

.back-link { display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); text-decoration: none; margin-bottom: 18px; }
.back-link:hover { color: var(--accent); }

header.top { border-bottom: 3px solid var(--ink); padding-bottom: 20px; margin-bottom: 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12.5px; color: var(--accent); font-weight: 700; }
h1 { font-size: 36px; line-height: 1.08; letter-spacing: -.01em; margin: 8px 0 6px; text-wrap: balance; font-weight: 700; }
.subtitle { color: var(--ink-soft); font-size: 16px; max-width: 58ch; font-family: Charter, Georgia, serif; font-style: italic; }
.subtitle a { color: var(--accent); }

.top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.explain-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; white-space: nowrap;
}

.thesis { background: var(--ink); color: var(--paper); border-radius: 3px; padding: 22px 24px; margin: 28px 0 40px; }
.thesis .eyebrow2 { font-size: 11px; text-transform: uppercase; letter-spacing: .16em; opacity: .65; margin-bottom: 10px; }
.thesis p { margin: 0 0 12px; font-size: 16.5px; line-height: 1.55; }
.thesis p:last-child { margin-bottom: 0; }
.thesis b { color: var(--code-accent); }

h2.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 44px 0 18px; }

.socle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.brique { border: 1px solid var(--line); border-radius: 3px; padding: 12px 14px; background: var(--surface); min-width: 0; }
.brique .name { font-family: ui-monospace, monospace; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.brique .role { font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }

.cat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 700; margin: 22px 0 8px; }
.cat-label:first-of-type { margin-top: 0; }
.glossary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.term { border: 1px solid var(--line); border-radius: 3px; padding: 12px 14px; background: var(--surface); min-width: 0; overflow-wrap: anywhere; }
.term-name { font-family: ui-monospace, "Cascadia Code", monospace; font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.term p { font-size: 13.5px; margin: 0 0 5px; line-height: 1.5; }
.term p:last-child { margin-bottom: 0; }
.term .k { color: var(--accent); font-family: Bahnschrift, "Arial Narrow", sans-serif; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-right: 5px; }
.stack-note { font-size: 13px; color: var(--ink-soft); background: var(--surface); border-radius: 4px; padding: 10px 14px; margin-top: 18px; }

details.lexique-details { margin: 44px 0 18px; }
details.lexique-details summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; gap: 12px;
}
details.lexique-details summary::-webkit-details-marker { display: none; }
details.lexique-details summary h2.section-title { margin: 0; border: none; padding: 0; }
details.lexique-details .toggle-hint { flex-shrink: 0; font-size: 12px; color: var(--accent); font-weight: 700; font-family: Bahnschrift, "Arial Narrow", sans-serif; }
details.lexique-details:not([open]) .toggle-hint::after { content: "Afficher ▾"; }
details.lexique-details[open] .toggle-hint::after { content: "Masquer ▴"; }
details.lexique-details .lexique-body { padding-top: 16px; }

.matrix-wrap { border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
table.matrix { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px; }
table.matrix th, table.matrix td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
table.matrix thead th { background: var(--surface); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; line-height: 1.4; }
table.matrix tbody th { font-weight: 700; font-size: 13px; }
table.matrix tbody tr:last-child td, table.matrix tbody tr:last-child th { border-bottom: none; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; white-space: normal; line-height: 1.3; }
.tag.on { background: var(--done-soft); color: var(--done); }
.tag.opt { background: var(--accent-soft); color: var(--accent); }
.tag.off { background: var(--off-soft); color: var(--off); }
@media (max-width: 680px) {
  table.matrix, table.matrix thead, table.matrix tbody, table.matrix th, table.matrix td, table.matrix tr { display: block; }
  table.matrix thead { display: none; }
  table.matrix tbody tr { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin-bottom: 10px; }
  table.matrix tbody tr:last-child { margin-bottom: 0; }
  table.matrix tbody tr th { border-bottom: 1px solid var(--line); padding: 2px 0 8px; margin-bottom: 8px; font-size: 14.5px; }
  table.matrix td { border: none; padding: 5px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  table.matrix td::before { content: attr(data-label); font-weight: 700; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-family: Bahnschrift, "Arial Narrow", sans-serif; flex-shrink: 0; }
}

.board { background: var(--ink); color: var(--paper); border-radius: 3px; padding: 16px 20px; margin: 26px 0 8px; box-shadow: var(--shadow); }
.board-title { font-size: 11px; text-transform: uppercase; letter-spacing: .16em; opacity: .65; margin-bottom: 10px; }
.board-row { display: grid; grid-template-columns: 2em 1fr auto; gap: 12px; align-items: baseline; padding: 5px 0; font-family: ui-monospace, "Cascadia Code", monospace; font-variant-numeric: tabular-nums; font-size: 14px; }
.board-row .n { color: var(--accent); font-weight: 700; }
.board-row .label { font-family: Bahnschrift, "Arial Narrow", sans-serif; font-size: 14.5px; }

.usage { background: var(--surface); border-left: 3px solid var(--accent); padding: 14px 18px; margin: 28px 0 40px; font-size: 15px; }
.usage strong { color: var(--accent); }

.lexique-link { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; font-size: 14.5px; color: var(--ink); margin: 0 0 40px; }
.lexique-link b { color: var(--accent); }

.ticket { display: grid; grid-template-columns: 78px 1fr; border: 1px solid var(--line); border-radius: 2px; break-inside: avoid; }
.ticket + .ticket { margin-top: 22px; }
.stub { background: var(--surface); border-right: 2px dashed var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 6px; min-width: 0; text-align: center; }
.stub .num { font-family: ui-monospace, monospace; font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent); }
.stub .icon { font-size: 26px; }
.ticket-body { padding: 20px 22px 22px; min-width: 0; }
.ticket-body, .ticket-body p, .ticket-body li, .why, .action, .objectif, .prereq { overflow-wrap: anywhere; }
h2.step-title { font-size: 20px; margin: 0 0 4px; letter-spacing: -.005em; }
.objectif { color: var(--ink-soft); font-size: 15px; font-style: italic; margin-bottom: 12px; font-family: Charter, Georgia, serif; }
.prereq { font-size: 13.5px; color: var(--ink-soft); margin: -6px 0 14px; }
.prereq b { color: var(--ink); }

.modules-row, .tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.pill.generique { background: var(--done-soft); color: var(--done); }
.pill.specifique { background: var(--accent-soft); color: var(--accent); }

ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.steps > li { counter-increment: step; position: relative; padding: 0 0 16px 32px; }
ol.steps > li:last-child { padding-bottom: 0; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 1px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
ol.steps > li > .action { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
ol.steps > li > .why { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
ol.steps > li > .why b { color: var(--ink); }
ol.steps > li > .result {
  font-size: 13.5px; color: var(--ink-soft); margin-top: 8px;
  background: var(--done-soft); border-radius: 4px; padding: 8px 11px;
}
ol.steps > li > .result b { color: var(--done); }
ol.steps > li > .result code { background: rgba(0,0,0,.06); }

pre.cmd {
  position: relative; background: var(--code-bg); color: var(--code-ink);
  padding: 12px 44px 12px 15px; border-radius: 4px; font-size: 13px; line-height: 1.55;
  overflow-x: auto; margin: 0 0 6px;
}
pre.cmd .c { color: #8a8579; }
pre.cmd .v { color: var(--code-accent); }

.copy-btn {
  position: absolute; top: 6px; right: 6px; font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: 4px 8px; border-radius: 4px; background: rgba(255,255,255,.08); color: var(--code-ink);
  border: 1px solid rgba(255,255,255,.18); cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.16); }
.copy-btn.copied { background: var(--done); color: var(--paper); border-color: var(--done); }

.check { background: var(--surface); border-radius: 4px; padding: 12px 16px 4px; margin-top: 16px; }
.check-title { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--done); font-weight: 700; margin-bottom: 8px; }
.check label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin-bottom: 8px; }
.check input { margin-top: 4px; }

.risk { font-size: 13.5px; color: var(--ink-soft); margin-top: 12px; }
.risk b { color: var(--accent); }

.see-more { display: inline-block; margin-top: 14px; font-size: 13.5px; padding: 6px 12px; background: var(--accent-soft); color: var(--accent); border-radius: 20px; text-decoration: none; font-weight: 600; }

footer.end { margin-top: 48px; padding-top: 20px; border-top: 3px solid var(--ink); font-size: 14px; color: var(--ink-soft); }
footer.end h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink); margin-bottom: 10px; }
footer.end p { margin: 0 0 10px; }
footer.end p:last-child { margin-bottom: 0; }

section.layer { margin-bottom: 40px; }
section.layer:last-of-type { margin-bottom: 0; }
h2.layer-title { display: flex; align-items: baseline; gap: 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 0 0 16px; }
h2.layer-title .n { font-family: ui-monospace, monospace; color: var(--ink-soft); font-weight: 400; }
.layer p { margin: 0 0 14px; font-size: 16px; }
.layer p:last-child { margin-bottom: 0; }
.layer b { color: var(--ink); }
.why-box { background: var(--surface); border-left: 3px solid var(--accent); border-radius: 0 3px 3px 0; padding: 12px 16px; margin: 14px 0; }
.why-box .why-name { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.why-box p { font-size: 14.5px; margin: 0; color: var(--ink-soft); }
.not-yet { background: var(--surface); border-radius: 3px; padding: 20px 22px; margin-top: 44px; }
.not-yet h2.layer-title { border-bottom-color: var(--surface-2); }

.quicknav {
  position: sticky; top: var(--header-h); z-index: 30;
  display: flex; align-items: center; gap: 4px;
  background: var(--paper); border-bottom: 1px solid var(--line); padding: 10px 0; margin: 0 0 8px;
}
.quicknav a {
  font-family: ui-monospace, monospace; font-size: 12.5px; font-weight: 700; text-decoration: none;
  color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 10px; white-space: nowrap;
}
.quicknav a.lex { color: var(--accent); border-color: var(--accent-soft); }
.quicknav .progress { margin-left: auto; font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; padding-left: 8px; }

@media print {
  body { background: #fff; }
  .site-header, .quicknav, .copy-btn, .mobile-menu, .menu-overlay { display: none; }
  .sheet { max-width: 100%; padding: 0; }
  .ticket { break-inside: avoid; page-break-inside: avoid; }
  @page { size: A4; margin: 16mm 14mm; }
}

@media (max-width: 560px) {
  .socle-grid { grid-template-columns: 1fr 1fr; }
  .ticket { grid-template-columns: 54px 1fr; }
  .stub .num { font-size: 20px; }
  h1 { font-size: 27px; }
  .glossary-grid { grid-template-columns: 1fr; }
  .quicknav { overflow-x: auto; justify-content: flex-start !important; }
}
