/* ==========================================================================
   Data Swimming Pool — reading site
   Editorial research aesthetic: restrained petrol palette, no decorative
   chrome, typography-led hierarchy. Part tints stay subtle and consistent.
   ========================================================================== */

:root {
  --ink: #15262e;
  --ink-2: #405862;
  --ink-3: #6a808a;
  --paper: #f7f8f8;
  --card: #ffffff;
  --line: #dfe5e8;
  --line-2: #eef2f4;

  --deep: #0a2a36;
  --deep-2: #123a49;
  --accent: #1a6f86;
  --accent-2: #2489a3;
  --accent-soft: #e8f3f6;

  --part: #1a6f86;
  --part2: #2489a3;
  --part-tint: #e8f3f6;

  --warn: #8a5a14;
  --warn-bg: #f8f1e6;
  --warn-line: #e6d4b4;
  --danger: #8b2f3f;
  --danger-bg: #f8ecef;
  --danger-line: #e5c4cb;
  --ok: #1f6b4a;
  --ok-bg: #eaf5ef;
  --ok-line: #c3dfcf;
  --note: #1a5f78;
  --note-bg: #eaf4f8;
  --note-line: #bdd7e2;

  --shadow-s: 0 1px 2px rgba(10, 42, 54, .04);
  --shadow-m: 0 4px 16px rgba(10, 42, 54, .06);

  --sans: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  --topbar-h: 64px;
  --sidebar-w: 300px;
  --rail-w: 220px;
  --column: 880px;
  --measure: 68ch;
}

[data-theme='dark'] {
  --ink: #e6eef1;
  --ink-2: #a8bec7;
  --ink-3: #7d96a0;
  --paper: #081820;
  --card: #0c222c;
  --line: #1a3a46;
  --line-2: #14303a;
  --accent-soft: rgba(36, 137, 163, .14);
  --part-tint: rgba(36, 137, 163, .14);
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-m: 0 6px 20px rgba(0, 0, 0, .4);
  --warn-bg: rgba(196, 140, 40, .1);
  --warn-line: rgba(196, 140, 40, .28);
  --danger-bg: rgba(196, 70, 90, .1);
  --danger-line: rgba(196, 70, 90, .28);
  --ok-bg: rgba(40, 150, 100, .1);
  --ok-line: rgba(40, 150, 100, .28);
  --note-bg: rgba(36, 137, 163, .1);
  --note-line: rgba(36, 137, 163, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }

.skip {
  position: fixed; left: -999px; top: 8px; z-index: 200;
  background: var(--deep); color: #fff; padding: 10px 14px; border-radius: 4px;
}
.skip:focus { left: 12px; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 90;
  display: flex; align-items: center; gap: 18px;
  height: var(--topbar-h);
  padding: 0 22px;
  background: var(--deep);
  color: #e8f1f4;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand { display: flex; align-items: center; gap: 12px; color: #fff; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 3px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  position: relative;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 8px 6px 6px;
  border: 1.5px solid rgba(255, 255, 255, .85); border-radius: 50% / 40%;
  border-top-color: transparent;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b {
  font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: -.01em;
}
.brand-text i {
  font-style: normal; font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(190, 215, 225, .7); font-weight: 500;
}

.searchwrap { position: relative; flex: 1 1 auto; max-width: 420px; margin: 0 auto; }
#q {
  width: 100%; height: 36px; padding: 0 12px;
  border-radius: 4px; border: 1px solid rgba(160, 195, 210, .22);
  background: rgba(255, 255, 255, .07);
  color: #fff; font: 400 13.5px/1 var(--sans);
}
#q::placeholder { color: rgba(190, 215, 225, .55); }
#q:focus {
  outline: none; background: rgba(255, 255, 255, .11);
  border-color: rgba(100, 180, 200, .55);
}

.results {
  position: absolute; top: 44px; left: 0; right: 0;
  max-height: 66vh; overflow-y: auto;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: var(--shadow-m); padding: 4px;
}
.results a { display: block; padding: 9px 11px; border-radius: 4px; color: var(--ink); }
.results a:hover, .results a.sel { background: var(--accent-soft); text-decoration: none; }
.results b { display: block; font-size: 13.5px; font-weight: 600; }
.results span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.results .none { padding: 12px; color: var(--ink-3); font-size: 13px; }
.results mark { background: rgba(36, 137, 163, .2); color: inherit; padding: 0 1px; }

.topactions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.audiobtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 11px;
  border: 1px solid rgba(160, 195, 210, .28); border-radius: 4px;
  background: transparent; color: #d7e7ed;
  font: 600 12.5px/1 var(--sans); letter-spacing: .02em;
  cursor: pointer;
}
.audiobtn:hover { background: rgba(255, 255, 255, .08); border-color: rgba(180, 215, 225, .45); }
.audiobtn:disabled { opacity: .45; cursor: not-allowed; }
.audio-wave { display: flex; align-items: center; gap: 2px; height: 14px; }
.audio-wave i { display: block; width: 1.5px; background: var(--accent-2); }
.audio-wave i:nth-child(1) { height: 5px; }
.audio-wave i:nth-child(2) { height: 11px; }
.audio-wave i:nth-child(3) { height: 14px; }
.audio-wave i:nth-child(4) { height: 8px; }

.iconbtn {
  width: 34px; height: 34px; border-radius: 4px; cursor: pointer; font-size: 14px;
  background: transparent; color: #c5dce4;
  border: 1px solid rgba(160, 195, 210, .2);
}
.iconbtn:hover { background: rgba(255, 255, 255, .08); }

.topactions .ghost {
  color: #b8d0da; font-size: 13px; font-weight: 500; padding: 7px 10px; border-radius: 4px;
}
.topactions .ghost:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }

.pdfbtn {
  display: flex; flex-direction: column; justify-content: center;
  padding: 6px 14px; border-radius: 4px;
  background: #fff; color: var(--deep) !important;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.pdfbtn:hover { background: #eef5f7; text-decoration: none; }
.pdf-ico { display: none; }
.pdf-txt { font-weight: 650; font-size: 13px; line-height: 1.15; letter-spacing: .01em; }
.pdf-sub { font-size: 10px; font-weight: 500; opacity: .65; letter-spacing: .02em; }

/* --------------------------------------------------------- audio reader */

.audio-panel {
  position: fixed; z-index: 180;
  top: calc(var(--topbar-h) + 14px); right: 18px;
  width: min(460px, calc(100vw - 36px));
  max-height: calc(100vh - var(--topbar-h) - 28px);
  overflow-y: auto;
  padding: 24px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 16px 48px rgba(8, 32, 42, .22);
}
.audio-panel[hidden], .audio-backdrop[hidden] { display: none; }
.audio-backdrop {
  position: fixed; inset: var(--topbar-h) 0 0; z-index: 170;
  background: rgba(8, 24, 32, .26);
  backdrop-filter: blur(1px);
}
.audio-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.audio-kicker {
  margin: 0 0 3px; color: var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase;
}
.audio-head h2 {
  margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.015em;
}
.audio-close {
  padding: 5px 0; border: 0; background: transparent; color: var(--ink-3);
  font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
.audio-close:hover { color: var(--ink); }
.audio-intro { margin: 14px 0 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.audio-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.audio-fields label {
  display: flex; flex-direction: column; gap: 5px;
  color: var(--ink-3); font-size: 10.5px; font-weight: 650;
  letter-spacing: .07em; text-transform: uppercase;
}
.audio-fields label:first-child { grid-column: 1 / -1; }
.audio-fields select {
  width: 100%; height: 36px; padding: 0 30px 0 10px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--paper); color: var(--ink);
  font: 500 12.5px/1 var(--sans); text-transform: none; letter-spacing: 0;
}
.audio-fields select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.audio-controls { display: flex; gap: 8px; margin-top: 18px; }
.audio-controls button {
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--card); color: var(--ink-2);
  font: 600 12.5px/1 var(--sans); cursor: pointer;
}
.audio-controls button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.audio-controls button:disabled { opacity: .42; cursor: not-allowed; }
.audio-controls .audio-primary {
  flex: 1; background: var(--deep); border-color: var(--deep); color: #fff;
}
.audio-controls .audio-primary:hover:not(:disabled) { background: var(--deep-2); color: #fff; border-color: var(--deep-2); }
.audio-progress { height: 3px; margin-top: 18px; background: var(--line-2); overflow: hidden; }
.audio-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s linear; }
.audio-status { margin: 9px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.audio-note {
  margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line-2);
  color: var(--ink-3); font-size: 11px; line-height: 1.5;
}

.progress { position: sticky; top: var(--topbar-h); z-index: 88; height: 2px; background: transparent; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.burger { display: none; width: 36px; height: 36px; border: 0; background: transparent; cursor: pointer; padding: 8px; }
.burger span { display: block; height: 1.5px; background: #c5dce4; margin: 5px 0; }

/* --------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
  max-width: 1480px; margin: 0 auto;
}
body.home .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

/* -------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 2px);
  height: calc(100vh - var(--topbar-h) - 2px);
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--card);
}
.sb-inner { padding: 18px 10px 48px; }

.sb-home {
  display: block;
  padding: 8px 12px; margin-bottom: 10px; border-radius: 4px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3);
}
.sb-home:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.sb-home.on { background: var(--accent-soft); color: var(--accent); }

.sb-label {
  display: flex; justify-content: space-between; align-items: center;
  margin: 14px 10px 7px; padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
}
.sb-flat { display: flex; flex-direction: column; gap: 1px; }
.sb-flat a {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: start;
  padding: 7px 9px; border-radius: 3px;
  color: var(--ink-2); text-decoration: none;
  border-left: 2px solid transparent;
}
.sb-flat a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.sb-flat a.on {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  border-left-color: var(--accent);
}
.sb-num {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  color: var(--ink-3); line-height: 1.45; padding-top: 1px;
}
.sb-flat a.on .sb-num { color: var(--accent); }
.sb-title { min-width: 0; font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }

.scrim { display: none; }

/* ----------------------------------------------------------------- main */

main { min-width: 0; padding: 0 clamp(22px, 4vw, 56px) 80px; }

/* ----------------------------------------------------------------- hero */

.hero {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center;
  padding: 56px 0 48px;
}
.eyebrow {
  font-size: 11px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 16px;
}
.hero h1 {
  font-family: var(--serif); font-weight: 650;
  font-size: clamp(42px, 5.6vw, 68px); line-height: .98; letter-spacing: -.028em;
  margin: 0 0 18px; color: var(--deep);
}
[data-theme='dark'] .hero h1 { color: #e8f1f4; }
.lede {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(18px, 1.8vw, 22px); line-height: 1.4;
  color: var(--ink-2); margin: 0 0 12px; max-width: 32ch;
}
.byline { font-size: 14px; color: var(--ink-3); margin: 0 0 28px; }

.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 18px; border-radius: 4px; font-weight: 600; font-size: 14px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--deep); color: #fff; }
.btn.primary:hover { background: var(--deep-2); }
.btn.solid {
  background: transparent; color: var(--deep);
  border: 1px solid var(--line);
}
.btn.solid:hover { border-color: var(--accent); color: var(--accent); }
[data-theme='dark'] .btn.solid { color: var(--ink); }
.btn.ghost {
  border: 1px solid var(--line); color: var(--ink-2); background: transparent;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.stats {
  display: flex; flex-wrap: wrap; gap: 28px; list-style: none;
  padding: 20px 0 0; margin: 0; border-top: 1px solid var(--line);
}
.stats li { display: flex; flex-direction: column; }
.stats b {
  font-family: var(--serif); font-size: 24px; font-weight: 600;
  color: var(--deep); line-height: 1;
}
[data-theme='dark'] .stats b { color: var(--ink); }
.stats span {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin-top: 5px; font-weight: 500;
}

.hero-art { position: relative; }
.hero-art img {
  border-radius: 6px; display: block;
  border: 1px solid var(--line); box-shadow: var(--shadow-m);
}

/* ---------------------------------------------------------------- pitch */

.pitch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 8px 0 56px; background: var(--line); border: 1px solid var(--line); }
.pitch-item {
  position: relative; padding: 24px 22px;
  background: var(--card); border-radius: 0;
}
.pitch-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
}
.pitch-num {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--accent); letter-spacing: .08em;
}
.pitch-item h3 {
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  margin: 8px 0 8px; letter-spacing: -.012em;
}
.pitch-item p { margin: 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.6; }
.pitch-item:nth-child(2)::before,
.pitch-item:nth-child(3)::before { background: var(--accent); }

/* -------------------------------------------------------------- section */

.section { margin: 0 0 56px; }
.sec-title {
  font-family: var(--serif); font-size: 28px; font-weight: 600;
  letter-spacing: -.02em; margin: 0 0 6px;
}
.sec-sub { color: var(--ink-3); margin: 0 0 22px; font-size: 14.5px; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.pcard {
  display: flex; flex-direction: column; padding: 20px 18px 18px;
  border-radius: 4px; background: var(--card); border: 1px solid var(--line);
  color: var(--ink); position: relative;
  transition: border-color .12s ease;
}
.pcard::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: var(--accent);
}
.pcard:hover { border-color: var(--accent); text-decoration: none; }
.pcard-ico {
  display: none;
}
.pcard-kicker {
  font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.pcard h3 {
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  margin: 0 0 8px; letter-spacing: -.01em;
}
.pcard p { margin: 0 0 16px; font-size: 13.8px; color: var(--ink-2); line-height: 1.55; flex: 1; }
.pcard-meta {
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
}

.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tcard {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  border-radius: 4px; background: var(--card); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .12s ease;
}
.tcard:hover { border-color: var(--accent); text-decoration: none; }
.tcard b { font-size: 14.5px; font-weight: 650; }
.tcard span { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }

.notice {
  padding: 22px 24px; border-radius: 4px; margin-bottom: 36px;
  background: var(--warn-bg); border: 1px solid var(--warn-line);
}
.notice h3 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--warn); font-weight: 700;
}
.notice p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--ink-2); }

/* -------------------------------------------------------- chapter pages */

.doc { max-width: var(--column); margin: 0 auto; padding-top: 36px; }

.chead {
  margin-bottom: 30px; padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.crumb { font-size: 12px; color: var(--ink-3); margin: 0 0 12px; letter-spacing: .02em; }
.crumb a { color: var(--ink-3); }
.crumb em { font-style: normal; opacity: .45; margin: 0 6px; }
.chead h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 4vw, 42px); line-height: 1.1; letter-spacing: -.022em;
  margin: 0 0 14px; color: var(--ink);
}
.cmeta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-3); margin: 0;
}
.chip {
  display: inline-flex; align-items: center;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 3px; font-weight: 600; font-size: 11.5px;
  letter-spacing: .02em;
}
.dot { opacity: .4; }

/* ---------------------------------------------------------------- prose */

.prose { font-size: 16.5px; line-height: 1.75; }
.prose > :first-child { margin-top: 0; }
.prose > p, .prose > ul, .prose > ol, .prose > blockquote,
.prose > h2, .prose > h3, .prose > h4, .prose > pre { max-width: var(--measure); }

.prose h2 {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  letter-spacing: -.018em; line-height: 1.2;
  margin: 52px 0 14px; padding-top: 18px;
  border-top: 1px solid var(--line); color: var(--ink);
}
.prose h3 {
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  letter-spacing: -.012em; margin: 34px 0 10px;
}
.prose h4 {
  font-size: 14px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; margin: 26px 0 8px; color: var(--accent);
}

.prose h2 .header-anchor, .prose h3 .header-anchor {
  margin-left: 8px; color: var(--accent); opacity: 0;
  font-weight: 400; text-decoration: none; font-size: .65em;
}
.prose h2:hover .header-anchor, .prose h3:hover .header-anchor { opacity: .45; }

.prose p { margin: 0 0 18px; }
.prose strong { font-weight: 650; color: var(--ink); }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--accent); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 36px 0; }

.prose blockquote {
  margin: 24px 0; padding: 2px 0 2px 18px;
  border-left: 2px solid var(--accent);
  font-family: var(--serif); font-style: italic; font-size: 17.5px; color: var(--ink-2);
}

.prose code {
  font-family: var(--mono); font-size: .84em;
  background: var(--accent-soft); color: var(--accent);
  padding: .12em .36em; border-radius: 3px;
}
.prose pre {
  background: var(--deep); color: #d5e6ec; border-radius: 4px;
  padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.6;
  margin: 22px 0; border: 1px solid rgba(255, 255, 255, .05);
}
.prose pre code { background: none; color: inherit; padding: 0; font-size: 13px; }

.tbl {
  overflow-x: auto; margin: 24px 0; border-radius: 4px;
  border: 1px solid var(--line); background: var(--card);
}
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose thead th {
  background: var(--deep); color: #fff;
  text-align: left; padding: 10px 13px; font-weight: 600; font-size: 12px;
  letter-spacing: .03em; white-space: nowrap;
}
.prose tbody td {
  padding: 10px 13px; border-top: 1px solid var(--line-2);
  vertical-align: top; line-height: 1.55;
}
.prose tbody tr:nth-child(even) { background: rgba(10, 42, 54, .02); }
[data-theme='dark'] .prose tbody tr:nth-child(even) { background: rgba(255, 255, 255, .02); }
.prose tbody tr:hover { background: var(--accent-soft); }
.prose td strong:only-child { color: var(--accent); }

/* Callouts — formal, restrained */
.cal {
  position: relative; margin: 24px 0; padding: 16px 18px 16px 20px;
  border-radius: 4px; font-size: 15px; line-height: 1.65;
  border: 1px solid; border-left-width: 3px;
}
.cal > :last-child { margin-bottom: 0; }
.cal > :first-child { margin-top: 0; }
.cal h3, .cal h4 {
  margin: 0 0 8px !important; padding: 0 !important; border: 0 !important;
  font-size: 15px !important; letter-spacing: 0 !important; text-transform: none !important;
}
.cal-label {
  display: flex; align-items: center; gap: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  margin: 0 0 8px;
}
.cal-dot { display: none; }

.cal-info { background: var(--note-bg); border-color: var(--note-line); color: var(--ink); }
.cal-info .cal-label, .cal-info h3, .cal-info h4 { color: var(--note); }

.cal-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ink); }
.cal-success .cal-label, .cal-success h3, .cal-success h4 { color: var(--ok); }

.cal-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--ink); }
.cal-warning .cal-label, .cal-warning h3, .cal-warning h4 { color: var(--warn); }

.cal-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--ink); }
.cal-danger .cal-label, .cal-danger h3, .cal-danger h4 { color: var(--danger); }

.cal code { background: rgba(0, 0, 0, .05); color: inherit; }
[data-theme='dark'] .cal code { background: rgba(255, 255, 255, .08); }

/* Figures */
.figure, figure {
  position: relative;
  margin: 28px 0; padding: 20px 18px; background: var(--card);
  border: 1px solid var(--line); border-radius: 4px;
  text-align: center;
}
.figure { overflow-x: auto; overflow-y: hidden; }
.figure pre.mermaid {
  background: none; box-shadow: none; border: 0; padding: 0; margin: 0; color: inherit;
  display: flex; justify-content: safe center;
}
.figure svg { max-width: none; height: auto; }
figure svg, figure img { max-width: 100%; height: auto; }

.figure[data-zoomable] { cursor: zoom-in; }
.figure[data-zoomable]::after {
  content: 'Enlarge';
  position: absolute; top: 10px; right: 12px;
  font-size: 10px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 3px 8px; border-radius: 3px; opacity: 0; transition: opacity .12s ease;
  pointer-events: none;
}
.figure[data-zoomable]:hover::after { opacity: 1; }

.lightbox {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(8, 24, 32, .88); padding: 36px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox-inner {
  background: #fff; border-radius: 4px; padding: 22px;
  max-width: 96vw; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-m);
}
[data-theme='dark'] .lightbox-inner { background: #0c222c; }
.lightbox-inner svg { max-width: none; height: auto; }
.lightbox-close {
  position: fixed; top: 16px; right: 18px; width: 38px; height: 38px; border-radius: 4px;
  border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 18px; cursor: pointer;
}

figcaption {
  font-size: 13px; color: var(--ink-3); line-height: 1.55; text-align: left;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2);
}
figcaption strong { color: var(--accent); }

/* --------------------------------------------------------------- pager */

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 52px; padding-top: 26px; border-top: 1px solid var(--line);
}
.pg {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--card);
  color: var(--ink); transition: border-color .12s ease;
}
.pg:hover { border-color: var(--accent); text-decoration: none; }
.pg span {
  font-size: 10.5px; font-weight: 650; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent);
}
.pg b { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.pg.next { text-align: right; }

/* ----------------------------------------------------------------- rail */

.rail { padding: 40px 18px 36px 8px; }
.rail-in { position: sticky; top: calc(var(--topbar-h) + 24px); }
.rail-t {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px;
}
.rail nav {
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line); max-height: 56vh; overflow-y: auto;
}
.rail nav a {
  padding: 4px 10px; font-size: 12.5px; line-height: 1.4; color: var(--ink-3);
  border-left: 1.5px solid transparent; margin-left: -1px;
}
.rail nav a:hover { color: var(--accent); text-decoration: none; }
.rail nav a.on { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.rail-pdf {
  display: block; margin-top: 18px; padding: 10px 12px; border-radius: 4px; text-align: center;
  background: var(--deep); color: #fff;
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
}
.rail-pdf:hover { text-decoration: none; background: var(--deep-2); }

/* --------------------------------------------------------------- footer */

.foot {
  background: var(--deep); color: #a8c4d0;
  margin-top: 32px; padding: 44px clamp(20px, 5vw, 60px) 36px;
}
.foot-grid {
  display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 28px;
  max-width: 1320px; margin: 0 auto;
}
.foot b { display: block; color: #fff; font-size: 13.5px; margin-bottom: 10px; font-weight: 650; }
.foot p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.55; }
.foot a { display: block; color: #8fb6c6; font-size: 13.5px; margin-bottom: 6px; }
.foot a:hover { color: #fff; }
.foot .muted { color: rgba(150, 185, 198, .65); font-size: 12.5px; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .rail { display: none; }
}

@media (max-width: 960px) {
  :root { --topbar-h: 58px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .burger { display: block; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 288px; z-index: 95;
    background: var(--card); transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--shadow-m);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(8, 24, 32, .45); z-index: 94;
  }
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 36px 0; }
  .hero-art { order: -1; }
  .pitch { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .pdf-sub { display: none; }
  .topactions .ghost { display: none; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .brand-text { display: none; }
  .searchwrap { max-width: none; }
  .pdf-txt { display: none; }
  .pdf-ico { display: block; font-size: 15px; font-weight: 700; }
  .pdfbtn { padding: 8px 11px; }
  .audiobtn { width: 34px; padding: 0; justify-content: center; font-size: 0; }
  .audio-panel {
    top: var(--topbar-h); right: 0; bottom: 0;
    width: min(100%, 480px); max-height: none; border-radius: 0; border-bottom: 0; border-right: 0;
    padding: 22px 20px;
  }
  .prose h2 { font-size: 22px; margin-top: 40px; }
  .pager { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr; }
  .stats { gap: 18px; }
}

@media print {
  .topbar, .sidebar, .rail, .pager, .foot, .progress, .scrim { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
