/* "Technical book" look: white page, light grey course menu, serif headings, hairlines instead of boxes.
   Loaded after styles.css; only overrides. */
:root {
  --bg: #ffffff;
  --side: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --ink: #1d1d1b;
  --muted: #575752;
  --line: #e4e4e1;
  --accent: #9b2c1f;
  --accent-soft: #f6e9e6;
  --data: #1f5f8b;
  --data-soft: #e6eff6;
  --ack: #2a6f43;
  --ack-soft: #e5f1e9;
  --mgmt: #5b4a9e;
  --mgmt-soft: #ece9f6;
  --lost: #b2391f;
  --lost-soft: #f9e5e0;
  --warn: #8a5d0c;
  --warn-soft: #f5ecda;
  --wire: #77776f;
  --node: #ffffff;
  --node-dim: #f6f6f4;
  --font-display: "Newsreader", "Noto Sans Telugu", "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans Hebrew", Georgia, serif;
  --font-body: "Source Sans 3", "Noto Sans Telugu", "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans Hebrew", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 4px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191c; --side: #1c1f23; --surface: #17191c; --surface-2: #202328; --ink: #e9e7e2; --muted: #adb3b9; --line: #2e3237;
    --accent: #e0705f; --accent-soft: #3a2420; --data: #6fa8d6; --data-soft: #1d2a35; --ack: #6cc08a; --ack-soft: #1b2b21;
    --mgmt: #a596e0; --mgmt-soft: #26223a; --lost: #ef7a62; --lost-soft: #3b211c; --warn: #d9a54a; --warn-soft: #33291a;
    --wire: #8b9097; --node: #1c1f23; --node-dim: #17191c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17191c; --side: #1c1f23; --surface: #17191c; --surface-2: #202328; --ink: #e9e7e2; --muted: #adb3b9; --line: #2e3237;
  --accent: #e0705f; --accent-soft: #3a2420; --data: #6fa8d6; --data-soft: #1d2a35; --ack: #6cc08a; --ack-soft: #1b2b21;
  --mgmt: #a596e0; --mgmt-soft: #26223a; --lost: #ef7a62; --lost-soft: #3b211c; --warn: #d9a54a; --warn-soft: #33291a;
  --wire: #8b9097; --node: #1c1f23; --node-dim: #17191c; color-scheme: dark;
}

body { font-size: 16px; }

/* ---------- no uppercase spaced labels anywhere ---------- */
.eyebrow, .metric .k, .callout .ct, .evidence .ct, .changes-h, th, .panel h4, .pg-k, .tl-label, .step-no, .where, .sb-meta, .ch-count, .tl-count, .keys, .lang-head {
  font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-weight: 500;
}
.eyebrow { font-size: 13.5px; color: var(--muted); }

/* ---------- frame: hairlines, not cards ---------- */
.card { background: transparent; border: 0; border-radius: 0; }
.topbar { background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--font-display); font-weight: 500; font-size: 20px; letter-spacing: 0; }
.brand-mark { display: none; }
.icon-btn, .pill-btn, .search-btn { border-radius: 4px; background: transparent; }
.search-btn { background: transparent; }
.search-ph { font-family: var(--font-body); font-size: 14px; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); }
.sb-title { font-family: var(--font-display); font-weight: 500; font-size: 19px; }
.ch-head { font-weight: 600; font-size: 14.5px; }
.ch-dot { display: none; }
.ch-head:hover, a.ls:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.ch-lessons { border-left-color: var(--line); }
.ls { font-size: 14.5px; }
.ls.is-current { background: transparent; box-shadow: none; color: var(--accent); }
.ls.is-done .ic { color: var(--muted); }
.progress-card { background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 4px 4px; }
.pg-bar { height: 3px; border: 0; border-radius: 0; background: var(--line); }
.pg-bar i { background: var(--ink); }

.sheet { margin: 0; border: 0; border-radius: 0; background: var(--bg); padding: 0 28px 14px; }
.lesson-head { padding: 22px 0 4px; }
.where { font-size: 14px; }
.where span { margin: 0 2px; }
.lesson-head h1 { font-family: var(--font-display); font-weight: 500; font-size: 40px; letter-spacing: -0.01em; }
.lesson-head p { font-size: 16px; }

/* lesson meta: one quiet line instead of pills */
.lh-pills { gap: 0; align-self: flex-end; color: var(--muted); }
.pill.tag { background: none; border: 0; padding: 0; font-family: var(--font-body); font-size: 14px; color: var(--muted); }
.pill.tag .ic { display: none; }
.pill.tag + .pill.tag::before { content: "\00b7"; margin: 0 8px; }

/* stage */
.stage { margin-top: 10px; border-top: 1px solid var(--line); }
.stage-top { padding: 12px 0 0; }
.hud { gap: 34px; }
.metric { background: none; border: 0; border-radius: 0; padding: 0; min-width: 0; }
.metric .k { font-size: 13px; color: var(--muted); }
.metric .v { font-size: 16px; font-weight: 500; }
.metric.changed { box-shadow: none; }
.metric.changed .v { color: var(--accent); }
.btn { border-radius: 3px; font-family: var(--font-body); font-size: 14px; }
.btn.sm { background: transparent; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn:hover { border-color: var(--ink); }
.canvas svg { inset: 6px 0; width: 100%; }
#panel.panel { margin: 0; }
.legend { padding: 6px 0 8px; font-size: 13px; }
.stage.has-figure .legend { display: none; }
.fig-cap { font-size: 14.5px; color: var(--muted); padding: 8px 0 6px; border-top: 1px solid var(--line); }
.fig-cap:empty { display: none; }

/* timeline: plain numbered line */
.timeline { margin-top: 6px; padding: 10px 0 8px; border-top: 1px solid var(--line); }
.tl-steps li::before { height: 1px; top: 12px; }
.tl-steps li.is-done::before, .tl-steps li.is-cur::before { background: var(--ink); }
.tl-dot { width: 24px; height: 24px; border-width: 1px; font-size: 11.5px; font-family: var(--font-body); }
.tl-dot.t-problem, .tl-dot.t-solution, .tl-dot.t-technique, .tl-dot.t-trade-off, .tl-dot.t-insight, .tl-dot.t-recap { border-color: var(--line); }
li.is-done .tl-dot { background: var(--surface-2); border-color: var(--muted); }
li.is-cur .tl-dot { background: var(--ink); border-color: var(--ink); color: var(--bg); box-shadow: none; }
.tl-label { font-size: 13px; }
li.is-cur .tl-label { color: var(--accent); font-weight: 600; }

/* right column */
.rail { background: var(--bg); border-left: 1px solid var(--line); padding: 14px 22px 12px; gap: 6px; }
.guide { padding: 10px 0 8px; }
.step-no { font-size: 14px; font-weight: 400; }
.type { background: none !important; border: 0 !important; padding: 0; text-transform: none; letter-spacing: 0; font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 15px; color: var(--muted) !important; }
.type-problem { color: var(--lost) !important; }
.g-title { font-family: var(--font-display); font-weight: 500; font-size: 28px; line-height: 1.18; letter-spacing: -0.005em; }
.g-body { font-size: 16.5px; line-height: 1.6; }
.callout { background: none !important; border: 0 !important; border-left: 3px solid var(--line) !important; border-radius: 0; padding: 2px 0 2px 14px; font-size: 15.5px; }
.callout .ct { font-size: 13px; font-weight: 600; }
.callout.key { border-left-color: var(--ink) !important; } .callout.key .ct { color: var(--ink); }
.callout.warn { border-left-color: var(--warn) !important; }
.callout.tip { border-left-color: var(--ack) !important; }
.evidence { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 10px 0 0; font-size: 14.5px; }
.evidence .ct { font-size: 13px; }
.filter { border-radius: 3px; }
.filter code { color: var(--ink); }
.changes .op { border-radius: 2px; }
.field { border-left: 3px solid var(--accent); padding: 2px 0 2px 16px; margin: 4px 0; }
.field p { margin: 0; font-family: var(--font-display); font-style: italic; font-size: 17px; line-height: 1.5; }
.field .fby { display: block; margin-top: 6px; font-size: 13px; color: var(--accent); }
.guide-foot { border-top: 1px solid var(--line); }
.goals { border-top: 1px solid var(--line); padding: 12px 0 0; }
.goals ul { font-size: 14px; }
.goals .tick { border-radius: 2px; border-width: 1px; }
.goals li.got .tick { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* home */
.chapter { background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 18px 0; }
.chapter-num { color: var(--accent); font-family: var(--font-display); }
.chapter-head h2, .hero h1, .lesson-card h3, .roadmap h2 { font-family: var(--font-display); font-weight: 500; }
.lesson-card { background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0; }
.lesson-card:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.road { border-radius: 0; border-style: solid; border-width: 1px 0 0; padding: 12px 0; }

/* panels */
.panel h4 { font-family: var(--font-display); font-size: 16px; font-weight: 500; color: var(--ink); }
th { font-size: 13px; }
.stack-row { border-radius: 3px; background: transparent; }
.bar-track, .bar-fill { border-radius: 2px; }

/* diagram: data frames in blue ink, the red accent is for emphasis only */
.link-air { stroke: var(--data); }
.node .icon { stroke: var(--ink); }
.node.hl rect.box { stroke: var(--ink); stroke-width: 1.6; }
.node rect.box { rx: 6px; }
.tone-accent rect { fill: var(--surface-2); stroke: var(--ink); } .tone-accent text { fill: var(--ink); }
.pkt.data rect { fill: var(--data-soft); stroke: var(--data); } .pkt.data text { fill: var(--data); }
.trail.data { stroke: var(--data); }
.legend i[style*="--accent"] { background: var(--data) !important; }
.node text.label { font-family: var(--font-body); font-weight: 600; }
.node text.sub, .badge text, .pkt text, .link-label text { font-family: var(--font-mono); }

/* spectrum figure */
.spec text { font-family: var(--font-mono); font-size: 12.5px; }
.fg-grid { stroke: var(--line); stroke-width: 1; }
.fg-axis { fill: var(--muted); }
.fg-small { font-size: 11.5px; }
.fg-bold { fill: var(--ink); font-weight: 600; }
.fg-tick { stroke: var(--muted); }
.fg-edge { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 3 4; }
.fg-shade { fill: var(--accent); opacity: .1; }
.sig-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.sig-fill { stroke: none; opacity: .06; }
.sig-ink.sig-line { stroke: var(--ink); } .sig-ink.sig-fill { fill: var(--ink); }
.sig-accent.sig-line { stroke: var(--accent); } .sig-accent.sig-fill { fill: var(--accent); }
.sig-data.sig-line { stroke: var(--data); } .sig-data.sig-fill { fill: var(--data); }
.sig-ghost.sig-line { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 5 5; opacity: .55; }
.spec .fg-lab { font-family: var(--font-display); font-size: 18px; stroke: none; }
.fg-lab.sig-ink { fill: var(--ink); } .fg-lab.sig-accent { fill: var(--accent); } .fg-lab.sig-data { fill: var(--data); }
.spec .fg-note { font-family: var(--font-display); font-style: italic; font-size: 16px; fill: var(--muted); }
.spec .fg-note.fg-accent { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .spec .sig-line { stroke-dasharray: 1600; stroke-dashoffset: 1600; animation: sig-draw 1.1s ease-out forwards; }
  .spec .sig-ghost.sig-line { stroke-dasharray: 5 5; stroke-dashoffset: 0; animation: none; }
  .spec .sig-fill, .spec .fg-shade { animation: sig-fade .9s ease-out both; }
}
@keyframes sig-draw { to { stroke-dashoffset: 0; } }
@keyframes sig-fade { from { opacity: 0; } }

.step-no { display: inline-block; text-transform: lowercase; }
.step-no::first-letter { text-transform: uppercase; }
.spec.narrow text { font-size: 10.5px; }
.spec.narrow .fg-small { font-size: 9.5px; }
.spec.narrow .fg-lab { font-size: 13px; }
.spec.narrow .fg-note { font-size: 12px; }
:root[data-layout="stack"] .stage.has-figure .canvas { min-height: 0; aspect-ratio: 10 / 7.4; }
.sig-thin.sig-line { stroke-width: 1.3; opacity: .55; }
.fg-dot { fill: var(--ink); opacity: .6; } .fg-dot-accent { fill: var(--accent); }
.fg-shade-data { fill: var(--data); }
.sig-ink.fg-lab { fill: var(--ink); }
.hud { gap: 8px 26px; }
.metric .v { font-size: 15px; }
td { padding: 5px 10px 5px 0; }
.seg { stroke: none; }
.seg-muted { fill: var(--line); } .seg-wait { fill: #c9c9c3; } .seg-data { fill: var(--data); } .seg-ack { fill: var(--ack); } .seg-ink { fill: var(--ink); opacity: .55; } .seg-accent { fill: var(--accent); }
.seg-lab-muted, .seg-lab-wait { fill: var(--muted); } .seg-lab-data { fill: var(--data); } .seg-lab-ack { fill: var(--ack); } .seg-lab-ink { fill: var(--ink); } .seg-lab-accent { fill: var(--accent); }
.spec.tl .fg-lab { font-size: 15px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg-wait { fill: #4a4e55; } }
:root[data-theme="dark"] .seg-wait { fill: #4a4e55; }
.upcoming { color: var(--muted); font-size: 14.5px; margin: 10px 0 0; }
.upcoming span { color: var(--ink); }
.nav .btn.primary span { white-space: normal; text-overflow: clip; text-align: left; line-height: 1.25; }

/* hex panel: the bytes of one frame, the explained fields coloured */
.hex { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; font-variant-ligatures: none; overflow-x: auto; }
.hx-row { display: flex; gap: 12px; white-space: nowrap; }
.hx-off { color: var(--muted); min-width: 3.4ch; }
.hx-bytes { display: flex; }
.hb { display: inline-block; width: 2.7ch; text-align: center; }
.hb.hgap { margin-left: 1ch; }
.hb.hd { color: var(--muted); opacity: 0.6; }
.hx-more { color: var(--muted); }
.hf0 { color: var(--data); } .hf1 { color: var(--accent); } .hf2 { color: var(--ack); }
.hf3 { color: var(--mgmt); } .hf4 { color: var(--warn); } .hf5 { color: var(--lost); }
.hb.hf0, .hb.hf1, .hb.hf2, .hb.hf3, .hb.hf4, .hb.hf5 { font-weight: 600; }
.hx-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; font-size: 14px; }
.hx-legend li { display: flex; gap: 7px; align-items: baseline; min-width: 0; }
.hx-legend b { font-weight: 600; }
.hsw { flex: none; width: 9px; height: 9px; border-radius: 2px; background: currentColor; transform: translateY(-1px); }
:root[data-layout="stack"] .hx-legend { grid-template-columns: minmax(0, 1fr); }
.pill.tag.cap-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ================= colour ================= */
:root { --teal: #0f766e; --k-ap: #0f766e; --k-phone: #be185d; --k-laptop: #4338ca; --k-sniffer: #b45309; --k-router: #334e68; --k-cloud: #0369a1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --teal: #5eead4; --k-ap: #5eead4; --k-phone: #f9a8d4; --k-laptop: #a5b4fc; --k-sniffer: #fcd34d; --k-router: #9fb3c8; --k-cloud: #7dd3fc; } }
:root[data-theme="dark"] { --teal: #5eead4; --k-ap: #5eead4; --k-phone: #f9a8d4; --k-laptop: #a5b4fc; --k-sniffer: #fcd34d; --k-router: #9fb3c8; --k-cloud: #7dd3fc; }
/* devices in the diagram: one colour per kind */
.node.k-ap { --kc: var(--k-ap); } .node.k-phone { --kc: var(--k-phone); } .node.k-laptop { --kc: var(--k-laptop); }
.node.k-sniffer { --kc: var(--k-sniffer); } .node.k-router { --kc: var(--k-router); } .node.k-cloud { --kc: var(--k-cloud); }
.node rect.box { fill: color-mix(in srgb, var(--kc, var(--line)) 9%, var(--node)); stroke: color-mix(in srgb, var(--kc, var(--line)) 55%, var(--line)); }
.node .icon { stroke: var(--kc, var(--ink)); }
.node.hl rect.box { fill: color-mix(in srgb, var(--kc, var(--line)) 17%, var(--node)); stroke: var(--kc, var(--ink)); stroke-width: 2.2; }
.node text.sub { fill: color-mix(in srgb, var(--kc, var(--muted)) 55%, var(--muted)); }
/* chapters: six hues, used on the home page, in the course menu and in the lesson heading */
.hue-0 { --ch: var(--accent); } .hue-1 { --ch: var(--data); } .hue-2 { --ch: var(--ack); } .hue-3 { --ch: var(--mgmt); } .hue-4 { --ch: var(--warn); } .hue-5 { --ch: var(--teal); }
.chapter { border-top: 3px solid var(--ch, var(--line)); }
.chapter-num, .lesson-card .n { color: var(--ch, var(--accent)); }
.ch .ch-chev { color: var(--ch); } .ch.is-open > .ch-head .ch-title { color: var(--ch); }
.ch .ls.is-current { color: var(--ch); } .ch-lessons { border-left-color: color-mix(in srgb, var(--ch, var(--line)) 40%, var(--line)); }
.lesson-head .where { color: var(--ch, var(--muted)); font-weight: 600; }
.lesson-head h1 { border-left: 5px solid var(--ch, var(--accent)); padding-left: 14px; margin-left: -19px; }
:root[data-layout="stack"] .lesson-head h1 { margin-left: 0; }
.pill.tag.cap-link { color: var(--k-sniffer); }
/* step kinds */
.type-setup { color: var(--teal) !important; } .type-technique { color: var(--data) !important; } .type-insight { color: var(--mgmt) !important; }
.type-trade-off { color: var(--warn) !important; } .type-solution { color: var(--ack) !important; } .type-recap { color: var(--ink) !important; }
.tl-dot.t-setup { --tc: var(--teal); } .tl-dot.t-problem { --tc: var(--lost); } .tl-dot.t-solution { --tc: var(--ack); } .tl-dot.t-technique { --tc: var(--data); }
.tl-dot.t-trade-off { --tc: var(--warn); } .tl-dot.t-insight { --tc: var(--mgmt); } .tl-dot.t-recap { --tc: var(--ink); }
.tl-steps li .tl-dot { border-color: color-mix(in srgb, var(--tc, var(--line)) 60%, var(--line)); color: var(--tc, var(--ink)); }
.tl-steps li.is-done .tl-dot { background: color-mix(in srgb, var(--tc, var(--muted)) 14%, var(--bg)); border-color: var(--tc, var(--muted)); }
.tl-steps li.is-cur .tl-dot { background: var(--tc, var(--ink)); border-color: var(--tc, var(--ink)); color: var(--bg); }
.tl-steps li.is-done::before, .tl-steps li.is-cur::before { background: var(--accent); }
/* frame of the page */
.topbar { border-bottom: 2px solid var(--accent); }
.brand-mark { display: grid; background: var(--accent); color: var(--bg); border-radius: 5px; width: 28px; height: 28px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { border-color: var(--ink); }
.pg-bar i { background: var(--accent); }
.panel h4 { border-left: 4px solid var(--data); padding-left: 9px; }
th { color: var(--data); border-bottom: 2px solid var(--data-soft); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--data-soft) 45%, transparent); }
.metric { border-left: 3px solid var(--line); padding-left: 10px; }
.metric.changed { border-left-color: var(--accent); }
.goals li.got .tick { background: var(--ack); border-color: var(--ack); }
.evidence .ct { color: var(--k-sniffer); } .evidence { border-top: 2px solid color-mix(in srgb, var(--k-sniffer) 45%, var(--line)); }
.g-title { color: var(--ink); }
.reading { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }

/* ================= home: search and counters ================= */
.hero-search { display: flex; align-items: center; gap: 10px; width: min(560px, 100%); height: 48px; margin-top: 10px; padding: 0 12px 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 16px; cursor: pointer; text-align: start; }
.hero-search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-search:hover { border-color: var(--accent); }
.hero-search kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--bg); }
.stats { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 14px; }
.stat { min-width: 118px; padding: 8px 14px 9px; border: 1px solid var(--line); border-top: 3px solid var(--ch); border-radius: 4px; background: color-mix(in srgb, var(--ch) 5%, var(--bg)); display: grid; gap: 1px; }
.stat b { font-family: var(--font-display); font-weight: 500; font-size: 28px; line-height: 1.1; color: var(--ch); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13.5px; color: var(--muted); }
.hero .scale { display: none; }

/* ================= end of a lesson ================= */
.takeaways { border-top: 1px solid var(--line); padding-top: 10px; }
.takeaways ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; font-size: 15px; }
.takeaways li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; }
.takeaways .ic { color: var(--ack); margin-top: 3px; }
.upnext { display: grid; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--ch, var(--accent)); border-radius: 4px; background: color-mix(in srgb, var(--ch, var(--accent)) 6%, var(--bg)); text-decoration: none; color: var(--ink); }
.upnext .ct { font-size: 13px; font-weight: 600; color: var(--ch, var(--accent)); }
.upnext b { font-family: var(--font-display); font-weight: 500; font-size: 21px; line-height: 1.2; }
.upnext .un-sum { font-size: 14.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.upnext .un-go { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ch, var(--accent)); }
.upnext:hover { border-color: var(--ch, var(--accent)); }

/* ================= course menu ================= */
.ls small.ls-min { color: var(--muted); opacity: .85; }
:root[data-layout="desktop"][data-side="closed"] .body { grid-template-columns: 0 minmax(0, 1fr) 376px; }
:root[data-layout="desktop"][data-side="closed"] .sidebar { display: none; }
:root[data-layout="desktop"][data-side="closed"] #drawer-open { display: grid; }

/* ================= captions ================= */
.cc { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: max-content; max-width: 94%; z-index: 3; padding: 6px 12px; border-radius: 5px; background: rgba(18, 18, 18, .88); color: #fff; font-size: 15.5px; line-height: 1.35; text-align: center; pointer-events: none; }
.cc[hidden] { display: none; }

/* ================= diagram and explanation as two tabs (text sizes M and L on narrower windows) ================= */
.tabs { display: none; }
.tl-nav { display: none; }
:root[data-tabs][data-view="lesson"] .tabs { display: inline-flex; margin-inline-start: 18px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-family: var(--font-body); font-size: 14.5px; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--bg); }
:root[data-tabs] .body { grid-template-columns: minmax(0, 1fr); }
:root[data-tabs][data-view="home"] .body { grid-template-columns: minmax(0, 1fr) 340px; }
:root[data-tabs="lesson"][data-view="lesson"] .rail { display: none; }
:root[data-tabs="explain"][data-view="lesson"] .sheet { display: none; }
:root[data-tabs="explain"][data-view="lesson"] .rail { width: min(920px, 100%); margin: 0 auto; border-left: 0; padding: 16px 28px 12px; }
:root[data-tabs="explain"][data-view="lesson"] .g-title { font-size: 32px; }
:root[data-tabs="explain"][data-view="lesson"] .g-body { font-size: 18.5px; }
:root[data-tabs="explain"][data-view="lesson"] .evidence, :root[data-tabs="explain"][data-view="lesson"] .callout { font-size: 16.5px; }
:root[data-tabs="explain"][data-view="lesson"] .goals { max-height: 26%; }
:root[data-tabs] .lesson-head { padding-top: 12px; }
:root[data-tabs] .lesson-head h1 { font-size: 30px; }
:root[data-tabs] .lesson-head p { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
:root[data-tabs] .stage:not(.has-figure) { display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; column-gap: 22px; }
:root[data-tabs] .stage:not(.has-figure) .stage-top { grid-column: 1 / -1; }
:root[data-tabs] .stage:not(.has-figure) .canvas { grid-column: 1; grid-row: 2; min-height: 0; }
:root[data-tabs] .stage:not(.has-figure) .fig-cap { grid-column: 1; grid-row: 3; }
:root[data-tabs] .stage:not(.has-figure) #panel.panel { grid-column: 2; grid-row: 2 / 4; max-height: none; align-self: stretch; overflow-y: auto; margin: 0; padding: 6px 0 6px 20px; border-top: 0; border-left: 1px solid var(--line); scrollbar-width: thin;
  background: linear-gradient(var(--bg) 30%, transparent) top / 100% 28px no-repeat local, linear-gradient(transparent, var(--bg) 70%) bottom / 100% 28px no-repeat local,
              linear-gradient(rgba(0, 0, 0, .22), transparent) top / 100% 9px no-repeat scroll, linear-gradient(transparent, rgba(0, 0, 0, .22)) bottom / 100% 9px no-repeat scroll; }
:root[data-tabs] .stage:not(.has-figure) .legend { grid-column: 1 / -1; grid-row: 4; }
:root[data-tabs] .stage:not(.has-figure):not(:has(#panel.panel)) .canvas, :root[data-tabs] .stage:not(.has-figure):not(:has(#panel.panel)) .fig-cap { grid-column: 1 / -1; }
:root[data-tabs] .stage.has-figure #panel.panel { max-height: 46%; }
:root[data-tabs] .timeline .tl-head { display: none; }
:root[data-tabs] .tl-nav { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.tl-nav .tn-mid { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.tl-nav .tn-mid b { font-family: var(--font-display); font-weight: 500; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-nav .btn.primary span { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* keep the window from growing wider than the screen when the top bar is full */
.window { grid-template-columns: minmax(0, 1fr); }
.topbar { min-width: 0; }
:root[data-tabs] .search-btn { width: auto; flex: none; }
:root[data-tabs] .search-ph, :root[data-tabs] .search-btn kbd { display: none; }
:root[data-tabs] .credit-top .credit-k { display: none; }
:root[data-tabs] .brand-text { max-width: 230px; }
.goals[hidden] { display: none; }

/* ---------- sign-in gate (shown only when the site runs behind it) ---------- */
.ls.is-locked { color: var(--muted); }
.ls.is-locked .ic { opacity: .75; }
.pill.lock { background: none; border: 1px solid var(--line); color: var(--muted); }
.lockbox .meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.gate { margin-top: 22px; padding: 18px 18px 14px; border: 1px solid var(--line); border-left: 5px solid var(--ch, var(--accent)); border-radius: 4px; background: color-mix(in srgb, var(--ch, var(--accent)) 6%, var(--bg)); display: grid; gap: 10px; max-width: 640px; text-align: start; }
.gate h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 24px; line-height: 1.2; }
.gate p { margin: 0; font-size: 16px; }
.gate-row { display: flex; gap: 8px; flex-wrap: wrap; }
.gate-row input { flex: 1 1 220px; min-width: 0; height: 42px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
.gate-row input:focus-visible { outline: 2px solid var(--ch, var(--accent)); outline-offset: 1px; }
.gate-row .btn { height: 42px; }
.gate .gate-msg { min-height: 1.4em; font-size: 15px; color: var(--muted); }
.gate .gate-msg.ok { color: var(--ack); font-weight: 600; }
.gate .gate-msg.bad { color: var(--warn); }
.gate .gate-note { font-size: 13.5px; color: var(--muted); }
.acct { display: grid; gap: 8px; padding: 10px 4px 2px; border-top: 1px solid var(--line); font-size: 13.5px; }
.acct[hidden] { display: none; }
.acct .btn { justify-content: center; gap: 6px; }
.acct-who { overflow-wrap: anywhere; color: var(--muted); }
.acct-who b { color: var(--ink); }
.acct-row { display: flex; gap: 14px; flex-wrap: wrap; }
#note-dlg { width: min(520px, calc(100vw - 32px)); }
#note-dlg textarea { width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.note-where { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; color: var(--warn); }
