  :root {
    --paper: #f3f6fb; --grid: #d6e0ee; --grid-strong: #b7c7de;
    --ink: #1c2b45; --muted: #5b6b85; --panel: #ffffff; --accent: #2f5bd3;
    --f-avant: #ff7f50; --f-arriere: #6c8cff; --f-droite: #19a974; --f-gauche: #e8b10c;
    --f-haut: #b45ad8; --f-bas: #2bb3c0; --face-ink: #ffffff;
    color-scheme: light;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #121a28; --grid: #1f2b40; --grid-strong: #2d3d58;
      --ink: #e4ebf7; --muted: #9aa8c0; --panel: #19233a; --accent: #7fa2ff; color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --paper: #121a28; --grid: #1f2b40; --grid-strong: #2d3d58;
    --ink: #e4ebf7; --muted: #9aa8c0; --panel: #19233a; --accent: #7fa2ff; color-scheme: dark;
  }
  *, *::before, *::after { box-sizing: inherit; }
  html { scroll-padding-top: env(safe-area-inset-top, 0px); }
  body {
    margin: 0; background: var(--paper); color: var(--ink);
    font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 17px; line-height: 1.55;
  }
  main { max-width: 720px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
  h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; }
  h2 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; font-weight: 600; }
  p { margin: 0 0 1rem; color: var(--muted); max-width: 62ch; }
  .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }

  .scene {
    position: relative; width: 100%; height: 440px; margin: 1.25rem 0 1rem;
    border: 1px solid var(--grid-strong); border-radius: 6px; overflow: hidden;
    background-color: var(--panel);
    background-image:
      linear-gradient(var(--grid) 1px, transparent 1px),
      linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center center;
    perspective: 600px;
  }
  .cube {
    position: absolute; top: 50%; left: 50%;
    transform-style: preserve-3d;
  }
  .face {
    position: absolute; display: grid; place-items: center;
    color: var(--face-ink); font-weight: 600; font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, .55);
    opacity: .9;
    transition: transform .9s cubic-bezier(.5, 0, .2, 1);
  }
  .face small { display: block; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .7rem; font-weight: 400; opacity: .85; text-align: center; }
  .avant { background: var(--f-avant); }
  .arriere { background: var(--f-arriere); }
  .droite { background: var(--f-droite); }
  .gauche { background: var(--f-gauche); }
  .haut { background: var(--f-haut); }
  .bas { background: var(--f-bas); }

  .controles { display: grid; gap: .85rem; }
  label.curseur { display: grid; grid-template-columns: 8.5rem 1fr 4.5rem; align-items: center; gap: .75rem; }
  label.curseur span:last-child { text-align: right; }
  input[type="range"] { width: 100%; accent-color: var(--accent); }
  .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .2rem; }
  button {
    font: inherit; font-size: .95rem; padding: .5rem .95rem; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--accent); background: transparent; color: var(--accent);
  }
  button.principal { background: var(--accent); color: var(--panel); }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .panneau {
    background: var(--panel); border: 1px solid var(--grid-strong); border-radius: 6px;
    padding: 1rem 1.1rem; margin-bottom: 1.1rem; overflow-x: auto;
  }
  .panneau .mono { font-size: .85rem; white-space: pre; display: block; }
  .css { color: var(--accent); font-weight: 600; }
  .pastille { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: baseline; }
  @media (prefers-reduced-motion: reduce) { .face { transition: none; } }

/* navigation entre chapitres */
.nav-haut { margin: 0 0 1rem; }
.nav-bas { margin: 2rem 0 0; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.nav-bas .suiv { margin-left: auto; text-align: right; }
.nav-haut a, .nav-bas a { color: var(--accent, #2f5bd3); text-decoration: none; font-weight: 600; }
.nav-haut a:hover, .nav-bas a:hover { text-decoration: underline; }
