/* ==========================================================================
   ALTITUDE — design system
   Tokens first; every component uses tokens so light/dark both work.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #0a0f1f;
  --bg-2: #0e1530;
  --surface: #131b34;
  --surface-2: #19223f;
  --surface-3: #212b4d;
  --border: #2a3558;
  --border-strong: #3a4775;
  --text: #e8ecf8;
  --text-2: #b6bfd9;
  --muted: #8892b0;
  --accent: #ff9f43;
  --accent-2: #ffcf6e;
  --accent-ink: #1a1206;
  --link: #8ab4ff;
  --good: #34d399;
  --good-bg: rgba(52, 211, 153, .12);
  --bad: #fb7185;
  --bad-bg: rgba(251, 113, 133, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, .12);
  --aha: #c084fc;
  --aha-bg: rgba(192, 132, 252, .13);
  --code-bg: #0b1126;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
  --glow: 0 0 0 1px rgba(255,159,67,.4), 0 0 24px rgba(255,159,67,.25);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sky-1: #0a0f1f;
  --sky-2: #121a3a;
  --sky-3: #1d1b45;
  --star: rgba(255,255,255,.55);

  /* AWS service-category colors (used by diagrams & console mocks) */
  --cat-compute: #f97316;
  --cat-storage: #22c55e;
  --cat-database: #6366f1;
  --cat-networking: #8b5cf6;
  --cat-security: #ef4444;
  --cat-integration: #ec4899;
  --cat-management: #e11d48;
  --cat-analytics: #0ea5e9;
  --cat-client: #94a3b8;
  --cat-ml: #14b8a6;
  --cat-generic: #64748b;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f7fd;
    --bg-2: #e9eefa;
    --surface: #ffffff;
    --surface-2: #f5f7fc;
    --surface-3: #eaeef8;
    --border: #d9e0ef;
    --border-strong: #bcc7e0;
    --text: #141a2e;
    --text-2: #3b4566;
    --muted: #66708f;
    --accent: #e8730c;
    --accent-2: #f59e0b;
    --accent-ink: #ffffff;
    --link: #2557d6;
    --good: #059669;
    --good-bg: rgba(5,150,105,.09);
    --bad: #e11d48;
    --bad-bg: rgba(225,29,72,.08);
    --warn: #b45309;
    --warn-bg: rgba(245,158,11,.12);
    --info: #2563eb;
    --info-bg: rgba(37,99,235,.08);
    --aha: #7c3aed;
    --aha-bg: rgba(124,58,237,.08);
    --code-bg: #f3f5fb;
    --shadow: 0 10px 30px rgba(30, 41, 80, .12);
    --shadow-sm: 0 2px 8px rgba(30, 41, 80, .08);
    --glow: 0 0 0 1px rgba(232,115,12,.4), 0 0 22px rgba(232,115,12,.18);
    --sky-1: #eef3ff;
    --sky-2: #e3ebff;
    --sky-3: #f3e9ff;
    --star: rgba(60,80,140,.18);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fd; --bg-2: #e9eefa; --surface: #ffffff; --surface-2: #f5f7fc; --surface-3: #eaeef8;
  --border: #d9e0ef; --border-strong: #bcc7e0; --text: #141a2e; --text-2: #3b4566; --muted: #66708f;
  --accent: #e8730c; --accent-2: #f59e0b; --accent-ink: #ffffff; --link: #2557d6;
  --good: #059669; --good-bg: rgba(5,150,105,.09); --bad: #e11d48; --bad-bg: rgba(225,29,72,.08);
  --warn: #b45309; --warn-bg: rgba(245,158,11,.12); --info: #2563eb; --info-bg: rgba(37,99,235,.08);
  --aha: #7c3aed; --aha-bg: rgba(124,58,237,.08); --code-bg: #f3f5fb;
  --shadow: 0 10px 30px rgba(30, 41, 80, .12); --shadow-sm: 0 2px 8px rgba(30, 41, 80, .08);
  --glow: 0 0 0 1px rgba(232,115,12,.4), 0 0 22px rgba(232,115,12,.18);
  --sky-1: #eef3ff; --sky-2: #e3ebff; --sky-3: #f3e9ff; --star: rgba(60,80,140,.18);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
body::before { /* the sky */
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, color-mix(in srgb, #7c3aed 16%, transparent), transparent 60%),
    linear-gradient(180deg, var(--sky-1), var(--sky-2) 55%, var(--sky-3));
}
body::after { /* stars */
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .9;
  background-image:
    radial-gradient(1px 1px at 12% 18%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 72% 12%, var(--star), transparent 60%),
    radial-gradient(1.5px 1.5px at 42% 32%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 88% 44%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 22% 66%, var(--star), transparent 60%),
    radial-gradient(1.5px 1.5px at 62% 78%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 8% 88%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 94% 86%, var(--star), transparent 60%);
}
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -.01em; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: .88em; }
kbd {
  display: inline-block; padding: .05em .45em; border-radius: 6px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; background: var(--surface-2); font-size: .8em;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5em; cursor: pointer;
  padding: .6em 1.1em; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .95rem;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  border-color: transparent; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: .35em .8em; font-size: .85rem; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.chip {
  display: inline-flex; align-items: center; gap: .35em; padding: .15em .65em; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.chip.branch { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); border-color: color-mix(in srgb, var(--c) 35%, transparent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: 62px;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #c084fc); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; }
.brand-sub { font-size: .75rem; color: var(--muted); display: block; line-height: 1; margin-top: 2px; }
.topbar .spacer { flex: 1; }
.altimeter {
  display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.altimeter .ring { width: 34px; height: 34px; }
.altimeter .ring circle { fill: none; stroke-width: 4; }
.altimeter .ring .track { stroke: var(--surface-3); }
.altimeter .ring .fill { stroke: url(#altGrad); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.alt-text { line-height: 1.1; }
.alt-text b { font-family: var(--font-display); font-size: .95rem; white-space: nowrap; }
.alt-text span { display: block; font-size: .72rem; color: var(--muted); }
.view-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.view-toggle button { white-space: nowrap; border: 0; background: transparent; padding: .35em .9em; border-radius: 999px; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--text-2); }
.view-toggle button.on { background: var(--surface-3); color: var(--text); }

/* ---------- map view ---------- */
.map-wrap { position: relative; height: calc(100vh - 62px); overflow: hidden; touch-action: none; cursor: grab; }
.map-wrap.dragging { cursor: grabbing; }
.map-svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.map-edge { fill: none; stroke: var(--border-strong); stroke-width: 2; opacity: .55; transition: stroke .3s, opacity .3s; }
.map-edge.lit { stroke: var(--c); opacity: .85; stroke-width: 2.5; }
.map-edge.req { stroke-dasharray: 4 6; stroke-width: 1.3; opacity: .35; }
.map-node { cursor: pointer; }
.map-node .halo { fill: var(--c); opacity: 0; transition: opacity .3s; }
.map-node .disc { fill: var(--surface); stroke: var(--border-strong); stroke-width: 2; transition: stroke .2s, fill .2s; }
.map-node .icon { font-size: 22px; dominant-baseline: central; text-anchor: middle; pointer-events: none; }
.map-node .label {
  fill: var(--text); font-family: var(--font-display); font-weight: 600; font-size: 13px; text-anchor: middle;
  paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none;
}
.map-node .badge { pointer-events: none; }
.map-node.locked .disc { fill: var(--bg-2); stroke-dasharray: 3 4; }
.map-node.locked .icon { opacity: .35; filter: grayscale(1); }
.map-node.locked .label { fill: var(--muted); }
.map-node.available .disc { stroke: var(--c); stroke-width: 3; }
.map-node.available .halo { opacity: .22; animation: pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.map-node.passed .disc { fill: color-mix(in srgb, var(--c) 26%, var(--surface)); stroke: var(--c); stroke-width: 3; }
.map-node:hover .disc { stroke-width: 4; }
.map-node.selected .disc { stroke: var(--text); stroke-width: 4; }
.map-node.root .disc { stroke-width: 4; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .22; } 50% { transform: scale(1.18); opacity: .08; } }
.map-branch-label {
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
  fill: var(--c); opacity: .75; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 5px;
}
.map-controls { position: absolute; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.map-controls .icon-btn { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.map-legend {
  position: absolute; left: 18px; bottom: 18px; z-index: 5; display: flex; gap: 14px; flex-wrap: wrap;
  font-size: .8rem; color: var(--text-2); background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(8px);
}
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; border: 2px solid var(--border-strong); }
.map-legend i.avail { border-color: var(--accent); }
.map-legend i.done { background: color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.map-legend i.lock { border-style: dashed; }
.map-hint { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: .8rem; color: var(--muted); z-index: 4; pointer-events: none; white-space: nowrap; }

/* first-visit card */
.first-visit { position: absolute; left: 0; right: 0; margin: 0 auto; bottom: 24px; z-index: 7; width: min(560px, calc(100% - 32px)); display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: panelIn .35s ease; }
.first-visit .fv-emoji { font-size: 2.2rem; line-height: 1; }
.first-visit b { font-family: var(--font-display); font-size: 1.1rem; }
.first-visit p { margin: 4px 0 10px; font-size: .9rem; color: var(--text-2); }

/* node detail panel */
.node-panel {
  position: absolute; top: 16px; right: 16px; width: min(380px, calc(100% - 32px)); z-index: 6;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 18px 16px; max-height: calc(100% - 100px); overflow: auto;
  animation: panelIn .22s ease;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.node-panel .np-head { display: flex; gap: 12px; align-items: flex-start; }
.node-panel .np-icon { font-size: 30px; width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); flex: none; }
.node-panel h3 { margin: 2px 0 6px; font-size: 1.2rem; }
.node-panel .np-concept { color: var(--text-2); font-size: .92rem; margin: 12px 0; }
.node-panel ul { margin: 6px 0 14px; padding-left: 1.1em; font-size: .88rem; color: var(--text-2); }
.node-panel .np-close { position: absolute; top: 8px; right: 8px; }
.node-panel .np-lock { font-size: .85rem; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 10px; margin-bottom: 12px; }
.np-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- outline (list) view ---------- */
.outline { max-width: 900px; margin: 0 auto; padding: 28px 18px 80px; }
.outline-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 6px; }
.outline-hero p { color: var(--text-2); margin: 0 0 22px; }
.ol-branch { margin: 22px 0; }
.ol-branch > h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .1em; color: var(--c); margin: 0 0 10px; }
.ol-list { list-style: none; margin: 0; padding: 0; }
.ol-list .ol-list { padding-left: 26px; border-left: 2px solid var(--border); margin-left: 18px; }
.ol-item a, .ol-item .ol-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; text-decoration: none; color: var(--text);
  border: 1px solid transparent; margin: 3px 0;
}
.ol-item a:hover { background: var(--surface); border-color: var(--border); }
.ol-item .ol-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, var(--surface-2)); flex: none; }
.ol-item .ol-title { font-weight: 600; flex: 1; }
.ol-item .ol-state { font-size: .8rem; color: var(--muted); }
.ol-item.locked .ol-row { color: var(--muted); }
.ol-item.locked .ol-ico { filter: grayscale(1); opacity: .5; }
.ol-item.passed .ol-state { color: var(--good); }
.ol-item.available .ol-state { color: var(--accent); }

/* ---------- lesson layout ---------- */
.lesson-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; max-width: 1220px; margin: 0 auto; padding: 28px 24px 120px; }
.lesson-toc { position: sticky; top: 86px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; font-size: .88rem; }
.lesson-toc .toc-title { text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.lesson-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.lesson-toc li a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--text-2); text-decoration: none; line-height: 1.35; }
.lesson-toc li a:hover { color: var(--text); }
.lesson-toc li a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.lesson-toc .toc-quiz a { color: var(--accent); font-weight: 600; }
.lesson-main { min-width: 0; max-width: 780px; }
.read-progress { position: fixed; top: 62px; left: 0; height: 3px; background: linear-gradient(90deg, var(--accent), #c084fc); z-index: 49; width: 0; transition: width .1s linear; }

.crumbs { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.lesson-hero { margin-bottom: 26px; }
.lesson-hero .hero-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.lesson-hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin: 0 0 12px; letter-spacing: -.025em; }
.lesson-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.big-idea {
  margin: 22px 0 8px; padding: 18px 20px 18px 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 16%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border)); position: relative; overflow: hidden;
}
.big-idea::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.big-idea .bi-label { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--c); }
.big-idea p { margin: 4px 0 0; font-size: 1.08rem; font-family: var(--font-display); font-weight: 500; line-height: 1.5; }
.learn-list { margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; padding: 0; list-style: none; font-size: .9rem; color: var(--text-2); }
.learn-list li::before { content: '◆'; color: var(--c); font-size: .7em; margin-right: 8px; vertical-align: 2px; }

/* ---------- lesson prose ---------- */
.prose h2 { font-size: 1.65rem; margin: 2.4em 0 .6em; padding-top: .2em; scroll-margin-top: 80px; }
.prose h2 .h-num { color: var(--c, var(--accent)); font-size: .8em; margin-right: .35em; opacity: .9; }
.prose h3 { font-size: 1.22rem; margin: 1.8em 0 .5em; }
.prose h4 { font-size: 1.02rem; margin: 1.4em 0 .4em; color: var(--text-2); }
.prose p { margin: .85em 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .8em 0; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--text); font-weight: 650; }
.prose hr { border: 0; height: 1px; background: var(--border); margin: 2.5em 0; }
.prose blockquote { margin: 1.2em 0; padding: .4em 1.2em; border-left: 3px solid var(--border-strong); color: var(--text-2); font-style: italic; }
.prose blockquote cite { display: block; font-style: normal; font-size: .85em; color: var(--muted); margin-top: .4em; }
.prose :not(pre) > code { background: var(--surface-3); padding: .12em .4em; border-radius: 6px; border: 1px solid var(--border); font-size: .84em; word-break: break-word; }
.prose figure { margin: 1.6em 0; }
.prose figcaption { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .6em; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.prose abbr[title] { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.prose .lead { font-size: 1.15rem; color: var(--text-2); }
.prose a[data-lesson] { color: var(--c-link, var(--accent)); font-weight: 600; text-decoration: none; border-bottom: 1px dashed currentColor; }
.prose a[data-lesson]::before { content: '◈ '; font-size: .8em; }

/* tables */
.table-wrap { overflow-x: auto; margin: 1.3em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: .9rem; line-height: 1.45; }
.prose th, .prose td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface-2); font-family: var(--font-display); font-weight: 600; font-size: .85rem; color: var(--text); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.prose td code, .prose th code { white-space: nowrap; word-break: normal; }
.prose td.yes, .prose td .yes { color: var(--good); font-weight: 600; }
.prose td.no, .prose td .no { color: var(--bad); font-weight: 600; }

/* code */
.code-block { position: relative; margin: 1.2em 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--code-bg); overflow: hidden; }
.code-block .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 6px 14px; font-size: .75rem; color: var(--muted); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 50%, var(--code-bg)); font-family: var(--font-mono); }
.code-block .copy { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: .75rem; padding: 2px 8px; border-radius: 6px; }
.code-block .copy:hover { background: var(--surface-3); color: var(--text); }
.prose pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: .84rem; line-height: 1.6; background: transparent; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
/* syntax colors (works with highlight.js classes) */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #c792ea; }
.hljs-string, .hljs-attr + .hljs-string { color: #c3e88d; }
.hljs-number, .hljs-literal { color: #f78c6c; }
.hljs-comment { color: #6b7699; font-style: italic; }
.hljs-attr, .hljs-property { color: #82aaff; }
.hljs-title, .hljs-function .hljs-title, .hljs-title.function_ { color: #ffcb6b; }
.hljs-variable, .hljs-template-variable { color: #f07178; }
.hljs-meta { color: #89ddff; }
:root[data-theme="light"] .hljs-keyword, :root[data-theme="light"] .hljs-built_in { color: #7c3aed; }
:root[data-theme="light"] .hljs-string { color: #15803d; }
:root[data-theme="light"] .hljs-number, :root[data-theme="light"] .hljs-literal { color: #c2410c; }
:root[data-theme="light"] .hljs-attr, :root[data-theme="light"] .hljs-property { color: #1d4ed8; }
:root[data-theme="light"] .hljs-title { color: #a16207; }
:root[data-theme="light"] .hljs-comment { color: #8a93ad; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .hljs-keyword, :root:not([data-theme="dark"]) .hljs-built_in { color: #7c3aed; }
  :root:not([data-theme="dark"]) .hljs-string { color: #15803d; }
  :root:not([data-theme="dark"]) .hljs-number, :root:not([data-theme="dark"]) .hljs-literal { color: #c2410c; }
  :root:not([data-theme="dark"]) .hljs-attr, :root:not([data-theme="dark"]) .hljs-property { color: #1d4ed8; }
  :root:not([data-theme="dark"]) .hljs-title { color: #a16207; }
  :root:not([data-theme="dark"]) .hljs-comment { color: #8a93ad; }
}

/* ---------- COMPONENTS ---------- */

/* callouts: <div class="callout" data-kind="tip|warn|info|aha|cost|exam|history|danger"> */
.callout { --k: var(--info); --kb: var(--info-bg); position: relative; margin: 1.4em 0; padding: 14px 16px 14px 50px; border-radius: var(--radius-sm); background: var(--kb); border: 1px solid color-mix(in srgb, var(--k) 30%, transparent); }
.callout::before { content: 'ℹ️'; position: absolute; left: 15px; top: 13px; font-size: 1.15rem; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title, .callout > strong:first-child { display: block; color: var(--k); font-family: var(--font-display); margin-bottom: 2px; }
.callout[data-kind="tip"] { --k: var(--good); --kb: var(--good-bg); } .callout[data-kind="tip"]::before { content: '💡'; }
.callout[data-kind="warn"] { --k: var(--warn); --kb: var(--warn-bg); } .callout[data-kind="warn"]::before { content: '⚠️'; }
.callout[data-kind="danger"] { --k: var(--bad); --kb: var(--bad-bg); } .callout[data-kind="danger"]::before { content: '🚨'; }
.callout[data-kind="aha"] { --k: var(--aha); --kb: var(--aha-bg); } .callout[data-kind="aha"]::before { content: '✨'; }
.callout[data-kind="cost"] { --k: var(--warn); --kb: var(--warn-bg); } .callout[data-kind="cost"]::before { content: '💰'; }
.callout[data-kind="history"] { --k: var(--text-2); --kb: var(--surface-2); } .callout[data-kind="history"]::before { content: '📜'; }
.callout[data-kind="exam"] { --k: var(--accent); --kb: color-mix(in srgb, var(--accent) 10%, transparent); } .callout[data-kind="exam"]::before { content: '🎓'; }
.callout[data-kind="new"] { --k: var(--good); --kb: var(--good-bg); } .callout[data-kind="new"]::before { content: '🆕'; }
.callout[data-kind="analogy"] { --k: var(--aha); --kb: var(--aha-bg); } .callout[data-kind="analogy"]::before { content: '🧸'; }

/* stats: <div class="stats"><div class="stat"><b>99.999999999%</b><span>S3 durability</span></div></div> */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 1.4em 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.55rem; line-height: 1.15; background: linear-gradient(135deg, var(--c, var(--accent)), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { font-size: .84rem; color: var(--text-2); line-height: 1.35; display: block; margin-top: 4px; }

/* steps: <ol class="steps"><li><b>Title</b> text</li></ol> */
.prose ol.steps { list-style: none; padding: 0; counter-reset: step; margin: 1.4em 0; }
.prose ol.steps > li { counter-increment: step; position: relative; padding: 0 0 18px 50px; margin: 0; }
.prose ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-family: var(--font-display); background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--surface)); color: var(--c, var(--accent)); border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, transparent); }
.prose ol.steps > li::after { content: ''; position: absolute; left: 15.5px; top: 34px; bottom: 2px; width: 1px; background: var(--border-strong); }
.prose ol.steps > li:last-child::after { display: none; }
.prose ol.steps > li > b:first-child, .prose ol.steps > li > strong:first-child { display: block; font-family: var(--font-display); }

/* terms: <dl class="terms"><dt>Term</dt><dd>Definition</dd></dl> */
.prose dl.terms { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 1.3em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.prose dl.terms dt { font-weight: 700; font-family: var(--font-display); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--c, var(--accent)); }
.prose dl.terms dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: .93rem; }
.prose dl.terms dt:last-of-type, .prose dl.terms dd:last-of-type { border-bottom: 0; }

/* grid of cards: <div class="grid-cards"><div class="gcard"><h4>..</h4><p>..</p></div></div> */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 1.3em 0; }
.gcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.gcard > :first-child { margin-top: 0; }
.gcard > :last-child { margin-bottom: 0; }
.gcard h4 { margin: 0 0 4px; color: var(--text); font-size: 1rem; }
.gcard .gicon { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.gcard p { font-size: .9rem; color: var(--text-2); margin: .4em 0; }

/* pros/cons: <div class="proscons"><div class="pros"><h4>..</h4><ul>..</ul></div><div class="cons">..</div></div> */
.proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 1.3em 0; }
.proscons > div { border-radius: var(--radius-sm); padding: 12px 16px; border: 1px solid var(--border); }
.proscons .pros { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.proscons .cons { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.proscons h4 { margin: 0 0 6px; }
.proscons ul { margin: 0; padding-left: 1.2em; font-size: .92rem; }

/* flip cards: <div class="flipcards"><div class="flip"><div class="front">..</div><div class="back">..</div></div></div> */
.flipcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 1.3em 0; }
.flip { perspective: 900px; min-height: 140px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; min-height: inherit; transition: transform .5s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip .front, .flip .back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--border); font-size: .92rem; }
.flip .front { background: linear-gradient(135deg, var(--surface-2), var(--surface)); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; text-align: center; align-items: center; }
.flip .front::after { content: 'tap to flip ↻'; font-family: var(--font); font-weight: 400; font-size: .72rem; color: var(--muted); margin-top: 8px; }
.flip .back { background: color-mix(in srgb, var(--c, var(--accent)) 12%, var(--surface)); transform: rotateY(180deg); border-color: color-mix(in srgb, var(--c, var(--accent)) 40%, transparent); overflow: auto; }

/* reveal: <details class="reveal"><summary>..</summary>..</details> */
details.reveal { margin: 1.1em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details.reveal > summary { cursor: pointer; padding: 11px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::before { content: '▸'; color: var(--c, var(--accent)); transition: transform .2s; }
details.reveal[open] > summary::before { transform: rotate(90deg); }
details.reveal > :not(summary) { padding: 0 16px; }
details.reveal[open] { padding-bottom: 8px; }
details.reveal.deep > summary::after { content: 'DEEP DIVE'; margin-left: auto; font-size: .68rem; letter-spacing: .1em; color: var(--aha); background: var(--aha-bg); padding: 2px 8px; border-radius: 999px; }

/* tabs: <div class="tabs"><div class="tab" data-label="Console">..</div>...</div> */
.tabs { margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.tabs .tab-bar { display: flex; gap: 2px; padding: 6px 6px 0; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs .tab-btn { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text-2); border-radius: 8px 8px 0 0; white-space: nowrap; }
.tabs .tab-btn:hover { color: var(--text); }
.tabs .tab-btn.on { background: var(--surface); color: var(--c, var(--accent)); box-shadow: inset 0 2px 0 var(--c, var(--accent)); }
.tabs .tab { display: none; padding: 4px 16px; }
.tabs .tab.on { display: block; }
.tabs .tab > .code-block:first-child { margin-top: 12px; }

/* checkpoint (ungraded inline question) */
.checkpoint { margin: 1.6em 0; padding: 16px 18px; border-radius: var(--radius); border: 1px dashed color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--c, var(--accent)) 6%, var(--surface)); }
.checkpoint .cp-label { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--c, var(--accent)); }
.checkpoint .cp-q { font-weight: 600; margin: 4px 0 10px; }
.checkpoint .cp-opts { display: grid; gap: 8px; }
.checkpoint .cp-opt { text-align: left; padding: 9px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .93rem; transition: border-color .15s, background .15s; }
.checkpoint .cp-opt:hover:not([disabled]) { border-color: var(--border-strong); background: var(--surface-2); }
.checkpoint .cp-opt.right { border-color: var(--good); background: var(--good-bg); }
.checkpoint .cp-opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.checkpoint .cp-opt[disabled] { cursor: default; }
.checkpoint .cp-explain { margin-top: 10px; font-size: .92rem; color: var(--text-2); display: none; }
.checkpoint.answered .cp-explain { display: block; animation: panelIn .25s ease; }

/* classify (bucket sorting) */
.classify { margin: 1.6em 0; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.classify .cl-title { font-weight: 700; font-family: var(--font-display); margin-bottom: 4px; }
.classify .cl-help { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.classify .cl-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; padding: 10px; border-radius: 10px; background: var(--surface-2); margin-bottom: 12px; }
.classify .cl-item { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: .88rem; user-select: none; transition: transform .1s; }
.classify .cl-item:hover { transform: translateY(-1px); }
.classify .cl-item.sel { border-color: var(--accent); box-shadow: var(--glow); }
.classify .cl-item.right { border-color: var(--good); background: var(--good-bg); }
.classify .cl-item.wrong { border-color: var(--bad); background: var(--bad-bg); }
.classify .cl-buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.classify .cl-bucket { min-height: 90px; border: 2px dashed var(--border-strong); border-radius: 12px; padding: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.classify .cl-bucket:hover { border-color: var(--accent); }
.classify .cl-bucket.armed { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.classify .cl-bucket h5 { margin: 0 0 8px; font-size: .85rem; text-align: center; color: var(--text-2); font-family: var(--font-display); }
.classify .cl-bucket .cl-drop { display: flex; flex-wrap: wrap; gap: 6px; }
.classify .cl-foot { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.classify .cl-result { font-size: .9rem; font-weight: 600; }

/* console mock */
.console { margin: 1.6em 0; border-radius: 12px; overflow: hidden; border: 1px solid #2b3445; background: #f2f3f3; color: #16191f; font-family: 'Amazon Ember', 'Helvetica Neue', Roboto, Arial, sans-serif; font-size: 14px; box-shadow: var(--shadow); line-height: 1.45; }
.console .cm-nav { background: #232f3e; color: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 12px; font-size: 13px; }
.console .cm-logo { font-weight: 800; font-size: 15px; letter-spacing: -.02em; color: #fff; display: flex; align-items: center; gap: 4px; }
.console .cm-logo::after { content: ''; display: inline-block; width: 22px; height: 6px; border-bottom: 2px solid #ff9900; border-radius: 0 0 14px 14px; margin-left: -26px; margin-top: 14px; }
.console .cm-search { flex: 1; max-width: 340px; background: #0f1b2a; border: 1px solid #5f6b7a; border-radius: 6px; padding: 4px 10px; color: #aab7b8; font-size: 12px; }
.console .cm-nav .cm-right { margin-left: auto; display: flex; gap: 14px; color: #d1d5db; font-size: 12px; }
.console .cm-nav .cm-region { color: #fff; font-weight: 600; }
.console .cm-sub { background: #fff; border-bottom: 1px solid #d5dbdb; padding: 8px 16px; font-size: 13px; color: #0972d3; }
.console .cm-sub .sep { color: #879596; margin: 0 6px; }
.console .cm-sub .cur { color: #545b64; }
.console .cm-body { padding: 16px; display: grid; gap: 14px; overflow-x: auto; }
.console .cm-body > * { min-width: 0; }
.console .cm-input, .console .cm-field, .console td { overflow-wrap: anywhere; }
.console .cm-title { font-size: 22px; font-weight: 700; color: #000716; margin: 0; }
.console .cm-desc { color: #545b64; font-size: 13px; margin: -8px 0 0; }
.console .cm-section { background: #fff; border-radius: 12px; box-shadow: 0 1px 1px rgba(0,28,36,.3), 1px 1px 1px rgba(0,28,36,.15); padding: 0; }
.console .cm-section > h6 { margin: 0; padding: 14px 18px; font-size: 16px; font-weight: 700; color: #000716; border-bottom: 1px solid #e9ebed; font-family: inherit; }
.console .cm-section .cm-inner { padding: 14px 18px; display: grid; gap: 14px; }
.console .cm-field label, .console .cm-field .cm-l { display: block; font-weight: 700; font-size: 14px; color: #000716; }
.console .cm-field .cm-hint { display: block; font-size: 12px; color: #5f6b7a; margin: 2px 0 6px; }
.console .cm-input { border: 2px solid #8c8c94; border-radius: 8px; padding: 5px 10px; background: #fff; color: #000716; min-height: 32px; font-size: 14px; font-family: inherit; }
.console .cm-input.cm-select::after { content: '▾'; float: right; color: #5f6b7a; }
.console .cm-input.empty { color: #8c8c94; font-style: italic; }
.console .cm-radios { display: flex; flex-direction: column; gap: 6px; }
.console .cm-radio { display: flex; gap: 8px; align-items: flex-start; }
.console .cm-radio i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #8c8c94; flex: none; margin-top: 2px; background: #fff; }
.console .cm-radio.on i { border: 5px solid #0972d3; }
.console .cm-check i { border-radius: 4px; }
.console .cm-check.on i { border: 0; background: #0972d3; position: relative; }
.console .cm-check.on i::after { content: '✓'; color: #fff; font-size: 11px; position: absolute; left: 3px; top: -1px; font-style: normal; font-weight: 700; }
.console .cm-radio small { display: block; color: #5f6b7a; font-size: 12px; }
.console .cm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.console .cm-tile { border: 2px solid #b6bec9; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.console .cm-tile.on { border-color: #0972d3; background: #f2f8fd; }
.console .cm-tile small { display: block; color: #5f6b7a; font-size: 11px; }
.console .cm-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 2px 0; }
.console .cm-btn { display: inline-block; padding: 5px 18px; border-radius: 20px; border: 2px solid #0972d3; color: #0972d3; font-weight: 700; background: #fff; font-size: 14px; }
.console .cm-btn.primary { background: #ff9900; border-color: #ff9900; color: #000716; }
.console .cm-btn.link { border-color: transparent; }
.console .cm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.console .cm-table th { text-align: left; padding: 8px 10px; border-bottom: 1px solid #d5dbdb; color: #414d5c; font-weight: 700; background: #fff; white-space: nowrap; font-family: inherit; }
.console .cm-table td { padding: 8px 10px; border-bottom: 1px solid #e9ebed; color: #000716; }
.console .cm-status { display: inline-flex; align-items: center; gap: 5px; }
.console .cm-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #037f0c; }
.console .cm-status.pending::before { background: #0972d3; }
.console .cm-status.stopped::before { background: #8c8c94; }
.console .cm-status.error::before { background: #d91515; }
.console .cm-note-mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #ff9900; color: #000; font-size: 11px; font-weight: 800; margin-left: 6px; vertical-align: 1px; font-family: var(--font); box-shadow: 0 0 0 3px rgba(255,153,0,.3); }
.console .cm-annot { position: relative; outline: 2px dashed rgba(255,153,0,.9); outline-offset: 4px; border-radius: 6px; }
.console-notes { margin: -0.8em 0 1.6em; padding: 12px 16px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface); font-size: .9rem; }
.console-notes ol { margin: 0; padding-left: 0; list-style: none; counter-reset: cn; }
.console-notes li { counter-increment: cn; display: flex; gap: 10px; margin: 6px 0; }
.console-notes li::before { content: counter(cn); flex: none; width: 20px; height: 20px; border-radius: 50%; background: #ff9900; color: #000; font-size: 11px; font-weight: 800; display: grid; place-items: center; margin-top: 2px; }
.console-wrap { margin: 1.6em 0; }
.console-wrap .console { margin: 0; border-radius: 12px 12px 0 0; }
.console-wrap .console-notes { margin: 0; }
.console-caption { font-size: .78rem; color: var(--muted); margin: 6px 2px 0; }

/* architecture diagram */
.arch { margin: 1.6em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.arch-title { padding: 10px 16px; font-weight: 700; font-family: var(--font-display); border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: .95rem; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.arch-canvas { padding: 10px; overflow-x: auto; }
.arch svg { display: block; margin: 0 auto; min-width: 520px; height: auto; }
.arch .g-box { fill: none; stroke-width: 1.5; rx: 10; }
.arch .g-label { font-size: 12px; font-weight: 700; font-family: var(--font-display); }
.arch .g-region { stroke: var(--text-2); stroke-dasharray: 6 4; fill: color-mix(in srgb, var(--text-2) 3%, transparent); }
.arch .g-vpc { stroke: var(--cat-networking); fill: color-mix(in srgb, var(--cat-networking) 5%, transparent); }
.arch .g-az { stroke: var(--info); stroke-dasharray: 3 4; fill: color-mix(in srgb, var(--info) 3%, transparent); }
.arch .g-public { stroke: var(--good); fill: color-mix(in srgb, var(--good) 8%, transparent); }
.arch .g-private { stroke: var(--info); fill: color-mix(in srgb, var(--info) 8%, transparent); }
.arch .g-account { stroke: var(--bad); stroke-dasharray: 8 4; fill: color-mix(in srgb, var(--bad) 3%, transparent); }
.arch .g-generic { stroke: var(--border-strong); fill: color-mix(in srgb, var(--surface-3) 40%, transparent); }
.arch .g-edge { stroke: var(--accent); stroke-dasharray: 2 4; fill: color-mix(in srgb, var(--accent) 4%, transparent); }
.arch .n-box { fill: var(--surface-2); stroke: var(--nc); stroke-width: 1.6; transition: all .25s; }
.arch .n-strip { fill: var(--nc); }
.arch .n-icon { font-size: 20px; dominant-baseline: central; text-anchor: middle; }
.arch .n-label { font-size: 12.5px; font-weight: 700; fill: var(--text); font-family: var(--font-display); dominant-baseline: central; }
.arch .n-sub { font-size: 10.5px; fill: var(--muted); dominant-baseline: central; }
.arch .e-line { fill: none; stroke: var(--muted); stroke-width: 1.6; transition: stroke .25s, opacity .25s; }
.arch .e-line.dashed { stroke-dasharray: 5 4; }
.arch .e-label { font-size: 11px; fill: var(--text-2); text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.arch .e-dot { fill: var(--accent); }
.arch.stepping .n, .arch.stepping .e { opacity: .16; filter: grayscale(.8); transition: opacity .3s, filter .3s; }
.arch.stepping .n.hl, .arch.stepping .e.hl { filter: none; }
.arch.stepping .n.hl, .arch.stepping .e.hl { opacity: 1; }
.arch .n.hl .n-box { stroke-width: 3; filter: drop-shadow(0 0 8px var(--nc)); }
.arch .e.hl .e-line { stroke: var(--accent); stroke-width: 2.4; }
.arch .n.bad .n-box { stroke: var(--bad); fill: var(--bad-bg); }
.arch .n.bad .n-label { text-decoration: line-through; }
.arch-steps { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 14px; align-items: flex-start; background: var(--surface-2); }
.arch-steps .as-text { flex: 1; font-size: .93rem; min-height: 3em; }
.arch-steps .as-text b { font-family: var(--font-display); display: block; margin-bottom: 2px; }
.arch-steps .as-ctrl { display: flex; gap: 6px; align-items: center; flex: none; }
.arch-steps .as-count { font-size: .78rem; color: var(--muted); min-width: 44px; text-align: center; }
.arch-legend { padding: 8px 16px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--border); }

/* sequence diagram */
.seq .s-actor-box { fill: var(--surface-2); stroke: var(--ac, var(--border-strong)); stroke-width: 1.6; }
.seq .s-actor { font-size: 12.5px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: var(--text); font-family: var(--font-display); }
.seq .s-life { stroke: var(--border-strong); stroke-dasharray: 4 4; }
.seq .s-msg line, .seq .s-msg path { stroke: var(--text-2); stroke-width: 1.6; fill: none; }
.seq .s-msg.async line, .seq .s-msg.async path { stroke-dasharray: 6 4; }
.seq .s-msg.reply line, .seq .s-msg.reply path { stroke-dasharray: 2 4; stroke: var(--muted); }
.seq .s-msg.fail line, .seq .s-msg.fail path { stroke: var(--bad); }
.seq .s-msg.good line, .seq .s-msg.good path { stroke: var(--good); }
.seq .s-msg text { font-size: 11.5px; fill: var(--text); text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.seq .s-msg.fail text { fill: var(--bad); }
.seq .s-note rect { fill: var(--warn-bg); stroke: color-mix(in srgb, var(--warn) 50%, transparent); }
.seq .s-note text { font-size: 11px; fill: var(--text); }
.seq .s-msg, .seq .s-note { transition: opacity .3s; }
.seq.stepping .s-msg.future, .seq.stepping .s-note.future { opacity: 0; }
.seq.stepping .s-msg.current line, .seq.stepping .s-msg.current path { stroke: var(--accent); stroke-width: 2.6; }
.seq .s-x { stroke: var(--bad); stroke-width: 2.5; }

/* sliders / generic widgets */
.widget { overflow-x: auto; margin: 1.6em 0; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.widget > h4:first-child, .widget .w-title { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.05rem; color: var(--text); }
.widget .w-help { font-size: .86rem; color: var(--muted); margin: 0 0 12px; }
.widget .w-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.widget .w-out { font-family: var(--font-display); font-weight: 700; color: var(--c, var(--accent)); }
.widget .w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.range { display: grid; gap: 4px; margin: 8px 0; }
.range .r-head { display: flex; justify-content: space-between; font-size: .88rem; color: var(--text-2); }
.range .r-head b { color: var(--text); font-family: var(--font-display); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: var(--surface-3); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--c, var(--accent)); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--c, var(--accent)); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--accent)); border: 3px solid var(--surface); cursor: pointer; }
.input, select.input, textarea.input { font: inherit; font-size: .92rem; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
textarea.input { font-family: var(--font-mono); font-size: .84rem; width: 100%; min-height: 140px; line-height: 1.5; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--c, var(--accent)), var(--accent-2)); transition: width .35s ease; border-radius: inherit; }
.pill-good { color: var(--good); background: var(--good-bg); padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: .85em; }
.pill-bad { color: var(--bad); background: var(--bad-bg); padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: .85em; }
.pill-warn { color: var(--warn); background: var(--warn-bg); padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: .85em; }

/* takeaways */
.takeaways { margin: 3em 0 1.5em; padding: 20px 22px; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 12%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border)); }
.takeaways h2 { margin: 0 0 10px !important; font-size: 1.25rem !important; }
.takeaways ul { margin: 0; padding-left: 0; list-style: none; }
.takeaways li { padding-left: 28px; position: relative; margin: 8px 0; }
.takeaways li::before { content: '✓'; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 800; background: var(--c); color: var(--bg); }

/* ---------- quiz ---------- */
.quiz { margin: 3em 0; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 80px; }
.quiz-head { padding: 18px 22px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 22%, var(--surface-2)), var(--surface-2)); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.quiz-head .qh-icon { font-size: 30px; }
.quiz-head h2 { margin: 0 !important; font-size: 1.3rem !important; padding: 0 !important; }
.quiz-head p { margin: 2px 0 0; font-size: .88rem; color: var(--text-2); }
.quiz-body { padding: 20px 22px 22px; }
.quiz-progress { display: flex; gap: 5px; margin-bottom: 18px; }
.quiz-progress i { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); transition: background .3s; }
.quiz-progress i.cur { background: var(--c); opacity: .5; }
.quiz-progress i.ok { background: var(--good); }
.quiz-progress i.ko { background: var(--bad); }
.quiz-q { font-size: 1.08rem; font-weight: 600; margin: 0 0 6px; line-height: 1.5; }
.quiz-q p { margin: .4em 0; }
.quiz-kind { font-size: .78rem; color: var(--muted); margin-bottom: 14px; }
.quiz-opts { display: grid; gap: 9px; }
.quiz-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s, transform .1s; font-size: .96rem; line-height: 1.45; }
.quiz-opt:hover:not([disabled]) { border-color: var(--border-strong); transform: translateX(2px); }
.quiz-opt .qo-key { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); font-family: var(--font-display); }
.quiz-opt.multi .qo-key { border-radius: 6px; }
.quiz-opt.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface-2)); }
.quiz-opt.sel .qo-key { background: var(--c); color: var(--bg); }
.quiz-opt.right { border-color: var(--good); background: var(--good-bg); }
.quiz-opt.right .qo-key { background: var(--good); color: var(--bg); }
.quiz-opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz-opt.wrong .qo-key { background: var(--bad); color: var(--bg); }
.quiz-opt.missed { border-style: dashed; border-color: var(--good); }
.quiz-opt[disabled] { cursor: default; }
.quiz-opt code { font-size: .85em; }
.quiz-feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: .94rem; animation: panelIn .25s ease; }
.quiz-feedback.ok { background: var(--good-bg); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.quiz-feedback.ko { background: var(--bad-bg); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.quiz-feedback b { font-family: var(--font-display); }
.quiz-feedback p { margin: .3em 0; }
.quiz-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; flex-wrap: wrap; }
.quiz-actions .qa-hint { font-size: .82rem; color: var(--muted); }
.quiz-result { text-align: center; padding: 10px 0 4px; }
.quiz-result .qr-score { font-family: var(--font-display); font-size: 3.2rem; font-weight: 700; line-height: 1; margin: 8px 0; }
.quiz-result .qr-emoji { font-size: 3rem; }
.quiz-result.pass .qr-score { color: var(--good); }
.quiz-result.fail .qr-score { color: var(--bad); }
.quiz-result p { color: var(--text-2); }
.unlock-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 16px 0; text-align: left; }
.unlock-card { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--text); transition: transform .12s, border-color .15s; }
.unlock-card:hover { transform: translateY(-2px); border-color: var(--c); }
.unlock-card .uc-ico { font-size: 1.4rem; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, var(--surface)); flex: none; }
.unlock-card small { display: block; color: var(--muted); font-size: .75rem; }
.unlock-card.locked { opacity: .6; }
.unlock-card.locked .uc-ico { filter: grayscale(1); }
.quiz-passed-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--good-bg); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); margin-bottom: 16px; font-size: .92rem; }

/* sources */
.sources { margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--border); }
.sources h2 { font-size: 1.15rem !important; margin: 0 0 .6em !important; }
.sources ol { font-size: .88rem; color: var(--text-2); padding-left: 1.4em; }
.sources li { margin: 6px 0; }
.sources li .src-note { color: var(--muted); }
.next-up { margin-top: 2.5em; }
.next-up h2 { font-size: 1.15rem !important; margin: 0 0 .6em !important; }
.lesson-footer-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 2em; flex-wrap: wrap; }

/* ---------- toasts, modal, confetti ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; width: min(440px, calc(100% - 32px)); }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 16px; display: flex; gap: 12px; align-items: center; animation: toastIn .35s cubic-bezier(.2,.9,.3,1.3); font-size: .93rem; }
.toast .t-ico { font-size: 1.5rem; }
.toast b { font-family: var(--font-display); }
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
.modal-back { position: fixed; inset: 0; background: rgba(5, 8, 20, .6); backdrop-filter: blur(4px); z-index: 150; display: grid; place-items: center; padding: 16px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; position: relative; }
.modal h2 { margin: 0 0 14px; }
.modal .m-close { position: absolute; top: 10px; right: 10px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { margin: 2px 0 0; font-size: .84rem; color: var(--muted); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .2s, background .2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.rank-ladder { display: grid; gap: 6px; margin: 10px 0; }
.rank-ladder div { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; font-size: .88rem; background: var(--surface-2); }
.rank-ladder div.me { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); font-weight: 700; }
.rank-ladder div.done { color: var(--muted); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; }

.loading { display: grid; place-items: center; min-height: 50vh; color: var(--muted); }
.loading .spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { max-width: 640px; margin: 60px auto; padding: 22px; border-radius: var(--radius); background: var(--bad-bg); border: 1px solid var(--bad); }
.locked-gate { max-width: 640px; margin: 40px auto; text-align: center; padding: 30px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.locked-gate .lg-ico { font-size: 3rem; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .lesson-shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 18px 16px 100px; }
  .lesson-toc { display: none; }
  .lesson-main { max-width: none; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .brand-sub, .alt-text span { display: none; }
  .brand-name { display: none; }
  .altimeter { padding: 4px 10px 4px 4px; }
  .view-toggle button { padding: .35em .65em; }
  .proscons { grid-template-columns: 1fr; }
  .prose dl.terms { grid-template-columns: 1fr; }
  .prose dl.terms dt { border-bottom: 0; padding-bottom: 2px; }
  .arch-steps { flex-direction: column; }
  .map-legend { display: none; }
  .first-visit { bottom: auto; top: 40px; }
  .quiz-body, .quiz-head { padding-left: 16px; padding-right: 16px; }
  .console .cm-search, .console .cm-nav .cm-right span:not(.cm-region) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
