/* ==========================================================================
   Build It with AI — DigiCollab
   Shared design system. Plain CSS, no build step, works offline.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Brand (from the DigiCollab logo) */
  --brand-ink: #1f1140;
  --brand-ink-2: #2d1b5c;
  --brand-amber: #f5a300;
  --brand-amber-2: #ffc23d;
  --brand-slate: #34374f;

  /* Light theme */
  --bg: #faf8f4;
  --bg-soft: #f3efe7;
  --surface: #ffffff;
  --surface-2: #f6f3ee;
  --text: #1f1140;
  --text-muted: #5d5872;
  --border: #e6e0d6;
  --border-strong: #cfc6b8;
  --primary: #2d1b5c;
  --primary-hover: #1f1140;
  --on-primary: #ffffff;
  --accent: #f5a300;
  --accent-soft: #fff4d9;
  --on-accent: #2a1a00;
  --link: #5a37c4;
  --code-bg: #1a1033;
  --code-text: #f1ecff;
  --code-muted: #a79fc7;
  --success: #1f8a4c;
  --success-soft: #e3f5ea;
  --danger: #c0392b;
  --danger-soft: #fde8e5;
  --info: #2563a8;
  --info-soft: #e5eefa;
  --warn: #9a6200;
  --warn-soft: #fff4d9;
  --shadow-sm: 0 1px 2px rgba(31, 17, 64, .06), 0 1px 3px rgba(31, 17, 64, .05);
  --shadow: 0 4px 16px rgba(31, 17, 64, .08), 0 1px 3px rgba(31, 17, 64, .06);
  --shadow-lg: 0 18px 50px rgba(31, 17, 64, .16);

  /* Type & layout */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --header-h: 64px;
  --sidebar-w: 280px;
  --content-w: 820px;
  --gutter: 16px;
  --fs-base: 17px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0a1f;
    --bg-soft: #140d28;
    --surface: #19122e;
    --surface-2: #221a3b;
    --text: #f1eefb;
    --text-muted: #aba4c6;
    --border: #2f2650;
    --border-strong: #463b70;
    --primary: #f5a300;
    --primary-hover: #ffc23d;
    --on-primary: #1f1140;
    --accent: #f5a300;
    --accent-soft: #2e2410;
    --on-accent: #1f1140;
    --link: #c6b3ff;
    --code-bg: #0b0716;
    --success: #4ccb82;
    --success-soft: #11291c;
    --danger: #ff7a6b;
    --danger-soft: #331512;
    --info: #7fb2f0;
    --info-soft: #112034;
    --warn: #ffc23d;
    --warn-soft: #2e2410;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0a1f;
  --bg-soft: #140d28;
  --surface: #19122e;
  --surface-2: #221a3b;
  --text: #f1eefb;
  --text-muted: #aba4c6;
  --border: #2f2650;
  --border-strong: #463b70;
  --primary: #f5a300;
  --primary-hover: #ffc23d;
  --on-primary: #1f1140;
  --accent: #f5a300;
  --accent-soft: #2e2410;
  --on-accent: #1f1140;
  --link: #c6b3ff;
  --code-bg: #0b0716;
  --success: #4ccb82;
  --success-soft: #11291c;
  --danger: #ff7a6b;
  --danger-soft: #331512;
  --info: #7fb2f0;
  --info-soft: #112034;
  --warn: #ffc23d;
  --warn-soft: #2e2410;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.65;
  overflow-x: hidden;
}
img, svg, video, iframe { max-width: 100%; }
img { height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 1.6em 0 .55em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 800; margin-top: .2em; }
h2 { font-size: clamp(1.45rem, 3vw, 1.95rem); font-weight: 800; }
h3 { font-size: 1.22rem; font-weight: 700; }
h4 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; margin: 0 0 1em; }
li { margin: .25em 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }
:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .08em .38em;
  border-radius: 6px;
  word-break: break-word;
}
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px 18px;
  border-radius: var(--radius);
  overflow: auto;
  line-height: 1.55;
  font-size: .88rem;
  margin: 0 0 1.2em;
  position: relative;
}
pre code { background: none; border: 0; padding: 0; color: inherit; }
kbd, .kbd {
  display: inline-block;
  padding: .05em .45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-size: .85em;
}
::selection { background: var(--brand-amber-2); color: #1f1140; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: 10px;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand__logo {
  height: 34px; width: auto; display: block;
  background: #fff; border-radius: 9px; padding: 4px 8px;
  box-shadow: var(--shadow-sm);
}
.brand__title { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.brand__title span { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.header-nav a, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 12px;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text); text-decoration: none;
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.header-nav a:hover, .icon-btn:hover { background: var(--surface-2); }
.header-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.header-nav .nav-studio { background: var(--primary); color: var(--on-primary); }
.header-nav .nav-studio:hover { background: var(--primary-hover); }
.icon-btn { padding: 0; width: 40px; }
.icon-btn svg { width: 20px; height: 20px; }
.menu-toggle { display: none; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.layout--full { display: block; }
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 20px 14px 40px;
}
.sidebar__title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; margin: 6px 10px 10px; }
.sidebar__progress { margin: 0 10px 18px; }
.progress-bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar__fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-amber), var(--brand-amber-2)); border-radius: 99px; transition: width .4s ease; }
.progress-label { font-size: .82rem; color: var(--text-muted); margin-top: 6px; }
.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list li { margin: 2px 0; }
.chapter-list a {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: .95rem; line-height: 1.3;
}
.chapter-list a:hover { background: var(--surface-2); }
.chapter-list a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 700; }
.chapter-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 800;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-muted);
}
.chapter-list a[aria-current="page"] .chapter-num { border-color: var(--accent); color: var(--text); }
.chapter-list .is-done .chapter-num { background: var(--success); border-color: var(--success); color: #fff; }
.chapter-day { font-size: .7rem; font-weight: 700; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; border-radius: 99px; }
.sidebar__extra { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

.main { min-width: 0; padding: 36px var(--gutter) 80px; }
.content { max-width: var(--content-w); margin: 0 auto; }
.content--wide { max-width: 1140px; }

/* ---------- Chapter header / footer ---------- */
.chapter-hero { margin-bottom: 28px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.lead { font-size: 1.2rem; color: var(--text-muted); line-height: 1.6; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.goals {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin: 24px 0 8px; box-shadow: var(--shadow-sm);
}
.goals h2, .goals h3 { margin: 0 0 8px; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.goals ul { margin: 0; }
.chapter-footer {
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border);
  display: grid; gap: 16px;
}
.done-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px;
}
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a {
  display: block; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none;
}
.pager a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.pager small { display: block; color: var(--text-muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.pager strong { display: block; margin-top: 2px; }
.pager .pager-next { text-align: right; grid-column: 2; }

/* ---------- Buttons & badges ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-size: .98rem; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--text-muted); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background: var(--brand-amber-2); border-color: var(--brand-amber-2); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn--lg { min-height: 54px; padding: 14px 26px; font-size: 1.08rem; border-radius: 14px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .78rem; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.badge--accent { background: var(--accent-soft); border-color: transparent; color: var(--warn); }
.badge--success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.badge--info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.badge--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 16px; margin: 20px 0; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h3 { margin: 0 0 6px; }
.card--link { text-decoration: none; color: var(--text); display: block; transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease; }
.card--link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.card__icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 12px;
  background: var(--accent-soft); color: var(--warn); font-size: 1.4rem;
}
.card__icon svg { width: 24px; height: 24px; }

/* ---------- Callouts ---------- */
.callout {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px;
  padding: 16px 18px; margin: 22px 0;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface);
}
.callout::before { content: "💡"; font-size: 1.25rem; line-height: 1.4; }
.callout > * { grid-column: 2; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: 2px; }
.callout--tip { background: var(--accent-soft); border-color: transparent; }
.callout--tip::before { content: "💡"; }
.callout--info { background: var(--info-soft); border-color: transparent; }
.callout--info::before { content: "ℹ️"; }
.callout--warn { background: var(--danger-soft); border-color: transparent; }
.callout--warn::before { content: "⚠️"; }
.callout--try { background: var(--success-soft); border-color: transparent; }
.callout--try::before { content: "🧪"; }
.callout--ai { background: linear-gradient(135deg, var(--accent-soft), var(--info-soft)); border-color: transparent; }
.callout--ai::before { content: "🤖"; }

/* ---------- Prompt boxes ---------- */
.prompt-box {
  position: relative;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  margin: 18px 0;
  box-shadow: var(--shadow-sm);
}
.prompt-box__label {
  font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.prompt-box__text { white-space: pre-wrap; font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; }
.prompt-box__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.prompt-box--bad { border-left-color: var(--danger); }
.prompt-box--good { border-left-color: var(--success); }

/* ---------- Compare (bad vs good) ---------- */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 20px 0; }
.compare > div { border-radius: var(--radius); padding: 16px 18px; border: 1px solid var(--border); background: var(--surface); }
.compare .compare__bad { border-top: 5px solid var(--danger); }
.compare .compare__good { border-top: 5px solid var(--success); }
.compare h4 { margin: 0 0 8px; }

/* ---------- Steps ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 20px 0; }
.steps > li {
  counter-increment: step; position: relative;
  padding: 0 0 18px 52px; margin: 0;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 800;
}
.steps > li::after {
  content: ""; position: absolute; left: 17px; top: 40px; bottom: 4px; width: 2px; background: var(--border);
}
.steps > li:last-child::after { display: none; }
.steps > li > strong:first-child { display: block; font-size: 1.05rem; }

/* ---------- Tabs ---------- */
.tabs { margin: 20px 0; }
.tabs__list { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs__list button {
  font: inherit; font-weight: 700; font-size: .95rem;
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 14px; color: var(--text-muted); cursor: pointer; margin-bottom: -1px;
}
.tabs__list button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs__panel[hidden] { display: none; }

/* ---------- Accordion (native details) ---------- */
details.accordion {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  margin: 10px 0; overflow: hidden;
}
details.accordion > summary {
  cursor: pointer; list-style: none; padding: 14px 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
details.accordion > summary::-webkit-details-marker { display: none; }
details.accordion > summary::after { content: "+"; font-size: 1.3rem; color: var(--text-muted); }
details.accordion[open] > summary::after { content: "−"; }
details.accordion > .accordion__body { padding: 0 18px 16px; }

/* ---------- Quiz ---------- */
.quiz {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin: 22px 0; box-shadow: var(--shadow-sm);
}
.quiz__q { font-weight: 700; margin: 0 0 12px; }
.quiz__options { display: grid; gap: 8px; }
.quiz__options button {
  text-align: left; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.quiz__options button:hover:not([disabled]) { border-color: var(--accent); }
.quiz__options button.is-correct { background: var(--success-soft); border-color: var(--success); }
.quiz__options button.is-wrong { background: var(--danger-soft); border-color: var(--danger); }
.quiz__options button[disabled] { cursor: default; }
.quiz__feedback { margin-top: 12px; font-size: .95rem; }
.quiz__feedback:empty { display: none; }

/* ---------- Checklist ---------- */
.checklist { list-style: none; padding: 0; margin: 16px 0; }
.checklist li { margin: 6px 0; }
.checklist label {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
}
.checklist input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--success); flex: none; }
.checklist input:checked + span { color: var(--text-muted); text-decoration: line-through; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
tr:last-child td { border-bottom: 0; }

/* ---------- Figures, frames, live editor ---------- */
figure { margin: 24px 0; }
figcaption { font-size: .88rem; color: var(--text-muted); margin-top: 8px; text-align: center; }
.frame {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow);
}
.frame__bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .8rem; color: var(--text-muted);
}
.frame__bar::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: #ff5f57; box-shadow: 16px 0 0 #febc2e, 32px 0 0 #28c840; margin-right: 38px;
}
.frame iframe { display: block; width: 100%; height: 420px; border: 0; background: #fff; }

.live-editor {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  margin: 22px 0; background: var(--surface); box-shadow: var(--shadow);
}
.live-editor__head {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .82rem; font-weight: 700; color: var(--text-muted);
}
.live-editor textarea {
  width: 100%; min-height: 320px; resize: vertical; border: 0; margin: 0;
  padding: 14px; background: var(--code-bg); color: var(--code-text);
  font-family: var(--font-mono); font-size: .85rem; line-height: 1.55; tab-size: 2;
}
.live-editor textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.live-editor iframe { width: 100%; height: 100%; min-height: 320px; border: 0; background: #fff; display: block; }

/* ---------- Hero (home) ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: clamp(28px, 6vw, 64px);
  background:
    radial-gradient(1200px 400px at 110% -20%, rgba(245, 163, 0, .35), transparent 60%),
    radial-gradient(800px 300px at -10% 120%, rgba(90, 55, 196, .35), transparent 60%),
    var(--brand-ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero h1 { color: #fff; margin: .3em 0 .35em; }
.hero h1 em { font-style: normal; color: var(--brand-amber-2); }
.hero .lead { color: #d9d2f2; max-width: 44em; }
.hero .eyebrow { color: #cfc6ee; }
.hero .btn--ghost { color: #fff; }
.hero .btn--ghost:hover { background: rgba(255, 255, 255, .1); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); }
.footer-logos {
  background: #ffffff; /* logos must stay on white in every theme */
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 28px 44px;
  padding: 22px var(--gutter);
  border-bottom: 1px solid var(--border);
}
.footer-logos img { height: 52px; width: auto; }
.footer-body {
  max-width: 1100px; margin: 0 auto; padding: 22px var(--gutter) 34px;
  display: grid; gap: 12px; font-size: .86rem; color: var(--text-muted); text-align: center;
}
.footer-body p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }

/* ---------- Toast ---------- */
.toast-region { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; width: min(92vw, 420px); }
.toast {
  pointer-events: auto;
  background: var(--brand-ink); color: #fff; border-radius: 12px; padding: 12px 16px;
  box-shadow: var(--shadow-lg); font-size: .95rem; animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Presenter mode ---------- */
body.presenter { --fs-base: 22px; --content-w: 1080px; }
body.presenter .sidebar { display: none; }
body.presenter .layout { grid-template-columns: minmax(0, 1fr); }
body.presenter .main { padding-top: 28px; }
body.presenter pre { font-size: 1.05rem; }
.presenter-badge {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  background: var(--brand-ink); color: #fff; border-radius: 99px; padding: 6px 12px; font-size: .8rem; font-weight: 700;
  box-shadow: var(--shadow); display: none;
}
body.presenter .presenter-badge { display: block; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.stack > * + * { margin-top: 12px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 12px 0; }
.pill-list li { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.form-field { display: grid; gap: 6px; margin: 0 0 14px; }
.form-field label { font-weight: 700; font-size: .92rem; }
.form-field .hint { font-size: .82rem; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="search"], input[type="email"], select, textarea.input {
  width: 100%; font: inherit; font-size: 1rem;
  padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 40;
    width: min(86vw, 320px); height: auto;
    transform: translateX(-105%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  .menu-toggle { display: inline-flex; }
  .brand__title { display: none; }
}
@media (max-width: 720px) {
  :root { --fs-base: 16px; --header-h: 58px; }
  .header-nav .nav-text { display: none; }
  .brand__logo { height: 30px; }
  .main { padding-top: 24px; }
  .live-editor { grid-template-columns: 1fr; }
  .live-editor iframe { min-height: 260px; border-top: 1px solid var(--border); }
  .pager { grid-template-columns: 1fr; }
  .pager .pager-next { grid-column: 1; }
  .footer-logos img { height: 40px; }
  .frame iframe { height: 340px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .sidebar, .chapter-footer, .site-footer .footer-links { display: none !important; }
  .layout { display: block; }
}
