/* 802.11 Step by Step: one fixed window (top bar; course sidebar | lesson sheet | step column), scaled to fit on desktop, a drawer on tablet, a scrolling page on phones. */
:root {
  --bg: #eef2f2;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --ink: #13212a;
  --muted: #5b6c75;
  --line: #d3dcdf;
  --accent: #0a6c8f;
  --accent-soft: #dcedf3;
  --ack: #2c8549;
  --ack-soft: #def0e3;
  --mgmt: #6a4fb6;
  --mgmt-soft: #ebe5f8;
  --lost: #c0412c;
  --lost-soft: #f8e1dc;
  --warn: #a8700f;
  --warn-soft: #f6ebd6;
  --wire: #6f7f88;
  --node: #ffffff;
  --node-dim: #f1f4f4;
  --font-display: "Inter Tight", "Inter", "Noto Sans Telugu", "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans Hebrew", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", "Noto Sans Telugu", "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans Hebrew", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1519; --surface: #141f25; --surface-2: #18252c; --ink: #e2ebee; --muted: #93a5ae; --line: #2a3a42;
    --accent: #4fb3d6; --accent-soft: #15333f; --ack: #5cc27e; --ack-soft: #163323; --mgmt: #a790ee; --mgmt-soft: #2a2244;
    --lost: #ee6d57; --lost-soft: #3d1f1a; --warn: #e2a63f; --warn-soft: #3a2c12; --wire: #8a9aa3; --node: #182730; --node-dim: #121c21;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1519; --surface: #141f25; --surface-2: #18252c; --ink: #e2ebee; --muted: #93a5ae; --line: #2a3a42;
  --accent: #4fb3d6; --accent-soft: #15333f; --ack: #5cc27e; --ack-soft: #163323; --mgmt: #a790ee; --mgmt-soft: #2a2244;
  --lost: #ee6d57; --lost-soft: #3d1f1a; --warn: #e2a63f; --warn-soft: #3a2c12; --wire: #8a9aa3; --node: #182730; --node-dim: #121c21;
  color-scheme: dark;
}


/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.55; font-variant-ligatures: none; }
:root:not([data-layout="stack"]) body { overflow: hidden; }
a { color: var(--accent); }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; font-variant-ligatures: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; color: inherit; }
.ic { flex: none; }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.err { background: var(--lost-soft); color: var(--lost); padding: 14px; border-radius: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- window ---------- */
.window { display: grid; grid-template-rows: 54px minmax(0, 1fr); width: 100vw; height: 100vh; overflow: hidden; position: relative; background: var(--bg); }
:root[data-layout="tablet"] .window { height: 100dvh; }
:root[data-layout="stack"] .window { display: block; height: auto; min-height: 100dvh; overflow: visible; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding-block: 0; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
:root[data-layout="stack"] .topbar { position: sticky; top: env(safe-area-inset-top, 0px); height: 54px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; min-width: 0; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--surface); display: grid; place-items: center; flex: none; }
.tb-spacer { flex: 1; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; cursor: pointer; flex: none; }
.icon-btn:hover, .pill-btn:hover, .search-btn:hover { border-color: var(--accent); }
.search-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 9px; cursor: pointer; font-size: 13.5px; min-width: 0; width: min(380px, 32vw); }
.search-ph { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); font-size: 12.5px; }
.search-btn kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--surface); }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }
.lang { position: relative; }
.lang-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .18); padding: 8px; display: grid; gap: 4px; }
.lang-menu[hidden] { display: none; }
.lang-menu button { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.lang-menu button:hover, .lang-menu button[aria-checked="true"] { background: var(--accent-soft); }
.lang-menu b { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.lang-menu small { color: var(--muted); font-size: 12px; }
.lang-note { margin: 4px 10px 6px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.only-drawer { display: none; }
:root:not([data-layout="desktop"]) .only-drawer { display: grid; }

/* ---------- body: sidebar | sheet | rail ---------- */
.body { display: grid; grid-template-columns: 296px minmax(0, 1fr) 376px; min-height: 0; position: relative; }
:root[data-layout="tablet"] .body { grid-template-columns: minmax(0, 1fr) 340px; }
:root[data-layout="stack"] .body { display: block; }

/* sidebar */
.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 18px 10px 14px 20px; border-right: 1px solid var(--line); background: var(--bg); }
:root:not([data-layout="desktop"]) .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 45; width: min(330px, 88vw); background: var(--surface); box-shadow: 0 0 60px -18px rgba(0, 0, 0, .4); transform: translateX(-105%); visibility: hidden; padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
@media (prefers-reduced-motion: no-preference) { :root:not([data-layout="desktop"]) .sidebar { transition: transform .22s ease, visibility .22s; } }
:root.drawer-open:not([data-layout="desktop"]) .sidebar { transform: none; visibility: visible; }
.drawer-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(10, 20, 26, .42); }
.drawer-scrim[hidden] { display: none; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px 0; }
.sb-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.sb-meta { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.course { flex: 1; min-height: 0; overflow-y: auto; margin: 8px 0 12px; padding-right: 6px; scrollbar-width: thin; }
.ch { margin-bottom: 2px; }
.ch-head { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 6px 4px 2px; border: 0; background: transparent; cursor: pointer; text-align: left; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.ch-head:hover { background: var(--surface-2); }
.ch-chev { color: var(--muted); display: grid; place-items: center; transition: transform .15s; }
.ch.is-open .ch-chev { transform: rotate(90deg); }
.ch-dot { width: 18px; height: 14px; border-radius: 3px; flex: none; background: var(--accent-soft); border: 1.5px solid var(--accent); }
.ch.is-planned .ch-dot { background: var(--surface-2); border-color: var(--line); }
.ch-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch.is-planned .ch-title { color: var(--muted); font-weight: 500; }
.ch-count { font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-weight: 600; flex: none; }
.ch-count.planned { font-weight: 400; letter-spacing: .04em; }
.ch-lessons { list-style: none; margin: 0 0 6px; padding: 0 0 0 30px; display: none; border-left: 1px solid var(--line); margin-left: 9px; }
.ch.is-open .ch-lessons { display: block; }
.ls { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.ls span { flex: 1; min-width: 0; }
.ls small { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
a.ls:hover { background: var(--surface-2); }
.ls .ic { color: var(--muted); }
.ls.is-done .ic { color: var(--ack); }
.ls.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); }
.ls.is-current .ic { color: var(--accent); }
.ls.is-planned { color: var(--muted); font-size: 13px; }
.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 7px; }
.pg-row { display: flex; justify-content: space-between; align-items: baseline; }
.pg-k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; font-weight: 600; }
.pg-v { font-family: var(--font-mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pg-bar { height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pg-bar i { display: block; height: 100%; background: var(--accent); }
.pg-sub { font-size: 12px; color: var(--muted); }

/* sheet (middle column) */
.sheet { display: flex; flex-direction: column; min-height: 0; min-width: 0; margin: 12px 0 12px 12px; padding: 0 14px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
:root[data-view="home"] .sheet { overflow-y: auto; display: block; }
:root[data-layout="stack"] .sheet { margin: 10px max(10px, env(safe-area-inset-left, 0px)) 0 max(10px, env(safe-area-inset-left, 0px)); overflow: visible; }

.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 4px 2px; flex: none; }
.lh-left { min-width: 0; display: grid; gap: 4px; }
.where { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.where span { margin: 0 4px; }
.lesson-head h1 { font-family: var(--font-display); font-size: 30px; line-height: 1.1; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
.lesson-head p { margin: 2px 0 0; color: var(--muted); font-size: 14.5px; max-width: 72ch; }
.lh-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.pill { font-family: var(--font-mono); font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.pill.tag { background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 4px 10px; font-size: 12px; }
.pill.tag .ic { color: var(--muted); }
.pill.muted { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.pill.done { background: var(--ack-soft); color: var(--ack); }

/* stage: numbers + tools, diagram, panel, legend */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 12px; overflow: hidden; }
.stage > *, .sheet > *, .rail > *, .guide > *, .guide-foot > *, .guide-scroll > * { min-width: 0; }
:root[data-layout="stack"] .stage { flex: none; min-height: clamp(320px, 70vw, 560px); }
:root[data-layout="stack"] .canvas { min-height: 240px; }
.stage-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 12px 0; flex: none; }
.hud { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.metric { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 5px 11px 6px; min-width: 118px; max-width: 260px; }
.metric .k { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .v { font-family: var(--font-mono); font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.3; }
.metric.changed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
@media (prefers-reduced-motion: no-preference) { .metric.changed { transition: box-shadow .4s, border-color .4s; } }
.tools { display: flex; gap: 6px; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 7px 13px; cursor: pointer; font-size: 13.5px; font-weight: 500; text-decoration: none; min-width: 0; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.icon-only { padding: 5px 8px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.42; cursor: default; }
.canvas { flex: 1; min-height: 140px; position: relative; }
.canvas svg { position: absolute; inset: 6px 12px; width: calc(100% - 24px); height: calc(100% - 12px); display: block; }
#panel.panel { flex: 0 1 auto; max-height: 48%; overflow-y: auto; margin: 0 12px; padding: 10px 0 4px; border-top: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--muted); padding: 6px 14px 10px; flex: none; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.stage:fullscreen { background: var(--surface); border-radius: 0; padding: 12px; }

/* timeline */
.timeline { margin-top: 12px; padding: 10px 14px 10px; flex: none; }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.tl-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.tl-track { overflow-x: auto; scrollbar-width: thin; }
.tl-rail { display: none; }
.tl-steps { list-style: none; margin: 0; padding: 0 0 2px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(78px, 1fr); }
.tl-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 2px; }
.tl-steps li::before { content: ""; position: absolute; top: 14px; right: 50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.tl-steps li:first-child::before { display: none; }
.tl-steps li.is-done::before, .tl-steps li.is-cur::before { background: var(--accent); }
.tl-dot { position: relative; z-index: 1; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-weight: 600; cursor: pointer; display: grid; place-items: center; padding: 0; }
.tl-dot.t-problem { border-color: var(--lost); }
.tl-dot.t-solution { border-color: var(--ack); }
.tl-dot.t-technique { border-color: var(--accent); }
.tl-dot.t-trade-off { border-color: var(--warn); }
.tl-dot.t-insight { border-color: var(--mgmt); }
.tl-dot.t-recap { border-color: var(--ink); }
li.is-done .tl-dot { background: var(--accent-soft); color: var(--ink); }
li.is-cur .tl-dot { background: var(--accent); border-color: var(--accent); color: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-align: center; line-height: 1.25; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
li.is-cur .tl-label { color: var(--ink); font-weight: 700; }

/* rail (right column) */
.rail { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px 12px; }
:root[data-layout="stack"] .rail { padding: 10px max(10px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); }
.guide { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 12px; }
:root[data-layout="stack"] .guide { flex: none; }
.guide-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex: none; }
.guide-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px; scrollbar-width: thin; display: grid; align-content: start; gap: 12px; }
:root[data-layout="stack"] .guide-scroll { overflow: visible; }
.guide-foot { flex: none; padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.step-no { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.05em; font-weight: 600; }
.type { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.type-setup { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.type-problem { background: var(--lost-soft); color: var(--lost); }
.type-solution { background: var(--ack-soft); color: var(--ack); }
.type-technique { background: var(--accent-soft); color: var(--accent); }
.type-trade-off { background: var(--warn-soft); color: var(--warn); }
.type-insight { background: var(--mgmt-soft); color: var(--mgmt); }
.type-recap { background: var(--ink); color: var(--surface); }
.g-title { font-family: var(--font-display); font-size: 21px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.muted-p { color: var(--muted); margin: 0; }
.g-body p { margin: 0 0 10px; }
.g-body p:last-child { margin-bottom: 0; }
.callout { border-radius: 10px; padding: 10px 12px; font-size: 14px; display: grid; gap: 3px; }
.callout .ct { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.callout.key { background: var(--mgmt-soft); } .callout.key .ct { color: var(--mgmt); }
.callout.warn { background: var(--warn-soft); } .callout.warn .ct { color: var(--warn); }
.callout.tip { background: var(--ack-soft); } .callout.tip .ct { color: var(--ack); }
.callout.next { background: var(--surface-2); border: 1px solid var(--line); } .callout.next .ct { color: var(--muted); }
.evidence { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; font-size: 13.5px; }
.evidence .ct, .changes-h { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.filter { display: flex; gap: 8px; align-items: center; justify-content: space-between; background: var(--surface-2); border-radius: 7px; padding: 5px 5px 5px 10px; min-width: 0; }
.filter code { overflow-wrap: anywhere; color: var(--accent); }
.changes-box { display: grid; gap: 5px; }
.changes { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.changes li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.changes .op { font-family: var(--font-mono); font-weight: 700; text-align: center; border-radius: 5px; }
.op-plus { color: var(--ack); background: var(--ack-soft); }
.op-minus { color: var(--lost); background: var(--lost-soft); }
.op-tilde { color: var(--accent); background: var(--accent-soft); }
.nav { display: flex; gap: 8px; }
.nav .btn.primary { flex: 1; justify-content: space-between; min-width: 0; }
.nav .btn.primary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-align: center; }
.keys kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin: 0 1px; background: var(--surface-2); font-family: inherit; }
.goals { flex: 0 1 auto; max-height: 34%; overflow-y: auto; padding: 13px 16px 12px; }
:root[data-layout="stack"] .goals { max-height: none; }
.goals ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 7px; font-size: 13.5px; }
.goals li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--muted); }
.goals li.got { color: var(--ink); }
.goals .tick { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line); margin-top: 2px; display: grid; place-items: center; }
.goals li.got .tick { background: var(--ack); border-color: var(--ack); color: var(--surface); }
a.xref { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- home (inside the sheet) ---------- */
.home { padding: 22px 6px 10px; }
.hero { padding-block: 4px 22px; max-width: 760px; display: grid; gap: 8px; }
.hero h1 { font-family: var(--font-display); font-size: 40px; line-height: 1.05; letter-spacing: -0.025em; margin: 0; text-wrap: balance; }
.hero p { color: var(--muted); font-size: 17px; margin: 0; max-width: 62ch; }
.hero .scale { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.03em; }
.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.chapter-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chapter-num { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }
.chapter-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; }
.chapter-head .sub { color: var(--muted); }
.lesson-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lesson-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.lesson-card:hover { border-color: var(--accent); }
.lesson-card .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.lesson-card h3 { font-family: var(--font-display); font-size: 17px; margin: 0; line-height: 1.25; }
.lesson-card p { margin: 0; color: var(--muted); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.roadmap h2 { font-family: var(--font-display); font-size: 18px; margin: 22px 0 4px; }
.roadmap > p { color: var(--muted); margin: 0 0 12px; }
.roadmap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.road { border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.road h3 { font-size: 15px; margin: 0 0 6px; font-family: var(--font-display); display: flex; gap: 8px; align-items: baseline; }
.road ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }

/* ---------- diagram ---------- */
.link-air { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 2 6; stroke-linecap: round; fill: none; opacity: .55; }
.link-wire { stroke: var(--wire); stroke-width: 2.4; fill: none; opacity: .6; }
.node rect.box { fill: var(--node); stroke: var(--line); stroke-width: 1.2; }
.node.hl rect.box { stroke: var(--accent); stroke-width: 1.8; }
.node.dim { opacity: .38; }
.node .icon { stroke: var(--accent); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.node text.label { fill: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 13.5px; }
.node text.sub { fill: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.badge rect { stroke-width: 1; }
.badge text { font-family: var(--font-mono); font-size: 10.5px; }
.tone-accent rect { fill: var(--accent-soft); stroke: var(--accent); } .tone-accent text { fill: var(--accent); }
.tone-muted rect { fill: var(--surface-2); stroke: var(--line); } .tone-muted text { fill: var(--muted); }
.tone-lost rect { fill: var(--lost-soft); stroke: var(--lost); } .tone-lost text { fill: var(--lost); }
.tone-warn rect { fill: var(--warn-soft); stroke: var(--warn); } .tone-warn text { fill: var(--warn); }
.link-label rect { fill: var(--surface); stroke: var(--line); }
.link-label text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--muted); }
.pkt rect { stroke-width: 1.2; }
.pkt text { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; }
.pkt.data rect { fill: var(--accent-soft); stroke: var(--accent); } .pkt.data text { fill: var(--accent); }
.pkt.ack rect { fill: var(--ack-soft); stroke: var(--ack); } .pkt.ack text { fill: var(--ack); }
.pkt.mgmt rect { fill: var(--mgmt-soft); stroke: var(--mgmt); } .pkt.mgmt text { fill: var(--mgmt); }
.pkt.lost rect { fill: var(--lost-soft); stroke: var(--lost); } .pkt.lost text { fill: var(--lost); }
.pkt.wire rect { fill: var(--surface-2); stroke: var(--wire); } .pkt.wire text { fill: var(--ink); }
.pkt .x { stroke: var(--lost); stroke-width: 2.4; stroke-linecap: round; }
.trail { stroke-width: 1.4; fill: none; stroke-dasharray: 4 4; opacity: .5; }
.trail.data { stroke: var(--accent); } .trail.ack { stroke: var(--ack); } .trail.mgmt { stroke: var(--mgmt); } .trail.lost { stroke: var(--lost); } .trail.wire { stroke: var(--wire); }

/* panel content */
.panel h4 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stack { display: grid; gap: 5px; }
.stack-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; }
.stack-row b { font-weight: 600; }
.stack-row span { color: var(--muted); font-size: 13px; }
.stack-row.new { border-color: var(--accent); background: var(--accent-soft); }
.stack-row.off { opacity: .45; border-style: dashed; background: transparent; }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13.5px; }
.bar-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; border: 1px solid var(--line); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px 0 0 5px; }
.bar-val { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.fill-accent { background: var(--accent-soft); border-right: 2px solid var(--accent); }
.fill-lost { background: var(--lost-soft); border-right: 2px solid var(--lost); }
.fill-warn { background: var(--warn-soft); border-right: 2px solid var(--warn); }
.fill-muted { background: var(--line); border-right: 2px solid var(--wire); }
.panel .foot { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 5px 10px 5px 0; }
td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; vertical-align: top; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* ---------- search dialog ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 20, 26, 0.42); z-index: 60; }
.scrim[hidden] { display: none; }
.search { position: fixed; z-index: 61; top: calc(10vh + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); padding: 12px; display: grid; gap: 8px; max-height: 76vh; grid-template-rows: auto minmax(0, 1fr) auto; }
.search[hidden] { display: none !important; }
.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.search-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 4px; align-content: start; }
.search-results a { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.search-results [aria-selected="true"] a, .search-results a:hover { background: var(--accent-soft); }
.hit-t { font-weight: 600; }
.hit-w { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.hit-s { font-size: 13px; color: var(--muted); }
.hit-s mark { background: var(--warn-soft); color: var(--ink); border-radius: 2px; }
.sr-empty { color: var(--muted); padding: 8px 10px; font-size: 14px; }
.search-hint { margin: 0; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .search-btn { width: auto; }
  .search-ph, .search-btn kbd { display: none; }
  .lesson-head { flex-direction: column; }
  .lh-pills { justify-content: flex-start; }
  .lesson-head h1 { font-size: 25px; }
  .stage-top { flex-direction: column; }
  .tools .btn span { display: none; }
  .bar-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .metric { min-width: 0; flex: 1 1 140px; }
  .hero h1 { font-size: 30px; }
}
@media (max-width: 420px) {
  .brand-text { display: none; }
}
@media (hover: none) { .keys, .search-btn kbd { display: none; } }

/* ---------- languages, voice, dialogs ---------- */
.lang-menu { width: min(560px, calc(100vw - 24px)); padding: 10px; }
.lang-head { padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; max-height: min(62vh, 560px); overflow-y: auto; }
.lang-menu button { grid-template-columns: 40px 1fr; padding: 7px 8px; }
.lg-badge { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--ink); background: var(--surface); }
.lang-menu button[aria-checked="true"] .lg-badge { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.lg-names { display: grid; min-width: 0; }
.lg-names b { font-size: 14px; color: var(--ink); font-family: var(--font-body); }
.lg-names small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .lang-grid { grid-template-columns: 1fr; } .lang-menu { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; } }
.notice { margin: 12px 4px 0; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); font-size: 13.5px; border: 1px solid var(--warn); flex: none; }
:root:not([data-layout="stack"]) .notice { margin: 4px 4px 0; padding: 3px 10px; font-size: 12.5px; line-height: 1.3; }
.gt-right { display: inline-flex; align-items: center; gap: 8px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.voice-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; flex: none; }
.voice-bar:empty { display: none; }
.btn.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.v-msg { flex-basis: 100%; font-size: 12.5px; color: var(--warn); }
.v-msg:empty { display: none; }
[data-say].reading { background: var(--warn-soft); box-shadow: 0 0 0 4px var(--warn-soft); border-radius: 4px; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.keys-dlg { width: min(440px, calc(100vw - 32px)); }
.kd-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-display); font-size: 16px; }
.kd-table td { padding: 7px 10px 7px 0; }
.kd-table td:first-child { white-space: nowrap; width: 1%; }
.kd-table kbd, .keys kbd { font-family: var(--font-mono); font-size: 11.5px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 9px 14px; border-radius: 10px; font-size: 13.5px; max-width: calc(100vw - 32px); overflow-wrap: anywhere; }
.toast[hidden] { display: none; }
:root:lang(te) body, :root:lang(hi) body { line-height: 1.7; }
:root:is(:lang(te), :lang(hi)):not([data-layout="stack"]) #panel.panel { max-height: 50%; }
:root[dir="rtl"]:not([data-layout="desktop"]) .sidebar { left: auto; right: 0; transform: translateX(105%); }
:root[dir="rtl"].drawer-open:not([data-layout="desktop"]) .sidebar { transform: none; }
:root[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--line); }
:root[dir="rtl"] .sheet { margin: 12px 12px 12px 0; }
:root[dir="rtl"] .ch-lessons { padding: 0 30px 0 0; border-left: 0; border-right: 1px solid var(--line); margin-left: 0; margin-right: 9px; }
:root[dir="rtl"] .ch-chev, :root[dir="rtl"] .nav .ic, :root[dir="rtl"] .guide-foot .ic { transform: scaleX(-1); }
:root[dir="rtl"] .ch.is-open .ch-chev { transform: rotate(90deg); }
:root[dir="rtl"] .tl-steps li::before { right: auto; left: 50%; }
:root[dir="rtl"] .search-ph, :root[dir="rtl"] .lang-menu button { text-align: right; }
:root[dir="rtl"] .lang-menu { right: auto; left: 0; }
:root[data-layout="desktop"] .lang-grid { max-height: none; }
/* non-Latin scripts: the monospace face has no glyphs for them, so small labels use the body face without letter-spacing */
:root:is(:lang(te), :lang(hi), :lang(ar), :lang(he), :lang(zh), :lang(ja), :lang(ko), :lang(el), :lang(ru), :lang(uk)) :is(.eyebrow, .metric .k, .metric .v, .type, .step-no, .ct, .changes-h, .tl-label, .pg-k, .sb-meta, .ch-count, .where, .tl-count, .keys, .pill, .hit-w, .search-hint, .search-ph, .panel h4, th, .lang-note) { font-family: var(--font-body); letter-spacing: 0; }
:root:is(:lang(te), :lang(hi)) .metric .k, :root:is(:lang(te), :lang(hi)) .type, :root:is(:lang(te), :lang(hi)) .eyebrow { text-transform: none; font-size: 12px; }
/* credit */
.credit { display: inline-flex; align-items: baseline; gap: 5px; color: var(--muted); font-size: 13px; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.credit b { color: var(--ink); font-weight: 600; }
.credit .ic { align-self: center; flex: none; }
.credit-site { color: var(--accent); font-weight: 600; }
.credit-k:empty { display: none; }
a.credit:hover b, a.credit:hover .credit-site { text-decoration: underline; text-underline-offset: 3px; }
a.credit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.credit-top { align-self: center; margin-inline-start: 4px; padding-inline-start: 14px; border-inline-start: 1px solid var(--line); }
.credit-side, .credit-home { display: none; }
:root[data-layout="stack"] .credit-top { display: none; }
:root[data-layout="stack"] .credit-home { display: inline-flex; margin-top: 4px; }
:root[data-layout="stack"] .credit-side { display: inline-flex; flex: none; padding: 12px 6px 0; }
/* English lesson text inside a right-to-left interface keeps its own direction, so full stops and brackets stay at the end */
:root[dir="rtl"] :is(#sheet, #guide, .guide-scroll) :is(h1, h2, h3, h4, p, li, td, th, b, span, code, .k, .v, .ct) { unicode-bidi: plaintext; }
/* text size button: A with the current size (S, M, L) */
.text-btn { width: auto; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; }
.text-btn span { font-family: var(--font-body); font-weight: 700; font-size: 15px; line-height: 1; letter-spacing: -0.02em; }
.text-btn small { font-size: 11px; font-weight: 700; }
.text-btn i { font-style: normal; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--accent); }
:root[data-layout="stack"] .text-btn { display: none; }
.only-desktop { display: none; }
:root[data-layout="desktop"] .only-desktop { display: grid; }
