:root {
  --bg: #030817;
  --surface: #09162c;
  --surface-sunk: #0e1e39;
  --surface-raised: #132746;
  --ink: #ffffff;
  --ink-soft: #b8c4d8;
  --ink-faint: #7f8da7;
  --rule: #20395f;
  --accent: #f7b900;
  --accent-strong: #ffcf3e;
  --accent-soft: rgba(247, 185, 0, .11);
  --red: #e82d2d;
  --red-soft: rgba(232, 45, 45, .12);
  --good: #38d996;
  --warn: #ffca55;
  --bad: #ff6b72;
  --display: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

:root[data-theme="dark"] {
  --bg: #030817;
  --surface: #09162c;
  --surface-sunk: #0e1e39;
  --surface-raised: #132746;
  --ink: #ffffff;
  --ink-soft: #b8c4d8;
  --ink-faint: #7f8da7;
  --rule: #20395f;
  --accent: #f7b900;
  --accent-strong: #ffcf3e;
  --accent-soft: rgba(247, 185, 0, .11);
  --good: #38d996;
  --warn: #ffca55;
  --bad: #ff6b72;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-sunk: #eaf0f8;
  --surface-raised: #dfe9f6;
  --ink: #07152c;
  --ink-soft: #53617a;
  --ink-faint: #7e8aa0;
  --rule: #dce3ee;
  --accent: #d99000;
  --accent-strong: #ef6c00;
  --accent-soft: rgba(217, 144, 0, .10);
  --good: #087c55;
  --warn: #946300;
  --bad: #c93849;
  color-scheme: light;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 92% 6%, rgba(25, 82, 155, .22), transparent 28rem),
    linear-gradient(180deg, #06132a 0, var(--bg) 38rem),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background-image: linear-gradient(rgba(255,255,255,.026) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.026) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000, transparent 76%);
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 100;
  background: rgba(255,255,255,.06);
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 18px rgba(255, 184, 0, .55);
}

.wrap { max-width: 1320px; padding: 0 clamp(18px, 4vw, 52px) 72px; }

.masthead {
  position: relative;
  overflow: hidden;
  width: 100vw;
  margin: 0 0 58px calc(50% - 50vw);
  padding: clamp(26px, 4vw, 48px) max(22px, calc((100vw - 1320px) / 2 + clamp(18px, 4vw, 52px))) clamp(34px, 5vw, 64px);
  border: 0;
  border-bottom: 1px solid #1e3b66;
  border-radius: 0;
  background:
    radial-gradient(circle at 83% 12%, rgba(247,185,0,.13), transparent 23rem),
    linear-gradient(125deg, #07162f 0%, #0a1e3d 56%, #071329 100%);
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
}

:root[data-theme="light"] .masthead { background: linear-gradient(125deg, #ffffff, #eaf2fc 72%, #fff7dc); }
:root[data-theme="light"] .meta-line span { border-color: #cad6e6; background: rgba(255,255,255,.76); }
:root[data-theme="light"] .journey-strip { border-color: #ccd8e8; background: #ccd8e8; }
:root[data-theme="light"] .ui-button { border-color: #d2dbea; background: rgba(255,255,255,.78); }

.masthead::after {
  content: "";
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  right: -115px;
  top: -235px;
  border: 72px solid rgba(247,185,0,.12);
}

.masthead::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0 12%, var(--accent) 12% 42%, transparent 42%);
}

.brand-row, .hero-actions, .journey-strip { position: relative; z-index: 1; }
.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-logo { width: 54px; height: 54px; border-radius: 17px; box-shadow: 0 10px 28px rgba(0,0,0,.22); }
.brand-wordmark { display: grid; line-height: 1.05; }
.brand-wordmark strong { font-size: 20px; letter-spacing: .01em; }
.brand-wordmark span { margin-top: 7px; color: var(--ink-faint); font-size: 10px; letter-spacing: .34em; text-transform: uppercase; }

.masthead h1 { max-width: 16ch; font-size: clamp(2.55rem, 5.2vw, 4.75rem); line-height: .99; letter-spacing: -.052em; }
.standfirst { max-width: 67ch; font-size: clamp(1.05rem, 2vw, 1.25rem); }
.meta-line span { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 10px; border: 1px solid #2a4670; border-radius: 999px; background: rgba(4,13,29,.34); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.ui-button {
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: 13px;
  padding: 10px 14px;
  background: var(--surface-sunk);
  color: var(--ink);
  font: 700 14px var(--body);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.ui-button:hover { transform: translateY(-2px); border-color: rgba(255,184,0,.55); }
.ui-button.primary { border-color: transparent; color: #07152c; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); box-shadow: 0 9px 26px rgba(247,185,0,.2); }

.journey-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  max-width: 1120px;
  margin-top: 32px;
  border: 1px solid #26456f;
  border-radius: 16px;
  overflow: hidden;
  background: var(--rule);
}
.journey-step { min-height: 102px; padding: 18px; background: rgba(3,10,23,.72); }
:root[data-theme="light"] .journey-step { background: rgba(255,255,255,.9); }
.journey-step small { display: block; color: var(--accent); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.journey-step strong { display: block; margin-top: 8px; font-size: 17px; }
.journey-step p { margin: 5px 0 0; font-size: 13.5px; color: var(--ink-soft); }

.layout { grid-template-columns: 224px minmax(0, 1fr); gap: clamp(30px, 4vw, 56px); }
nav.toc { top: 24px; padding: 18px; border: 1px solid var(--rule); border-radius: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(20px); box-shadow: 0 18px 50px rgba(0,0,0,.12); }
nav.toc h2 { color: var(--accent); }
nav.toc a { border-radius: 10px; padding-block: 8px; }
nav.toc a:hover { background: var(--accent-soft); }
nav.toc a.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }

main { min-width: 0; }
section { position: relative; }
section + section { margin-top: 88px; }
.sec-head { border-top: 0; padding: 0 0 14px; border-bottom: 1px solid var(--rule); }
.sec-num { color: var(--accent); }
h2.sec-title { font-size: clamp(1.8rem, 3vw, 2.55rem); letter-spacing: -.035em; }
h3 { font-size: 1.22rem; color: var(--ink); }
p, ul, ol.steps { max-width: 74ch; }
.lede { border-left-width: 3px; background: linear-gradient(90deg, rgba(22,55,99,.65), transparent); border-radius: 0 14px 14px 0; padding: 15px 18px; }

.tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tab { border-radius: 16px; padding: 18px; background: linear-gradient(145deg, var(--surface), #0b1a32); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
:root[data-theme="light"] .tab { background: linear-gradient(145deg, #fff, #edf3fa); }
.tab:hover { transform: translateY(-3px); border-color: rgba(255,184,0,.4); box-shadow: 0 14px 34px rgba(0,0,0,.12); }
.tab h4::before { content: "•"; color: var(--accent); margin-right: 8px; }

.note { border: 1px solid rgba(255,184,0,.24); border-radius: 17px; }
.formula { border-radius: 15px; border-color: rgba(255,184,0,.22); color: var(--ink); }
.pill { border-radius: 999px; }

.shot {
  display: block;
  width: min(100%, 720px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0,0,0,.2);
}
.shot__open { display: block; position: relative; width: 100%; padding: 0; border: 0; background: #07101f; cursor: zoom-in; overflow: hidden; }
.shot__open::after { content: "Agrandir"; position: absolute; right: 14px; bottom: 14px; padding: 7px 10px; border-radius: 10px; color: #fff; background: rgba(5,11,24,.76); backdrop-filter: blur(10px); font: 700 12px var(--body); opacity: 0; transform: translateY(6px); transition: .2s ease; }
.shot__open:hover::after { opacity: 1; transform: translateY(0); }
.shot__open img { display: block; width: 100%; height: clamp(220px, 28vw, 350px); object-fit: cover; object-position: top center; transition: transform .45s ease; }
.shot__open:hover img { transform: scale(1.012); }
.shot figcaption { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 14px 16px 16px; border-top: 3px solid var(--accent); }
.shot__tag { grid-row: 1 / span 2; border-radius: 12px; color: #07101f; }
.shot__body strong { font-family: var(--body); font-size: 15px; }
.shot__body p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13.5px; }
.shot__file { display: none; }

.lightbox { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 24px; background: rgba(0,4,12,.9); backdrop-filter: blur(14px); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: min(1500px, 95vw); max-height: 88vh; border-radius: 18px; box-shadow: 0 34px 100px rgba(0,0,0,.55); }
.lightbox__close { position: fixed; top: 20px; right: 22px; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.24); border-radius: 14px; color: #fff; background: rgba(255,255,255,.08); font-size: 26px; cursor: pointer; }

.back-to-top { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 48px; height: 48px; border: 1px solid var(--rule); border-radius: 15px; background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 12px 38px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .55s ease, transform .55s ease; }
.reveal.visible { opacity: 1; transform: none; }

footer.end { max-width: none; border-color: var(--accent); padding: 24px; border-radius: 18px 18px 0 0; background: var(--surface); }

@media (max-width: 860px) {
  body {
    background: linear-gradient(180deg, #06132a 0, var(--bg) 32rem);
    overflow-x: hidden;
  }
  .wrap { width: 100%; max-width: none; padding: 0 16px 52px; }
  .masthead {
    margin: 0 0 28px calc(50% - 50vw);
    padding: 22px 18px 30px;
    border-radius: 0;
    box-shadow: none;
  }
  .masthead::after {
    width: 235px;
    height: 235px;
    right: -92px;
    top: -126px;
    border-width: 38px;
  }
  .brand-row { gap: 11px; margin-bottom: 24px; }
  .brand-logo { width: 46px; height: 46px; border-radius: 14px; }
  .brand-wordmark strong { font-size: 18px; }
  .brand-wordmark span { margin-top: 5px; font-size: 9px; }
  .kicker { margin-bottom: 9px; font-size: 11px; letter-spacing: .12em; }
  .masthead h1 {
    max-width: 14ch;
    margin-bottom: 14px;
    font-size: clamp(2.25rem, 10.5vw, 3.1rem);
    line-height: 1.01;
    letter-spacing: -.047em;
    text-wrap: balance;
  }
  .standfirst { max-width: 38rem; font-size: .98rem; line-height: 1.55; }
  .journey-strip {
    display: flex;
    gap: 11px;
    width: calc(100vw - 18px);
    max-width: none;
    margin: 24px -2px 0;
    padding: 0 18px 8px 0;
    overflow-x: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .journey-strip::-webkit-scrollbar { display: none; }
  .journey-step {
    flex: 0 0 min(78vw, 310px);
    min-height: 0;
    padding: 16px;
    border: 1px solid #26456f;
    border-radius: 14px;
    scroll-snap-align: start;
  }
  .layout {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  nav.toc {
    width: auto;
    margin-inline: -16px;
    margin-bottom: 30px;
    padding: 9px 16px;
    border: 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    background: rgba(3, 8, 23, .92);
    backdrop-filter: blur(18px);
  }
  nav.toc ol { scroll-padding-inline: 16px; }
  nav.toc a { min-height: 38px; padding: 8px 10px; font-size: 13.5px; align-items: center; }
  nav.toc a.active { box-shadow: none; }
  main { width: 100%; min-width: 0; }
  section { width: 100%; min-width: 0; scroll-margin-top: 74px; }
  section + section { margin-top: 62px; }
  h2.sec-title { font-size: clamp(1.75rem, 8vw, 2.2rem); }
  h3 { margin-top: 25px; font-size: 1.12rem; }
  p, li { font-size: 15.5px; }
  ul, ol.steps { padding-left: 18px; }
  .lede { padding: 13px 14px; font-size: 1rem; }
  .tabs { grid-template-columns: 1fr; }
  .tab { padding: 16px; }
  .scroll-x {
    width: 100vw;
    margin-inline: calc(50% - 50vw);
    padding-inline: 16px;
    overscroll-behavior-inline: contain;
  }
  .scroll-x table { min-width: 620px; }
  .scroll-x table.perm { min-width: 570px; }
  .formula { white-space: normal; overflow-wrap: anywhere; }
  .shot { width: 100%; max-width: 680px; margin: 18px 0 24px; }
  .shot__open img { height: clamp(190px, 54vw, 315px); }
  .shot figcaption { grid-template-columns: 32px 1fr; }
  .lightbox { padding: 10px; }
  .lightbox img { max-width: 100%; max-height: 84vh; border-radius: 12px; }
  .lightbox__close { top: 10px; right: 10px; }
  .back-to-top { right: 14px; bottom: 14px; width: 44px; height: 44px; }
  .reveal { opacity: 1; transform: none; }
}

@media (max-width: 540px) {
  .masthead h1 { max-width: 12ch; }
  .shot { width: 100%; border-radius: 14px; }
  .shot__open img { height: clamp(180px, 52vw, 225px); }
  .shot__open::after { display: none; }
  .shot figcaption { gap: 10px; padding: 12px 13px 14px; }
  .shot__body strong { font-size: 14px; }
  .shot__body p { font-size: 13px; line-height: 1.45; }
  .note { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-sunk: #f4f4f4; --ink: #111; --ink-soft: #444; --ink-faint: #666; --rule: #ddd; --accent: #c47d00; }
  body { background: #fff; }
  body::before, .reading-progress, nav.toc, .hero-actions, .back-to-top, .lightbox { display: none !important; }
  .masthead { margin-top: 0; box-shadow: none; }
  .layout { display: block; }
  section { break-inside: avoid; }
  .shot { box-shadow: none; break-inside: avoid; }
  .reveal { opacity: 1; transform: none; }
}
