/* ===== Tokens (mirror of index.html) ===== */
:root {
  --indigo: #4F46E5;
  --indigo-2: #6366f1;
  --cyan: #06B6D4;
  --ink: #0F172A;
  --paper: #F8FAFC;
  --muted: #64748B;
  --border: #e2e8f0;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --grad: linear-gradient(135deg, #4F46E5 0%, #06B6D4 100%);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 10px 24px -8px rgba(15, 23, 42, 0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --nav-h: 56px;
}
[data-theme="dark"] {
  --ink: #F8FAFC;
  --paper: #0a0e1a;
  --muted: #94a3b8;
  --border: #1f2a44;
  --surface: #0e1525;
  --surface-2: #131c33;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 10px 24px rgba(0,0,0,0.35);
}

/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Nav ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  min-height: 44px;
}
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.nav-actions { display: flex; align-items: center; gap: 6px; }
.nav-back {
  display: none;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-back:hover { background: var(--surface-2); text-decoration: none; }
.nav-back svg { width: 14px; height: 14px; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  padding: 0;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: block; }

@media (min-width: 600px) {
  :root { --nav-h: 64px; }
  .nav-inner { padding: 0 24px; }
  .brand-name { font-size: 22px; }
  .nav-back { display: inline-flex; }
}

/* ===== Page hero ===== */
.page-hero {
  padding: 56px 16px 40px;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.page-hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto auto;
  width: 60vw;
  max-width: 480px;
  height: 60vw;
  max-height: 480px;
  background: radial-gradient(circle at center, rgba(79, 70, 229, 0.14), transparent 60%);
  pointer-events: none;
}
.page-hero::after {
  content: "";
  position: absolute;
  inset: auto auto -40% -10%;
  width: 50vw;
  max-width: 380px;
  height: 50vw;
  max-height: 380px;
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.10), transparent 60%);
  pointer-events: none;
}
.page-hero-inner {
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--indigo);
  margin: 0 0 18px;
  box-shadow: var(--shadow-sm);
}
.page-hero h1 {
  font-size: clamp(32px, 5.5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 14px;
  color: var(--ink);
}
.page-hero h1 em {
  font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.page-hero .lede {
  font-size: clamp(15px, 2vw, 17px);
  color: var(--muted);
  margin: 0;
  max-width: 60ch;
  line-height: 1.6;
}
.page-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 0;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ===== Prose ===== */
.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}
.prose h2 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 40px 0 14px;
  color: var(--ink);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--ink);
}
.prose p {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 16px;
}
.prose ul, .prose ol {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--ink);
}
.prose li { margin-bottom: 8px; }
.prose strong { font-weight: 600; }
.prose code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--indigo);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 0 0 24px;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  color: var(--ink);
}
.callout p { margin: 0; }
.callout p + p { margin-top: 10px; }

/* ===== TOC card ===== */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 0 0 36px;
  box-shadow: var(--shadow-sm);
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.toc ol {
  margin: 0;
  padding-left: 18px;
  columns: 1;
}
@media (min-width: 600px) { .toc ol { columns: 2; column-gap: 24px; } }
.toc li {
  margin-bottom: 4px;
  font-size: 14px;
  break-inside: avoid;
}

@media (min-width: 600px) {
  .page-hero { padding: 80px 24px 56px; }
  .prose { padding: 56px 24px 88px; }
}

/* ===== Footer ===== */
footer {
  background: var(--ink);
  color: rgba(248, 250, 252, 0.7);
  padding: 56px 16px 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] footer { background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  padding-bottom: 36px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.footer-brand-col img { height: 44px; width: auto; margin-bottom: 12px; }
.footer-tagline {
  font-size: 14px;
  color: rgba(248, 250, 252, 0.6);
  line-height: 1.5;
  max-width: 28ch;
  margin: 0;
}
.footer-col h4 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.55);
  margin: 0 0 14px;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer-col.subjects ul { grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.footer-col a {
  color: rgba(248, 250, 252, 0.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  transition: color 0.12s;
  display: inline-block;
  padding: 2px 0;
}
.footer-col a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  font-size: 12px;
  color: rgba(248, 250, 252, 0.45);
}
.footer-legal { display: flex; gap: 18px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
.footer-legal a {
  color: rgba(248, 250, 252, 0.6);
  font-size: 12px;
  text-decoration: none;
}
.footer-legal a:hover { color: #fff; }

@media (min-width: 600px) {
  footer { padding: 64px 24px 32px; }
  .footer-cols { grid-template-columns: 1.4fr 1.8fr 1fr; gap: 32px; }
  .footer-bottom { flex-direction: row; justify-content: space-between; align-items: center; }
}
