:root {
    /* Palette sampled from the cover: night-plum ground, arena firelight, teal signage. */
    --ground:#0b0410; --ground-2:#170a18; --rule-dark:#3a1730;
    --paper:#f3ece1; --paper-2:#e9ded0; --ink:#1a1014; --ink-soft:#4e3b3c;
    --ink-faint:#8b7566; --rule:#ded1bd;
    --fire:#eb341f; --amber:#fe9819; --gold:#ffc93f; --crimson:#8a1220;
    /* Panel: identity, telemetry, and the red of the DOOM status bar right above it. */
    --hud:#e02718; --panel-ink:#f0e6ea; --panel-dim:#9a8a8f;
    --teal:#2fd4c8;
    --code-bg:#160d18;
    --pixel:"Silkscreen","Courier New",monospace;
    --display:"Archivo Black",Impact,"Haettenschweiler",sans-serif;
    --serif:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,"Times New Roman",serif;
    --sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
    --mono:"SF Mono","JetBrains Mono","Menlo",Consolas,monospace;
  }
  * { box-sizing:border-box; }
  html { scroll-behavior:smooth; }
  body { margin:0; background:var(--paper); color:var(--ink); font-family:var(--serif);
    font-size:18px; line-height:1.65; -webkit-font-smoothing:antialiased; }

  .shell { display:grid; grid-template-columns:300px minmax(0,1fr); }

  /* ---------- the cabinet: dark rail, level-select TOC, cover at the foot ---------- */
  .sidebar { position:sticky; top:0; align-self:start; height:100vh; overflow:hidden;
    background:var(--ground); color:#cbb8bd; font-family:var(--sans);
    padding:28px 20px 26px; border-right:2px solid var(--crimson);
    display:flex; flex-direction:column; }
  .brand { display:block; font-family:var(--display); font-size:19px; line-height:1.2;
    color:#f0e6ea; text-decoration:none; padding-bottom:18px; margin-bottom:10px;
    border-bottom:2px solid var(--rule-dark); }
  .brand:hover { color:#fff; }

  /* Only the middle band scrolls, so the cover below it never leaves. */
  nav.toc { font-size:14px; flex:1 1 auto; min-height:0; overflow-y:auto;
    scrollbar-width:thin; scrollbar-color:var(--rule-dark) transparent; }
  nav.toc .toc > ul { counter-reset:sec; }
  nav.toc ul { list-style:none; margin:0; padding:0; }
  nav.toc a { display:block; color:#a08f97; text-decoration:none; padding:5px 10px;
    border-radius:3px; border-left:2px solid transparent; }
  nav.toc a:hover { background:var(--ground-2); color:#f0e6ea; }
  nav.toc a.active { color:#fff; border-left-color:var(--fire);
    background:linear-gradient(90deg, rgba(235,52,31,.24), transparent); }
  /* level 1 = h2: numbered like a level select */
  nav.toc .toc > ul > li > a { font-size:13.5px; color:#e4d7dc; font-weight:600; }
  nav.toc .toc > ul > li > a::before { counter-increment:sec;
    content:counter(sec,decimal-leading-zero) " "; font-family:var(--pixel); font-size:9px;
    color:var(--amber); margin-right:7px; }
  /* levels 2-3 = h3/h4: stepped in, dimmer, tied to the parent by a rail */
  nav.toc ul ul li { border-left:1px solid var(--rule-dark); margin-left:12px; }
  nav.toc ul ul a { padding-left:14px; font-size:12.5px; color:#8d7b84; }
  nav.toc ul ul ul a { padding-left:26px; font-size:12px; }
  nav.toc ul ul a:hover { color:#d8ccd1; }

  .cover { flex:none; padding-top:24px; }
  /* No frame: the artwork has its own dark border, and a second one would outshout the
     fire rule marking the section you are reading. */
  .cover img { display:block; width:100%; max-height:34vh; object-fit:contain; }
  .cover-cap { font-family:var(--pixel); font-size:9px; line-height:1.8; letter-spacing:.08em;
    color:#8d7b84; margin-top:10px; }
  .cover-cap a { color:var(--teal); text-decoration:none; }
  .cover-cap a:hover { color:var(--gold); }

  /* ---------- page ---------- */
  main { padding:0 0 120px; }
  .wrap { max-width:840px; padding:0 44px; margin:0 auto; }
  header.hero { padding:56px 0 0; margin-bottom:34px; }
  h1 { font-family:var(--display); font-weight:400; font-size:44px; line-height:1.06;
    letter-spacing:-.015em; text-wrap:balance; margin:18px 0 18px; color:#140b10; }
  /* The body serif, not the pixel face: a credit line, not another piece of chrome.
     Flex + gap keeps the links apart without separators to clean up when they wrap. */
  .byline { font-size:15px; line-height:1.3; margin:0;
    display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 16px;
    color:var(--ink-faint); }
  .byline b { font-weight:600; color:var(--ink); }
  .byline a { color:var(--crimson); text-decoration:none; }
  .byline a:hover { color:var(--fire); }
  .lede { font-size:20px; line-height:1.55; color:var(--ink-soft); margin-top:20px; }

  /* ---------- the two screens ---------- */
  section.demo { margin:0 0 56px; }
  /* Marquee: episode and seed are the same for both models, so they are stated once. */
  .cabinet { background:var(--ground); border:2px solid #000; border-radius:4px;
    overflow:hidden; box-shadow:0 6px 26px rgba(26,16,20,.28); }
  .sync-strip { display:flex; align-items:center; gap:26px; flex-wrap:wrap;
    font-family:var(--pixel); font-size:12px; letter-spacing:.06em; color:var(--panel-dim);
    padding:14px 15px; border-bottom:2px solid var(--rule-dark); }
  .sync-strip b { font-weight:700; color:var(--panel-ink); }
  /* Subgrid puts head/screen/stats on shared rows, so a name that wraps on one side
     cannot push that screen lower than the other. */
  .demo-grid { display:grid; grid-template-columns:1fr 1fr; grid-template-rows:auto auto auto; }
  .feed { background:var(--ground); min-width:0;
    display:grid; grid-row:span 3; grid-template-rows:subgrid; }
  .feed + .feed { border-left:2px solid var(--rule-dark); }
  /* Pixel = identity and labels, mono = live numbers, serif = the article. The name is
     the first thing to read in a panel, so it is the biggest thing in the chrome. */
  .feed-head { padding:14px 15px 13px; display:flex; flex-direction:column; gap:7px;
    background:var(--ground-2); border-bottom:2px solid var(--rule-dark); }
  .feed-head .feed-name { font-family:var(--pixel); font-weight:700; font-size:12px;
    line-height:1.3; color:var(--panel-ink); letter-spacing:0; white-space:nowrap; }
  .feed-head .tag { font-family:var(--pixel); font-size:10px; letter-spacing:.08em;
    color:var(--panel-dim); }
  /* Marks the model this article is about: gold, so it reads as a badge rather than as
     part of the name, and after it, so both panel headers stay left-aligned.
     line-height:0 stops a star bigger than the name from growing the header band — the
     two panels share that row, so it would push the other one down too. */
  .feed-name .ours { color:var(--gold); font-size:17px; line-height:0;
    vertical-align:-1px; margin-left:7px; }
  .screen-wrap { position:relative; }
  .screen-img { display:block; width:100%; aspect-ratio:4/3; background:#000; object-fit:cover; }
  /* CRT scanlines, over the feed only: texture at a glance, invisible up close */
  .screen-wrap::after { content:""; position:absolute; inset:0; pointer-events:none;
    background:repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
    box-shadow:inset 0 0 34px rgba(0,0,0,.55); }

  .stats { padding:14px 15px 15px; display:flex; flex-direction:column;
    font-family:var(--pixel); }
  .stats .kills { display:flex; align-items:baseline; gap:10px; }
  .stats .kills b { font-weight:700; font-size:26px; line-height:1; color:var(--hud); }
  .stats .kills .lbl { font-size:11px; letter-spacing:.08em; color:var(--panel-dim); }
  .k-meta { font-size:11px; letter-spacing:.04em; color:var(--panel-dim); margin-top:11px; }
  /* Session average, set apart by a rule: the score above is the one number that shouts. */
  /* Pinned to the bottom, so the two averages stay level when one action label wraps. */
  .k-avg { display:flex; align-items:baseline; gap:8px; margin-top:auto;
    padding-top:14px; border-top:1px solid var(--rule-dark); }
  .k-avg .lbl { font-size:11px; letter-spacing:.08em; color:var(--panel-dim); }
  .k-avg b { color:var(--panel-ink); font-weight:700; font-size:14px; }

  /* ---------- article ---------- */
  .prose { counter-reset:h2sec; }
  .prose p, .prose li { text-align:justify; hyphens:auto; -webkit-hyphens:auto; }
  .prose p { margin:16px 0; }
  .prose h2 { font-family:var(--display); font-weight:400; font-size:30px; line-height:1.15;
    letter-spacing:-.01em; margin:58px 0 12px; scroll-margin-top:24px; color:#140b10;
    padding-top:14px; border-top:2px solid var(--rule); }
  .prose h2::before { counter-increment:h2sec;
    content:counter(h2sec,decimal-leading-zero); display:block;
    font-family:var(--pixel); font-size:10px; color:var(--fire); margin-bottom:8px; }
  .prose h3 { font-family:var(--sans); font-weight:700; font-size:19px; margin:36px 0 8px;
    scroll-margin-top:24px; }
  /* One step below h3, same voice: the pixel face belongs to the chrome, not the text. */
  .prose h4 { font-family:var(--sans); font-weight:700; font-size:15.5px; color:var(--ink-soft);
    margin:30px 0 6px; scroll-margin-top:24px; }
  .prose a { color:var(--crimson); text-decoration:none; border-bottom:1px solid var(--rule); }
  .prose a:hover { border-bottom-color:var(--fire); color:var(--fire); }
  .prose strong { font-weight:600; }
  .prose ul, .prose ol { padding-left:22px; }
  .prose li { margin:6px 0; }
  .prose li::marker { color:var(--fire); }
  /* The diagrams have white backgrounds; multiply drops that white into the bone paper. */
  .prose img { display:block; max-width:100%; height:auto; margin:26px auto;
    mix-blend-mode:multiply; }
  .prose code { font-family:var(--mono); font-size:.85em; background:var(--paper-2);
    border:1px solid var(--rule); border-radius:3px; padding:1px 5px; }
  /* Dark code blocks break the bone column, the way the lit arena breaks the cover. */
  .prose pre { margin:22px 0; background:var(--code-bg); border:2px solid #000; border-radius:4px;
    padding:16px 18px; overflow-x:auto; font-family:var(--mono); font-size:13px; line-height:1.6;
    color:#e7dcd8; }
  .prose pre code { background:none; border:0; padding:0; font-size:inherit; color:inherit; }
  .prose table { width:100%; border-collapse:collapse; font-family:var(--sans); font-size:14px;
    margin:22px 0; font-variant-numeric:tabular-nums; }
  .prose th, .prose td { text-align:left; padding:10px 12px; border-bottom:1px solid var(--rule); }
  .prose thead th { font-size:11.5px; font-weight:700; letter-spacing:.07em;
    text-transform:uppercase; color:var(--ink-faint); vertical-align:bottom;
    border-bottom:2px solid var(--ink-faint); }
  .prose blockquote { margin:24px 0; padding:12px 16px; background:var(--paper-2);
    border-left:3px solid var(--fire); font-size:15.5px; color:var(--ink-soft); }
  /* codehilite wraps <pre> in a .codehilite div; keep only the inner <pre> styled */
  .prose .codehilite { background:transparent; margin:0; padding:0; border:0; }
  .prose .codehilite pre { margin:22px 0; }

  @media (min-width:1051px) and (max-width:1180px) {
    .feed-head .feed-name { font-size:11px; }
  }

  @media (max-width:1050px) {
    /* minmax(0,1fr), not 1fr: a bare 1fr takes its minimum from the content, and the
       widest table was stretching the page to 840px. */
    .shell { grid-template-columns:minmax(0,1fr); }
    /* Wide tables scroll inside themselves instead of widening the page. */
    .prose table { display:block; width:max-content; max-width:100%; overflow-x:auto; }
    /* Stacked, the rail becomes a footer: a phone opens on the demo, not on the index. */
    main { order:1; }
    .sidebar { order:2; position:static; height:auto; overflow:visible;
      border-right:0; border-top:2px solid var(--crimson); }
    nav.toc { overflow-y:visible; }
    .cover { margin-top:26px; max-width:220px; }
    .demo-grid { grid-template-columns:1fr; }
    .feed + .feed { border-left:0; border-top:2px solid var(--rule-dark); }
    /* Stacked panels don't need one line, and .cabinet's overflow:hidden would amputate
       the name silently rather than let it scroll. */
    .feed-head .feed-name { white-space:normal; }
    .wrap { padding:0 22px; }
    h1 { font-size:31px; }
    .prose h2 { font-size:25px; }
  }
