/* ===========================================================
   Staff Engineer Academy — design tokens + layout
   Zero-build CSS. Light/dark via [data-theme] on <html>.
   =========================================================== */

:root {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef2f8;
  --card: #ffffff;
  --text: #16203a;
  --text-soft: #46536e;
  --muted: #6b7893;
  --line: #dde4ef;

  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;

  --fe: #0ea5e9;
  --be: #f97316;
  --ai: #a855f7;
  --px: #10b981;
  --st: #e11d48;

  --good: #0f766e;
  --good-bg: #ecfdf5;
  --warn: #a16207;
  --warn-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;

  --code-bg: #0f172a;
  --code-text: #dbe4f0;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 32, 58, .05), 0 8px 24px rgba(16, 32, 58, .05);
  --shadow-lg: 0 20px 50px rgba(16, 32, 58, .14);
  --header-h: 58px;
  --maxw: 1560px;
}

html[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-elev: #111726;
  --bg-sunken: #0d1320;
  --card: #121927;
  --text: #e9edf6;
  --text-soft: #b6c0d4;
  --muted: #8492ab;
  --line: #25304a;

  --accent: #8b8cf9;
  --accent-soft: #1c2140;
  --accent-text: #b4b5ff;

  --good: #34d399;
  --good-bg: #0c2a23;
  --warn: #fbbf24;
  --warn-bg: #2a2110;
  --danger: #f87171;
  --danger-bg: #2b1416;

  --code-bg: #060a14;
  --code-text: #cdd8ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code:not(pre code) {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .87em;
}

kbd {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-soft);
}

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

/* ---------------- Skip link + a11y ---------------- */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------- Header ---------------- */
header.top {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  header.top {
    background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
  }
}

.nav {
  max-width: var(--maxw); margin: auto; height: var(--header-h);
  padding: 0 18px; display: flex; align-items: center; gap: 14px;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; letter-spacing: -.02em; white-space: nowrap; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--ai));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 900;
}
.brand small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.nav-links { display: flex; gap: 2px; margin-left: 10px; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 11px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-soft);
}
.nav-links a:hover { background: var(--bg-sunken); text-decoration: none; color: var(--text); }
.nav-links a.on { background: var(--accent-soft); color: var(--accent-text); }

.nav-spacer { flex: 1; }

.searchbtn {
  display: flex; align-items: center; gap: 9px; min-width: 230px;
  background: var(--bg-sunken); border: 1px solid var(--line); color: var(--muted);
  padding: 7px 10px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px;
}
.searchbtn:hover { border-color: var(--accent); }
.searchbtn .grow { flex: 1; text-align: left; }

.iconbtn {
  background: var(--bg-sunken); border: 1px solid var(--line); color: var(--text-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: grid; place-items: center;
  font-size: 15px; flex: none;
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent-text); }

.menubtn { display: none; }

/* ---------------- Layout ---------------- */
.layout {
  max-width: var(--maxw); margin: auto;
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 34px;
  padding: 0 18px;
}

aside.side {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 8px 60px; scrollbar-width: thin;
}
aside.side::-webkit-scrollbar { width: 8px; }
aside.side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.side-group { margin-bottom: 6px; }
.side-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; padding: 15px 10px 6px;
}
.side-title .dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
aside.side a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px; color: var(--text-soft); font-size: 13.5px;
}
aside.side a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
aside.side a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
aside.side a .tick { font-size: 11px; color: var(--good); flex: none; width: 12px; }
aside.side a .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main.main { padding: 26px 0 110px; min-width: 0; }

/* ---------------- Generic bits ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin: 14px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

h1 { font-size: 36px; line-height: 1.12; letter-spacing: -.028em; margin: 0 0 12px; }
h2 { font-size: 25px; line-height: 1.22; letter-spacing: -.02em; margin: 38px 0 10px; }
h3 { font-size: 18.5px; line-height: 1.3; margin: 26px 0 8px; }
h4 { font-size: 15px; margin: 18px 0 6px; color: var(--text-soft); }
p { margin: 10px 0; }
.lead { font-size: 16.5px; color: var(--text-soft); line-height: 1.65; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
ul, ol { margin: 10px 0; padding-left: 22px; }
li { margin: 5px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 9px 16px; border-radius: 9px; font: inherit; font-size: 13.5px; font-weight: 650;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; color: #fff; }
.btn.ghost { background: var(--bg-elev); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-text); filter: none; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-text); letter-spacing: .01em;
}
.pill.fe { background: color-mix(in srgb, var(--fe) 15%, transparent); color: var(--fe); }
.pill.be { background: color-mix(in srgb, var(--be) 15%, transparent); color: var(--be); }
.pill.ai { background: color-mix(in srgb, var(--ai) 15%, transparent); color: var(--ai); }
.pill.px { background: color-mix(in srgb, var(--px) 15%, transparent); color: var(--px); }
.pill.st { background: color-mix(in srgb, var(--st) 15%, transparent); color: var(--st); }
.pill.plain { background: var(--bg-sunken); color: var(--muted); }

.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: var(--bg-sunken); border: 1px solid var(--line); color: var(--muted);
}

/* ---------------- Tables ---------------- */
.tablewrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 13px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--bg-sunken); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

/* ---------------- Code + diagrams ---------------- */
pre {
  background: var(--code-bg); color: var(--code-text);
  padding: 16px; border-radius: var(--radius-sm); overflow-x: auto;
  font-size: 12.8px; line-height: 1.6; margin: 12px 0; border: 1px solid var(--line);
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }

.codeblock { position: relative; }
.codeblock .lang {
  position: absolute; top: 8px; right: 10px; font-size: 10.5px; color: #7c8ba5;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700; pointer-events: none;
}

.diagram {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; margin: 14px 0; overflow-x: auto; text-align: center; min-height: 60px;
}
.diagram svg { max-width: 100%; height: auto; }
.diagram .loadingdiag { color: var(--muted); font-size: 13px; padding: 24px; }

/* ---------------- Notes ---------------- */
.note {
  padding: 13px 16px; margin: 14px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft); border-left: 3px solid var(--accent); color: var(--text);
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note .nt { display: block; font-weight: 750; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; color: var(--accent-text); }
.note.good { background: var(--good-bg); border-left-color: var(--good); }
.note.good .nt { color: var(--good); }
.note.warn { background: var(--warn-bg); border-left-color: var(--warn); }
.note.warn .nt { color: var(--warn); }
.note.danger { background: var(--danger-bg); border-left-color: var(--danger); }
.note.danger .nt { color: var(--danger); }

/* ---------------- Grids ---------------- */
.grid { display: grid; gap: 13px; margin: 14px 0; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.mini {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px;
}
.mini > b { display: block; margin-bottom: 5px; font-size: 14px; }
.mini > p { margin: 0; font-size: 13.5px; color: var(--text-soft); }
.mini ul, .mini ol { font-size: 13.5px; color: var(--text-soft); }

/* ---------------- Trade-offs / failures ---------------- */
.tradeoffs { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin: 14px 0; }
.tocol { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--bg-elev); }
.tocol h5 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tocol.gain { border-left: 3px solid var(--good); } .tocol.gain h5 { color: var(--good); }
.tocol.cost { border-left: 3px solid var(--warn); } .tocol.cost h5 { color: var(--warn); }
.tocol ul { margin: 0; padding-left: 18px; font-size: 13.5px; }

/* ---------------- Details ---------------- */
details.dd {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0; margin: 12px 0; overflow: hidden;
}
details.dd > summary {
  cursor: pointer; font-weight: 680; padding: 12px 15px; font-size: 14.5px;
  list-style: none; display: flex; align-items: center; gap: 9px;
}
details.dd > summary::-webkit-details-marker { display: none; }
details.dd > summary::before {
  content: "▸"; color: var(--muted); font-size: 12px; transition: transform .15s;
}
details.dd[open] > summary::before { transform: rotate(90deg); }
details.dd[open] > summary { border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.dd-body { padding: 4px 15px 14px; }

/* ---------------- Quiz ---------------- */
.quiz { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin: 14px 0; }
.quiz .qq { font-weight: 680; margin: 0 0 10px; }
.quiz + .quiz { margin-top: 10px; }
.opts { display: grid; gap: 7px; }
.opt {
  display: flex; gap: 9px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; cursor: pointer; font: inherit; font-size: 13.8px; color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .ol { font-weight: 800; color: var(--muted); flex: none; width: 14px; }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.right .ol { color: var(--good); }
.opt.wrong { border-color: var(--danger); background: var(--danger-bg); }
.opt.wrong .ol { color: var(--danger); }
.opt:disabled { cursor: default; }
.why { margin-top: 10px; font-size: 13.5px; color: var(--text-soft); padding: 10px 13px; background: var(--bg-sunken); border-radius: 8px; }

/* ---------------- Progress bars ---------------- */
.bar { height: 6px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.fe > i { background: var(--fe); } .bar.be > i { background: var(--be); }
.bar.ai > i { background: var(--ai); } .bar.px > i { background: var(--px); } .bar.st > i { background: var(--st); }

.ring { --v: 0; width: 46px; height: 46px; flex: none; border-radius: 99px;
  background: conic-gradient(var(--accent) calc(var(--v) * 1%), var(--bg-sunken) 0);
  display: grid; place-items: center; position: relative; }
.ring::after {
  content: attr(data-pct); position: absolute; inset: 4px; border-radius: 99px;
  background: var(--card); display: grid; place-items: center; font-size: 11px; font-weight: 800;
}

/* ---------------- Hero ---------------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #10152b 0%, #272a79 55%, #3b2a86 100%);
  color: #fff; border-radius: 20px; padding: 42px; margin-bottom: 8px;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -120px; width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(168, 85, 247, .45), transparent 62%);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 41px; margin: 0 0 14px; letter-spacing: -.032em; }
.hero p { font-size: 16.5px; max-width: 760px; color: #d7dcf3; }
.hero .tags .tag { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .2); color: #e5e9fb; }
.hero .btn.ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .26); }
.hero .btn.ghost:hover { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------------- Track / topic cards ---------------- */
.trackcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 22px 0; }
.trackcard {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 19px; color: var(--text); position: relative; overflow: hidden;
}
.trackcard:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.trackcard { transition: transform .15s, box-shadow .15s, border-color .15s; }
.trackcard::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--accent); }
.trackcard.fe::before { background: var(--fe); } .trackcard.be::before { background: var(--be); }
.trackcard.ai::before { background: var(--ai); } .trackcard.px::before { background: var(--px); } .trackcard.st::before { background: var(--st); }
.trackcard h3 { margin: 0 0 6px; font-size: 17px; }
.trackcard p { font-size: 13.5px; color: var(--text-soft); margin: 0 0 14px; min-height: 42px; }

.topiclist { display: grid; gap: 10px; margin: 16px 0; }
.topicrow {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; color: var(--text);
}
.topicrow:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); }
.topicrow .num {
  width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--bg-sunken); color: var(--muted); font-size: 12px; font-weight: 800;
}
.topicrow.done .num { background: var(--good-bg); color: var(--good); }
.topicrow .body { flex: 1; min-width: 0; }
.topicrow .body b { display: block; font-size: 15px; font-weight: 680; }
.topicrow .body p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.topicrow .meta { flex: none; display: flex; align-items: center; gap: 8px; }

/* ---------------- Topic page ---------------- */
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; display: flex; gap: 7px; align-items: center; }
.topic-head { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 6px; }
.topic-foot {
  display: flex; gap: 12px; justify-content: space-between; align-items: stretch;
  margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--line);
}
.navcard {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; color: var(--text); max-width: 46%;
}
.navcard:hover { text-decoration: none; border-color: var(--accent); }
.navcard span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.navcard b { font-weight: 680; }
.navcard.next { text-align: right; margin-left: auto; }

.onthispage {
  position: sticky; top: calc(var(--header-h) + 20px);
  align-self: start; font-size: 13px;
}

.blocks h2:first-of-type { margin-top: 24px; }

/* ---------------- Drills ---------------- */
.drill { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--ai); border-radius: var(--radius-sm); padding: 16px; margin: 12px 0; }
.drill .dq { font-weight: 680; margin: 0 0 8px; }
.drill .lvls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; font-size: 13.5px; }
.drill .lvls ul { padding-left: 18px; margin: 4px 0; }
.drill .lvls b { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.drill .lvls .s b { color: var(--good); } .drill .lvls .w b { color: var(--danger); }

/* ---------------- Command palette / search ---------------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(9, 13, 26, .55);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
}
.palette {
  width: 100%; max-width: 660px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column; max-height: 72vh;
}
.palette input {
  border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text);
  padding: 16px 18px; font: inherit; font-size: 16px; outline: none; width: 100%;
}
.palette .results { overflow-y: auto; padding: 8px; }
.pres {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer;
  color: var(--text); font: inherit;
}
.pres:hover, .pres.sel { background: var(--accent-soft); }
.pres .pbody { flex: 1; min-width: 0; }
.pres .pbody b { display: block; font-size: 14px; font-weight: 650; }
.pres .pbody span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pres mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.palette .foot {
  border-top: 1px solid var(--line); padding: 9px 16px; font-size: 11.5px; color: var(--muted);
  display: flex; gap: 14px; background: var(--bg-sunken);
}
.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------------- Practice: bank ---------------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.chip {
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text-soft);
  padding: 6px 12px; border-radius: 99px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.qrow {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0; margin: 9px 0; overflow: hidden;
}
.qrow > .qhead {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px; cursor: pointer;
  width: 100%; background: none; border: 0; font: inherit; color: var(--text); text-align: left;
}
.qrow > .qhead:hover { background: var(--bg-sunken); }
.qrow .qn { font-size: 12px; font-weight: 800; color: var(--muted); width: 26px; flex: none; }
.qrow .qt { flex: 1; font-weight: 650; font-size: 14.5px; min-width: 0; }
.qrow .qbody { padding: 4px 16px 18px 55px; border-top: 1px solid var(--line); }
.qrow .qbody h5 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-text); }
.qrow .qbody ul { font-size: 13.8px; }

/* ---------------- Practice: mock interview ---------------- */
.mockgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.timer {
  font-family: ui-monospace, monospace; font-size: 30px; font-weight: 700;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.timer.over { color: var(--danger); }
.phase {
  display: flex; gap: 10px; align-items: center; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-elev); margin: 7px 0; font-size: 13.5px;
}
.phase.on { border-color: var(--accent); background: var(--accent-soft); }
.phase.past { opacity: .55; }
.phase .pn { width: 22px; height: 22px; border-radius: 99px; background: var(--bg-sunken); color: var(--muted);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; }
.phase.on .pn { background: var(--accent); color: #fff; }
.phase .pb { flex: 1; }
.phase .pb b { display: block; }
.phase .pb span { font-size: 11.5px; color: var(--muted); }

textarea.pad {
  width: 100%; min-height: 340px; resize: vertical; padding: 15px;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font: inherit; font-size: 14.5px; line-height: 1.7;
}
textarea.pad:focus { outline: none; border-color: var(--accent); }

.rubric { display: grid; gap: 8px; }
.rubitem { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.rubitem input { margin-top: 5px; flex: none; }

/* ---------------- Practice: flashcards ---------------- */
.fcwrap { max-width: 720px; margin: 0 auto; }
.fc {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 260px; padding: 34px; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; cursor: pointer;
  box-shadow: var(--shadow);
}
.fc .fq { font-size: 21px; font-weight: 650; line-height: 1.4; }
.fc .fa { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); width: 100%;
  font-size: 15.5px; color: var(--text-soft); line-height: 1.7; text-align: left; }
.fc .hintflip { margin-top: 22px; font-size: 12px; color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 16px; }
.grade { padding: 11px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-elev);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 650; color: var(--text); }
.grade:hover { border-color: var(--accent); }
.grade span { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.grade.g0:hover { border-color: var(--danger); } .grade.g3:hover { border-color: var(--good); }

/* ---------------- Stats ---------------- */
.statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin: 18px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-top: 4px; }

footer.bot {
  max-width: var(--maxw); margin: auto; padding: 30px 18px 50px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .trackcards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mockgrid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  aside.side {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; width: 290px; z-index: 45;
    background: var(--bg-elev); border-right: 1px solid var(--line);
    transform: translateX(-102%); transition: transform .2s ease; height: auto;
  }
  body.sidenav aside.side { transform: none; box-shadow: var(--shadow-lg); }
  .menubtn { display: grid; }
  .nav-links { display: none; }
  .searchbtn { min-width: 0; }
  .searchbtn .grow, .searchbtn kbd { display: none; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 30px; } .hero h1 { font-size: 32px; }
  h1 { font-size: 29px; }
}

@media (max-width: 620px) {
  .grid.c2, .grid.c3, .grid.c4, .tradeoffs, .drill .lvls, .trackcards, .statgrid { grid-template-columns: 1fr; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .navcard { max-width: none; }
  .topic-foot { flex-direction: column; }
  .qrow .qbody { padding-left: 16px; }
  .brand small { display: none; }
}

@media print {
  header.top, aside.side, .topic-foot, footer.bot, .scrim { display: none !important; }
  .layout { grid-template-columns: 1fr; } body { background: #fff; }
  .card, .diagram { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
