/* ==========================================================================
   DSA Atlas — design system  v2
   Priorities this pass: lighter, calmer, far more breathing room.
   Light theme is the default. No build step, no CDN, no webfonts.
   ========================================================================== */

:root {
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  /* light — the default */
  --bg:        #fbfbfd;
  --bg-sunk:   #f4f5f9;
  --surface:   #ffffff;
  --raised:    #ffffff;
  --line:      #e6e8f0;
  --line-soft: #eef0f6;

  --text:      #15171e;
  --text-dim:  #545c6e;
  --text-mute: #8a91a2;

  --primary:   #5b53d6;
  --primary-2: #7c6ce8;
  --teal:      #0d9488;
  --amber:     #b45309;
  --rose:      #be123c;

  --core:         var(--teal);
  --intermediate: var(--amber);
  --advanced:     var(--rose);
  --easy:   var(--teal);
  --medium: var(--amber);
  --hard:   var(--rose);

  --tint-primary: #f2f1fd;
  --tint-teal:    #eefaf7;
  --tint-amber:   #fdf6ec;
  --tint-rose:    #fdf0f3;

  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;

  --sidebar: 292px;
  --rail: 200px;
  --measure: 70ch;      /* reading width for prose */
  --shell: 940px;

  --sh-1: 0 1px 2px rgba(21,23,30,.04), 0 1px 3px rgba(21,23,30,.03);
  --sh-2: 0 2px 4px rgba(21,23,30,.04), 0 8px 20px -10px rgba(21,23,30,.10);
  --sh-3: 0 20px 56px -20px rgba(21,23,30,.22);

  --ease: cubic-bezier(.22,.61,.36,1);
}

[data-theme='dark'] {
  --bg:        #0e1016;
  --bg-sunk:   #141822;
  --surface:   #14171f;
  --raised:    #171b24;
  --line:      #252a36;
  --line-soft: #1d222c;

  --text:      #e9ecf3;
  --text-dim:  #a2aabb;
  --text-mute: #737c8e;

  --primary:   #9b8cfa;
  --primary-2: #b3a5ff;
  --teal:      #2dd4bf;
  --amber:     #fbbf24;
  --rose:      #fb7185;

  --tint-primary: #1c1b33;
  --tint-teal:    #102b29;
  --tint-amber:   #2b2413;
  --tint-rose:    #2c1620;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 2px 6px rgba(0,0,0,.35), 0 10px 26px -14px rgba(0,0,0,.6);
  --sh-3: 0 24px 60px -22px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }
::selection { background: var(--tint-primary); }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1,h2,h3,h4 { line-height: 1.28; letter-spacing: -.018em; margin: 0; font-weight: 640; }
code, kbd, pre { font-family: var(--mono); font-variant-ligatures: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ==========================================================================
   shell
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 22px 22px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--primary);
  display: grid; place-items: center;
  font: 700 14px/1 var(--mono); color: #fff;
}
.brand-name { font-size: 14.5px; font-weight: 650; letter-spacing: -.015em; }
.brand-sub { font-size: 11.5px; color: var(--text-mute); }

.side-search { padding: 0 16px 18px; }
.searchbtn {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; font: inherit; font-size: 13.5px; color: var(--text-mute);
  background: var(--bg-sunk); border: 1px solid transparent; border-radius: 9px;
  cursor: pointer; transition: border-color .16s, background .16s;
}
.searchbtn:hover { border-color: var(--line); background: var(--surface); }
.searchbtn kbd {
  margin-left: auto; font-size: 10.5px; padding: 2px 5px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-mute);
}

.side-nav { flex: 1; overflow-y: auto; padding: 0 10px 34px; scrollbar-width: thin; }
.side-nav::-webkit-scrollbar { width: 10px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; border: 3.5px solid transparent; background-clip: content-box; }

.nav-quick { display: grid; gap: 1px; margin-bottom: 22px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-dim); cursor: pointer;
  transition: background .14s, color .14s;
}
.nav-link:hover { background: var(--bg-sunk); color: var(--text); text-decoration: none; }
.nav-link.on { background: var(--tint-primary); color: var(--primary); font-weight: 560; }
.nav-link .ico { width: 14px; text-align: center; font-size: 11px; opacity: .75; }

.nav-kind {
  padding: 18px 11px 8px; font: 600 10.5px/1 var(--sans);
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute);
}
.nav-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 6.5px 11px; border-radius: 8px; font-size: 13px;
  color: var(--text-dim); transition: background .14s;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--bg-sunk); color: var(--text); }
.nav-group > summary .caret { font-size: 8px; opacity: .5; transition: transform .18s var(--ease); }
.nav-group[open] > summary .caret { transform: rotate(90deg); }
.nav-group > summary .cnt { margin-left: auto; font: 500 10.5px var(--mono); color: var(--text-mute); }

.nav-items { display: grid; gap: 1px; padding: 2px 0 8px 19px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5.5px 10px; border-radius: 7px;
  font-size: 12.8px; color: var(--text-dim); cursor: pointer;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--bg-sunk); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--tint-primary); color: var(--primary); font-weight: 560; }

/* ---------- learning-path navigation ----------
   Reuses .seg / .seg-pill from the level switcher; these rules only narrow it
   to the sidebar and label the stages. */
.nav-seg { margin: 0 0 16px; }
.nav-seg .seg { width: 100%; }
.nav-seg .seg button { flex: 1 1 0; padding: 7px 6px; font-size: 11.8px; }
.nav-stage > summary .nav-stage-n { font: 500 10.5px var(--mono); color: var(--text-mute); letter-spacing: .03em; }
.nav-goal {
  padding: 2px 10px 8px; font-size: 11.5px; line-height: 1.5;
  color: var(--text-mute); max-width: 34ch;
}
.nav-ord { width: 13px; flex: none; text-align: right; font: 500 10px var(--mono); color: var(--text-mute); }
.nav-item.on .nav-ord { color: var(--primary); }
.tier-dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.tier-core { background: var(--core); }
.tier-intermediate { background: var(--intermediate); }
.tier-advanced { background: var(--advanced); }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 0 38px; min-height: 56px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.crumb { font-size: 12.5px; color: var(--text-mute); display: flex; align-items: center; gap: 7px; min-width: 0; }
.crumb b { color: var(--text-dim); font-weight: 500; }
.crumb .sep { opacity: .35; }
.topbar-right { margin-left: auto; display: flex; gap: 7px; }

.iconbtn {
  width: 31px; height: 31px; display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--text-mute); cursor: pointer; font-size: 13px;
  transition: color .15s, background .15s;
}
.iconbtn:hover { color: var(--text); background: var(--bg-sunk); }

.page { flex: 1; padding: 44px 38px 140px; }
.wrap { max-width: var(--shell); margin: 0 auto; }
.wrap-rail {
  max-width: calc(var(--shell) + var(--rail) + 56px); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0,1fr) var(--rail); gap: 56px; align-items: start;
}

/* ==========================================================================
   level switcher
   ========================================================================== */
.levelbar { position: sticky; top: 56px; z-index: 30; margin: 0 0 40px; padding: 16px 0; background: linear-gradient(to bottom, var(--bg) 68%, transparent); }
.levelbar-inner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.levelbar-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); font-weight: 600; }

.seg { position: relative; display: flex; gap: 2px; padding: 3px; background: var(--bg-sunk); border-radius: 10px; }
.seg-pill { position: absolute; top: 3px; bottom: 3px; left: 3px; border-radius: 7px; background: var(--surface); box-shadow: var(--sh-1); transition: transform .32s var(--ease), width .32s var(--ease); }
.seg button {
  position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  font: 560 12.5px/1 var(--sans); color: var(--text-mute);
  padding: 7px 14px; border-radius: 7px; white-space: nowrap; transition: color .2s;
}
.seg button.on { color: var(--primary); font-weight: 620; }
.seg button:hover:not(.on) { color: var(--text-dim); }
.seg-hint { font-size: 12.5px; color: var(--text-mute); }
@media (prefers-reduced-motion: reduce) { .seg-pill { transition: none; } .hero-orb { animation: none; } }

/* ==========================================================================
   sections — open by default, or folded for the heavy ones
   ========================================================================== */
.sec { margin: 0 0 52px; scroll-margin-top: 130px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.sec-num { font: 500 11px var(--mono); color: var(--text-mute); letter-spacing: .04em; }
.sec-title { font-size: 19px; font-weight: 640; letter-spacing: -.022em; }
.sec-note { margin-left: auto; font-size: 12px; color: var(--text-mute); }

/* folded variant */
.sec-fold { margin: 0 0 14px; border-top: 1px solid var(--line-soft); }
.sec-fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px;
  padding: 18px 0; transition: opacity .14s;
}
.sec-fold > summary::-webkit-details-marker { display: none; }
.sec-fold > summary:hover { opacity: .68; }
.sec-fold > summary .sec-title { font-size: 17px; }
.sec-fold > summary .fold-caret { margin-left: auto; font-size: 9px; color: var(--text-mute); transition: transform .2s var(--ease); }
.sec-fold[open] > summary .fold-caret { transform: rotate(90deg); }
.sec-fold > summary .sec-note { margin-left: 0; }
.sec-fold-body { padding: 4px 0 34px; }

.prose { color: var(--text-dim); max-width: var(--measure); }
.prose p { margin: 0 0 16px; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 620; }
.prose code {
  font-size: 12.8px; padding: 1.5px 5px; border-radius: 5px;
  background: var(--bg-sunk); color: var(--primary);
}
.prose ul { margin: 0 0 16px; padding-left: 21px; }
.prose li { margin-bottom: 7px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font: 500 12px/1 var(--mono); padding: 5.5px 9px; border-radius: 6px; background: var(--bg-sunk); color: var(--text-dim); }
.pill-yes { background: var(--tint-teal); color: var(--teal); }
.pill-no  { background: var(--tint-rose); color: var(--rose); }

.badge { display: inline-flex; align-items: center; font: 600 10px/1 var(--sans); letter-spacing: .07em; text-transform: uppercase; padding: 4.5px 7px; border-radius: 5px; }
.badge-core, .badge-easy   { background: var(--tint-teal);  color: var(--teal); }
.badge-intermediate, .badge-medium { background: var(--tint-amber); color: var(--amber); }
.badge-advanced, .badge-hard { background: var(--tint-rose); color: var(--rose); }
.badge-ds   { background: var(--tint-teal); color: var(--teal); }
.badge-algo { background: var(--tint-primary); color: var(--primary); }

.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.wordcount { font: 500 11px var(--mono); color: var(--text-mute); letter-spacing: .03em; }

/* ==========================================================================
   home
   ========================================================================== */
.hero { position: relative; padding: 36px 0 52px; }
.hero-orb {
  position: absolute; right: -60px; top: -70px; width: 320px; height: 320px;
  pointer-events: none; opacity: .16; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--primary), transparent 68%);
  animation: drift 20s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(-26px, 22px) scale(1.1); } }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 22px;
  font: 500 12px/1 var(--sans); color: var(--text-mute);
}
.hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.hero h1 { font-size: clamp(30px, 4.4vw, 44px); font-weight: 680; letter-spacing: -.032em; margin-bottom: 20px; max-width: 20ch; }
.hero h1 .g { color: var(--primary); }
.hero-lede { max-width: 60ch; margin: 0 0 30px; font-size: 16.5px; color: var(--text-dim); }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 17px; border-radius: 9px; border: 1px solid var(--line);
  font: 560 13.5px/1 var(--sans); cursor: pointer; background: var(--surface); color: var(--text);
  transition: background .14s, border-color .14s;
}
.btn:hover { background: var(--bg-sunk); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--primary-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 0; margin: 0 0 56px; border-top: 1px solid var(--line-soft); }
.stat { padding: 20px 20px 20px 0; }
.stat-n { font: 650 26px/1 var(--sans); letter-spacing: -.028em; color: var(--text); }
.stat-l { margin-top: 7px; font-size: 12px; color: var(--text-mute); }

.feat { display: block; padding: 0; cursor: pointer; }
.feat:hover { text-decoration: none; }
.feat:hover h3 { color: var(--primary); }
.feat-ico { font-size: 15px; color: var(--primary); margin-bottom: 12px; }
.feat h3 { font-size: 15px; margin-bottom: 8px; color: var(--text); transition: color .15s; }
.feat p { margin: 0; font-size: 13.5px; color: var(--text-dim); line-height: 1.62; max-width: 34ch; }

/* topic list — flat rows, much lighter than cards */
.tlist { display: grid; }
.trow {
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: baseline;
  padding: 15px 2px; border-top: 1px solid var(--line-soft); cursor: pointer;
  transition: background .13s;
}
.trow:hover { background: var(--bg-sunk); text-decoration: none; }
.trow:hover .trow-name { color: var(--primary); }
.trow-main { min-width: 0; }
.trow-name { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 580; color: var(--text); margin-bottom: 4px; transition: color .15s; }
.trow-tag { font-size: 13.2px; color: var(--text-mute); line-height: 1.55; max-width: 68ch; }
.trow-meta { display: flex; align-items: center; gap: 10px; font: 500 11px var(--mono); color: var(--text-mute); white-space: nowrap; }
.grouphead { margin: 44px 0 4px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); font-weight: 600; }
.kindhead { margin: 60px 0 8px; font-size: 22px; font-weight: 650; letter-spacing: -.024em; }
.kindsub { font-size: 13.5px; color: var(--text-mute); margin-bottom: 4px; }

/* ==========================================================================
   topic page
   ========================================================================== */
.thead { margin-bottom: 0; }
.thead-badges { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.thead h1 { font-size: clamp(26px, 3.4vw, 36px); letter-spacing: -.03em; margin-bottom: 14px; max-width: 26ch; }
.thead-tag { font-size: 17px; color: var(--text-dim); max-width: 62ch; line-height: 1.6; }
.thead-aka { margin-top: 14px; font-size: 12.5px; color: var(--text-mute); }

/* where the topic sits in the learning path, just under the badges */
.thead-path {
  display: flex; align-items: baseline; gap: 8px 14px; flex-wrap: wrap;
  margin: -6px 0 16px; font-size: 12.5px; color: var(--text-mute);
}
.thead-stage { color: var(--text-dim); font-weight: 560; }
.thead-needs a { color: var(--text-dim); }
.thead-needs a:hover { color: var(--primary); }

.analogy { margin: 28px 0 0; padding: 0 0 0 20px; border-left: 2px solid var(--primary); max-width: var(--measure); }
.analogy .q { display: none; }
.analogy p { margin: 0; font-size: 15.5px; font-style: italic; color: var(--text-dim); }

.expl { position: relative; }
.expl-body { display: none; }
.expl-body.on { display: block; animation: fade .26s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.expl-6  .prose { font-size: 18px; line-height: 1.82; max-width: 54ch; }
.expl-12 .prose { font-size: 16.2px; line-height: 1.78; max-width: 62ch; }

/* complexity — plain rows, no boxes */
.cxbox { display: grid; gap: 0; max-width: var(--measure); }
.cxrow { display: grid; grid-template-columns: 84px 1fr; gap: 18px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.cxk { font: 600 10.5px/1.9 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); }
.cxv { font-size: 13.8px; color: var(--text-dim); }
.cxv b { color: var(--text); font-family: var(--mono); font-weight: 600; font-size: 13px; }
.optable { width: 100%; border-collapse: collapse; font-size: 13px; }
.optable td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.optable tr:last-child td { border-bottom: 0; }
.optable td:first-child { font-family: var(--mono); color: var(--text); width: 45%; }
.optable td:last-child { font-family: var(--mono); color: var(--primary); }

/* recognise */
.reco { display: grid; gap: 26px; }
.reco-rule { padding: 18px 20px; border-radius: var(--r-lg); background: var(--tint-primary); font-size: 14.5px; color: var(--text); max-width: var(--measure); }
.reco-rule b { display: block; font: 600 10.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--primary); margin-bottom: 9px; }
.reco-sub { font: 600 10.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 10px; }
.chints { display: grid; gap: 0; max-width: var(--measure); }
.chint { display: grid; grid-template-columns: minmax(140px, 36%) 1fr; gap: 18px; padding: 13px 0; border-top: 1px solid var(--line-soft); font-size: 13.2px; }
.chint code { font-size: 12.4px; color: var(--amber); }
.chint span { color: var(--text-dim); }
@media (max-width: 760px) { .chint { grid-template-columns: 1fr; gap: 5px; } }

/* mental model */
.mlist { display: grid; gap: 14px; max-width: var(--measure); padding: 0; margin: 0; counter-reset: m; }
.mlist li { counter-increment: m; list-style: none; display: grid; grid-template-columns: 22px 1fr; gap: 14px; font-size: 14px; color: var(--text-dim); }
.mlist li::before { content: counter(m); font: 500 11.5px/1.7 var(--mono); color: var(--text-mute); }

/* code */
.codeblk { margin: 0 0 20px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.codebar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg-sunk); border-bottom: 1px solid var(--line); }
.dots { display: none; }
.codelabel { font: 560 12.5px var(--sans); color: var(--text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codelang { font: 600 9.5px var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.copybtn { margin-left: auto; font: 500 11.5px var(--sans); padding: 3.5px 9px; border-radius: 6px; background: none; border: 1px solid var(--line); color: var(--text-mute); cursor: pointer; transition: color .14s, border-color .14s; }
.copybtn:hover { color: var(--primary); border-color: var(--primary); }
.copybtn.done { color: var(--teal); border-color: var(--teal); }
.codeblk pre { margin: 0; padding: 18px 20px; overflow-x: auto; font-size: 12.8px; line-height: 1.72; background: var(--surface); }
.codeblk pre::-webkit-scrollbar { height: 9px; }
.codeblk pre::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }
.codenotes { padding: 13px 16px; border-top: 1px solid var(--line-soft); background: var(--bg-sunk); display: grid; gap: 7px; }
.codenotes div { font-size: 12.8px; color: var(--text-dim); padding-left: 15px; position: relative; }
.codenotes div::before { content: '\2014'; position: absolute; left: 0; color: var(--text-mute); }

/* syntax — restrained */
.tok-key { color: #a626a4; }
.tok-str { color: #0a8754; }
.tok-com { color: var(--text-mute); font-style: italic; }
.tok-num { color: #b06000; }
.tok-fn  { color: #3d5afe; }
[data-theme='dark'] .tok-key { color: #c792ea; }
[data-theme='dark'] .tok-str { color: #7ee0b8; }
[data-theme='dark'] .tok-num { color: #ffcb6b; }
[data-theme='dark'] .tok-fn  { color: #82aaff; }

/* walkthrough */
.steps { display: grid; gap: 0; max-width: var(--measure); }
.step { padding: 13px 0; border-top: 1px solid var(--line-soft); }
.step-state { font: 500 12.8px var(--mono); color: var(--text); white-space: pre-wrap; }
.step-note { margin-top: 5px; font-size: 13px; color: var(--text-mute); }
.wt-io { display: grid; gap: 10px; margin-bottom: 8px; max-width: var(--measure); }
.wt-io > div { padding: 13px 16px; border-radius: var(--r); background: var(--bg-sunk); }
.wt-io b { font: 600 10.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); display: block; margin-bottom: 7px; }
.wt-io code { font-size: 12.8px; color: var(--text); white-space: pre-wrap; }
.wt-res { background: var(--tint-teal) !important; }
.wt-res code { color: var(--teal); font-weight: 600; }

/* variants */
.vgroup { margin-bottom: 30px; }
.vgroup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.vgroup-line { display: none; }
.vcard { padding: 20px 0; border-top: 1px solid var(--line-soft); }
.vcard-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.vcard-title { font-size: 14.8px; font-weight: 600; color: var(--text); }
.vcard-src { font: 500 11.5px var(--mono); color: var(--text-mute); margin-left: auto; }
.vrow { display: grid; grid-template-columns: 82px 1fr; gap: 16px; font-size: 13.4px; margin-bottom: 8px; max-width: var(--measure); }
.vrow b { font: 600 10px/1.9 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.vrow span { color: var(--text-dim); }
.vrow.cx span { font-family: var(--mono); font-size: 12.4px; color: var(--text-mute); }
@media (max-width: 700px) { .vrow { grid-template-columns: 1fr; gap: 2px; } }

/* escalation */
.escl-split { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
@media (max-width: 1020px) { .escl-split { grid-template-columns: 1fr; gap: 30px; } }
.escl-h { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; font: 600 11.5px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase; }
.escl-h.e2m { color: var(--amber); }
.escl-h.m2h { color: var(--rose); }
.rung { padding: 0 0 26px; }
.rung-mark { display: none; }
.rung-lever { font-size: 14.4px; font-weight: 600; color: var(--text); margin-bottom: 11px; }
.rung-grid { display: grid; gap: 8px; }
.rung-item { display: grid; grid-template-columns: 74px 1fr; gap: 14px; font-size: 13.2px; }
.rung-item b { font: 600 10px/1.9 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.rung-item span { color: var(--text-dim); }
.rung-item.handling { padding: 12px 14px; border-radius: var(--r); background: var(--tint-teal); margin-top: 6px; }
.rung-item.handling b { color: var(--teal); }
@media (max-width: 700px) { .rung-item { grid-template-columns: 1fr; gap: 2px; } }

.tells, .drills { display: grid; gap: 0; max-width: var(--measure); }
.tell, .drill { display: grid; grid-template-columns: 20px 1fr; gap: 14px; font-size: 13.6px; color: var(--text-dim); padding: 13px 0; border-top: 1px solid var(--line-soft); }
.tell::before { content: '\25B8'; color: var(--amber); font-size: 11px; line-height: 1.9; }
.drills { counter-reset: d; }
.drill { counter-increment: d; }
.drill::before { content: counter(d); font: 500 11.5px/1.9 var(--mono); color: var(--text-mute); }

/* pitfalls */
.pit { padding: 18px 0; border-top: 1px solid var(--line-soft); max-width: var(--measure); }
.pit-trap { display: grid; grid-template-columns: 18px 1fr; gap: 13px; font-size: 13.6px; color: var(--text); margin-bottom: 9px; }
.pit-trap::before { content: '\00d7'; font: 600 15px/1.4 var(--mono); color: var(--rose); }
.pit-fix { display: grid; grid-template-columns: 18px 1fr; gap: 13px; font-size: 13.4px; color: var(--text-dim); }
.pit-fix::before { content: '\2713'; font: 600 12px/1.6 var(--mono); color: var(--teal); }

/* tables */
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
.ptable, .ctable { width: 100%; border-collapse: collapse; font-size: 13.4px; }
.ptable th, .ctable th { text-align: left; padding: 12px 16px; font: 600 10.5px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); background: var(--bg-sunk); border-bottom: 1px solid var(--line); }
.ptable td, .ctable td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.ptable tr:last-child td, .ctable tr:last-child td { border-bottom: 0; }
.ptable tr:hover td, .ctable tr:hover td { background: var(--bg-sunk); }
.ptable .why { color: var(--text-mute); font-size: 12.9px; }
.ctable code { font-size: 12.3px; color: var(--amber); }
.ctable .tname { font-weight: 580; white-space: nowrap; }

/* rail */
.rail { position: sticky; top: 130px; }
.rail-title { font: 600 10.5px/1 var(--sans); letter-spacing: .11em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 14px; }
.rail-links { display: grid; gap: 2px; }
.rail-link { display: block; padding: 4px 0 4px 13px; font-size: 12.6px; color: var(--text-mute); cursor: pointer; border-left: 2px solid var(--line); transition: color .14s, border-color .14s; }
.rail-link:hover { color: var(--text); text-decoration: none; }
.rail-link.on { color: var(--primary); border-left-color: var(--primary); }
@media (max-width: 1160px) { .wrap-rail { grid-template-columns: 1fr; } .rail { display: none; } }

/* related / sources */
.rel { display: flex; flex-wrap: wrap; gap: 7px; }
.rel a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 8px; font-size: 13px; background: var(--bg-sunk); color: var(--text-dim); transition: background .14s, color .14s; }
.rel a:hover { background: var(--tint-primary); color: var(--primary); text-decoration: none; }
.rel a.missing { opacity: .4; cursor: not-allowed; }
.srcs { display: grid; gap: 9px; max-width: var(--measure); }
.srcs a { font-size: 13.2px; color: var(--text-dim); display: flex; gap: 10px; align-items: baseline; }
.srcs .n { font: 500 11px var(--mono); color: var(--text-mute); flex: none; }

/* prev / next */
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; padding-top: 30px; border-top: 1px solid var(--line); }
.pn a { padding: 16px 18px; border-radius: var(--r-lg); border: 1px solid var(--line); transition: background .15s; }
.pn a:hover { background: var(--bg-sunk); text-decoration: none; }
.pn .k { font-size: 11.5px; color: var(--text-mute); display: block; margin-bottom: 6px; }
.pn .v { font-size: 14px; font-weight: 580; color: var(--text); }
.pn .next { text-align: right; }
@media (max-width: 700px) { .pn { grid-template-columns: 1fr; } }

/* ==========================================================================
   pattern finder
   ========================================================================== */
.finder-in textarea {
  width: 100%; min-height: 170px; resize: vertical; padding: 18px 20px;
  font: 14.5px/1.65 var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color .16s, box-shadow .16s;
}
.finder-in textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--tint-primary); }
.finder-in textarea::placeholder { color: var(--text-mute); }
.finder-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.finder-samples { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.samplebtn { font: 500 12px var(--sans); padding: 6px 11px; border-radius: 7px; background: var(--bg-sunk); border: 1px solid transparent; color: var(--text-dim); cursor: pointer; transition: border-color .14s, color .14s; }
.samplebtn:hover { border-color: var(--primary); color: var(--primary); }

.hit { padding: 24px 0; border-top: 1px solid var(--line-soft); }
.hit-top { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; flex-wrap: wrap; }
.hit-rank { font: 500 12px var(--mono); color: var(--text-mute); flex: none; }
.hit-1 .hit-rank { color: var(--primary); font-weight: 700; }
.hit-name { font-size: 15.5px; font-weight: 620; color: var(--text); }
.hit-score { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.meter { width: 92px; height: 4px; border-radius: 99px; background: var(--bg-sunk); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s var(--ease); }
.hit-pct { font: 600 11.5px var(--mono); color: var(--text-mute); min-width: 32px; text-align: right; }
.hit-why { display: grid; gap: 9px; max-width: var(--measure); }
.hit-why-row { display: grid; grid-template-columns: 96px 1fr; gap: 14px; font-size: 12.8px; align-items: start; }
.hit-why-row b { font: 600 10px/1.7 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.hit-rule { margin-top: 14px; padding: 13px 16px; border-radius: var(--r); background: var(--bg-sunk); font-size: 13.2px; color: var(--text-dim); max-width: var(--measure); }
@media (max-width: 700px) { .hit-why-row { grid-template-columns: 1fr; gap: 3px; } }

.empty { text-align: center; padding: 70px 20px; color: var(--text-mute); max-width: 52ch; margin: 0 auto; }
.empty-ico { font-size: 26px; margin-bottom: 16px; opacity: .4; }

/* cheatsheet */
.budget { display: grid; gap: 0; }
.budget-row { display: grid; grid-template-columns: 110px 150px 1fr; gap: 20px; align-items: baseline; padding: 14px 0; border-top: 1px solid var(--line-soft); font-size: 13.4px; }
.budget-row .n { font: 600 13px var(--mono); color: var(--text); }
.budget-row .cx { font: 500 12.8px var(--mono); color: var(--primary); }
.budget-row .hint { color: var(--text-dim); }
@media (max-width: 780px) { .budget-row { grid-template-columns: 1fr; gap: 4px; } }

/* ==========================================================================
   command palette
   ========================================================================== */
.pal-veil { position: fixed; inset: 0; z-index: 100; background: rgba(21,23,30,.34); backdrop-filter: blur(3px); display: none; }
.pal-veil.on { display: block; animation: fade .15s; }
.pal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px)); z-index: 101; display: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); overflow: hidden;
}
.pal.on { display: block; animation: pop .19s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%); } }
.pal-in { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.pal-in input { flex: 1; border: 0; background: none; font: 16px var(--sans); color: var(--text); }
.pal-in input:focus { outline: none; }
.pal-esc { font: 500 10.5px var(--mono); padding: 3px 6px; border-radius: 4px; background: var(--bg-sunk); color: var(--text-mute); }
.pal-list { max-height: min(440px, 56vh); overflow-y: auto; padding: 8px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.pal-item.on { background: var(--tint-primary); }
.pal-item-name { font-size: 14px; font-weight: 550; color: var(--text); }
.pal-item-sub { font-size: 11.8px; color: var(--text-mute); }
.pal-item-why { margin-left: auto; font: 500 11px var(--mono); color: var(--text-mute); flex: none; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item mark { background: var(--tint-amber); color: var(--amber); border-radius: 3px; }
.pal-foot { display: flex; gap: 16px; padding: 10px 20px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--text-mute); }
.pal-foot kbd { font: 500 10.5px var(--mono); padding: 2px 5px; border-radius: 4px; background: var(--bg-sunk); }

/* mobile */
.menubtn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 286px; z-index: 90; transform: translateX(-100%); transition: transform .26s var(--ease); }
  .side.open { transform: none; box-shadow: var(--sh-3); }
  .menubtn { display: grid; }
  .page { padding: 30px 20px 100px; }
  .topbar { padding: 0 20px; }
  .hero { padding: 20px 0 40px; }
}

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(70px); z-index: 200; padding: 10px 18px; border-radius: 99px; background: var(--text); color: var(--bg); box-shadow: var(--sh-3); font-size: 13px; opacity: 0; transition: transform .28s var(--ease), opacity .28s; }
.toast.on { transform: translateX(-50%); opacity: 1; }

/* fallback where color-mix() is unavailable */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}

/* ==================================================================
   "Where this is used in the real world"
   One card per real system. A numbered badge, the place, why it is
   used there, then plain numbered steps. Kept airy on purpose: this
   section is meant to be read, not scanned.
   ================================================================== */
.usedin { display: grid; gap: 18px; max-width: var(--measure); }
.usedin-item { padding: 22px 24px; }
.usedin-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.usedin-n {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tint-teal); color: var(--teal);
  font: 600 12px/1 var(--sans);
}
.usedin-where { font: 600 15.5px/1.35 var(--sans); color: var(--text); }
.usedin-why { font-size: 14.5px; line-height: 1.65; color: var(--text-dim); }
.usedin-howlabel {
  margin: 16px 0 8px; font: 600 10.5px/1 var(--sans);
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute);
}
.usedin-steps { margin: 0; padding-left: 22px; display: grid; gap: 9px; }
.usedin-steps li { font-size: 14.5px; line-height: 1.65; color: var(--text-dim); }
.usedin-steps li::marker { color: var(--teal); font-weight: 600; font-size: 13px; }

@media (max-width: 720px) {
  .usedin-item { padding: 18px 16px; }
}

/* ==================================================================
   verified video explainers
   Ranked list, best explanation first. No thumbnails on purpose — an
   image from a video host would make every topic page reach out to a
   third party, and this site otherwise loads entirely from disk.
   ================================================================== */
.vids { display: grid; gap: 12px; max-width: var(--measure); }
.vid {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
/* The rank is the whole point of the section, so it reads as a rank and
   not as a bullet. First place is tinted; the rest are quiet. */
.vid-rank {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 12px/1 var(--sans);
  background: var(--bg-sunk); color: var(--text-mute);
}
.vid:first-child .vid-rank { background: var(--tint-primary); color: var(--primary); }
.vid-main { min-width: 0; }
.vid-title {
  display: block;
  font: 600 15px/1.4 var(--sans);
  color: var(--text);
  text-decoration: none;
}
.vid-title:hover { color: var(--primary); text-decoration: underline; }
.vid-meta {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 10px;
  margin-top: 7px;
  font: 500 12.2px/1.5 var(--sans);
  color: var(--text-mute);
}
.vid-meta b { color: var(--text-dim); font-weight: 600; }
/* Dot separators drawn in CSS so the markup stays plain text. */
.vid-meta span + span::before { content: '\00b7'; margin-right: 10px; color: var(--line); }
.vid-why {
  margin-top: 10px;
  font-size: 13.6px; line-height: 1.65;
  color: var(--text-dim);
}
@media (max-width: 720px) {
  .vid { padding: 14px; gap: 10px; grid-template-columns: 24px minmax(0, 1fr); }
}

/* ==================================================================
   company tags on practice problems, and the per-topic roll-up
   ================================================================== */

/* Chips under a problem name in the practice table. */
.cochips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.cochip {
  font: 500 10.8px/1 var(--sans);
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--tint-primary);
  color: var(--primary);
  white-space: nowrap;
  cursor: help;
}
.cochip-more { background: var(--bg-sunk); color: var(--text-mute); }

/* The roll-up section. */
.asked-head { max-width: var(--measure); margin-bottom: 16px; }
.asked-head p { margin: 0; font-size: 13.6px; line-height: 1.7; color: var(--text-dim); }
.asked-head b { color: var(--text); font-weight: 600; }
.asked-none {
  max-width: var(--measure);
  padding: 16px 18px;
  background: var(--bg-sunk);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  font-size: 13.4px; line-height: 1.65;
  color: var(--text-mute);
}
.asked-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 12px;
}
.asked-co {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
}
.asked-co-name {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font: 600 14px/1.3 var(--sans);
  color: var(--text);
  padding-bottom: 9px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.asked-co-name span {
  flex: none;
  font: 500 10.5px/1 var(--sans);
  letter-spacing: .04em;
  color: var(--text-mute);
}
.asked-probs { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.asked-probs a { font-size: 12.9px; line-height: 1.5; color: var(--text-dim); }
.asked-probs a:hover { color: var(--primary); }
/* Where the data came from and what it does not claim. */
.asked-src {
  max-width: var(--measure);
  margin-top: 16px;
  font-size: 12.4px; line-height: 1.7;
  color: var(--text-mute);
}

/* ==================================================================
   pattern finder — clue highlighting and worked examples
   ================================================================== */

/* The pasted statement, with the giveaway phrases marked in place. */
.clue-text {
  max-width: var(--measure);
  padding: 20px 22px;
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-dim);
  white-space: pre-wrap;
}

/* A matched clue. Medium clues are quieter than strong ones, so the eye
   lands on the phrase that actually settles the question. */
mark.clue {
  background: var(--tint-amber);
  color: var(--text);
  padding: 1px 4px;
  border-radius: var(--r-sm);
  box-shadow: inset 0 -2px 0 var(--amber);
  font-weight: 500;
}
mark.clue-strong {
  background: var(--tint-teal);
  box-shadow: inset 0 -2px 0 var(--teal);
  font-weight: 600;
}

/* One row per clue: phrase, arrow, where it points and why. */
.clue-list {
  display: grid;
  gap: 2px;
  max-width: var(--measure);
  margin-top: 18px;
}
.clue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.35fr);
  align-items: start;
  gap: 10px;
  padding: 14px 4px;
  border-top: 1px solid var(--line-soft);
}
.clue-row:first-child { border-top: 0; }
.clue-phrase { font-size: 14px; line-height: 1.6; }
.clue-weak {
  display: inline-block;
  margin-top: 4px;
  font: 500 11px/1.4 var(--sans);
  color: var(--text-mute);
}
.clue-arrow {
  text-align: center;
  color: var(--text-mute);
  font-size: 15px;
  line-height: 1.7;
}
.clue-target a {
  font: 600 14.5px/1.4 var(--sans);
  color: var(--primary);
  text-decoration: none;
}
.clue-target a:hover { text-decoration: underline; }
.clue-target p {
  margin: 5px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
}

/* The always-on teaching section. */
.worked-intro {
  max-width: var(--measure);
  margin: 0 0 22px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-dim);
}
.worked {
  max-width: var(--measure);
  margin-bottom: 26px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.worked-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.worked-n {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tint-primary);
  color: var(--primary);
  font: 600 12px/1 var(--sans);
}
.worked-name {
  font: 600 15.5px/1.3 var(--sans);
  color: var(--text);
  text-decoration: none;
}
.worked-name:hover { text-decoration: underline; }
.worked-answer {
  margin-left: auto;
  font: 500 13px/1.4 var(--sans);
  color: var(--text-mute);
}
.worked-answer a { color: var(--teal); text-decoration: none; font-weight: 600; }
.worked-answer a:hover { text-decoration: underline; }
.worked .clue-text { padding: 16px 18px; font-size: 14px; }
.worked-lesson {
  margin: 14px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--primary);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
}

@media (max-width: 720px) {
  .clue-row { grid-template-columns: 1fr; gap: 4px; }
  .clue-arrow { display: none; }
  .worked { padding: 16px; }
  .worked-answer { margin-left: 0; }
}
