/* =========================================================================
   SHIPYARD — Design System
   A 0→100 Field Manual for Building Web Apps with AI Agents
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. TOKENS — colors, type, space, motion
   ------------------------------------------------------------------------- */

:root {
  /* Type scale — 1.250 modular */
  --fs-xs:    0.75rem;   /* 12 */
  --fs-sm:    0.8125rem; /* 13 */
  --fs-base:  1rem;      /* 16 */
  --fs-md:    1.125rem;  /* 18 */
  --fs-lg:    1.25rem;   /* 20 */
  --fs-xl:    1.5rem;    /* 24 */
  --fs-2xl:   1.875rem;  /* 30 */
  --fs-3xl:   2.5rem;    /* 40 */
  --fs-4xl:   3.25rem;   /* 52 */
  --fs-5xl:   4.5rem;    /* 72 */

  /* Line heights */
  --lh-tight:   1.1;
  --lh-snug:    1.25;
  --lh-normal:  1.5;
  --lh-body:    1.7;

  /* Spacing — 4px base */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;
  --sp-32: 8rem;

  /* Layout */
  --content-max: 720px;
  --wide-max: 1080px;
  --shell-max: 1440px;
  --rail-w: 280px;
  --toc-w: 220px;
  --topbar-h: 64px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 300ms;

  /* Borders */
  --border-w: 1px;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Fonts */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Light theme — clean white, neutral grayscale, blue accent */
:root,
[data-theme="light"] {
  --bg:           #FFFFFF;
  --bg-soft:      #FAFAFA;
  --bg-elevated:  #FFFFFF;
  --bg-sunken:    #F4F4F5;
  --bg-grid:      rgba(15, 23, 42, 0.04);

  --ink:          #0A0A0A;
  --ink-soft:     #404040;
  --ink-muted:    #737373;
  --ink-faint:    #A3A3A3;

  --rule:         #E5E5E5;
  --rule-soft:    #F0F0F0;
  --rule-strong:  #D4D4D4;

  --accent:       #2563EB;          /* clean blue — universally professional */
  --accent-soft:  #DBEAFE;
  --accent-faint: rgba(37, 99, 235, 0.08);
  --accent-ink:   #FFFFFF;

  --signal:       #16A34A;          /* good / shipped */
  --signal-soft:  #DCFCE7;
  --warn:         #EA580C;          /* warn / pitfall */
  --warn-soft:    #FFEDD5;
  --danger:       #DC2626;
  --danger-soft:  #FEE2E2;
  --info:         #2563EB;
  --info-soft:    #DBEAFE;

  --code-bg:      #F8F9FA;
  --code-border:  #E5E5E5;

  --shadow-sm: 0 1px 0 rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.30);
}

/* Dark theme — true near-black, neutral grayscale, brighter blue accent */
[data-theme="dark"] {
  --bg:           #0A0A0A;
  --bg-soft:      #141414;
  --bg-elevated:  #1A1A1A;
  --bg-sunken:    #050505;
  --bg-grid:      rgba(255, 255, 255, 0.03);

  --ink:          #FAFAFA;
  --ink-soft:     #D4D4D4;
  --ink-muted:    #A3A3A3;
  --ink-faint:    #737373;

  --rule:         #262626;
  --rule-soft:    #1F1F1F;
  --rule-strong:  #404040;

  --accent:       #60A5FA;          /* lighter blue — brighter on dark */
  --accent-soft:  rgba(96, 165, 250, 0.18);
  --accent-faint: rgba(96, 165, 250, 0.10);
  --accent-ink:   #0A0A0A;

  --signal:       #4ADE80;
  --signal-soft:  rgba(74, 222, 128, 0.14);
  --warn:         #FB923C;
  --warn-soft:    rgba(251, 146, 60, 0.14);
  --danger:       #F87171;
  --danger-soft:  rgba(248, 113, 113, 0.14);
  --info:         #60A5FA;
  --info-soft:    rgba(96, 165, 250, 0.14);

  --code-bg:      #141414;
  --code-border:  #262626;

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.30), 0 4px 12px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.40), 0 2px 6px rgba(0, 0, 0, 0.30);
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.35);
}

/* -------------------------------------------------------------------------
   2. RESET + BASE
   ------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-4));
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--ink);
  background-color: var(--bg);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-optical-sizing: auto;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}

img, svg, video { max-width: 100%; height: auto; display: block; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-sunken); }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border: 3px solid var(--bg-sunken);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
   3. TYPOGRAPHY
   ------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-4);
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 { font-size: var(--fs-4xl); font-weight: 700; letter-spacing: -0.035em; }
h2 { font-size: var(--fs-2xl); margin-top: var(--sp-12); letter-spacing: -0.025em; }
h3 { font-size: var(--fs-xl); margin-top: var(--sp-8); letter-spacing: -0.015em; }
h4 { font-size: var(--fs-lg); margin-top: var(--sp-6); font-weight: 600; }
h5 { font-size: var(--fs-md); font-family: var(--font-body); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }

p { margin: 0 0 var(--sp-5); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-faint);
  transition: text-decoration-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
a:hover { text-decoration-color: var(--accent); }
a:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}

a[target="_blank"]::after {
  content: "↗";
  display: inline-block;
  margin-left: 0.2em;
  font-size: 0.85em;
  color: var(--ink-muted);
  transition: transform var(--t-fast) var(--ease-out);
}
a[target="_blank"]:hover::after { transform: translate(1px, -1px); color: var(--accent); }

strong, b { font-weight: 600; color: var(--ink); }
em, i { font-style: italic; }

small { font-size: var(--fs-sm); }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.12em 0.4em;
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-feature-settings: "calt" 0;
}

kbd {
  background: var(--bg-elevated);
  border-bottom-width: 2px;
  font-size: 0.8em;
  padding: 0.15em 0.45em;
}

mark {
  background: var(--accent-soft);
  color: var(--ink);
  padding: 0.05em 0.25em;
  border-radius: var(--radius-xs);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--sp-10) 0;
}

blockquote {
  margin: var(--sp-6) 0;
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-6);
  border-left: 3px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-md);
  color: var(--ink-soft);
  
}

/* Lists with proper nested hierarchy */
ul, ol { padding-left: var(--sp-6); margin: 0 0 var(--sp-5); }
ul { list-style: none; }
ol { list-style-position: outside; }

ul li {
  position: relative;
  padding-left: var(--sp-5);
  margin-bottom: var(--sp-2);
}
ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 8px;
  height: 1px;
  background: var(--accent);
}

/* Nested ul: change marker */
ul ul li::before {
  width: 6px;
  height: 6px;
  top: 0.55em;
  background: transparent;
  border: 1px solid var(--ink-muted);
  border-radius: 50%;
}
ul ul ul li::before {
  width: 4px;
  height: 4px;
  background: var(--ink-muted);
  border: 0;
  border-radius: 0;
  transform: rotate(45deg);
  top: 0.7em;
}

ol { padding-left: var(--sp-8); }
ol li {
  margin-bottom: var(--sp-2);
  padding-left: var(--sp-2);
}
ol li::marker {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
  font-weight: 600;
}

li ul, li ol { margin-top: var(--sp-2); margin-bottom: var(--sp-3); }

/* Definition list */
dl { margin: 0 0 var(--sp-5); }
dt {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  margin-top: var(--sp-3);
}
dd { margin: var(--sp-1) 0 var(--sp-3) 0; color: var(--ink-soft); }

/* -------------------------------------------------------------------------
   4. LAYOUT — shell, topbar, rail, content, toc
   ------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: 100vh;
}

.shell--with-toc {
  grid-template-columns: var(--rail-w) 1fr var(--toc-w);
}

.shell--full {
  display: block;
  max-width: var(--shell-max);
  margin: 0 auto;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: rgba(242, 238, 229, 0.85);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
[data-theme="dark"] .topbar { background: rgba(14, 22, 34, 0.85); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand__sub {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  margin-left: var(--sp-2);
  padding-left: var(--sp-2);
  border-left: 1px solid var(--rule);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.topnav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.topnav__link:hover {
  color: var(--ink);
  background: var(--bg-soft);
  text-decoration: none;
}
.topnav__link[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-faint);
}

.topnav__dropdown { position: relative; }
.topnav__dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out), visibility 0s linear var(--t-base);
}
.topnav__dropdown[data-open="true"] .topnav__dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}
.topnav__dropdown-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.topnav__dropdown-link:hover { background: var(--bg-soft); text-decoration: none; }
.topnav__dropdown-link__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}

.topbar__tools { display: flex; align-items: center; gap: var(--sp-2); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.icon-btn:hover { color: var(--ink); background: var(--bg-soft); }
.icon-btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.cmdk-trigger:hover { border-color: var(--rule-strong); }
.cmdk-trigger kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  font-size: var(--fs-xs);
  border-bottom-width: 1px;
}

/* Left rail */
.rail {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-12);
  border-right: 1px solid var(--rule);
  background: var(--bg-soft);
}

.rail__section { margin-bottom: var(--sp-8); }
.rail__title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 var(--sp-3);
  padding: 0 var(--sp-2);
}

.progress-rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  list-style: none;
  margin: 0;
}
.progress-rail li::before { content: none; }
.progress-rail li { padding: 0; margin: 0; }

.progress-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  position: relative;
}
.progress-item:hover { background: var(--bg-elevated); color: var(--ink); text-decoration: none; }
.progress-item[aria-current="page"] {
  background: var(--accent-faint);
  color: var(--ink);
  font-weight: 500;
}
.progress-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.progress-item__num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: 600;
}
.progress-item__range {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-faint);
}

.rail__sub {
  list-style: none;
  padding: var(--sp-1) 0 var(--sp-2) 32px;
  margin: 0;
  display: none;
  border-left: 1px dashed var(--rule);
  margin-left: 14px;
}
.rail__sub li::before { content: none; }
.rail__sub li { padding: 0; margin: 0; }
.progress-item[aria-current="page"] + .rail__sub,
.rail__sub.is-open { display: block; }
.rail__sub-link {
  display: block;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  text-decoration: none;
  border-radius: var(--radius-xs);
}
.rail__sub-link:hover { color: var(--ink); background: var(--bg-elevated); text-decoration: none; }
.rail__sub-link.is-active { color: var(--accent); }

/* Main content area */
.main {
  padding: var(--sp-12) var(--sp-10) var(--sp-24);
  min-width: 0;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
}

.content--wide { max-width: var(--wide-max); }

/* Right TOC */
.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--sp-12) var(--sp-5) var(--sp-12);
  border-left: 1px solid var(--rule);
}
.toc__title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 var(--sp-3);
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li::before { content: none; }
.toc li { padding: 0; margin: 0; }
.toc__link {
  display: block;
  padding: var(--sp-1) 0;
  padding-left: var(--sp-3);
  border-left: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.toc__link:hover { color: var(--ink); text-decoration: none; }
.toc__link.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc__link--depth-3 { padding-left: var(--sp-6); font-size: var(--fs-xs); }

/* Mobile rail toggle */
.rail-toggle { display: none; }

@media (max-width: 1100px) {
  .shell, .shell--with-toc {
    grid-template-columns: 1fr;
  }
  .rail {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: 320px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .rail[data-open="true"] { transform: translateX(0); }
  .rail-toggle {
    display: inline-flex;
  }
  .toc { display: none; }
  .main { padding: var(--sp-8) var(--sp-6) var(--sp-16); }
}

@media (max-width: 700px) {
  .topnav__link--text { display: none; }
  .cmdk-trigger__hint { display: none; }
  .main { padding: var(--sp-6) var(--sp-4) var(--sp-12); }
  h1 { font-size: var(--fs-3xl); }
}

/* -------------------------------------------------------------------------
   5. COMPONENTS
   ------------------------------------------------------------------------- */

/* Tag / pill */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  font-weight: 500;
}
.tag--accent { background: var(--accent-faint); color: var(--accent); border-color: transparent; }
.tag--signal { background: var(--signal-soft); color: var(--signal); border-color: transparent; }
.tag--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag--info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Eyebrow label */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 0 0 var(--sp-3);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
}

/* Page header — editorial */
.page-header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: var(--sp-8);
  margin-bottom: var(--sp-10);
}
.page-header__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-4);
}
.page-header__meta span { display: inline-flex; align-items: center; gap: var(--sp-1); }
.page-header__meta strong { color: var(--accent); font-weight: 600; }
.page-header__title {
  font-size: var(--fs-4xl);
  margin: var(--sp-2) 0 var(--sp-5);

  letter-spacing: -0.035em;
}
.page-header__lede {
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0;
}

/* Callouts */
.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  margin: var(--sp-6) 0;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
  background: var(--bg-soft);
  position: relative;
}
.callout__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-sm);
  border-radius: 50%;
  margin-top: 2px;
}
.callout__body { min-width: 0; }
.callout__title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 var(--sp-2);
}
.callout p:last-child { margin-bottom: 0; }

.callout--info { border-color: var(--info); background: var(--info-soft); }
.callout--info .callout__icon { background: var(--info); color: var(--bg-elevated); }
.callout--info .callout__title { color: var(--info); }

.callout--pitfall { border-color: var(--danger); background: var(--danger-soft); }
.callout--pitfall .callout__icon { background: var(--danger); color: var(--bg-elevated); }
.callout--pitfall .callout__title { color: var(--danger); }

.callout--warn { border-color: var(--warn); background: var(--warn-soft); }
.callout--warn .callout__icon { background: var(--warn); color: var(--bg-elevated); }
.callout--warn .callout__title { color: var(--warn); }

.callout--pro { border-color: var(--signal); background: var(--signal-soft); }
.callout--pro .callout__icon { background: var(--signal); color: var(--bg-elevated); }
.callout--pro .callout__title { color: var(--signal); }

.callout--jargon { border-color: var(--accent); background: var(--accent-faint); border-left-width: 4px; }
.callout--jargon .callout__icon { background: var(--accent); color: var(--accent-ink); }
.callout--jargon .callout__title { color: var(--accent); }

/* Code block */
pre.codeblock {
  position: relative;
  margin: var(--sp-5) 0;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  overflow: hidden;
}
.codeblock__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--code-border);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-soft);
}
.codeblock__lang { font-weight: 600; }
.codeblock__copy {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  transition: all var(--t-fast);
}
.codeblock__copy:hover { color: var(--accent); border-color: var(--rule); background: var(--bg-elevated); }
.codeblock__copy.is-copied { color: var(--signal); }
.codeblock pre,
.codeblock code,
pre.codeblock code {
  display: block;
  margin: 0;
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  white-space: pre;
  overflow-x: auto;
}

/* Inline jargon term — hover-card */
.term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  position: relative;
  color: var(--ink);
  font-weight: 500;
}
.term[data-def]:hover::after,
.term[data-def]:focus::after {
  content: attr(data-def);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 280px;
  padding: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  white-space: normal;
  pointer-events: none;
}

/* Tables */
.table-wrap {
  margin: var(--sp-6) 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;
  background: var(--bg-elevated);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
thead { background: var(--bg-soft); }
th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
}
td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: var(--bg-soft); }
td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

/* Accordion */
details.accordion {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  margin: var(--sp-3) 0;
  background: var(--bg-elevated);
  overflow: hidden;
  transition: box-shadow var(--t-fast);
}
details.accordion[open] { box-shadow: var(--shadow-sm); }
details.accordion summary {
  cursor: pointer;
  padding: var(--sp-4) var(--sp-5);
  font-weight: 500;
  font-size: var(--fs-md);
  list-style: none;
  position: relative;
  transition: background var(--t-fast);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
details.accordion summary::-webkit-details-marker { display: none; }
details.accordion summary:hover { background: var(--bg-soft); }
details.accordion summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--accent);
  font-size: var(--fs-xl);
  transition: transform var(--t-base) var(--ease-out);
  line-height: 1;
}
details.accordion[open] summary::after { content: "−"; }
details.accordion .accordion__body {
  padding: var(--sp-2) var(--sp-5) var(--sp-5);
  border-top: 1px solid var(--rule);
}

/* Tabs */
.tabs { margin: var(--sp-5) 0; }
.tabs__list {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  margin: 0 0 var(--sp-4);
  padding: 0;
  list-style: none;
}
.tabs__list li::before { content: none; }
.tabs__list li { padding: 0; margin: 0; }
.tabs__btn {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tabs__btn:hover { color: var(--ink); }
.tabs__btn[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tabs__panel { display: none; }
.tabs__panel[data-active="true"] { display: block; animation: fadein var(--t-base) var(--ease-out); }
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.card:hover { border-color: var(--rule-strong); box-shadow: var(--shadow-md); }
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { transform: translateY(-1px); }

.card__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: var(--sp-2);
  font-weight: 600;
}
.card__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  margin: 0 0 var(--sp-2);
  letter-spacing: -0.01em;
  
}
.card__desc {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

/* Card grids */
.card-grid {
  display: grid;
  gap: var(--sp-4);
  margin: var(--sp-6) 0;
}
.card-grid--2 { grid-template-columns: repeat(2, 1fr); }
.card-grid--3 { grid-template-columns: repeat(3, 1fr); }
.card-grid--auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 800px) {
  .card-grid--2, .card-grid--3 { grid-template-columns: 1fr; }
}

/* Level cards (home) */
.level-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--sp-5);
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all var(--t-base) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 50%, var(--accent-faint) 100%);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}
.level-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.level-card:hover::before { opacity: 1; }
.level-card__num {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 500;
  color: var(--accent);

  letter-spacing: -0.05em;
  line-height: 1;
}
.level-card__num small {
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  display: block;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.level-card__body { min-width: 0; }
.level-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  margin: 0 0 var(--sp-2);
  letter-spacing: -0.02em;

}
.level-card__desc {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}
.level-card__arrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  color: var(--ink-muted);
  transition: transform var(--t-base) var(--ease-out), color var(--t-base);
}
.level-card:hover .level-card__arrow { color: var(--accent); transform: translateX(4px); }

@media (max-width: 700px) {
  .level-card { grid-template-columns: 48px 1fr; padding: var(--sp-4); }
  .level-card__arrow { display: none; }
}

/* Hero (home) */
.hero {
  padding: var(--sp-16) 0 var(--sp-12);
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.hero__eyebrow::before, .hero__eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  max-width: 80px;
}
.hero__title {
  font-size: clamp(2.5rem, 5.5vw, 5rem);
  line-height: 1;
  letter-spacing: -0.045em;
  margin: 0 0 var(--sp-6);
  font-weight: 700;
  text-align: center;
}
.hero__title em {
  font-style: normal;
  color: var(--accent);
  font-weight: 700;
}
.hero__lede {
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 auto var(--sp-8);
  text-align: center;
}
.hero__cta-row {
  display: flex;
  justify-content: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.hero__meta {
  margin-top: var(--sp-12);
  display: flex;
  justify-content: center;
  gap: var(--sp-8);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-wrap: wrap;
}
.hero__meta strong { color: var(--accent); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  color: var(--ink);
  text-decoration: none;
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); text-decoration: none; transform: translateY(-1px); }
.btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }

.btn--primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
[data-theme="dark"] .btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn--ghost:hover { background: var(--bg-soft); color: var(--ink); }

.btn--sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); }

/* Prev / Next link list */
.next-prev {
  margin-top: var(--sp-16);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
.next-prev__item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all var(--t-fast);
}
.next-prev__item:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.next-prev__item--next { text-align: right; }
.next-prev__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}
.next-prev__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--ink);

}
@media (max-width: 700px) { .next-prev { grid-template-columns: 1fr; } .next-prev__item--next { text-align: left; } }

/* See also block */
.see-also {
  margin-top: var(--sp-12);
  padding: var(--sp-5) var(--sp-6);
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.see-also__title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 var(--sp-3);
}
.see-also ul { margin: 0; padding: 0; }
.see-also li {
  padding-left: var(--sp-4);
  position: relative;
  margin-bottom: var(--sp-1);
}
.see-also li::before {
  content: "→";
  position: absolute;
  left: 0;
  top: 0;
  background: none;
  width: auto;
  height: auto;
  font-family: var(--font-mono);
  color: var(--accent);
}
.see-also a { color: var(--ink); text-decoration: none; }
.see-also a:hover { color: var(--accent); text-decoration: underline; }

/* Module endcap (Recap / Should-be-able-to / Mini-exercise) */
.endcap {
  margin: var(--sp-12) 0;
  padding: var(--sp-8);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-soft));
  display: grid;
  gap: var(--sp-6);
}
.endcap__section h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.endcap__section h4::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 1px;
  background: var(--accent);
}
.endcap dl dt { font-size: var(--fs-sm); }
.endcap dl dd { margin-bottom: var(--sp-2); font-size: var(--fs-sm); }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding-left: 0; margin-bottom: var(--sp-2); }
.checklist li::before { content: none; }
.checklist label {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  font-size: var(--fs-sm);
}
.checklist label:hover { background: var(--bg-soft); }
.checklist input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--rule-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all var(--t-fast);
  position: relative;
}
.checklist input[type="checkbox"]:hover { border-color: var(--accent); }
.checklist input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checklist input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.checklist input:checked + span { color: var(--ink-muted); text-decoration: line-through; }

/* Prompt comparison block (bad vs good) */
.prompt-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin: var(--sp-6) 0;
}
@media (max-width: 800px) { .prompt-pair { grid-template-columns: 1fr; } }
.prompt-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.prompt-card__head {
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--rule);
}
.prompt-card--bad .prompt-card__head { color: var(--danger); background: var(--danger-soft); border-bottom-color: var(--danger); }
.prompt-card--good .prompt-card__head { color: var(--signal); background: var(--signal-soft); border-bottom-color: var(--signal); }
.prompt-card__body {
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  flex: 1;
}
.prompt-card__why {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px dashed var(--rule);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  background: var(--bg-soft);
}
.prompt-card__why strong { color: var(--ink); font-weight: 600; }

/* Diagram container */
.diagram {
  margin: var(--sp-6) 0;
  padding: var(--sp-6);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}
.diagram::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
  opacity: 0.6;
}
.diagram svg { position: relative; z-index: 1; max-width: 100%; height: auto; display: block; margin: 0 auto; }
.diagram__caption {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--rule);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Glossary entries */
.glossary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--sp-3);
}
.glossary-list li::before { content: none; }
.glossary-list li { padding: 0; margin: 0; }
.glossary-entry {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  transition: border-color var(--t-fast);
}
.glossary-entry:hover { border-color: var(--rule-strong); }
.glossary-entry__term {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.glossary-entry__cat {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 400;
}
.glossary-entry__def { font-size: var(--fs-sm); color: var(--ink-soft); line-height: 1.6; }
.glossary-entry__def strong { color: var(--ink); }
.glossary-entry__usage {
  font-style: italic;
  font-family: var(--font-display);
  color: var(--ink-muted);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--rule);
  
}
@media (max-width: 700px) { .glossary-entry { grid-template-columns: 1fr; gap: var(--sp-2); } }

/* Filters bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-6) 0;
  padding: var(--sp-4);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  align-items: center;
}
.filters__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-right: var(--sp-2);
}
.filters input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--ink);
  transition: border-color var(--t-fast);
}
.filters input[type="search"]:focus { outline: 0; border-color: var(--accent); box-shadow: var(--focus-ring); }
.filter-chip {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-chip:hover { border-color: var(--rule-strong); color: var(--ink); }
.filter-chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
[data-theme="dark"] .filter-chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Footer */
.footer {
  margin-top: var(--sp-24);
  padding: var(--sp-12) var(--sp-10);
  border-top: 1px solid var(--rule);
  background: var(--bg-soft);
}
.footer__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--sp-10);
}
@media (max-width: 800px) { .footer__inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 500px) { .footer__inner { grid-template-columns: 1fr; } }
.footer h5 {
  margin-bottom: var(--sp-3);
  margin-top: 0;
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
}
.footer ul { margin: 0; padding: 0; }
.footer li { padding-left: 0; margin-bottom: var(--sp-2); }
.footer li::before { content: none; }
.footer a { color: var(--ink-soft); text-decoration: none; font-size: var(--fs-sm); }
.footer a:hover { color: var(--accent); text-decoration: underline; }
.footer__brand-block { display: flex; flex-direction: column; gap: var(--sp-3); }
.footer__tagline { font-family: var(--font-display); font-style: italic; color: var(--ink-muted); font-size: var(--fs-md); max-width: 32ch;  margin: 0; }
.footer__bottom {
  max-width: var(--shell-max);
  margin: var(--sp-10) auto 0;
  padding-top: var(--sp-6);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Cmd-K palette */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--sp-4) var(--sp-4);
  background: rgba(20, 24, 31, 0.5);
  backdrop-filter: blur(4px);
}
.cmdk[data-open="true"] { display: flex; animation: fadein var(--t-fast); }
.cmdk__panel {
  width: 100%;
  max-width: 600px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.cmdk__input {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: 0;
  background: transparent;
  font-size: var(--fs-md);
  color: var(--ink);
  outline: 0;
  border-bottom: 1px solid var(--rule);
}
.cmdk__input::placeholder { color: var(--ink-muted); }
.cmdk__results {
  overflow-y: auto;
  padding: var(--sp-2);
  flex: 1;
}
.cmdk__group { margin-bottom: var(--sp-2); }
.cmdk__group-title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  padding: var(--sp-2) var(--sp-3);
}
.cmdk__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-align: left;
}
.cmdk__item:hover, .cmdk__item.is-active { background: var(--bg-soft); text-decoration: none; }
.cmdk__item-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-muted); }
.cmdk__empty { padding: var(--sp-8); text-align: center; color: var(--ink-muted); font-size: var(--fs-sm); }

/* Theme toggle */
.theme-toggle__sun, .theme-toggle__moon { display: none; }
[data-theme="light"] .theme-toggle__moon { display: block; }
[data-theme="dark"] .theme-toggle__sun { display: block; }

/* Stats / KPI tiles */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  margin: var(--sp-6) 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
}
.stat {
  padding: var(--sp-5);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.stat:last-child { border-right: 0; }
.stat__num {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 500;
  color: var(--accent);
  line-height: 1;

  letter-spacing: -0.03em;
  margin-bottom: var(--sp-2);
}
.stat__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

/* Steps (numbered process) */
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: var(--sp-6) 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 56px;
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px dashed var(--rule);
}
.steps > li:last-child { border-bottom: 0; }
.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-faint);
  border: 1px solid var(--accent);
  border-radius: 50%;
}
.steps h4 { margin-top: 0; }

/* Splitter for L1 hero illustrations on level pages */
.section-rule {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin: var(--sp-12) 0 var(--sp-8);
}
.section-rule::before { content: ""; flex: 1; height: 1px; background: var(--rule); }
.section-rule::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.section-rule__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  flex-shrink: 0;
}

/* Visually hidden */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Print */
@media print {
  .topbar, .rail, .toc, .footer, .cmdk { display: none !important; }
  .main { padding: 0; }
  body { background: white; }
}

/* =========================================================================
   v2 ADDITIONS — Apprentice/Yardmaster split, Tech section, Mindmaps
   ========================================================================= */

/* ---------- Rail: split tracks ---------- */
.rail__section--track + .rail__section--track {
  position: relative;
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
}
.rail__section--track + .rail__section--track::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--rule) 0 4px, transparent 4px 8px);
}
.rail__track-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-3);
}
.rail__range {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rail__section--yardmaster .progress-item__num { color: var(--ochre, var(--accent)); }
[data-theme="dark"] .rail__section--yardmaster .progress-item__num { color: var(--accent); }

/* ---------- Topbar dropdown — groups & glyph ---------- */
.topnav__dropdown-trigger.is-section-active {
  color: var(--accent);
  background: var(--accent-faint);
}
.topnav__dropdown-menu--levels,
.topnav__dropdown-menu--tech {
  min-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
}
.topnav__dropdown-menu--tech { min-width: 360px; }
.topnav__dropdown-group-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-muted);
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  border-top: 1px solid var(--rule-soft);
  margin-top: var(--sp-1);
}
.topnav__dropdown-group-label:first-child { border-top: 0; margin-top: 0; }
.topnav__dropdown-group-label--track {
  color: var(--accent);
  background: var(--accent-faint);
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.topnav__dropdown-link--lead {
  background: linear-gradient(to right, var(--accent-faint), transparent 80%);
  border-bottom: 1px solid var(--rule-soft);
}
.topnav__dropdown-link--lead span:first-child { font-weight: 600; color: var(--ink); }

/* The mindmap glyph that appears in tech tab labels */
.mm-glyph {
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 0.4em;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8em;
  vertical-align: -1px;
  line-height: 1;
}
.mm-glyph--inline {
  margin-left: 0.3em;
  margin-right: 0;
  color: var(--accent);
  opacity: 0.7;
}

/* ---------- Tech section: tab strip ---------- */
.tech-section { padding-top: 0; }
.tech-tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 8;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  margin: 0 calc(-1 * var(--sp-8)) var(--sp-8);
  padding: 0 var(--sp-8);
}
.tech-tabs__inner {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--sp-3) 0;
  scroll-snap-type: x proximity;
}
.tech-tabs__inner::-webkit-scrollbar { display: none; }
.tech-tabs__group {
  display: flex;
  gap: 2px;
  padding-right: var(--sp-3);
  margin-right: var(--sp-3);
  border-right: 1px solid var(--rule-soft);
  flex-shrink: 0;
  scroll-snap-align: start;
}
.tech-tabs__group:last-child { border-right: 0; }
.tech-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  border: 1px solid transparent;
  position: relative;
}
.tech-tab:hover {
  background: var(--bg-soft);
  color: var(--ink);
  text-decoration: none;
}
.tech-tab[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--accent);
  font-weight: 600;
}
.tech-tab[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: -4px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--accent);
}
.tech-tab--lead {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--rule);
}
.tech-tab--lead .mm-glyph { color: var(--accent); opacity: 1; }
.tech-tab__group-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  align-self: center;
  padding-right: var(--sp-2);
  flex-shrink: 0;
}

/* ---------- Tech page header ---------- */
.tech-header {
  padding: var(--sp-10) 0 var(--sp-6);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--sp-8);
}
.tech-header__meta {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-3);
}
.tech-header__tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--accent);
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent-faint);
}
.tech-header__intro {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.tech-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  line-height: 1.05;
  margin: 0 0 var(--sp-3);
  letter-spacing: -0.035em;
  font-weight: 700;
}
.tech-header__lede {
  font-size: var(--fs-md);
  color: var(--ink-soft);
  max-width: 60ch;
  line-height: 1.6;
  margin: 0;
}

/* ---------- Mindmap canvas ---------- */
.mindmap {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  margin: var(--sp-6) 0 var(--sp-10);
  overflow: hidden;
}
.mindmap__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.mindmap__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0;
  font-weight: 500;
}
.mindmap__title .mm-glyph { color: var(--accent); }
.mindmap__controls {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
}
.mindmap__view-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.mindmap__view-btn {
  background: transparent;
  border: 0;
  padding: var(--sp-1) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border-right: 1px solid var(--rule);
}
.mindmap__view-btn:last-child { border-right: 0; }
.mindmap__view-btn:hover { color: var(--ink); background: var(--bg-soft); }
.mindmap__view-btn[aria-pressed="true"] {
  background: var(--accent-faint);
  color: var(--accent);
  font-weight: 600;
}
.mindmap__hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}
.mindmap__svg-wrap {
  position: relative;
  background:
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg-elevated);
  min-height: 480px;
  overflow: hidden;
}
.mindmap__svg {
  display: block;
  width: 100%;
  height: 480px;
  cursor: grab;
}
.mindmap__svg:active { cursor: grabbing; }
.mindmap__legend {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  border-top: 1px solid var(--rule);
  background: var(--bg-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  flex-wrap: wrap;
}
.mindmap__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mindmap__legend-swatch {
  display: inline-block;
  width: 14px; height: 8px;
  border: 1px solid var(--ink-soft);
  border-radius: 1px;
}
.mindmap__legend-swatch--center { background: var(--accent); border-color: var(--accent); }
.mindmap__legend-swatch--depends { background: transparent; }
.mindmap__legend-swatch--alt { background: transparent; border-style: dashed; }
.mindmap__legend-swatch--anchor { background: var(--accent-faint); border-color: var(--accent); }

/* SVG mindmap node styling — driven by class on group elements */
.mm-node-rect {
  fill: var(--bg);
  stroke: var(--ink-soft);
  stroke-width: 1.2;
  transition: fill var(--t-fast), stroke var(--t-fast);
}
.mm-node-rect--center { fill: var(--accent); stroke: var(--accent); }
.mm-node-rect--depends { fill: var(--bg); stroke: var(--ink-soft); }
.mm-node-rect--used { fill: var(--bg); stroke: var(--info); }
.mm-node-rect--alt { fill: transparent; stroke: var(--ink-muted); stroke-dasharray: 3 2; }
.mm-node-rect--anchor { fill: var(--accent-faint); stroke: var(--accent); }
.mm-node-rect--glossary { fill: var(--bg-soft); stroke: var(--rule-strong); }
.mm-node-text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--ink);
  pointer-events: none;
  user-select: none;
}
.mm-node-text--center { fill: var(--accent-ink); font-weight: 600; font-size: 13px; }
.mm-node-text--small { font-size: 10px; fill: var(--ink-soft); }
.mm-node-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}
.mm-edge { stroke: var(--ink-soft); stroke-width: 1; fill: none; }
.mm-edge--alt { stroke-dasharray: 3 2; stroke: var(--ink-muted); }
.mm-edge--anchor { stroke: var(--accent); stroke-opacity: 0.6; }
.mm-ring-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mm-node {
  cursor: pointer;
  transition: opacity var(--t-fast);
}
.mm-node:hover .mm-node-rect { stroke-width: 2; }
.mm-node:hover .mm-node-rect:not(.mm-node-rect--center) { fill: var(--accent-faint); }
.mindmap[data-focus] .mm-node:not([data-focused]) { opacity: 0.25; }
.mindmap[data-focus] .mm-edge:not([data-focused]) { opacity: 0.15; }

/* Tooltip */
.mm-tooltip {
  position: absolute;
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  max-width: 280px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.mm-tooltip[data-visible] { opacity: 1; }

/* ---------- Tech-specific content blocks ---------- */
.tech-block {
  margin: var(--sp-10) 0;
}
.tech-block + .tech-block {
  border-top: 1px solid var(--rule-soft);
  padding-top: var(--sp-8);
}
.tech-block__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}
.tech-block h3 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  letter-spacing: -0.02em;
  margin: 0 0 var(--sp-4);
  font-weight: 500;
}
.tech-anchor-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
}
.tech-anchor-list li { margin: 0; padding-left: 0; }
.tech-anchor-list li::before { display: none; }
.tech-anchor-card {
  display: block;
  padding: var(--sp-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  text-decoration: none;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.tech-anchor-card:hover {
  border-color: var(--accent);
  background: var(--accent-faint);
  text-decoration: none;
}
.tech-anchor-card__lvl {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.tech-anchor-card__title {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--ink);
  font-weight: 500;
}

/* Mobile: dropdown menus & tabs */
@media (max-width: 700px) {
  .topnav__dropdown-menu--tech,
  .topnav__dropdown-menu--levels { min-width: 280px; }
  .tech-tabs { margin-left: calc(-1 * var(--sp-4)); margin-right: calc(-1 * var(--sp-4)); padding: 0 var(--sp-4); }
  .mindmap__svg { height: 380px; }
}
