/* ============================================================================
   ChipDesignWorks — shared site stylesheet
   Every page links this file. Change things here, not in eight places.

   Sections:
     1. Design tokens          ← colours, fonts, shader colours live here
     2. Reset & base type
     3. Wordmark
     4. Top navigation
     5. Hero
     6. Sections & headings
     7. Components (cards, lists, boxes, chips, buttons, figures, code)
     8. Footer
     9. Motion & responsive
    10. Reading-shell layout (documentation pages)
   ========================================================================== */


/* ── 1. DESIGN TOKENS ────────────────────────────────────────────────────── */
:root {
  /* palette */
  --navy:       #0f1c2e;
  --navy-mid:   #162338;
  --navy-light: #1e3050;
  --accent:       #d05f31;
  --accent-light: #e2794d;
  --accent-dim:   #a8461f;
  --amber:      #e8a020;
  --white:      #f4f6f8;
  --off-white:  #dde3ea;
  --muted:      #96a7bb;
  --text:       #ccd8e4;
  --border:     rgba(208,95,49,0.18);
  --border-hi:  rgba(208,95,49,0.42);
  --card-bg:    rgba(22,35,56,0.82);

  /* ---- SHADER BACKGROUND ---------------------------------------------------
     Placeholder colours — safe to change to anything, incl. a light scheme.
     c1 is the base/darkest field, c4 the accent that drifts through it.
     --shader-opacity  0 = off, 1 = full strength
     --shader-speed    1 = default drift, 0.5 = half as fast                  */
  --shader-c1:      #0d1826;
  --shader-c2:      #14314a;
  --shader-c3:      #7a3a18;
  --shader-c4:      #d05f31;
  --shader-opacity: 0.55;
  --shader-speed:   1;

  /* typography — Arial body, Arial Black headings */
  --font-body:  Arial, Helvetica, "Helvetica Neue", sans-serif;
  --font-black: "Arial Black", "Arial Bold", "Helvetica Neue", Arial, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* legacy aliases, so any leftover page CSS keeps working */
  --font-sans:  var(--font-body);
  --font-serif: var(--font-black);

  /* ---- TYPE SCALE ----------------------------------------------------------
     Six steps, and nothing outside them. Every font-size in this file (and in
     the pages' own small style blocks) resolves to one of these or to a
     heading size, so the whole site can be re-scaled from right here.        */
  --fs-lead:   20px;     /* lead paragraph under a heading, key bullet lists  */
  --fs-body:   18.5px;   /* running text                                      */
  --fs-sm:     17px;     /* copy inside cards, boxes and lists                */
  --fs-xs:     15px;     /* captions, footers, meta, chips, code              */
  --fs-nav:    16px;     /* navigation links                                  */
  --fs-label:  13px;     /* uppercase mono eyebrows, kickers, tags            */

  /* layout */
  --content-w: 1040px;   /* pages may override this          */
  --topnav-h:  58px;
  --radius:    8px;
}


/* ── 2. RESET & BASE TYPE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  background-color: var(--navy);
  /* static fallback that also enriches the base under the shader */
  background-image:
    radial-gradient(70% 55% at 18% 0%,   rgba(208,95,49,0.10), transparent 70%),
    radial-gradient(60% 50% at 92% 22%,  rgba(30,48,80,0.55),  transparent 72%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

body {
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.72;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* animated shader canvas, injected by assets/shader.js */
#shader-bg {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: -1;
  pointer-events: none;
  display: block;
}

/* faint circuit grid, sits above the shader and below the content */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(208,95,49,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(208,95,49,0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

p { margin-bottom: 1rem; color: var(--text); }
sub, sup { line-height: 0; }

a { color: var(--accent-light); }

/* visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 3px;
  border-radius: 3px;
}

/* skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--navy);
  font-weight: 700; padding: 0.6rem 1rem; border-radius: 0 0 6px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }


/* ── 3. WORDMARK ─────────────────────────────────────────────────────────── */
/* "ChipDesignWorks" in Arial Black: white on dark, black on light. */
.wordmark {
  font-family: var(--font-black);
  font-weight: 900;
  letter-spacing: -0.012em;
  color: #ffffff;
  white-space: nowrap;
}
.wordmark--on-light { color: #000000; }


/* ── 4. TOP NAVIGATION ───────────────────────────────────────────────────── */
nav.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,28,46,0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem;
  padding: 0 2.5rem; height: var(--topnav-h);
}
.nav-logo { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; flex-shrink: 0; }
.nav-logo-mark { height: 40px; display: flex; align-items: center; }
.nav-logo-mark img { height: 40px; width: auto; display: block; }
.nav-logo .wordmark { font-size: 17px; }

.nav-links { display: flex; gap: 1.9rem; list-style: none; align-items: center; }
.nav-links > li { position: relative; }
.nav-links a {
  color: var(--muted); text-decoration: none;
  font-size: var(--fs-nav); font-weight: 400; letter-spacing: 0.01em;
  white-space: nowrap; transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--accent-light); }
.nav-links a[aria-current="page"] { font-weight: 700; }

.dropdown > a::after { content: ' \25BE'; font-size: 0.8em; }
.submenu {
  position: absolute; top: 100%; left: -0.6rem;
  list-style: none; min-width: 220px;
  background: rgba(15,28,46,0.98);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.4rem 0; display: none;
  box-shadow: 0 12px 34px rgba(0,0,0,0.4);
  backdrop-filter: blur(10px);
}
.submenu li { width: 100%; }
.submenu a {
  display: block; padding: 0.6rem 1rem;
  color: var(--muted); font-size: var(--fs-nav);
  transition: background 0.2s, color 0.2s;
}
.submenu a:hover { background: rgba(208,95,49,0.09); color: var(--accent-light); }
/* :focus-within keeps the menu usable by keyboard and on touch devices */
.dropdown:hover > .submenu,
.dropdown:focus-within > .submenu { display: block; }


/* ── 5. HERO ─────────────────────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 1;
  padding: 5rem 2.5rem 2rem;
  max-width: var(--content-w); margin: 0 auto;
}
/* index.html: copy on the left, version card on the right */
.hero--split {
  display: grid; grid-template-columns: 1fr auto;
  gap: 3rem; align-items: center;
  padding-bottom: 3rem;
}
.hero-eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 1rem; display: flex; align-items: center; gap: 0.6rem;
}
.hero-eyebrow::before { content: ''; display: inline-block; width: 28px; height: 1px; background: var(--accent); }

h1 {
  font-family: var(--font-black); font-weight: 900;
  font-size: clamp(1.95rem, 4vw, 2.85rem);
  color: var(--white); line-height: 1.14;
  margin-bottom: 1.2rem; letter-spacing: -0.025em;
  text-transform: none;
}
/* Arial Black has no true italic — emphasise with colour instead */
h1 em, h2 em, h3 em { font-style: normal; color: var(--accent-light); }

.hero-sub {
  font-size: var(--fs-lead); color: var(--text);
  max-width: 640px; line-height: 1.7;
}
.hero-sub b { color: var(--white); font-weight: 700; }
.hero--split .hero-sub { margin-bottom: 2.2rem; }

.version-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.6rem 1.8rem;
  text-align: center; backdrop-filter: blur(8px); min-width: 165px;
}
.version-num {
  font-family: var(--font-black); font-weight: 900; font-size: 2.5rem;
  color: var(--accent-light); line-height: 1; margin-bottom: 0.35rem; letter-spacing: -0.03em;
}
.version-label {
  font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-family: var(--font-mono);
}
.version-date { margin-top: 0.9rem; font-size: var(--fs-xs); color: var(--muted); }


/* ── 6. SECTIONS & HEADINGS ──────────────────────────────────────────────── */
section {
  position: relative; z-index: 1;
  max-width: var(--content-w); margin: 0 auto;
  padding: 3.5rem 2.5rem;
}
section + section { border-top: 1px solid var(--border); }

.section-label {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 0.7rem;
}
h2 {
  font-family: var(--font-black); font-weight: 900; font-size: 1.75rem;
  color: var(--white); line-height: 1.2;
  margin-bottom: 1.4rem; letter-spacing: -0.02em;
}
h3 {
  font-family: var(--font-black); font-weight: 900; font-size: 1.15rem;
  color: var(--white); margin-bottom: 0.5rem; letter-spacing: -0.01em;
}
.lead { font-size: var(--fs-lead); max-width: 740px; line-height: 1.7; }


/* ── 7. COMPONENTS ───────────────────────────────────────────────────────── */

/* buttons */
.cta-row, .hero-cta-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: 1.6rem; }
.hero--split .hero-cta-row { margin-top: 0; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.7rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: var(--navy); font-family: var(--font-black); font-weight: 900;
  font-size: var(--fs-sm); letter-spacing: -0.01em; text-decoration: none;
  padding: 0.85rem 2rem; border-radius: 6px;
  transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
  box-shadow: 0 4px 24px rgba(208,95,49,0.28);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(208,95,49,0.45); filter: brightness(1.08); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--accent-light); font-size: var(--fs-sm); text-decoration: none;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.85rem 1.5rem; transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-secondary:hover { border-color: var(--border-hi); color: var(--white); background: rgba(208,95,49,0.06); }

/* big number */
.bignum-row { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; margin: 1.8rem 0 0.5rem; }
.bignum {
  font-family: var(--font-black); font-weight: 900;
  font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1;
  color: var(--accent-light); letter-spacing: -0.035em; white-space: nowrap;
}
.bignum-note { font-size: var(--fs-sm); color: var(--text); line-height: 1.62; }
.bignum-note b { color: var(--white); font-weight: 700; }
.bignum-sub {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted);
  margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border);
}
.bignum-sub b { color: var(--off-white); }

/* cards */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem 1.5rem;
  backdrop-filter: blur(6px); transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.card p { font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; margin: 0; }
.card-num {
  font-family: var(--font-black); font-weight: 900; font-size: 1.75rem;
  color: var(--accent-light); margin-bottom: 0.3rem; line-height: 1; letter-spacing: -0.03em;
}
.card-kicker {
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem;
}

/* two-column comparison / prose columns */
.compare, .who { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.compare-col, .who-col {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.45rem 1.6rem; backdrop-filter: blur(6px);
}
.compare-col h3 { margin-bottom: 0.9rem; }
.compare-col ul, .who-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.compare-col li {
  position: relative; padding-left: 1.5rem;
  font-size: var(--fs-sm); line-height: 1.55; color: var(--muted);
}
.compare-col li::before { position: absolute; left: 0; top: 0; font-family: var(--font-mono); font-weight: 700; }
.compare-col li.pro { color: var(--off-white); }
.compare-col li.pro::before  { content: '+'; color: var(--accent); }
.compare-col li.con::before  { content: '\2212'; color: var(--amber); }
.compare-col .note { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 0.8rem; line-height: 1.6; }
.compare-col .note:last-child { color: var(--off-white); margin-bottom: 0; }

.who-col h3 { font-size: 1.15rem; margin-bottom: 0.9rem; color: var(--accent-light); }
.who-col li {
  position: relative; padding-left: 1.45rem;
  font-size: var(--fs-sm); line-height: 1.6; color: var(--text);
}
.who-col li::before { content: '\2192'; position: absolute; left: 0; top: 0; font-family: var(--font-mono); color: var(--accent); }
.who-col li b { color: var(--white); font-weight: 700; }

/* numbered ladder */
.ladder { list-style: none; margin-top: 1.6rem; display: flex; flex-direction: column; gap: 0.7rem; counter-reset: step; }
.ladder li {
  position: relative; counter-increment: step;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.4rem 1.1rem 3.5rem;
  backdrop-filter: blur(6px);
}
.ladder li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 1.3rem; top: 1.05rem;
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: 0.06em;
}
.ladder li:last-child { border-color: var(--border-hi); }
.ladder-head { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.ladder-tag { font-family: var(--font-black); font-weight: 900; color: var(--white); font-size: var(--fs-sm); letter-spacing: -0.01em; }
.ladder-dim {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-light);
  background: rgba(208,95,49,0.1); border: 1px solid rgba(208,95,49,0.22);
  border-radius: 4px; padding: 0.12em 0.6em;
}
.ladder li p { font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; margin: 0; }
.ladder li p b { color: var(--off-white); font-weight: 700; }

/* arrow lists */
.cap-list, .rows { list-style: none; margin-top: 1rem; display: flex; flex-direction: column; }
.cap-list { gap: 0.6rem; }
.cap-list li {
  position: relative; padding-left: 1.6rem;
  font-size: var(--fs-lead); color: var(--text); line-height: 1.62;
}
.cap-list li::before { content: '\2192'; position: absolute; left: 0; top: 0; font-family: var(--font-mono); color: var(--accent); }

.rows { gap: 0.5rem; }
.rows li {
  position: relative; font-size: var(--fs-sm); color: var(--text); line-height: 1.6;
  padding: 0.65rem 1rem 0.65rem 1.9rem; border-radius: 6px;
  background: rgba(22,35,56,0.5); border: 1px solid var(--border);
}
.rows li::before {
  content: '\00b7'; position: absolute; left: 1rem; top: 0.55rem;
  font-family: var(--font-mono); color: var(--accent); font-size: 1.3em; line-height: 1.3;
}
.rows b { color: var(--white); font-weight: 700; }

/* highlighted box */
.info-box {
  margin-top: 1.4rem;
  background: rgba(208,95,49,0.06);
  border: 1px solid rgba(208,95,49,0.2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  font-size: var(--fs-sm); color: var(--off-white); line-height: 1.65;
}
.info-box strong { color: var(--accent-light); font-family: var(--font-black); font-weight: 900; letter-spacing: -0.01em; }
.info-box p:last-child { margin-bottom: 0; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 1.1rem 0; }
.chip {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: rgba(208,95,49,0.08); border: 1px solid rgba(208,95,49,0.22);
  color: var(--accent-light); padding: 0.3em 0.75em; border-radius: 4px; letter-spacing: 0.02em;
}
.chip.solid { background: rgba(208,95,49,0.2); color: var(--white); }

/* figures */
.gui-frame {
  margin-top: 1.5rem;
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: var(--card-bg);
  backdrop-filter: blur(6px); text-align: center; padding: 1.5rem;
}
.gui-frame img { width: 72%; max-width: 100%; height: auto; border-radius: 6px; }
.gui-caption, .stage-caption, .shot figcaption, .hub-hint {
  font-size: var(--fs-xs); color: var(--muted); line-height: 1.55;
}
.gui-caption { margin-top: 0.8rem; font-style: italic; }

.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.shot {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; backdrop-filter: blur(6px); text-align: center;
}
.shot img { width: 88%; max-width: 100%; height: auto; border-radius: 4px; }
.shot figcaption { margin-top: 0.6rem; font-style: italic; text-align: left; }

/* code */
pre {
  background: rgba(8,15,26,0.9); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem; overflow-x: auto;
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--off-white);
  line-height: 1.6; margin: 1rem 0;
}
pre .c { color: var(--muted); }
pre .k { color: var(--accent-light); }


/* ── 8. FOOTER ───────────────────────────────────────────────────────────── */
footer {
  position: relative; z-index: 1;
  border-top: 1px solid var(--border);
  padding: 2rem 2.5rem;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  max-width: var(--content-w); margin: 0 auto;
  font-size: var(--fs-xs); color: var(--muted);
}
footer a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--accent-light); }
footer .wordmark { font-size: var(--fs-xs); color: var(--off-white); }


/* ── 9. MOTION & RESPONSIVE ──────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
.hero, section { animation: fadeUp 0.6s ease both; }

@media (max-width: 900px) {
  .gui-frame img { width: 100%; }
}
@media (max-width: 820px) {
  .compare, .who { grid-template-columns: 1fr; }
  .bignum-row { grid-template-columns: 1fr; gap: 0.8rem; }
}
@media (max-width: 680px) {
  /* one step down across the board so the bigger scale still fits a phone */
  :root { --fs-lead: 19px; --fs-body: 18px; --fs-sm: 16.5px; --fs-nav: 15px; }
  /* two-row nav: logo on top, links scroll horizontally below */
  nav.site-nav {
    height: auto; flex-direction: column; align-items: stretch;
    gap: 0.2rem; padding: 0.55rem 0.9rem 0;
  }
  .nav-links {
    gap: 1rem; padding: 0.35rem 0 0.55rem;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .submenu { position: static; display: block; background: none; border: none;
             box-shadow: none; padding: 0; min-width: 0; }
  .submenu li { display: none; }          /* keep the mobile bar to one line */
  .hero, .hero--split { grid-template-columns: 1fr; padding: 3.2rem 1.2rem 2.5rem; }
  .version-card { display: none; }
  section { padding: 2.5rem 1.2rem; }
  footer { flex-direction: column; gap: 0.8rem; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ── 10. READING-SHELL LAYOUT ────────────────────────────────────────────── */
/* Used by <folder>/navigation.html: topnav + site sidebar + chapter sidebar
   + an iframe holding the LaTeX-generated content.                          */
html.reading, html.reading body { height: 100%; overflow: hidden; }
body.reading { display: flex; flex-direction: column; min-height: 0; }

body.reading #topnav {
  position: relative; z-index: 100;
  background: rgba(15,28,46,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem 0 0; height: var(--topnav-h); flex-shrink: 0;
}
body.reading .nav-logo {
  padding: 0 1.1rem; height: 100%;
  border-right: 1px solid var(--border);
}
body.reading .nav-logo-mark, body.reading .nav-logo-mark img { height: 34px; }

#topnav-title {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--muted); letter-spacing: 0.06em;
  flex: 1; padding-left: 1.4rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#topnav-title span { color: var(--accent-light); }

.topnav-links { display: flex; gap: 0; list-style: none; height: 100%; }
.topnav-links li a {
  display: flex; align-items: center; height: 100%; padding: 0 1rem;
  color: var(--muted); text-decoration: none;
  font-size: var(--fs-nav); letter-spacing: 0.01em;
  border-left: 1px solid var(--border);
  transition: color 0.2s, background 0.2s;
}
.topnav-links li a:hover { color: var(--accent-light); background: rgba(208,95,49,0.05); }

#layout { display: flex; flex: 1; overflow: hidden; position: relative; z-index: 1; min-height: 0; }

#sidenav {
  width: 220px; min-width: 220px; flex-shrink: 0;
  background: rgba(12,22,37,0.97);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidenav-section-label, .chaptnav-header {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-dim); padding: 1.1rem 1rem 0.4rem;
}
.sidenav-divider { height: 1px; background: var(--border); margin: 0.5rem 0; }
#sidenav a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.54rem 1rem;
  color: var(--muted); text-decoration: none;
  font-size: var(--fs-nav); line-height: 1.35;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
#sidenav a svg { flex-shrink: 0; opacity: 0.7; }
#sidenav a:hover { color: var(--white); background: rgba(208,95,49,0.06); border-left-color: var(--accent-dim); }
#sidenav a.active { color: var(--accent-light); background: rgba(208,95,49,0.09); border-left-color: var(--accent); font-weight: 700; }

#chaptnav {
  width: 210px; min-width: 210px; flex-shrink: 0;
  background: rgba(15,26,42,0.96);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.chaptnav-header { border-bottom: 1px solid var(--border); }
.toc-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1rem;
  color: var(--accent); text-decoration: none;
  font-family: var(--font-black); font-weight: 900; font-size: var(--fs-xs); letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border); border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s;
}
.toc-link:hover { color: var(--accent-light); background: rgba(208,95,49,0.07); }
#chaptnav a[data-file] {
  display: flex; align-items: baseline; gap: 0.45rem;
  padding: 0.54rem 1rem;
  color: var(--muted); text-decoration: none;
  font-size: var(--fs-xs); line-height: 1.4;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
#chaptnav a[data-file]:hover { color: var(--white); background: rgba(208,95,49,0.06); border-left-color: var(--accent-dim); }
#chaptnav a[data-file].active { color: var(--accent-light); background: rgba(208,95,49,0.09); border-left-color: var(--accent); font-weight: 700; }
.sec-num { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--accent-dim); flex-shrink: 0; }

#bg-iframe { flex: 1; border: none; background: #fff; min-width: 0; }

#sidenav::-webkit-scrollbar, #chaptnav::-webkit-scrollbar { width: 4px; }
#sidenav::-webkit-scrollbar-track, #chaptnav::-webkit-scrollbar-track { background: transparent; }
#sidenav::-webkit-scrollbar-thumb, #chaptnav::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 2px; }

@media (max-width: 900px) {
  #sidenav { display: none; }
  #chaptnav { width: 168px; min-width: 168px; }
  .topnav-links li a { padding: 0 0.7rem; font-size: var(--fs-xs); }
  #topnav-title { display: none; }
}
