/* ============================================================
   Marketing Ops Library: AI Integrations — main.css
   Dark by default. Accent switchable (amber / teal). Light mode.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --ink:        #0f0f12;
  --surface:    #15151a;
  --surface-2:  #1b1b22;
  --surface-3:  #232330;
  --paper:      #f1eee9;
  --muted:      #b6b2a9;
  --faint:      #8c887f;
  --line:       rgba(255,255,255,0.09);
  --line-2:     rgba(255,255,255,0.15);
  --shadow:     0 1px 2px rgba(0,0,0,0.4), 0 8px 30px rgba(0,0,0,0.28);

  --accent:     #d4860a;
  --accent-soft:rgba(212,134,10,0.14);
  --accent-line:rgba(212,134,10,0.32);
  --accent-ink: #f3b24e;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap:  1140px;
  --read:  760px;
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 64px;
  --ease: 150ms ease;
}

:root[data-accent="teal"] {
  --accent:     #00c9a7;
  --accent-soft:rgba(0,201,167,0.13);
  --accent-line:rgba(0,201,167,0.30);
  --accent-ink: #46e0c4;
}

:root[data-theme="light"] {
  --ink:        #fbfaf7;
  --surface:    #ffffff;
  --surface-2:  #f6f3ec;
  --surface-3:  #eee9df;
  --paper:      #1c1b18;
  --muted:      #56544d;
  --faint:      #7c786f;
  --line:       rgba(20,18,14,0.12);
  --line-2:     rgba(20,18,14,0.20);
  --shadow:     0 1px 2px rgba(40,34,22,0.06), 0 10px 30px rgba(40,34,22,0.07);
}
:root[data-theme="light"][data-accent="amber"]  { --accent:#b06f06; --accent-ink:#8a5505; --accent-soft:rgba(176,111,6,0.10); --accent-line:rgba(176,111,6,0.28); }
:root[data-theme="light"][data-accent="teal"]   { --accent:#0a8c75; --accent-ink:#076553; --accent-soft:rgba(10,140,117,0.10); --accent-line:rgba(10,140,117,0.26); }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 24px); -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background var(--ease), color var(--ease);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--paper); }

/* ---------- Reading progress bar ---------- */
#read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--accent); z-index: 200; transition: width 80ms linear;
}

/* ---------- Top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 100; height: var(--nav-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav__brand { display: flex; align-items: center; gap: 11px; font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: 0.2px; white-space: nowrap; }
.nav__brand:hover { opacity: 0.85; }
.brand-text { display: flex; flex-direction: column; line-height: 1.04; }
.brand-name { font-family: var(--serif); font-weight: 500; font-size: 18px; letter-spacing: 0.2px; }
.brand-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent-ink); margin-top: 3px; }
.footer__brand .brand-name { font-size: 19px; }
.mark { width: 30px; height: 30px; flex: none; position: relative; display: grid; place-items: center; }
.mark svg { width: 30px; height: 30px; }
.nav__spacer { flex: 1; }
.nav__links { display: flex; align-items: center; gap: 6px; }
.nav__item { position: relative; }
.nav__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14.5px; font-weight: 500;
  background: none; border: none; cursor: pointer; font-family: var(--sans);
  transition: color var(--ease), background var(--ease);
}
.nav__btn:hover, .nav__btn[aria-expanded="true"] { color: var(--paper); background: var(--surface-2); }
.nav__btn.is-active { color: var(--accent-ink); }
.dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 248px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 7px; opacity: 0; visibility: hidden;
  transform: translateY(-5px); transition: all var(--ease); z-index: 110;
}
.nav__item.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown a { display: flex; align-items: baseline; gap: 9px; padding: 9px 11px; border-radius: var(--radius-sm); transition: background var(--ease); }
.dropdown a:hover { background: var(--surface-2); }
.dropdown .dd-n { font-family: var(--mono); font-size: 11px; color: var(--accent-ink); }
.dropdown .dd-t { font-size: 14.5px; color: var(--paper); }
.iconbtn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  transition: all var(--ease); font-size: 17px;
}
.iconbtn:hover { color: var(--paper); border-color: var(--line-2); }
.accent-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.accent-switch button { padding: 7px 11px; background: var(--surface-2); border: none; color: var(--faint); font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: var(--sans); transition: all var(--ease); }
.accent-switch button.on { color: var(--ink); background: var(--accent); }
:root[data-theme="light"] .accent-switch button.on { color: #fff; }

/* reading-mode switch (Standard / Plain) */
.mode-switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; flex: none; }
.mode-switch button { padding: 7px 13px; background: var(--surface-2); border: none; color: var(--muted); font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: var(--sans); transition: all var(--ease); white-space: nowrap; }
.mode-switch button:hover { color: var(--paper); }
.mode-switch button.on { color: var(--ink); background: var(--accent); }
:root[data-theme="light"] .mode-switch button.on { color: #fff; }
.mode-switch--mobile { width: 100%; margin-bottom: 14px; }
.mode-switch--mobile button { flex: 1; padding: 12px; font-size: 15px; }

.nav__menu-toggle { display: none; }

/* ---------- Layout helpers ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 26px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--accent-ink); }
.serif { font-family: var(--serif); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 500; font-family: var(--sans);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--paper);
  cursor: pointer; transition: all var(--ease); white-space: nowrap;
}
.btn:hover { border-color: var(--accent-line); background: var(--surface-3); transform: translateY(-1px); }
.btn--primary { background: var(--accent); color: var(--ink); border-color: transparent; }
:root[data-theme="light"] .btn--primary { color: #fff; }
.btn--primary:hover { background: var(--accent-ink); color: var(--ink); }
:root[data-theme="light"] .btn--primary:hover { color: #fff; }
.btn--ghost { background: none; }
.btn--sm { padding: 8px 13px; font-size: 13.5px; }

/* ---------- Hero (home) ---------- */
.hero { padding: 86px 0 54px; position: relative; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
.hero__eyebrow { margin-bottom: 22px; }
.hero h1 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(40px, 7vw, 76px);
  line-height: 1.04; letter-spacing: -0.5px; max-width: 14ch;
}
.hero h1 em { font-style: italic; color: var(--accent-ink); }
.hero__sub { margin-top: 24px; max-width: 56ch; font-size: 19px; color: var(--muted); line-height: 1.6; }
.hero__meta { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 10px 26px; font-size: 14px; color: var(--faint); }
.hero__meta b { color: var(--paper); font-weight: 500; }
.hero__note { margin-top: 26px; max-width: 62ch; font-size: 14.5px; color: var(--muted); line-height: 1.62; padding: 13px 18px; border-radius: var(--radius-sm); background: var(--accent-soft); border-left: 3px solid var(--accent); }
.hero__note i { color: var(--accent-ink); margin-right: 6px; vertical-align: -1px; }
.hero__note strong { color: var(--accent-ink); font-weight: 500; }

/* ---------- Section scaffolding ---------- */
.section { padding: 66px 0; border-bottom: 1px solid var(--line); }
.section__head { max-width: var(--read); margin-bottom: 40px; }
.section__head h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 4vw, 40px); line-height: 1.12; letter-spacing: -0.3px; }
.section__head p { margin-top: 16px; color: var(--muted); font-size: 18px; }

/* ---------- Course cards ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 26px 22px; transition: all var(--ease); overflow: hidden;
}
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--card-c, var(--accent)); opacity: 0.85; }
.card:hover { border-color: var(--line-2); transform: translateY(-3px); box-shadow: var(--shadow); }
.card__n { font-family: var(--mono); font-size: 12px; color: var(--faint); letter-spacing: 1.5px; }
.card__title { font-family: var(--serif); font-weight: 500; font-size: 27px; margin-top: 8px; line-height: 1.1; }
.card__tag { color: var(--accent-ink); font-size: 14.5px; margin-top: 7px; font-weight: 500; }
.card__blurb { color: var(--muted); font-size: 15.5px; margin-top: 13px; line-height: 1.62; flex: 1; }
.card__stats { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 20px; }
.chip { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 100px; padding: 4px 11px; }
.card__actions { display: flex; gap: 10px; margin-top: 20px; }
.card__actions .btn { flex: 1; justify-content: center; }

/* ---------- "What's inside" rows ---------- */
.rows { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 230px 1fr; gap: 30px; padding: 26px 28px; background: var(--surface); border-bottom: 1px solid var(--line); transition: background var(--ease); }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }
.row__label { }
.row__label .row__n { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.row__label h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin-top: 5px; }
.row__label a { display: inline-block; margin-top: 10px; font-size: 13.5px; color: var(--accent-ink); font-weight: 500; }
.row__label a:hover { text-decoration: underline; }
.row ul { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; }
.row li { position: relative; padding-left: 20px; font-size: 15px; color: var(--muted); line-height: 1.5; }
.row li::before { content: ""; position: absolute; left: 0; top: 10px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: 0.7; }

/* ---------- Philosophy block ---------- */
.prose-block { max-width: var(--read); }
.prose-block p { font-size: 19px; line-height: 1.66; color: var(--paper); }
.prose-block p + p { margin-top: 18px; }
.prose-block strong { color: var(--accent-ink); font-weight: 500; }

/* ---------- Course hub ---------- */
.hub-hero { padding: 64px 0 48px; border-bottom: 1px solid var(--line); }
.hub-hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(36px, 6vw, 62px); line-height: 1.05; letter-spacing: -0.4px; margin-top: 16px; }
.hub-hero__tag { color: var(--accent-ink); font-size: 20px; margin-top: 14px; font-weight: 500; }
.hub-hero__blurb { max-width: 60ch; color: var(--muted); font-size: 18px; margin-top: 18px; }
.hub-hero__actions { margin-top: 30px; display: flex; gap: 12px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 56px 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; transition: all var(--ease); }
.panel:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.panel .eyebrow { display: block; margin-bottom: 14px; }
.panel h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; }
.panel p { color: var(--muted); margin-top: 12px; font-size: 16px; }
.panel ul { list-style: none; margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.panel li { position: relative; padding-left: 22px; font-size: 15px; color: var(--muted); }
.panel li::before { content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.panel .btn { margin-top: 22px; }

/* ---------- Course sub-nav ---------- */
.subnav { position: sticky; top: var(--nav-h); z-index: 90; display: flex; align-items: center; gap: 16px; padding: 12px 26px; background: color-mix(in srgb, var(--ink) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.subnav__back { font-size: 13.5px; color: var(--faint); display: inline-flex; align-items: center; gap: 6px; }
.subnav__back:hover { color: var(--paper); }
.subnav__title { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.subnav__sep { width: 1px; height: 20px; background: var(--line-2); }
.subnav__tabs { display: flex; gap: 4px; margin-left: auto; }
.subnav__tabs a { padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; color: var(--muted); transition: all var(--ease); }
.subnav__tabs a:hover { background: var(--surface-2); color: var(--paper); }
.subnav__tabs a.is-active { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Roadmap phase stepper ---------- */
.stepper { display: flex; gap: 0; margin: 40px 0 10px; counter-reset: step; flex-wrap: wrap; }
.step { flex: 1; min-width: 120px; position: relative; padding: 0 4px; text-align: center; cursor: pointer; background: none; border: none; font-family: var(--sans); }
.step__dot { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 13px; color: var(--muted); position: relative; z-index: 2; transition: all var(--ease); }
.step:not(:last-child)::after { content: ""; position: absolute; top: 17px; left: 50%; width: 100%; height: 1px; background: var(--line-2); z-index: 1; }
.step__label { font-size: 13px; color: var(--faint); font-weight: 500; }
.step:hover .step__dot { border-color: var(--accent); color: var(--accent-ink); }
.step:hover .step__label { color: var(--paper); }
.step.done .step__dot { background: var(--accent); border-color: var(--accent); color: var(--ink); }
:root[data-theme="light"] .step.done .step__dot { color:#fff; }

/* ---------- Reader layout (roadmap + textbook) ---------- */
.reader { display: grid; grid-template-columns: 270px minmax(0,1fr); gap: 48px; align-items: start; padding: 36px 0 80px; }
.toc { position: sticky; top: calc(var(--nav-h) + 58px); max-height: calc(100vh - var(--nav-h) - 80px); overflow-y: auto; padding-right: 6px; }
.toc__head { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--faint); margin-bottom: 14px; padding-left: 14px; }
.toc__list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.toc__list a { display: flex; gap: 10px; align-items: baseline; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 14px; color: var(--muted); line-height: 1.35; border-left: 2px solid transparent; transition: all var(--ease); }
.toc__list a:hover { background: var(--surface-2); color: var(--paper); }
.toc__list a.active { color: var(--accent-ink); background: var(--accent-soft); border-left-color: var(--accent); }
.toc__list .toc-n { font-family: var(--mono); font-size: 11px; color: var(--faint); flex: none; padding-top: 2px; }
.toc__list a.active .toc-n { color: var(--accent-ink); }
.toc__done { margin-left: auto; color: var(--accent); opacity: 0; flex: none; }
.toc__list a.complete .toc__done { opacity: 1; }

/* content column */
.content { max-width: var(--read); min-width: 0; }

/* ---------- Markdown rendering ---------- */
.md { font-size: 17px; line-height: 1.75; color: var(--paper); }
.md > *:first-child { margin-top: 0; }
.md h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 4.2vw, 44px); line-height: 1.1; letter-spacing: -0.3px; margin: 8px 0 6px; }
.md h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.16; letter-spacing: -0.2px; margin: 58px 0 4px; padding-top: 14px; scroll-margin-top: calc(var(--nav-h) + 70px); }
.md h2:first-of-type { margin-top: 20px; }
.md h3 { font-family: var(--sans); font-weight: 600; font-size: 21px; margin: 38px 0 10px; color: var(--paper); scroll-margin-top: calc(var(--nav-h) + 70px); }
.md h4 { font-family: var(--sans); font-weight: 600; font-size: 17px; margin: 26px 0 8px; color: var(--accent-ink); text-transform: none; letter-spacing: 0; }
.md p { margin: 14px 0; }
.md a:not(.btn) { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.md a:not(.btn):hover { text-decoration-color: var(--accent); }
.md strong { font-weight: 600; color: var(--paper); }
.md em { font-style: italic; }
.md ul, .md ol { margin: 14px 0; padding-left: 4px; }
.md li { margin: 7px 0; padding-left: 26px; position: relative; list-style: none; }
.md ul > li::before { content: ""; position: absolute; left: 4px; top: 11px; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); opacity: 0.75; }
.md ol { counter-reset: li; }
.md ol > li { counter-increment: li; }
.md ol > li::before { content: counter(li); position: absolute; left: 0; top: 1px; font-family: var(--mono); font-size: 12px; color: var(--accent-ink); width: 18px; text-align: right; }
.md li > ul, .md li > ol { margin: 6px 0; }
.md hr { border: none; height: 1px; background: var(--line); margin: 44px 0; }

/* chapter meta strip (injected) */
.chap-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 14px 0 30px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.chap-meta .rt { font-size: 13.5px; color: var(--faint); display: inline-flex; align-items: center; gap: 7px; }
.mark-complete { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--muted); user-select: none; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 100px; transition: all var(--ease); background: var(--surface-2); }
.mark-complete:hover { border-color: var(--accent-line); color: var(--paper); }
.mark-complete input { display: none; }
.mark-complete .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: all var(--ease); }
.mark-complete .box svg { width: 10px; height: 10px; opacity: 0; }
.mark-complete.checked { color: var(--accent-ink); border-color: var(--accent-line); background: var(--accent-soft); }
.mark-complete.checked .box { background: var(--accent); border-color: var(--accent); }
.mark-complete.checked .box svg { opacity: 1; }

/* tables */
.md .table-wrap { overflow-x: auto; margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius); }
.md table { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 440px; }
.md thead th { background: var(--surface-2); text-align: left; font-weight: 600; padding: 13px 16px; color: var(--paper); border-bottom: 1px solid var(--line-2); font-size: 13px; letter-spacing: 0.3px; }
.md tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.md td strong { color: var(--paper); }

/* blockquote callouts (neutral by default) */
.md blockquote {
  margin: 24px 0; padding: 16px 22px; border-radius: var(--radius-sm);
  background: var(--surface-2); border-left: 3px solid var(--line-2);
  color: var(--paper);
}
.md blockquote p { margin: 6px 0; font-size: 16px; }
.md blockquote p:first-child { margin-top: 0; }
.md blockquote p:last-child { margin-bottom: 0; }
.md blockquote strong { color: var(--paper); }

/* "What This Means in Plain English" — amber callout */
.md blockquote.cl-plain {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.md blockquote.cl-plain .cl-label {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent-ink); font-weight: 600; font-size: 13px;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.md blockquote.cl-plain .cl-label i { font-size: 16px; }
.md blockquote.cl-plain strong { color: var(--accent-ink); }

/* "Real Marketing Business Example" — blue callout */
.md .cl-example {
  margin: 24px 0; padding: 16px 22px 6px; border-radius: var(--radius-sm);
  background: rgba(55,138,221,0.08); border-left: 3px solid #378add;
}
:root[data-theme="light"] .md .cl-example { background: rgba(24,95,165,0.07); }
.md .cl-example__label {
  display: inline-flex; align-items: center; gap: 8px;
  color: #85b7eb; font-weight: 600; font-size: 13px;
  letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 6px;
}
:root[data-theme="light"] .md .cl-example__label { color: #185fa5; }
.md .cl-example__label i { font-size: 16px; }
.md .cl-example > p:last-child { margin-bottom: 12px; }

/* Before / After / Why it works blocks */
.md .ba { border-radius: var(--radius-sm); padding: 13px 18px; margin: 12px 0; border-left: 3px solid; }
.md .ba-before { background: rgba(226,75,74,0.07); border-color: #e24b4a; }
.md .ba-after  { background: rgba(29,158,117,0.08); border-color: #1d9e75; }
.md .ba-why    { background: var(--accent-soft); border-color: var(--accent); }
.md .ba strong:first-child { display: inline-block; font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 2px; }
.md .ba-before strong:first-child { color: #f09595; }
.md .ba-after strong:first-child { color: #5dcaa5; }
.md .ba-why strong:first-child { color: var(--accent-ink); }
:root[data-theme="light"] .md .ba-before strong:first-child { color: #a32d2d; }
:root[data-theme="light"] .md .ba-after strong:first-child { color: #0f6e56; }

/* Inline term definitions: **Term** *(definition)* */
.md em.term-def { font-style: italic; color: var(--faint); font-size: 0.92em; }

/* stat callout (auto-detected source lines) */
.md .stat {
  display: block; margin: 20px 0; padding: 16px 20px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent-ink);
  font-size: 15.5px; color: var(--paper);
}
.md .stat .src { color: var(--faint); font-size: 13px; }

/* inline + block code */
.md code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--line); padding: 1.5px 6px; border-radius: 5px; color: var(--accent-ink); }
.md pre { position: relative; margin: 22px 0; border-radius: var(--radius); border: 1px solid var(--line-2); background: #0c0c10; overflow: hidden; }
:root[data-theme="light"] .md pre { background: #15151b; border-color: rgba(20,18,14,0.18); }
.md pre code { display: block; padding: 20px 22px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; background: none; border: none; color: #e8e6e1; border-radius: 0; }
.md pre .copy { position: absolute; top: 9px; right: 9px; padding: 5px 10px; font-size: 11.5px; font-family: var(--sans); font-weight: 500; color: #b6b2a9; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; cursor: pointer; opacity: 0; transition: all var(--ease); }
.md pre:hover .copy { opacity: 1; }
.md pre .copy:hover { color: #fff; background: rgba(255,255,255,0.12); }
.md pre .copy.done { color: var(--accent-ink); border-color: var(--accent-line); }

/* prev / next chapter */
.chap-nav { display: flex; gap: 14px; margin-top: 56px; padding-top: 30px; border-top: 1px solid var(--line); }
.chap-nav a { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); transition: all var(--ease); }
.chap-nav a:hover { border-color: var(--accent-line); background: var(--surface); }
.chap-nav a.next { text-align: right; align-items: flex-end; }
.chap-nav .dir { font-size: 12px; color: var(--faint); font-family: var(--mono); letter-spacing: 1px; }
.chap-nav .ttl { font-family: var(--serif); font-size: 17px; color: var(--paper); }
.chap-nav a.disabled { opacity: 0.35; pointer-events: none; }

/* ---------- Back to top ---------- */
#to-top { position: fixed; right: 24px; bottom: 24px; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-2); color: var(--paper); display: grid; place-items: center; cursor: pointer; opacity: 0; pointer-events: none; transition: all var(--ease); z-index: 80; box-shadow: var(--shadow); font-size: 18px; }
#to-top.show { opacity: 1; pointer-events: auto; }
#to-top:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 48px 0 56px; margin-top: 10px; }
.footer__grid { display: flex; flex-wrap: wrap; gap: 30px; justify-content: space-between; align-items: flex-start; }
.footer__brand { display: flex; align-items: center; gap: 11px; font-family: var(--serif); font-size: 19px; }
.footer__by { color: var(--faint); font-size: 14px; margin-top: 12px; max-width: 40ch; line-height: 1.6; }
.footer__by a { color: var(--accent-ink); }
.footer__cols { display: flex; gap: 54px; flex-wrap: wrap; }
.footer__col h4 { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; }
.footer__col a { display: block; color: var(--muted); font-size: 14.5px; padding: 4px 0; }
.footer__col a:hover { color: var(--accent-ink); }
.footer__base { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--faint); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 500ms ease, transform 500ms ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .reader { grid-template-columns: 1fr; gap: 0; }
  .toc { position: relative; top: 0; max-height: none; margin-bottom: 24px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); }
  .toc--collapsed .toc__list { display: none; }
  .toc--collapsed #prog-label { display: none; }
  .toc__head { cursor: pointer; display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; padding-left: 0; }
  .toc:not(.toc--collapsed) .toc__head { margin-bottom: 12px; }
}
@media (max-width: 820px) {
  .cards { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: 14px; }
  .row ul { grid-template-columns: 1fr; }
  .nav__links--desktop { display: none; }
  .nav__menu-toggle { display: inline-grid; }
  .subnav { gap: 10px; }
  .subnav__title { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 18px; }
  .nav { padding: 0 16px; gap: 12px; }
  .hero { padding: 56px 0 40px; }
  .section { padding: 48px 0; }
  .card__actions { flex-direction: column; }
  .md h2 { font-size: 25px; }
  .accent-switch { display: none; }
  .nav .mode-switch { display: none; }
  #to-top { right: 14px; bottom: 14px; }
}

/* mobile slide-out menu */
.mobile-menu { position: fixed; inset: 0; z-index: 150; background: var(--ink); padding: 26px; display: none; flex-direction: column; gap: 6px; }
.mobile-menu.open { display: flex; }
.mobile-menu__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.mobile-menu a { padding: 14px 6px; font-family: var(--serif); font-size: 22px; border-bottom: 1px solid var(--line); }
.mobile-menu a .dd-n { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); margin-right: 10px; }

/* ---------- Print ---------- */
@media print {
  .nav, .subnav, #to-top, #read-progress, .toc, .chap-nav, .footer, .accent-switch, .mark-complete, .stepper { display: none !important; }
  body { background: #fff; color: #111; font-size: 12pt; }
  .reader { display: block; padding: 0; }
  .content { max-width: 100%; }
  .md pre { background: #f5f5f5; border: 1px solid #ddd; }
  .md pre code { color: #111; }
  .md a { color: #111; text-decoration: underline; }
}

/* ---------- Loading / empty ---------- */
.loading { display: flex; align-items: center; gap: 12px; padding: 80px 0; color: var(--faint); font-size: 15px; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { max-width: var(--read); margin: 60px auto; padding: 28px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); }
.error-box h3 { font-family: var(--serif); font-size: 22px; margin-bottom: 10px; }
.error-box code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 2px 7px; border-radius: 5px; color: var(--accent-ink); }
