/* =========================================================================
   lab.fozzy.me : une seule feuille de style, quatre thèmes, deux modes.
   Les thèmes ne changent que des variables CSS, et quelques touches propres à chacun.
   ========================================================================= */

/* ---------- 1. Jetons de thème ---------- */

/* Éditorial : serif, papier chaud, accent bordeaux */
:root,
[data-theme="editorial"] {
  --bg: #f7f4ee; --surface: #fffdf9; --surface-2: #efeae0;
  --fg: #1d1a16; --muted: #6e665b; --border: #ddd5c7;
  --accent: #8c2f39; --accent-fg: #fff; --accent-2: #2f5d62;
  --font-body: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --font-head: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --head-weight: 600; --head-tracking: -0.015em; --head-transform: none;
  --radius: 4px; --radius-lg: 6px;
  --shadow: none; --shadow-hover: 0 1px 0 var(--border);
  --rule: 1px solid var(--border);
  --measure: 40rem;
  color-scheme: light;
}
[data-theme="editorial"][data-mode="dark"] {
  --bg: #17150f; --surface: #1f1c16; --surface-2: #2a261e;
  --fg: #ece6da; --muted: #a39a8b; --border: #3a352b;
  --accent: #e08a8f; --accent-fg: #17150f; --accent-2: #8fc1c5;
  color-scheme: dark;
}

/* Terminal : monospace, phosphore, grilles visibles */
[data-theme="terminal"] {
  --bg: #f2efe4; --surface: #fbf9f2; --surface-2: #e6e2d3;
  --fg: #1b2a1f; --muted: #5d6b5f; --border: #1b2a1f;
  --accent: #0a7d3e; --accent-fg: #f2efe4; --accent-2: #b25c00;
  --font-body: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --font-head: var(--font-body);
  --font-mono: var(--font-body);
  --head-weight: 700; --head-tracking: 0; --head-transform: none;
  --radius: 0; --radius-lg: 0;
  --shadow: 4px 4px 0 var(--border); --shadow-hover: 6px 6px 0 var(--accent);
  --rule: 1px dashed var(--border);
  --measure: 46rem;
  color-scheme: light;
}
[data-theme="terminal"][data-mode="dark"] {
  --bg: #0b0f0c; --surface: #0f1511; --surface-2: #16201a;
  --fg: #c8f7d4; --muted: #6fa47e; --border: #2e5a3c;
  --accent: #39ff88; --accent-fg: #0b0f0c; --accent-2: #ffb454;
  color-scheme: dark;
}

/* Pop : sans-serif arrondi, dégradés doux, cartes */
[data-theme="pop"] {
  --bg: #fbf8ff; --surface: #ffffff; --surface-2: #f1ecff;
  --fg: #1e1636; --muted: #6c6488; --border: #e4dcf7;
  --accent: #6d3df5; --accent-fg: #fff; --accent-2: #ff5c8a;
  --font-body: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: var(--font-body);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --head-weight: 800; --head-tracking: -0.025em; --head-transform: none;
  --radius: 14px; --radius-lg: 24px;
  --shadow: 0 1px 2px rgb(30 22 54 / .06), 0 8px 24px rgb(109 61 245 / .08);
  --shadow-hover: 0 2px 4px rgb(30 22 54 / .08), 0 16px 40px rgb(109 61 245 / .18);
  --rule: 1px solid var(--border);
  --measure: 42rem;
  color-scheme: light;
}
[data-theme="pop"][data-mode="dark"] {
  --bg: #120d24; --surface: #1b1433; --surface-2: #251c45;
  --fg: #f1ecff; --muted: #a89fca; --border: #33285c;
  --accent: #a78bfa; --accent-fg: #120d24; --accent-2: #ff8fb0;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  --shadow-hover: 0 2px 4px rgb(0 0 0 / .4), 0 16px 40px rgb(167 139 250 / .22);
  color-scheme: dark;
}

/* Suisse : grille stricte, grotesque, noir, blanc et rouge */
[data-theme="suisse"] {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f2f2f2;
  --fg: #111111; --muted: #6b6b6b; --border: #111111;
  --accent: #e3000f; --accent-fg: #fff; --accent-2: #111111;
  --font-body: "Helvetica Neue", Helvetica, "Inter", Arial, sans-serif;
  --font-head: var(--font-body);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --head-weight: 700; --head-tracking: -0.035em; --head-transform: none;
  --radius: 0; --radius-lg: 0;
  --shadow: none; --shadow-hover: none;
  --rule: 2px solid var(--border);
  --measure: 38rem;
  color-scheme: light;
}
[data-theme="suisse"][data-mode="dark"] {
  --bg: #0d0d0d; --surface: #0d0d0d; --surface-2: #1c1c1c;
  --fg: #f5f5f5; --muted: #9a9a9a; --border: #f5f5f5;
  --accent: #ff3b3b; --accent-fg: #0d0d0d; --accent-2: #f5f5f5;
  color-scheme: dark;
}

/* Sans JavaScript, le thème par défaut suit quand même le mode sombre du système */
@media (prefers-color-scheme: dark) {
  html:not(.js) {
    --bg: #17150f; --surface: #1f1c16; --surface-2: #2a261e;
    --fg: #ece6da; --muted: #a39a8b; --border: #3a352b;
    --accent: #e08a8f; --accent-fg: #17150f; --accent-2: #8fc1c5;
    color-scheme: dark;
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.08rem);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-fg); }
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  letter-spacing: var(--head-tracking);
  text-transform: var(--head-transform);
  line-height: 1.12;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.3rem, 1.6rem + 3.4vw, 4.4rem); }
h2 { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.4rem); }
h3 { font-size: clamp(1.15rem, 1.08rem + .4vw, 1.4rem); }
p { margin: 0 0 1em; text-wrap: pretty; }
code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
kbd {
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  padding: .05em .4em; background: var(--surface);
}
hr { border: 0; border-top: var(--rule); margin: 3rem 0; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--accent-fg); padding: .6rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 3. Mise en page ---------- */
.container { width: min(72rem, 100% - 2.5rem); margin-inline: auto; }
.narrow { width: min(var(--measure), 100% - 2.5rem); margin-inline: auto; }
main { display: block; padding-block: clamp(2.5rem, 6vw, 5rem) 4rem; }
section + section { margin-top: clamp(3.5rem, 8vw, 6rem); }

/* En-tête */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: var(--rule);
}
.site-header .container { position: relative; display: flex; align-items: center; gap: 1.25rem; min-height: 4rem; }
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.05rem;
  color: var(--fg); text-decoration: none; letter-spacing: var(--head-tracking);
}
.brand svg { width: 1.6rem; height: 1.6rem; color: var(--accent); }
.brand-dot { color: var(--accent); }

.nav { margin-left: auto; }
.nav ul { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; }
.nav a {
  display: block; padding: .45rem .7rem; border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-size: .95rem;
}
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); }

.header-tools { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--fg); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.menu-toggle { display: none; }

/* Sélecteur de thème */
.theme-panel {
  position: absolute; right: 1.25rem; top: calc(100% + .5rem);
  width: min(22rem, calc(100vw - 2.5rem));
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgb(0 0 0 / .18); padding: 1rem;
}
.theme-panel h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .6rem; font-family: var(--font-mono); font-weight: 500; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.theme-choice {
  display: grid; gap: .45rem; text-align: left; padding: .6rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--fg);
  font: inherit; font-size: .88rem;
}
.theme-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.swatch { display: flex; height: 1.4rem; border-radius: 3px; overflow: hidden; }
.swatch i { flex: 1; }
.sw-editorial i:nth-child(1) { background: #f7f4ee; } .sw-editorial i:nth-child(2) { background: #1d1a16; } .sw-editorial i:nth-child(3) { background: #8c2f39; }
.sw-terminal i:nth-child(1) { background: #0b0f0c; } .sw-terminal i:nth-child(2) { background: #c8f7d4; } .sw-terminal i:nth-child(3) { background: #39ff88; }
.sw-pop i:nth-child(1) { background: #f1ecff; } .sw-pop i:nth-child(2) { background: #6d3df5; } .sw-pop i:nth-child(3) { background: #ff5c8a; }
.sw-suisse i:nth-child(1) { background: #ffffff; } .sw-suisse i:nth-child(2) { background: #111111; } .sw-suisse i:nth-child(3) { background: #e3000f; }
.segmented { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  flex: 1; padding: .45rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: .88rem;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.theme-hint { font-size: .8rem; color: var(--muted); margin: .8rem 0 0; }

/* Pied de page */
.site-footer { border-top: var(--rule); padding-block: 2.5rem; color: var(--muted); font-size: .9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: baseline; }
.site-footer a { color: inherit; }
.footer-links { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }

/* ---------- 4. Composants ---------- */
.eyebrow {
  display: inline-block; font-family: var(--font-mono); font-size: .8rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 1rem;
}
.lead { font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); color: var(--muted); max-width: 38rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.15rem;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-fg); font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-ghost:hover, .btn-ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn-ghost[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

/* Héros */
.hero { position: relative; padding-block: clamp(1rem, 4vw, 3rem) 1rem; }
.hero h1 { max-width: 15ch; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: 2.5rem; color: var(--muted); font-size: .9rem; font-family: var(--font-mono); }
.hero-meta span::before { content: "● "; color: var(--accent); }
.hero-art { position: absolute; inset: auto -2rem -2rem auto; width: min(26rem, 45vw); color: var(--accent); opacity: .9; pointer-events: none; }

/* En-têtes de section */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 2rem; }
.section-head h2 { margin: 0; }
.section-head a { font-size: .95rem; }

/* Cartes */
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: .6rem;
  padding: 1.4rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
.card h3 { margin: 0; }
.card h3 a { color: var(--fg); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; } /* toute la carte est cliquable */
.card p { color: var(--muted); margin: 0; font-size: .95rem; }
.card-icon { width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: var(--radius); background: var(--surface-2); color: var(--accent); }
.card-icon svg { width: 1.4rem; height: 1.4rem; }
.card-foot { margin-top: auto; padding-top: .6rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.status { font-family: var(--font-mono); font-size: .75rem; margin-left: auto; color: var(--muted); }
.status::before { content: "◆ "; }
.status-live::before { color: #1f9d55; } .status-wip::before { color: #d68a00; } .status-idea::before { color: var(--muted); }

.tag {
  display: inline-block; font-family: var(--font-mono); font-size: .74rem; line-height: 1;
  padding: .35em .6em; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid transparent;
}

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.chip {
  font: inherit; font-size: .88rem; padding: .4rem .85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
}
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.filter-count { font-family: var(--font-mono); font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
.card[hidden] { display: none; }

/* Liste de notes */
.note-list { list-style: none; margin: 0; padding: 0; border-top: var(--rule); }
.note-list li { border-bottom: var(--rule); }
.note-list a {
  display: grid; grid-template-columns: 7.5rem 1fr auto; gap: 1rem; align-items: baseline;
  padding: 1.25rem .25rem; color: var(--fg); text-decoration: none;
}
.note-list a:hover h3 { color: var(--accent); }
.note-list time, .note-list .read { font-family: var(--font-mono); font-size: .82rem; color: var(--muted); }
.note-list h3 { margin: 0 0 .25rem; transition: color .15s; }
.note-list p { margin: 0; color: var(--muted); font-size: .95rem; }

/* Chiffres */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); border: var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.stat { padding: 1.4rem; background: var(--surface); }
.stat + .stat { border-left: var(--rule); }
.stat strong { display: block; font-family: var(--font-head); font-size: clamp(2rem, 1.6rem + 1.5vw, 2.8rem); line-height: 1; letter-spacing: var(--head-tracking); font-weight: var(--head-weight); }
.stat span { color: var(--muted); font-size: .9rem; }

/* Frise chronologique */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.5rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 2rem 1rem; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1.5rem - 7px); top: .45rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.timeline time { font-family: var(--font-mono); font-size: .82rem; color: var(--accent); }
.timeline h3 { margin: .2rem 0 .3rem; }
.timeline p { color: var(--muted); margin: 0; }

/* Encadrés */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; padding: 1.1rem 1.25rem; margin: 1.75rem 0;
  border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius);
  background: var(--surface);
}
.callout svg { width: 1.3rem; height: 1.3rem; color: var(--accent); margin-top: .2rem; }
.callout p:last-child { margin: 0; }
.callout-warn { border-left-color: var(--accent-2); }
.callout-warn svg { color: var(--accent-2); }

/* Prose d'article */
.article-head { margin-bottom: 2.5rem; }
.article-head h1 { font-size: clamp(2rem, 1.5rem + 2.6vw, 3.4rem); max-width: 20ch; }
.article-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--muted); font-family: var(--font-mono); font-size: .85rem; }
.prose { font-size: 1.07em; }
.prose h2 { font-size: clamp(1.4rem, 1.2rem + .9vw, 1.9rem); margin-top: 2.5em; }
.prose h3 { margin-top: 2em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li + li { margin-top: .35em; }
.prose blockquote {
  margin: 2rem 0; padding: .2rem 0 .2rem 1.4rem; border-left: 3px solid var(--accent);
  font-family: var(--font-head); font-size: 1.25em; line-height: 1.45; color: var(--fg);
}
.prose blockquote p { margin: 0; }
.prose figure { margin: 2.25rem 0; }
.prose figcaption { font-size: .85rem; color: var(--muted); margin-top: .6rem; font-family: var(--font-mono); }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table-wrap { overflow-x: auto; margin: 1.75rem 0; border: var(--rule); border-radius: var(--radius); }
.prose th, .prose td { text-align: left; padding: .65rem .9rem; border-bottom: var(--rule); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose :not(pre) > code { background: var(--surface-2); padding: .12em .38em; border-radius: 4px; }

.code-block { position: relative; margin: 1.75rem 0; }
.code-block pre {
  margin: 0; overflow-x: auto; padding: 1.1rem 1.2rem; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.code-label {
  display: block; font-family: var(--font-mono); font-size: .74rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem;
}
.copy-btn {
  position: absolute; top: 1.85rem; right: .5rem; font: inherit; font-size: .75rem; cursor: pointer;
  padding: .3rem .55rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.tok-c { color: var(--muted); font-style: italic; }
.tok-k { color: var(--accent); font-weight: 600; }
.tok-s { color: var(--accent-2); }

.chart { width: 100%; color: var(--fg); }
.chart .bar { fill: var(--accent); }
.chart .bar-2 { fill: var(--accent-2); }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; }

/* Barre de lecture */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none;
  background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0));
}

/* Table des matières */
.article-layout { display: grid; grid-template-columns: minmax(0, var(--measure)) 13rem; gap: 4rem; justify-content: center; }
.toc { position: sticky; top: 6rem; align-self: start; font-size: .88rem; }
.toc h2 { font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: var(--rule); }
.toc a { display: block; padding: .3rem 0 .3rem .9rem; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--fg); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }

.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; }
.article-nav a { padding: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--fg); background: var(--surface); }
.article-nav a:hover { border-color: var(--accent); }
.article-nav small { display: block; color: var(--muted); font-family: var(--font-mono); font-size: .78rem; }
.article-nav .next { text-align: right; grid-column: 2; }

/* Formulaires (page Design) */
.form { display: grid; gap: 1.1rem; max-width: 30rem; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; padding: .65rem .8rem; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field small { color: var(--muted); font-size: .82rem; }
.check { display: flex; gap: .6rem; align-items: center; }
.check input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }

/* Notification */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 70; transform: translate(-50%, 150%);
  background: var(--fg); color: var(--bg); padding: .75rem 1.1rem; border-radius: var(--radius);
  font-size: .92rem; box-shadow: 0 10px 30px rgb(0 0 0 / .25); transition: transform .3s ease;
}
.toast.is-shown { transform: translate(-50%, 0); }

/* Guide de style */
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .75rem; }
.color { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.color div { height: 4.5rem; }
.color span { display: block; padding: .5rem .6rem; font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
.c-bg { background: var(--bg); } .c-surface { background: var(--surface); } .c-surface-2 { background: var(--surface-2); }
.c-fg { background: var(--fg); } .c-muted { background: var(--muted); } .c-border { background: var(--border); }
.c-accent { background: var(--accent); } .c-accent-2 { background: var(--accent-2); }
.type-scale > * { margin: 0 0 .6rem; }
.type-scale small { font-family: var(--font-mono); color: var(--muted); font-size: .75rem; margin-left: .6rem; letter-spacing: 0; text-transform: none; font-weight: 400; }
.demo-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 2.5rem; }

/* Page 404 */
.big-404 { font-family: var(--font-head); font-size: clamp(6rem, 4rem + 14vw, 14rem); line-height: .9; font-weight: var(--head-weight); letter-spacing: -.05em; color: var(--accent); margin: 0; }

/* ---------- 5. Touches propres à chaque thème ---------- */

/* Éditorial : lettrine, filets fins, petites capitales */
[data-theme="editorial"] .prose > p:first-of-type::first-letter {
  float: left; font-size: 3.6em; line-height: .85; padding: .08em .1em 0 0; color: var(--accent); font-weight: 600;
}
[data-theme="editorial"] .eyebrow { font-family: var(--font-body); font-variant: small-caps; text-transform: lowercase; letter-spacing: .08em; font-size: 1rem; }
[data-theme="editorial"] .hero h1 { font-weight: 500; font-style: italic; }
[data-theme="editorial"] .hero h1 em { font-style: normal; color: var(--accent); }

/* Terminal : invite de commande, curseur, cadres pointillés */
[data-theme="terminal"] h1::before, [data-theme="terminal"] h2::before { content: "> "; color: var(--accent); }
[data-theme="terminal"] .hero h1::after {
  content: "_"; color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: .05em;
}
[data-theme="terminal"] .hero h1 em { font-style: normal; color: var(--accent); }
[data-theme="terminal"] .card { border-style: solid; }
[data-theme="terminal"] .tag, [data-theme="terminal"] .chip { border-radius: 0; }
[data-theme="terminal"] .tag::before { content: "#"; }
[data-theme="terminal"] .tag { background: transparent; border: 1px dashed var(--border); }
[data-theme="terminal"] .nav a[aria-current="page"]::before { content: "["; color: var(--accent); }
[data-theme="terminal"] .nav a[aria-current="page"]::after { content: "]"; color: var(--accent); }
[data-theme="terminal"] .nav a[aria-current="page"] { box-shadow: none; }
[data-theme="terminal"][data-mode="dark"] body {
  background-image: repeating-linear-gradient(0deg, rgb(57 255 136 / .025) 0 1px, transparent 1px 3px);
}
[data-theme="terminal"][data-mode="dark"] h1, [data-theme="terminal"][data-mode="dark"] .stat strong { text-shadow: 0 0 18px rgb(57 255 136 / .35); }
@keyframes blink { 50% { opacity: 0; } }

/* Pop : halos de couleur, titres en dégradé, pastilles */
[data-theme="pop"] body {
  background-image:
    radial-gradient(40rem 30rem at 85% -5%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    radial-gradient(35rem 28rem at -10% 25%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%);
  background-attachment: fixed;
}
[data-theme="pop"] .hero h1 em {
  font-style: normal; background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
[data-theme="pop"] .btn { border-radius: 999px; }
[data-theme="pop"] .btn:not(.btn-ghost) { background: linear-gradient(100deg, var(--accent), var(--accent-2)); border-color: transparent; }
[data-theme="pop"] .card-icon { border-radius: 12px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-2) 18%, transparent)); }
[data-theme="pop"] .stats { border: 0; gap: 1rem; overflow: visible; }
[data-theme="pop"] .stat { border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 0; }
[data-theme="pop"] .stat + .stat { border-left: 0; }
[data-theme="pop"] .nav a[aria-current="page"] { box-shadow: none; background: var(--surface-2); color: var(--accent); }

/* Suisse : grille visible, capitales, typo serrée, rouge */
[data-theme="suisse"] h1 { font-size: clamp(2.6rem, 1.6rem + 5vw, 6rem); line-height: .95; }
[data-theme="suisse"] .hero h1 em { font-style: normal; color: var(--accent); }
[data-theme="suisse"] .eyebrow, [data-theme="suisse"] .nav a, [data-theme="suisse"] .btn, [data-theme="suisse"] .chip, [data-theme="suisse"] .tag {
  text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-body); font-weight: 700;
}
[data-theme="suisse"] .eyebrow { color: var(--fg); border-top: 4px solid var(--accent); padding-top: .5rem; }
[data-theme="suisse"] .card { border-width: 2px; }
[data-theme="suisse"] .card:hover { transform: none; background: var(--fg); color: var(--bg); border-color: var(--fg); }
[data-theme="suisse"] .card:hover h3 a, [data-theme="suisse"] .card:hover p, [data-theme="suisse"] .card:hover .status { color: var(--bg); }
[data-theme="suisse"] .card:hover .card-icon { background: var(--accent); color: #fff; }
[data-theme="suisse"] .tag { border-radius: 0; background: transparent; border: 1px solid var(--muted); }
[data-theme="suisse"] .chip { border-radius: 0; border-width: 2px; }
[data-theme="suisse"] .nav a[aria-current="page"] { box-shadow: none; background: var(--accent); color: #fff; }
[data-theme="suisse"] main {
  background-image: linear-gradient(to right, color-mix(in srgb, var(--fg) 6%, transparent) 1px, transparent 1px);
  background-size: calc(100% / 12) 100%;
}

/* ---------- 6. Animations ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
.hero-art .orbit { transform-origin: 50% 50%; animation: spin 40s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- 7. Responsive ---------- */
@media (max-width: 62rem) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .hero-art { opacity: .25; }
}
@media (max-width: 48rem) {
  .menu-toggle { display: inline-grid; }
  .site-header .container { flex-wrap: wrap; }
  .header-tools { margin-left: auto; }
  .nav { order: 3; width: 100%; margin: 0; }
  .nav ul { flex-direction: column; padding-bottom: .75rem; }
  .js .nav { display: none; }
  .js .nav.is-open { display: block; }
  .note-list a { grid-template-columns: 1fr; gap: .25rem; }
  .stat + .stat { border-left: 0; border-top: var(--rule); }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { grid-column: 1; }
  .theme-panel { right: .75rem; }
}

@media print {
  .site-header, .site-footer, .progress, .toc, .copy-btn, .article-nav { display: none !important; }
  body { background: #fff; color: #000; }
}
