/* ==========================================================================
   SO-101 interactive course
   A single stylesheet for the overview, chapters and embedded labs.
   ========================================================================== */

:root {
  --bg: #eef2f8;
  --bg-deep: #e6ecf5;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eff4fb;
  --ink: #172236;
  --ink-2: #3f4d63;
  --muted: #66758c;
  --faint: #8b98ad;
  --line: #e2e8f1;
  --line-strong: #d2dceb;
  --accent: #245ed8;
  --accent-ink: #1b47a6;
  --accent-soft: #eaf1ff;
  --teal: #0e8f86;
  --orange: #e8833a;
  --red: #cf4545;
  --green: #17875e;
  --code-bg: #f5f7fb;
  --shadow: 0 10px 30px rgba(26, 43, 74, 0.07);
  --shadow-lg: 0 24px 60px rgba(26, 43, 74, 0.13);
  --radius: 18px;
  --article: 16.5px;
  --maxw: 900px;
  --side-w: 252px;
  --toc-w: 212px;
  --topbar: 58px;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono",
    monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0f16;
  --bg-deep: #080c12;
  --surface: #141b25;
  --surface-2: #101722;
  --surface-3: #1a2331;
  --ink: #e9eef8;
  --ink-2: #c2cddd;
  --muted: #93a3b9;
  --faint: #738299;
  --line: #243040;
  --line-strong: #2f3d50;
  --accent: #6ea8ff;
  --accent-ink: #a9c9ff;
  --accent-soft: #16253e;
  --teal: #4ec9bd;
  --orange: #f0a05a;
  --red: #f07b7b;
  --green: #4cc38f;
  --code-bg: #0e1520;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

[data-font="s"] { --article: 15.2px; }
[data-font="m"] { --article: 16.5px; }
[data-font="l"] { --article: 18px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(36, 94, 216, 0.09), transparent 65%),
    radial-gradient(700px 420px at 6% 8%, rgba(14, 143, 134, 0.06), transparent 60%);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(110, 168, 255, 0.12), transparent 65%),
    radial-gradient(700px 420px at 6% 8%, rgba(78, 201, 189, 0.06), transparent 60%);
}

::selection { background: rgba(36, 94, 216, 0.22); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font-family: inherit; }
svg { display: block; }
img { max-width: 100%; height: auto; }
code, pre, kbd { font-family: var(--mono); }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); text-decoration: none; }
.crumb b {
  overflow: hidden;
  color: var(--ink);
  font-weight: 650;
  text-overflow: ellipsis;
}
.crumb-sep { color: var(--faint); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.text-btn { width: auto; padding: 0 10px; font-size: 12.5px; font-weight: 650; }
.font-btn { display: inline-flex; align-items: center; justify-content: center; gap: 1px; width: auto; padding: 0 8px; font-size: 13px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }
.font-btn span { color: var(--accent); }
.menu-btn { display: none; }
.mobile-brand { display: none; color: var(--ink); font-size: 14px; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.mobile-brand:hover { text-decoration: none; color: var(--accent); }

.top-actions .i-sun { display: none; }
[data-theme="dark"] .top-actions .i-sun { display: block; }
[data-theme="dark"] .top-actions .i-moon { display: none; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 9px 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.search-trigger:hover { border-color: var(--line-strong); background: var(--surface); }
.search-trigger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-trigger kbd { margin-left: 3px; background: var(--surface); }

.read-progress {
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: transparent;
}
.read-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  max-width: 1420px;
  margin: var(--topbar) auto 0;
  min-height: calc(100vh - var(--topbar));
}
.page-chapter .layout {
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
}
.main { min-width: 0; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.side {
  position: sticky;
  top: var(--topbar);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar));
  padding: 18px 14px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 14px;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #2f6bea, #1d4bb5);
  box-shadow: 0 5px 14px rgba(36, 94, 216, 0.3);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-text b { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand-text small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; letter-spacing: 0.06em; }

.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.side-search:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side-search svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.side-search span { flex: 1; }
.side-search kbd { font-size: 10.5px; }

.side-nav { flex: 1; padding-bottom: 12px; }

.nav-group { margin-top: 14px; }
.nav-label {
  padding: 0 10px 5px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-ch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
}
.nav-ch:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-ch.on {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650;
}
.nav-ch.on::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-num {
  width: 21px;
  flex: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  text-align: center;
}
.nav-ch.on .nav-num { color: var(--accent); }
.nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-mark {
  width: 8px;
  height: 8px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
}
.nav-ch.partial .nav-mark {
  border-color: var(--accent);
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), transparent 0);
}
.nav-ch.read .nav-mark {
  position: relative;
  border-color: var(--green);
  background: var(--green);
}
.nav-ch.read .nav-mark::after {
  content: "";
  position: absolute;
  left: 1.2px;
  top: 0.2px;
  width: 2.6px;
  height: 4.6px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(42deg);
}
.nav-home .nav-num { letter-spacing: -0.1em; }

.side-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.side-progress { display: flex; align-items: center; gap: 10px; }
.side-progress-text b { display: block; font-size: 12px; }
.side-progress-text small { display: block; margin-top: 1px; color: var(--muted); font-size: 10.5px; }
.side-links {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 2px;
}
.side-links button,
.side-links a {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.side-links button:hover,
.side-links a:hover { color: var(--accent); text-decoration: none; }

/* Progress rings */
.ring {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
}
.ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface);
}
.ring span {
  position: relative;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink);
}
.ring.big { width: 82px; height: 82px; }
.ring.big::before { inset: 6px; }
.ring.big span { font-size: 17px; }

/* --------------------------------------------------------------------------
   Article sheet
   -------------------------------------------------------------------------- */

.sheet {
  max-width: var(--maxw);
  margin: 24px auto 40px;
  padding: 42px 48px 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ch-hero { padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.ch-eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.ch-num {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
}
.track-pill {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.ch-time { color: var(--faint); font-size: 12px; }

.ch-hero h1 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(30px, 3.2vw, 40px);
  line-height: 1.22;
  letter-spacing: -0.02em;
}
.ch-lead {
  max-width: 680px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.ch-lead strong { color: var(--ink-2); }
.ch-lead code { padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--code-bg); color: var(--accent-ink); font-size: .88em; }
.ch-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  color: var(--faint);
  font-size: 12px;
}
.ch-meta b { color: var(--ink-2); font-weight: 700; }
.ch-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.tag {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.ch-body {
  padding-top: 4px;
  color: var(--ink-2);
  font-size: var(--article);
  line-height: 1.85;
  overflow-wrap: break-word;
}

.ch-body > p:first-child { margin-top: 26px; }
.ch-body p { margin: 15px 0; }
.ch-body strong { color: var(--ink); font-weight: 700; }
.ch-body em { font-style: normal; color: var(--accent-ink); }
.ch-body ul, .ch-body ol { margin: 14px 0; padding-left: 24px; }
.ch-body li { margin: 6px 0; }
.ch-body li > p { margin: 6px 0; }
.ch-body hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

.ch-body h2 {
  position: relative;
  margin: 46px 0 14px;
  padding-top: 6px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.ch-body h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: -12px;
  width: 28px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
}
.ch-body h3 {
  margin: 30px 0 10px;
  color: var(--ink);
  font-size: 18.5px;
  line-height: 1.45;
}
.ch-body h4 { margin: 22px 0 8px; font-size: 16px; color: var(--ink); }

.anchor {
  margin-left: 9px;
  color: var(--line-strong);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); text-decoration: none; }

.ch-body a:not(.anchor) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 32%, transparent);
  text-underline-offset: 3px;
}
.ch-body a:not(.anchor):hover { text-decoration-color: var(--accent); }

.callout {
  position: relative;
  margin: 22px 0;
  padding: 14px 18px 14px 44px;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.75;
}
.callout::before {
  content: "i";
  position: absolute;
  left: 15px;
  top: 16px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: 700 11px/1 var(--sans);
}
.callout p { margin: 5px 0; }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn {
  border-color: #f0d3b4;
  border-left-color: var(--orange);
  background: #fdf4ea;
}
[data-theme="dark"] .callout.warn { border-color: #53371f; background: #291d12; }
.callout.warn::before { content: "!"; background: var(--orange); }
.callout.tip { border-left-color: var(--teal); background: #eaf8f6; }
[data-theme="dark"] .callout.tip { background: #102823; border-color: #1d443d; }
.callout.tip::before { content: "✦"; background: var(--teal); font-size: 10px; }

/* Tables */
.table-wrap {
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.65; }
.table-wrap th {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  white-space: normal;
}
.table-wrap td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: var(--surface-2); }
.table-wrap td:first-child { color: var(--ink); font-weight: 600; }
.table-wrap code { white-space: normal; overflow-wrap: anywhere; }

/* Inline code */
.ch-body :not(pre) > code {
  padding: 1.5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--accent-ink);
  font-size: 0.84em;
  overflow-wrap: anywhere;
}
.ch-body :not(pre) > code code { border: 0; padding: 0; background: none; }

/* Code blocks */
.code-block {
  margin: 22px 0;
  overflow: hidden;
  border: 1px solid #223047;
  border-radius: 12px;
  background: #0f1722;
  box-shadow: 0 8px 24px rgba(10, 18, 30, 0.12);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px 0 15px;
  border-bottom: 1px solid #1f2c40;
  background: #131d2a;
  color: #8fa2bd;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.code-lang { font-family: var(--mono); font-weight: 600; }
.copy-btn {
  padding: 3px 9px;
  border: 1px solid #2a3a52;
  border-radius: 6px;
  background: #1a2637;
  color: #a9b8cd;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: #fff; border-color: #456183; }
.copy-btn.done { color: #7ee2b4; border-color: #2f6b52; }
.code-block .hl { margin: 0; }
.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: transparent;
  color: #d7e0ee;
  font-size: 12.8px;
  line-height: 1.7;
  tab-size: 4;
  scrollbar-width: thin;
}
.ch-body > pre {
  margin: 22px 0;
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid #223047;
  border-radius: 12px;
  background: #0f1722;
  color: #d7e0ee;
  font-size: 12.8px;
  line-height: 1.7;
}

/* Pygments tokens (dark code always) */
.hl .c, .hl .c1, .hl .cm, .hl .cs, .hl .ch { color: #62788f; font-style: italic; }
.hl .k, .hl .kc, .hl .kd, .hl .kn, .hl .kp, .hl .kr, .hl .kt { color: #ff9d66; }
.hl .o, .hl .ow { color: #89b4f8; }
.hl .p, .hl .punctuation { color: #a9b8cd; }
.hl .n, .hl .nv, .hl .nx { color: #d7e0ee; }
.hl .nb, .hl .bp { color: #7fd1c8; }
.hl .nf, .hl .fm { color: #82c7ff; }
.hl .nc, .hl .nn { color: #f4cf7a; }
.hl .nd { color: #c792ea; }
.hl .s, .hl .s1, .hl .s2, .hl .sb, .hl .sc, .hl .sd, .hl .se, .hl .sh, .hl .si, .hl .sx { color: #a8d48a; }
.hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .mo, .hl .il { color: #f1a8c6; }
.hl .ge { font-style: italic; }
.hl .gs { font-weight: 700; }
.hl .gh, .hl .gu { color: #82c7ff; font-weight: 700; }
.hl .err { color: #ff6b6b; border: 0; }

/* Figures */
.doc-fig { margin: 26px 0; }
.fig-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 12px;
}
.doc-fig img {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: 0 6px 22px rgba(22, 38, 64, 0.07);
  transition: transform 0.2s, box-shadow 0.2s;
}
.fig-btn:hover img { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(22, 38, 64, 0.14); }
figcaption {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}

/* Heading-adjacent widget spacing */
.widget + h2, .code-block + h2, .table-wrap + h2, .doc-fig + h2 { margin-top: 50px; }

/* --------------------------------------------------------------------------
   Right-hand table of contents
   -------------------------------------------------------------------------- */

.toc { position: relative; }
.toc-inner {
  position: sticky;
  top: calc(var(--topbar) + 24px);
  max-height: calc(100vh - var(--topbar) - 48px);
  overflow-y: auto;
  padding: 4px 18px 20px 4px;
  scrollbar-width: thin;
}
.toc-title {
  margin-bottom: 10px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.toc nav { display: flex; flex-direction: column; gap: 1px; }
.toc nav a {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.14s, background 0.14s;
}
.toc nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.toc nav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.toc-dot {
  margin-top: 7px;
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--line-strong);
}
.toc nav a.on .toc-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toc nav a.passed .toc-dot { background: var(--teal); }
.toc-meter {
  height: 3px;
  margin: 14px 8px 8px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}
.toc-meter i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--teal)); }
.toc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}
.toc-foot button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.toc-foot button:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Chapter footer
   -------------------------------------------------------------------------- */

.ch-foot { margin-top: 52px; padding-top: 24px; border-top: 1px solid var(--line); }
.read-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 14px;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface));
}
.read-cta b { display: block; color: var(--ink); font-size: 14px; }
.read-cta span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.read-cta .btn { flex: none; }
.read-cta .btn.done { background: var(--green); border-color: var(--green); color: #fff; }

.btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #2f6bea, #1d4bb5); box-shadow: 0 6px 16px rgba(36, 94, 216, 0.22); }
.btn.primary:hover { box-shadow: 0 9px 24px rgba(36, 94, 216, 0.32); }
.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn.big { height: 46px; padding: 0 22px; font-size: 14px; }
.btn.big span { font-size: 17px; }
.btn kbd { background: transparent; border-color: color-mix(in srgb, currentColor 30%, transparent); color: inherit; }

.pager-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.pager {
  display: block;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.pager:hover { border-color: var(--accent); background: var(--surface-2); text-decoration: none; transform: translateY(-1px); }
.pager small { display: block; color: var(--faint); font-size: 10.5px; }
.pager b { display: block; margin-top: 3px; overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.pager.next { text-align: right; }
.pager.disabled { opacity: 0.55; pointer-events: none; }
.keyhint { margin-top: 18px; color: var(--faint); font-size: 11px; text-align: center; }
.keyhint kbd { margin: 0 1px; }

/* --------------------------------------------------------------------------
   Home
   -------------------------------------------------------------------------- */

.home-wrap { max-width: 1120px; margin: 0 auto; padding: 26px 30px 50px; }

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 34px;
  align-items: center;
  padding: 46px 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    radial-gradient(600px 300px at 88% 4%, rgba(36, 94, 216, 0.14), transparent 68%),
    linear-gradient(150deg, var(--surface) 40%, var(--surface-2));
  box-shadow: var(--shadow);
}
.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  opacity: 0.35;
  mask-image: radial-gradient(600px 360px at 78% 30%, #000, transparent 72%);
}
.hero-copy, .hero-visual { position: relative; z-index: 1; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(23, 135, 94, 0.45);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(23, 135, 94, 0.4); }
  70% { box-shadow: 0 0 0 7px rgba(23, 135, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 135, 94, 0); }
}
.home-hero h1 {
  margin: 18px 0 16px;
  font-size: clamp(36px, 4.6vw, 54px);
  line-height: 1.16;
  letter-spacing: -0.035em;
}
.home-hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 10%, var(--teal) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-hero p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.8;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.hero-stats div { display: flex; align-items: baseline; gap: 5px; }
.hero-stats b { color: var(--ink); font-family: var(--mono); font-size: 19px; }
.hero-stats span { color: var(--faint); font-size: 11.5px; }

.hero-visual { min-height: 350px; }
.hero-frame {
  position: relative;
  width: 88%;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #0f1722;
  box-shadow: var(--shadow-lg);
  transform: rotate(1.6deg);
}
.hero-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3.4;
  object-fit: cover;
  object-position: top center;
  opacity: 0.94;
}
.hero-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 8px 22px rgba(18, 34, 58, 0.14);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.hero-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.hero-chip .dot.green { background: var(--green); }
.hero-chip .dot.orange { background: var(--orange); }
.chip-a { left: -6px; top: 16%; }
.chip-b { right: -4px; top: 54%; }
.chip-c { left: 4%; bottom: 8%; }

.progress-panel {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  margin-top: 18px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pp-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.pp-left > div:last-child { min-width: 0; }
.pp-left h2 { margin: 3px 0 2px; font-size: 19px; }
.pp-left p { margin: 0; color: var(--muted); font-size: 12.5px; }
.pp-tracks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1; gap: 8px 16px; }
.pp-track { min-width: 0; }
.pp-track span { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 6px; color: var(--muted); font-size: 10.5px; line-height: 1.3; white-space: normal; }
.pp-track span b { color: var(--ink); font-family: var(--mono); font-size: 10.5px; }
.pp-bar { height: 5px; margin-top: 6px; overflow: hidden; border-radius: 5px; background: var(--line); }
.pp-bar i { display: block; width: 0; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--teal)); transition: width 0.4s; }
.progress-panel > .btn { flex: none; }

.home-section { margin-top: 52px; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.section-head h2 { margin: 4px 0 0; font-size: 27px; letter-spacing: -0.02em; }
.section-head p { max-width: 400px; margin: 0 0 3px; color: var(--muted); font-size: 12.5px; text-align: right; }

.tracks { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.track-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.track-row:last-child { border-bottom: 0; }
.track-row:hover { background: var(--surface-2); }
.track-badge {
  width: 118px;
  flex: none;
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 750;
}
.track-copy { flex: 1; min-width: 0; }
.track-copy b { display: block; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.track-copy span { display: block; margin-top: 2px; color: var(--faint); font-size: 11px; }
.track-row > a {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.track-row > a:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }

.filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.filters button {
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.filters button:hover { color: var(--ink); }
.filters button.on { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: 0 1px 4px rgba(20, 36, 60, 0.09); }

.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ch-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(24, 40, 68, 0.04);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.ch-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-3px);
  text-decoration: none;
}
.ch-card.dim { display: none; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-num { color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 700; }
.card-track { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--faint); font-size: 10px; }
.card-state { margin-left: auto; color: var(--faint); font-size: 10.5px; }
.card-state.read { color: var(--green); font-weight: 650; }
.card-state.partial { color: var(--accent); }
.ch-card h3 { margin: 10px 0 7px; font-size: 18px; letter-spacing: -0.01em; }
.ch-card p { flex: 1; margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.card-tags span { padding: 2px 7px; border-radius: 5px; background: var(--surface-2); color: var(--faint); font-size: 10.5px; }
.card-foot { display: flex; justify-content: space-between; margin-top: 14px; color: var(--faint); font-size: 10.5px; }
.card-foot b { color: var(--ink-2); font-family: var(--mono); }
.card-bar { height: 3px; margin: 7px -22px -18px; background: var(--line); }
.card-bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--teal)); transition: width 0.4s; }

.lab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lab-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.lab-card:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-2px); text-decoration: none; }
.lab-kicker { color: var(--accent); font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; }
.lab-card b { font-size: 13.5px; }
.lab-card span:not(.lab-kicker) { color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.lab-card i { margin-top: 4px; color: var(--accent); font-size: 10.5px; font-style: normal; }

.tools-panel {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 28px;
  align-items: center;
  margin-top: 52px;
  padding: 30px 32px;
  border: 1px solid #1f2c40;
  border-radius: 20px;
  background:
    radial-gradient(500px 240px at 100% 0%, rgba(47, 107, 234, 0.22), transparent 70%),
    #0f1722;
  color: #e8eef8;
}
.tools-panel .eyebrow { color: #7fb0ff; }
.tools-panel h2 { margin: 5px 0 7px; color: #fff; font-size: 24px; }
.tools-panel p { margin: 0; color: #9fb0c8; font-size: 12.5px; line-height: 1.7; }
.tool-links { display: grid; gap: 8px; }
.tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border: 1px solid #233248;
  border-radius: 10px;
  background: #131d2a;
  color: #e8eef8;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.tool-card:hover { border-color: #3c5a86; background: #172334; text-decoration: none; }
.tool-card b { width: 110px; flex: none; font-size: 12.5px; }
.tool-card span { flex: 1; color: #8fa2bd; font-size: 11px; }
.tool-card i { color: #7fb0ff; font-size: 10.5px; font-style: normal; white-space: nowrap; }

.home-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-top: 46px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.home-foot b { display: block; font-size: 12px; }
.home-foot span { display: block; margin-top: 2px; color: var(--faint); font-size: 11px; }
.home-foot p { max-width: 430px; margin: 0; color: var(--faint); font-size: 11px; line-height: 1.7; text-align: right; }
.home-foot code { padding: 1px 4px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 10px; }

/* --------------------------------------------------------------------------
   Search palette
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 18px 24px;
  background: rgba(7, 12, 20, 0.56);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.14s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }

.palette {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: 72vh;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: popIn 0.16s ease-out;
}
.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.palette-input svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.palette-input input {
  flex: 1;
  height: 54px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 15px var(--sans);
  outline: none;
}
.palette-input input::placeholder { color: var(--faint); }
.palette-body { flex: 1; overflow-y: auto; padding: 8px; scrollbar-width: thin; }
.palette-foot {
  display: flex;
  gap: 16px;
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--faint);
  font-size: 10.5px;
}
.palette-foot span { display: flex; align-items: center; gap: 3px; }
.palette-foot kbd { font-size: 9.5px; padding: 0 4px; }

.sr-group { padding: 8px 10px 4px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.sr-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.sr-item:hover, .sr-item.on { background: var(--accent-soft); text-decoration: none; }
.sr-item.on .sr-title { color: var(--accent-ink); }
.sr-badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
}
.sr-item.on .sr-badge { background: var(--accent); color: #fff; }
.sr-main { min-width: 0; flex: 1; }
.sr-title { display: block; overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { display: block; margin-top: 2px; overflow: hidden; color: var(--faint); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.sr-snip { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 11.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-snip mark, .search-mark { padding: 0 2px; border-radius: 3px; background: rgba(232, 131, 58, 0.26); color: inherit; }
.sr-empty { padding: 34px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.sr-hints { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.sr-hints button { padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 11px; cursor: pointer; }
.sr-hints button:hover { border-color: var(--accent); color: var(--accent); }

/* --------------------------------------------------------------------------
   Glossary drawer
   -------------------------------------------------------------------------- */

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(7, 12, 20, 0.45);
  animation: fadeIn 0.15s;
}
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 300;
  display: flex;
  flex-direction: column;
  width: min(430px, 94vw);
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.22);
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 4px 0 0; font-size: 21px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px 22px 30px; scrollbar-width: thin; }
.gloss-item { padding: 14px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.gloss-item:last-child { border-bottom: 0; }
.gloss-item h3 { margin: 0 0 4px; font-size: 14px; }
.gloss-item h3 span { margin-left: 6px; color: var(--faint); font-family: var(--mono); font-size: 10px; font-weight: 400; }
.gloss-item p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.gloss-item a { font-size: 11px; }
.gloss-item.hl { background: var(--accent-soft); box-shadow: 0 0 0 10px var(--accent-soft); border-radius: 4px; }

.term {
  display: inline;
  padding: 0;
  border: 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: none;
  color: inherit;
  font: inherit;
  cursor: help;
}
.term:hover { color: var(--accent); border-bottom-style: solid; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  flex-direction: column;
  background: rgba(5, 9, 15, 0.93);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.15s;
}
.lb-stage { flex: 1; display: grid; place-items: center; overflow: hidden; padding: 46px 30px 10px; cursor: grab; }
.lb-stage.dragging { cursor: grabbing; }
.lb-stage img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-close {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.lb-close:hover { background: rgba(255, 255, 255, 0.16); }
.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px 18px;
  color: #aab8cb;
  font-size: 12px;
}
.lb-tools { display: flex; align-items: center; gap: 2px; }
.lb-tools button {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e8eef8;
  font-size: 12px;
  cursor: pointer;
}
.lb-tools button:first-child { border-radius: 7px 0 0 7px; }
.lb-tools button:last-child { border-radius: 0 7px 7px 0; }
.lb-tools button:hover { background: rgba(255, 255, 255, 0.14); }

/* --------------------------------------------------------------------------
   Toast / menu mask
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 340;
  max-width: min(90vw, 460px);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
[data-theme="dark"] .toast { background: #e9eef8; color: #101722; }

.menu-mask {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(7, 12, 20, 0.45);
}
body.menu-open { overflow: hidden; }

/* --------------------------------------------------------------------------
   Widgets shared
   -------------------------------------------------------------------------- */

.widget {
  position: relative;
  margin: 34px 0;
  overflow: hidden;
  border: 1px solid #223047;
  border-radius: 20px;
  background: #0f1722;
  color: #e8eef8;
  box-shadow: 0 18px 44px rgba(9, 17, 29, 0.2);
  font-size: 13px;
}
.widget::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px 220px at 88% 0%, rgba(47, 107, 234, 0.15), transparent 70%);
}
.w-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 0;
}
.w-kicker {
  display: block;
  color: #7fb0ff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}
.w-head h3 { margin: 5px 0 0; color: #fff; font-size: 21px; line-height: 1.3; }
.w-badge {
  padding: 4px 10px;
  border: 1px solid #2a3b52;
  border-radius: 999px;
  background: #162233;
  color: #93a8c5;
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}
.w-lede {
  position: relative;
  max-width: 740px;
  margin: 9px 24px 18px;
  color: #a9b8cd;
  font-size: 12.5px;
  line-height: 1.75;
}
.w-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
  border-top: 1px solid #1e2b3e;
}
.w-stage {
  position: relative;
  min-width: 0;
  padding: 12px 14px 14px;
  border-right: 1px solid #1e2b3e;
  background:
    radial-gradient(520px 300px at 50% 16%, rgba(47, 107, 234, 0.08), transparent 70%),
    #0b1119;
}
.w-stage > svg { width: 100%; height: auto; overflow: visible; }
.w-controls { min-width: 0; padding: 16px 18px 18px; background: #131c28; }
.w-note {
  position: relative;
  padding: 10px 24px 13px;
  border-top: 1px solid #1e2b3e;
  background: #101924;
  color: #7d90aa;
  font-size: 10.5px;
  line-height: 1.65;
}
.w-note code { color: #a9c3e8; }

.w-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 2px 4px 4px;
  color: #7d90aa;
  font-size: 10px;
}
.w-legend span { display: flex; align-items: center; gap: 5px; }
.w-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--c, #fff); }

.w-readout {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid #1e2b3e;
  border-radius: 9px;
  background: #1e2b3e;
}
.w-readout > div { padding: 7px 4px; background: #0e1621; text-align: center; }
.w-readout span { display: block; color: #6f829b; font-size: 8.5px; letter-spacing: 0.06em; }
.w-readout b { display: inline-block; margin-top: 2px; color: #e8eef8; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.w-readout small { margin-left: 1px; color: #6f829b; font-size: 8.5px; }

.slider-list { display: flex; flex-direction: column; gap: 11px; }
.slider-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) 46px; align-items: center; gap: 9px; }
.sl-name { color: #c3cfe0; font-family: var(--mono); font-size: 10.5px; line-height: 1.25; }
.sl-name small { display: block; margin-top: 1px; color: #6f829b; font-family: var(--sans); font-size: 9px; }
.slider-row output { color: #e8eef8; font-family: var(--mono); font-size: 11px; text-align: right; }
.slider-row.dim { opacity: 0.65; }

input[type="range"] {
  --v: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #5b9bff var(--v), #253448 var(--v));
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 3px solid #0f1722;
  border-radius: 50%;
  background: #9dc2ff;
  box-shadow: 0 0 0 1px #5b9bff, 0 2px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #0f1722;
  border-radius: 50%;
  background: #9dc2ff;
  box-shadow: 0 0 0 1px #5b9bff;
}
input[type="range"]:focus-visible { box-shadow: 0 0 0 3px rgba(91, 155, 255, 0.28); }

.w-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.w-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #2c3e56;
  border-radius: 8px;
  background: #1a2637;
  color: #d5e2f4;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.w-btn:hover { border-color: #456183; background: #203047; }
.w-btn.primary { border-color: #2f6bea; background: #2f6bea; color: #fff; }
.w-btn.primary:hover { background: #3c78f5; }
.w-btn.ghost { background: transparent; }
.w-toggle { display: flex; align-items: center; gap: 6px; color: #91a4bf; font-size: 11px; cursor: pointer; }
.w-toggle input { accent-color: #5b9bff; }
.w-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 13px; }
.w-chip {
  padding: 5px 9px;
  border: 1px solid #263850;
  border-radius: 999px;
  background: transparent;
  color: #91a4bf;
  font-size: 10.5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.w-chip:hover { border-color: #5b9bff; color: #cfe2ff; background: #172335; }

.widget :not(pre) > code { padding: 1px 4px; border: 1px solid #263850; border-radius: 4px; background: #0f1722; color: #a9c3e8; font-size: 0.92em; }

/* SVG arm primitives */
.arm-base { fill: #2a3a50; stroke: #45617f; stroke-width: 1; }
.arm-link { stroke-linecap: round; stroke-linejoin: round; }
.arm-joint { fill: #0f1722; stroke: #e2b13c; stroke-width: 2.5; }
.arm-joint.hot { fill: #e2b13c; }
.arm-tcp { fill: #ff8a4c; stroke: #0f1722; stroke-width: 2; }
.arm-gripper { stroke: #ffb27a; stroke-width: 2.5; stroke-linecap: round; }
.table-grid { stroke: #2a3a50; stroke-width: 0.7; opacity: 0.55; }
.table-edge { stroke: #3c5472; stroke-width: 1.2; fill: #131c28; }
.height-line { stroke: #ff8a4c; stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.7; }
.svg-label { fill: #8fa2bd; font-family: var(--mono); font-size: 9.5px; }
.svg-label.warm { fill: #ffab7e; }
.svg-small { fill: #6f829b; font-family: var(--mono); font-size: 8.5px; }
.ghost-tcp { fill: none; stroke: #ff8a4c; stroke-width: 1.5; stroke-dasharray: 3 3; }
.target-ring { fill: none; stroke: #ff8a4c; stroke-width: 1.5; opacity: 0.7; }
.approach-arrow { stroke: #ff8a4c; stroke-width: 2; fill: none; marker-end: url(#arrowHead); }

/* checklist */
.checklist-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr); }
.checklist { padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 2px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 6px; border-radius: 8px; cursor: pointer; }
.check-item:hover { background: #141f2e; }
.check-item input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  position: relative;
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 2px;
  border: 1.5px solid #3b4f6a;
  border-radius: 5px;
  background: #0f1722;
  transition: background 0.15s, border-color 0.15s;
}
.check-item input:checked + .check-box { border-color: #2fbf8a; background: #2fbf8a; }
.check-item input:checked + .check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.check-item b { display: block; color: #dce7f6; font-size: 12.5px; font-weight: 600; }
.check-item small { display: block; margin-top: 1px; color: #7d90aa; font-size: 10.5px; line-height: 1.55; }
.check-item code { color: #a9c3e8; }
.check-item input:checked ~ span b { color: #6ee2b0; }
.check-side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 22px; background: #101924; border-left: 1px solid #1e2b3e; text-align: center; }
.check-ring { position: relative; width: 96px; height: 96px; }
.check-ring svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.check-ring circle { fill: none; stroke-width: 6; }
.cr-bg { stroke: #223047; }
.cr-fg { stroke: #2fbf8a; stroke-dasharray: 327; stroke-dashoffset: 327; stroke-linecap: round; transition: stroke-dashoffset 0.35s; }
.check-ring > div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.check-ring b { color: #fff; font-family: var(--mono); font-size: 21px; }
.check-ring b small { color: #6f829b; font-size: 11px; }
.check-ring span { color: #7d90aa; font-size: 9.5px; }
.check-status { margin: 0; color: #9fb0c8; font-size: 11.5px; line-height: 1.6; }
.check-status.ok { color: #6ee2b0; }

/* pose */
.pose-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.pose-inputs label { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px; border: 1px solid #263850; border-radius: 8px; background: #0f1722; }
.pose-inputs label > span { display: flex; justify-content: space-between; color: #93a8c5; font-family: var(--mono); font-size: 9.5px; }
.pose-inputs label small { color: #6f829b; font-family: var(--sans); font-size: 8.5px; }
.pose-inputs input {
  width: 100%;
  border: 0;
  background: none;
  color: #e8eef8;
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
}
.pose-inputs label:focus-within { border-color: #5b9bff; }
.pose-sentence { margin-top: 12px; padding: 11px 12px; border: 1px solid #223047; border-radius: 9px; background: #0f1722; color: #b9c8db; font-size: 11px; line-height: 1.75; }
.pose-sentence b { color: #ffd28c; font-family: var(--mono); font-weight: 600; }
.pose-alert { margin-top: 8px; padding: 9px 11px; border: 1px solid #5a3a22; border-radius: 8px; background: #2a1d12; color: #ffc08f; font-size: 10.5px; line-height: 1.6; }
.pose-alert.info { border-color: #23423d; background: #102823; color: #8bd9cc; }

/* IK */
.ik-grid { grid-template-columns: minmax(0, 1.13fr) minmax(0, 0.87fr); }
.ik-status { display: flex; align-items: center; gap: 7px; margin-top: 7px; padding: 8px 10px; border: 1px solid #223047; border-radius: 8px; background: #0e1621; }
.ik-status b { color: #dce7f6; font-size: 11px; font-weight: 600; }
.ik-status small { overflow: hidden; color: #7d90aa; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.ik-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #f2b33d; }
.ik-status.ok .ik-dot { background: #2fbf8a; }
.ik-status.err .ik-dot { background: #ff6b6b; }
.ik-status.ok b { color: #6ee2b0; }
.ik-status.err b { color: #ff9b9b; }
.ik-result { margin-top: 13px; padding-top: 12px; border-top: 1px solid #1e2b3e; }
.ik-verdict { color: #9fb0c8; font-size: 10.5px; line-height: 1.65; }
.ik-verdict.ok { color: #6ee2b0; }
.ik-verdict.err { color: #ff9b9b; }
.ik-joints { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; margin-top: 8px; }
.ik-joints div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #1a2636; color: #7d90aa; font-family: var(--mono); font-size: 9.5px; }
.ik-joints div b { color: #dce7f6; font-weight: 500; }

/* arrive */
.arrive-grid { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.arrive-list { display: flex; flex-direction: column; padding: 12px; gap: 4px; border-right: 1px solid #1e2b3e; }
.arrive-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 11px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #c3cfe0; text-align: left; cursor: pointer; }
.arrive-item:hover { background: #141f2e; }
.arrive-item span { font-size: 11.5px; }
.arrive-item small { color: #6f829b; font-size: 9.5px; }
.arrive-item.on { border-color: #2f6bea; background: #16233a; }
.arrive-item.on span { color: #fff; font-weight: 600; }
.arrive-panel { padding: 16px 18px; background: #131c28; }
.arrive-now { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.arrive-now .eyebrow { color: #6f829b; font-size: 8.5px; }
.arrive-now b { color: #fff; font-size: 13px; }
.metric { margin-bottom: 13px; }
.metric-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; align-items: baseline; }
.metric-top span { color: #9fb0c8; font-size: 10.5px; white-space: nowrap; }
.metric-top b { color: #e8eef8; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.metric-top small { grid-column: 1 / -1; color: #6f829b; font-size: 9px; text-align: right; }
.metric-bar { position: relative; height: 6px; margin-top: 5px; border-radius: 6px; background: #223047; }
.metric-bar i { display: block; width: 0; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #5b9bff, #7fd1c8); transition: width 0.35s; }
.metric-bar i.warn { background: linear-gradient(90deg, #f2b33d, #ff8a4c); }
.metric-bar i.bad { background: linear-gradient(90deg, #ff8a4c, #ff6b6b); }
.metric-bar .base { position: absolute; top: -3px; width: 1px; height: 12px; background: #7d90aa; }
.arrive-verdict { margin-top: 14px; padding: 9px 11px; border: 1px solid #223047; border-radius: 8px; background: #0f1722; color: #9fb0c8; font-size: 10.5px; line-height: 1.7; }
.arrive-verdict b { color: #ffd28c; }

/* teleop */
.teleop-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
.teleop-formula { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 7px 10px; border: 1px solid #223047; border-radius: 8px; background: #0e1621; }
.teleop-formula code { color: #a9c3e8; font-size: 10.5px; }
.teleop-formula span { color: #ffd28c; font-family: var(--mono); font-size: 10.5px; }
.teleop-status { margin-top: 6px; color: #7d90aa; font-size: 10px; line-height: 1.6; }
.teleop-status.warn { color: #ffb27a; }
.teleop-status.err { color: #ff9b9b; }
.teleop-status.ok { color: #6ee2b0; }
.seg { display: flex; gap: 3px; padding: 3px; border: 1px solid #223047; border-radius: 9px; background: #0e1621; }
.seg button { flex: 1; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: #91a4bf; font-size: 11px; cursor: pointer; }
.seg button.on { background: #2f6bea; color: #fff; font-weight: 600; }

/* calib */
.calib-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); }
#calib-svg { cursor: crosshair; touch-action: none; }
.calib-copy { margin: 0 0 9px; color: #a9b8cd; font-size: 11px; line-height: 1.7; }
.calib-copy b { color: #ffd28c; }
.calib-table { margin-top: 12px; }
.calib-table table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 9.5px; }
.calib-table th { padding: 4px 5px; border-bottom: 1px solid #223047; color: #6f829b; font-weight: 500; text-align: right; }
.calib-table td { padding: 4px 5px; border-bottom: 1px solid #1a2636; color: #c3cfe0; text-align: right; }
.calib-table td:first-child, .calib-table th:first-child { text-align: left; }
.calib-table tr.bad td { color: #ffb27a; }
.calib-handle { fill: #ff8a4c; stroke: #0f1722; stroke-width: 2; cursor: grab; }
.calib-handle:active { cursor: grabbing; }
.calib-target { fill: #7fd1c8; stroke: #0f1722; stroke-width: 1.5; }

/* fps */
.fps-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
.fps-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px; color: #7d90aa; font-size: 9.5px; }
.fps-legend span { display: flex; align-items: center; gap: 5px; }
.fps-legend i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.fps-scenarios { display: flex; flex-direction: column; gap: 3px; }
.fps-item { display: flex; flex-direction: column; gap: 1px; padding: 6px 9px; border: 1px solid transparent; border-radius: 7px; background: none; color: #c3cfe0; text-align: left; cursor: pointer; }
.fps-item:hover { background: #141f2e; }
.fps-item b { font-size: 11px; font-weight: 600; }
.fps-item small { color: #6f829b; font-size: 9.5px; }
.fps-item.on { border-color: #2f6bea; background: #16233a; }
.fps-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 12px; overflow: hidden; border: 1px solid #223047; border-radius: 8px; background: #223047; }
.fps-result > div { padding: 8px 5px; background: #0f1722; text-align: center; }
.fps-result span { display: block; color: #6f829b; font-size: 8.5px; }
.fps-result b { color: #e8eef8; font-family: var(--mono); font-size: 14px; }
.fps-result small { color: #6f829b; font-size: 8.5px; }
.fps-verdict { margin-top: 9px; padding: 8px 10px; border: 1px solid #223047; border-radius: 8px; background: #0f1722; color: #9fb0c8; font-size: 10px; line-height: 1.65; }
.fps-verdict.ok { color: #6ee2b0; border-color: #23423d; }
.fps-verdict.warn { color: #ffd28c; border-color: #5a4a22; }
.fps-verdict.err { color: #ff9b9b; border-color: #5a2222; }

/* QC */
.qc-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); }
.qc-list { display: flex; flex-direction: column; padding: 12px 14px; gap: 1px; border-right: 1px solid #1e2b3e; }
.qc-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 6px; border-radius: 7px; cursor: pointer; }
.qc-item:hover { background: #141f2e; }
.qc-item input { margin: 3px 0 0; accent-color: #5b9bff; }
.qc-sev { flex: none; min-width: 34px; margin-top: 1px; padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 8px; text-align: center; text-transform: uppercase; }
.qc-sev.err { background: #3a1a1a; color: #ff9b9b; }
.qc-sev.warn { background: #3a2c14; color: #ffd28c; }
.qc-sev.info { background: #1a2c3a; color: #9dc2ff; }
.qc-item b { display: block; color: #c3cfe0; font-size: 10.5px; font-weight: 600; }
.qc-item small { display: block; color: #6f829b; font-size: 9px; }
.qc-panel { padding: 14px 16px; background: #131c28; }
.qc-dup > div:first-child { display: flex; align-items: baseline; gap: 5px; }
.qc-dup span { color: #9fb0c8; font-size: 10px; }
.qc-dup b { margin-left: auto; color: #e8eef8; font-family: var(--mono); font-size: 14px; }
.qc-dup small { color: #6f829b; font-size: 9px; }
.qc-dup input { margin: 7px 0 3px; }
.qc-dup-hint { display: flex; justify-content: space-between; color: #6f829b; font-size: 8.5px; }
.qc-verdict { margin-top: 12px; padding: 10px 12px; border: 1px solid #223047; border-radius: 8px; background: #0f1722; }
.qc-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 9.5px; font-weight: 700; }
.qc-badge.ok { background: #123527; color: #6ee2b0; }
.qc-badge.warn { background: #3a2c14; color: #ffd28c; }
.qc-badge.err { background: #3a1a1a; color: #ff9b9b; }
.qc-verdict p { margin: 6px 0 0; color: #9fb0c8; font-size: 10px; line-height: 1.6; }
.qc-findings { display: flex; flex-direction: column; gap: 3px; margin-top: 9px; }
.qc-findings div { color: #8fa2bd; font-size: 9.5px; line-height: 1.5; }
.qc-findings div b { color: #ffb27a; font-weight: 600; }
.qc-none { color: #6f829b; font-size: 9.5px; }

/* train */
.train-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); }
.train-panel { padding: 16px 18px; background: #131c28; }
.train-big { padding-bottom: 12px; border-bottom: 1px solid #1e2b3e; }
.train-big span { color: #6f829b; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.train-big b { display: block; margin: 2px 0; color: #fff; font-family: var(--mono); font-size: 30px; line-height: 1.1; }
.train-big small { color: #6f829b; font-size: 9px; }
.train-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 12px 0; overflow: hidden; border: 1px solid #223047; border-radius: 8px; background: #223047; }
.train-metrics div { padding: 8px 6px; background: #0f1722; text-align: center; }
.train-metrics span { display: block; color: #6f829b; font-size: 8.5px; }
.train-metrics b { color: #e8eef8; font-family: var(--mono); font-size: 12px; }
.train-verdict { padding: 9px 11px; border: 1px solid #223047; border-radius: 8px; background: #0f1722; color: #9fb0c8; font-size: 10px; line-height: 1.65; }
.train-verdict b { color: #ffd28c; }
.train-note { margin-top: 7px; color: #6f829b; font-size: 9.5px; line-height: 1.6; }


/* Search hit banner (when arriving from a query) */
.search-hit-note {
  position: sticky;
  top: calc(var(--topbar) + 8px);
  z-index: 6;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(20, 36, 60, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 6px;
  padding: 9px 13px;
  border: 1px solid color-mix(in srgb, var(--orange) 35%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--orange) 9%, var(--surface));
  color: var(--ink-2);
  font-size: 12px;
}
.search-hit-note b { color: var(--orange); }
.search-hit-note button {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.search-hit-note button:hover { color: var(--accent); border-color: var(--accent); }
mark.search-mark { padding: 0 2px; border-radius: 3px; background: rgba(232, 131, 58, 0.24); color: inherit; }

/* Back to top */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(20, 36, 60, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { background: var(--accent); color: #fff; }
@media (max-width: 760px) {
  .to-top { right: 14px; bottom: 14px; width: 36px; height: 36px; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1400px) {
  .sheet { padding: 38px 40px 32px; }
}

@media (max-width: 1260px) {
  .page-chapter .layout { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc { display: none; }
  .sheet { max-width: 920px; }
}

@media (max-width: 1080px) {
  .home-hero { grid-template-columns: 1fr; padding: 38px 34px; }
  .hero-visual { display: none; }
  .hero-stats { margin-top: 24px; }
  .progress-panel { grid-template-columns: minmax(0, 1fr) auto; }
  .pp-tracks { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .progress-panel > .btn { margin-left: auto; }
  .tools-panel { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 980px) {
  .layout, .page-chapter .layout { display: block; }
  .side {
    position: fixed;
    left: 0;
    top: var(--topbar);
    z-index: 110;
    width: 290px;
    height: calc(100vh - var(--topbar));
    border-right: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 8px 0 32px rgba(8, 15, 26, 0.16);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }
  body.menu-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .crumb { font-size: 12px; }
  .sheet { margin: 14px 14px 30px; padding: 32px 30px 28px; }
  .home-wrap { padding: 18px 16px 36px; }
  .home-hero { padding: 32px 26px; border-radius: 18px; }
  .home-foot { flex-direction: column; }
  .home-foot p { text-align: left; }
}

@media (max-width: 760px) {
  :root { --topbar: 54px; }
  .crumb { display: none; }
  .mobile-brand { display: inline-flex; align-items: center; }
  .top-actions .text-btn { display: none; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { width: 34px; padding: 0; justify-content: center; }
  .crumb b { max-width: 42vw; }
  .sheet { margin: 10px 8px 24px; padding: 24px 18px 22px; border-radius: 14px; }
  .ch-hero h1 { font-size: 30px; }
  .ch-meta { gap: 6px 12px; }
  .ch-tags { margin-left: 0; width: 100%; }
  .ch-body { line-height: 1.8; }
  .ch-body h2 { font-size: 21px; margin-top: 38px; }
  .ch-body h3 { font-size: 17px; }
  .table-wrap { margin-left: -4px; margin-right: -4px; }
  .table-wrap table { font-size: 12.5px; }
  .table-wrap th, .table-wrap td { padding: 8px 9px; }
  .w-grid, .joints-grid, .ik-grid, .pose-grid, .arrive-grid, .teleop-grid, .calib-grid, .fps-grid, .qc-grid, .train-grid, .checklist-grid { grid-template-columns: 1fr; }
  .w-stage { border-right: 0; border-bottom: 1px solid #1e2b3e; }
  .check-side { border-left: 0; border-top: 1px solid #1e2b3e; }
  .arrive-list { border-right: 0; border-bottom: 1px solid #1e2b3e; }
  .qc-list { border-right: 0; border-bottom: 1px solid #1e2b3e; }
  .w-head { padding: 18px 16px 0; }
  .w-lede { margin: 8px 16px 14px; }
  .w-note { padding: 9px 16px 11px; }
  .w-controls { padding: 14px 15px 16px; }
  .slider-row { grid-template-columns: 92px minmax(0, 1fr) 44px; }
  .ch-foot { margin-top: 38px; }
  .read-cta { flex-direction: column; align-items: flex-start; }
  .read-cta .btn { width: 100%; }
  .pager-row { grid-template-columns: 1fr; }
  .pager.next { text-align: left; }
  .page-chapter .main { padding-bottom: 20px; }
  .home-hero h1 { font-size: 34px; }
  .home-hero p { font-size: 14px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { flex: none; width: 100%; }
  .hero-stats { gap: 14px; }
  .progress-panel { grid-template-columns: 1fr; align-items: flex-start; padding: 18px; }
  .pp-tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .pp-track span { font-size: 10px; }
  .progress-panel > .btn { width: 100%; margin-left: 0; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-head p { text-align: left; }
  .chapter-grid, .lab-grid { grid-template-columns: 1fr; }
  .track-badge { width: 86px; font-size: 12px; }
  .track-copy b { font-size: 12px; }
  .tools-panel { padding: 22px; }
  .tool-card { flex-wrap: wrap; }
  .tool-card b { width: auto; }
  .tool-card span { flex-basis: 100%; }
  .palette { max-height: 82vh; }
  .overlay { padding-top: 7vh; }
  .lb-stage { padding: 50px 10px 8px; }
  .lb-bar { padding: 8px 12px 14px; }
}

@media (max-width: 430px) {
  .crumb { display: none; }
  .ch-meta span:not(.ch-tags) { font-size: 10.5px; }
  .w-readout { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
  .w-readout > div:last-child { grid-column: span 1; }
  .hero-stats div:nth-child(3) { display: none; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  :root { --article: 10.5pt; }
  body { background: #fff; }
  body::before, .topbar, .side, .toc, .ch-foot, .home-foot, .filters,
  .overlay, .drawer, .drawer-mask, .lightbox, .toast, .menu-mask, .page-hero-actions { display: none !important; }
  .layout, .page-chapter .layout { display: block; margin: 0; }
  .sheet { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .ch-body { font-size: 10.5pt; }
  .ch-body h2 { break-after: avoid; }
  .doc-fig, .table-wrap, .widget { break-inside: avoid; }
  .doc-fig img { max-width: 100%; }
  .widget { border: 1px solid #ccc; box-shadow: none; }
  .widget, .widget * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --------------------------------------------------------------------------
   Motion / focus preferences
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* language switch in the top bar */
.lang-btn { font-size: 11px; letter-spacing: .02em; }
@media (max-width: 760px) {
  /* Keep the language switch reachable; the other text buttons can stay hidden. */
  .top-actions .lang-btn { display: inline-flex; }
}

/* Training log feature on the home page and the standalone record page */
.training-feature {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: 30px;
  align-items: center;
  margin-top: 48px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}
.training-copy h2 { margin: 6px 0 10px; font-size: 24px; letter-spacing: -.02em; }
.training-copy p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.training-media { min-width: 0; }
.training-media video {
  display: block;
  width: 100%;
  max-height: 420px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #000;
}
.record-page .ch-hero { padding-bottom: 20px; }
.record-page .ch-body { max-width: 820px; }
.record-video { margin: 18px 0 24px; }
.record-video video {
  display: block;
  width: 100%;
  max-height: 520px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #000;
}
.record-back { margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line); }
@media (max-width: 820px) {
  .training-feature { grid-template-columns: 1fr; padding: 18px; }
  .training-media { order: -1; }
}

.hbso-site-link{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 14px 12px;padding:9px 10px;border:1px solid var(--line);border-radius:9px;color:var(--muted);font-size:12px}.hbso-site-link img{max-width:132px;height:auto}.hbso-site-link:hover{background:var(--surface-2)}[data-theme="dark"] .hbso-site-link img{filter:brightness(0) invert(1)}.console-unavailable{display:block;opacity:.6;cursor:help}.console-unavailable small{display:block;font-size:11px;color:var(--muted)}
