:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #1a1d29;
  --text-dim: #5b6072;
  --border: #e2e4ec;
  --accent: #4f46e5;
  --accent-2: #0ea5a4;
  --accent-soft: #eef0ff;
  --simple: #b45309;
  --intermediate: #0369a1;
  --structured: #15803d;
  --warn: #b91c1c;
  --warn-soft: #fef2f2;
  --radius: 12px;
  --maxw: 1140px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --surface: #161925; --surface-2: #1f2333; --text: #eef0f6;
    --text-dim: #9aa0b4; --border: #2a2e40; --accent: #818cf8; --accent-2: #2dd4bf;
    --accent-soft: #23264a; --simple: #f2b477; --intermediate: #7dd3fc; --structured: #86efac;
    --warn: #fca5a5; --warn-soft: #2a1717;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.7; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.brand a { color: var(--text); }
.brand .crumb { color: var(--accent); }

/* Hero */
.hero { padding: 54px 0 26px; border-bottom: 1px solid var(--border); }
.hero .eyebrow { color: var(--accent); font-weight: 700; font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); line-height: 1.08; letter-spacing: -0.03em; margin: 12px 0 14px; max-width: 880px; }
.hero .dek { color: var(--text-dim); font-size: 1.1rem; max-width: 720px; margin: 0; }
.hero .meta { display: flex; gap: 16px; align-items: center; margin-top: 20px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-dim); }
.hero .meta .d { width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim); opacity: 0.5; }

/* Layout: TOC + article */
.shell { display: grid; grid-template-columns: 230px 1fr; gap: 46px; padding: 34px 0 90px; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .toc { display: none; } }
.toc { position: sticky; top: 78px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.toc .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 10px; }
.toc a { display: block; font-size: 0.85rem; color: var(--text-dim); padding: 5px 10px; border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--accent); }

/* Read controls */
.read-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 22px; }
.read-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.read-btn:hover { border-color: var(--accent); }
.read-btn.active { background: var(--accent); color: #fff; }
.read-select { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 0.82rem; cursor: pointer; }
.read-select:focus { outline: none; border-color: var(--accent); }
.tts-panel { display: none; background: #0f172a; border-radius: var(--radius); padding: 14px 16px; margin: 0 0 26px; }
.tts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tts-c { background: #1e293b; border: 1px solid #334155; color: #e2e8f0; border-radius: 6px; width: 34px; height: 30px; font-size: 14px; cursor: pointer; }
.tts-c:hover { background: #334155; } .tts-c.tts-x { color: #fca5a5; }
.tts-count { margin-left: auto; color: #94a3b8; font-size: 0.78rem; }
.tts-bar { height: 7px; background: #1e293b; border-radius: 4px; cursor: pointer; overflow: hidden; }
.tts-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }
.tts-now { margin-top: 10px; color: #cbd5e1; font-size: 0.88rem; line-height: 1.6; }

/* Article */
article h2 { font-size: 1.5rem; letter-spacing: -0.02em; margin: 46px 0 8px; scroll-margin-top: 76px; }
article h2 .k { color: var(--accent); font-size: 0.9rem; font-weight: 700; margin-right: 8px; }
article h3 { font-size: 1.12rem; margin: 26px 0 6px; }
article p { font-size: 1.05rem; margin: 0 0 16px; }
article p.teach { }
article .lead-in { font-size: 1.15rem; color: var(--text); }
article strong { font-weight: 700; }
article em { font-style: italic; }
.section-first h2 { margin-top: 8px; }

/* Callouts */
.callout { border-radius: var(--radius); padding: 16px 20px; margin: 22px 0; font-size: 0.98rem; border: 1px solid var(--border); background: var(--surface); }
.callout.key { border-color: var(--accent); background: var(--accent-soft); }
.callout.key b { color: var(--accent); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-soft); }
.callout.warn b { color: var(--warn); }
.callout .h { font-weight: 700; display: block; margin-bottom: 4px; }

/* Failure / move lists */
.deflist { margin: 18px 0; padding: 0; list-style: none; }
.deflist li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.deflist li b { color: var(--text); }
.deflist.moves li b { color: var(--accent); }
.deflist.fails li b { color: var(--warn); }

/* Diagram */
.diagram { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin: 24px 0; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .cap { color: var(--text-dim); font-size: 0.85rem; margin-top: 12px; text-align: center; }

/* 3-tier prompts */
.practice { margin: 26px 0; }
.practice .task { font-size: 0.98rem; color: var(--text-dim); margin-bottom: 14px; }
.prompt-tiers { display: flex; flex-direction: column; gap: 14px; }
.prompt-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.prompt-card .tier-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface-2); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.prompt-card .dot { width: 9px; height: 9px; border-radius: 50%; }
.prompt-card.simple .dot { background: var(--simple); }
.prompt-card.intermediate .dot { background: var(--intermediate); }
.prompt-card.structured .dot { background: var(--structured); }
.prompt-card pre { margin: 0; padding: 16px; font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.85rem; white-space: pre-wrap; background: var(--surface); line-height: 1.55; }
.prompt-card .note { padding: 0 16px 14px; font-size: 0.85rem; color: var(--text-dim); }

/* recall + test */
.recall-box { background: var(--surface-2); border-radius: var(--radius); padding: 18px 22px; margin: 26px 0 0; }
.recall-box h4 { margin: 0 0 10px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.recall-box ul { margin: 0; padding-left: 18px; }
.recall-box li { margin-bottom: 6px; }
.test-yourself { background: #1a1d29; color: #eef0f6; border-radius: var(--radius); padding: 20px 22px; margin: 16px 0 0; }
@media (prefers-color-scheme: dark) { .test-yourself { background: #0a0c12; } }
.test-yourself h4 { margin: 0 0 12px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }
.test-yourself .qa { margin-bottom: 10px; font-size: 0.95rem; }
.test-yourself .qa b { color: var(--accent-2); }

.next-strip { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin: 34px 0 0; background: var(--surface); }
.next-strip b { color: var(--text); }

footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--text-dim); font-size: 0.85rem; text-align: center; }
footer a { color: var(--text-dim); }
