@import url("fonts.css");
@import url("icons.css");

:root {
  --font-body: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-code: "JetBrains Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --font-mc: "Monocraft", "JetBrains Mono", Consolas, monospace;
  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 14px;
  --topbar-h: 3.45rem;
  --sidebar-w: 17.5rem;
  --toc-w: 14rem;
  --content-w: 54rem;
  --measure: 41rem;
  --tooltip-bg: rgba(16, 0, 16, 0.95);
  --tooltip-border-top: rgba(80, 0, 255, 0.55);
  --tooltip-border-bottom: rgba(40, 0, 127, 0.55);
  --mc-white: #ffffff;
  --mc-gray: #aaaaaa;
  --mc-dark-gray: #7d7d7d;
  --mc-aqua: #55ffff;
  --mc-yellow: #ffff55;
  --mc-gold: #ffaa00;
  --mc-green: #55ff55;
  --mc-purple: #ff55ff;
  --mc-blue: #8b8bff;
  --xp: #80ff20;
  --xp-dark: #3a7a0f;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e2125;
  --surface: #25292e;
  --raised: #2e3339;
  --line: #3a4047;
  --line-soft: #30353b;
  --text: #e7e5e1;
  --muted: #a9afb6;
  --faint: #7c838b;
  --accent: #a47cff;
  --accent-ink: #c7b0ff;
  --accent-soft: rgba(164, 124, 255, 0.16);
  --accent-contrast: #16121f;
  --ok: #6ccb5f;
  --warn: #f0b640;
  --bad: #f06a5f;
  --info: #4fc9d9;
  --deep: #e07cf0;
  --ok-soft: rgba(108, 203, 95, 0.16);
  --warn-soft: rgba(240, 182, 64, 0.16);
  --bad-soft: rgba(240, 106, 95, 0.16);
  --info-soft: rgba(79, 201, 217, 0.16);
  --deep-soft: rgba(224, 124, 240, 0.16);
  --code-bg: #1e1f22;
  --code-head: #2b2d30;
  --code-fg: #bcbec4;
  --code-gutter: #4b5059;
  --code-line: #26282e;
  --code-sel: #214283;
  --code-border: #393b40;
  --t-kw: #cf8e6d;
  --t-str: #6aab73;
  --t-num: #2aacb8;
  --t-ann: #b3ae60;
  --t-fdecl: #56a8f5;
  --t-fn: #57aaf7;
  --t-field: #c77dbb;
  --t-type: #bcbec4;
  --t-key: #cf8e6d;
  --t-tag: #d5b778;
  --t-com: #7a7e85;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --raised: #eef0f3;
  --line: #d8dce1;
  --line-soft: #e6e9ed;
  --text: #1d2025;
  --muted: #59616b;
  --faint: #868e98;
  --accent: #6b3fd4;
  --accent-ink: #5530b5;
  --accent-soft: rgba(107, 63, 212, 0.1);
  --accent-contrast: #ffffff;
  --ok: #2f8a2f;
  --warn: #a86a00;
  --bad: #c7372c;
  --info: #11808f;
  --deep: #a13bb5;
  --ok-soft: rgba(47, 138, 47, 0.1);
  --warn-soft: rgba(168, 106, 0, 0.1);
  --bad-soft: rgba(199, 55, 44, 0.1);
  --info-soft: rgba(17, 128, 143, 0.1);
  --deep-soft: rgba(161, 59, 181, 0.1);
  --code-bg: #ffffff;
  --code-head: #f2f3f5;
  --code-fg: #080808;
  --code-gutter: #a7abb1;
  --code-line: #f5f8fe;
  --code-sel: #a6d2ff;
  --code-border: #dfe1e5;
  --t-kw: #0033b3;
  --t-str: #067d17;
  --t-num: #1750eb;
  --t-ann: #9e880d;
  --t-fdecl: #00627a;
  --t-fn: #00627a;
  --t-field: #871094;
  --t-type: #080808;
  --t-key: #0033b3;
  --t-tag: #0033b3;
  --t-com: #8c8c8c;
  --shadow-1: 0 1px 2px rgba(20, 24, 31, 0.08);
  --shadow-2: 0 12px 32px rgba(20, 24, 31, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); font-size: clamp(16px, 11.5px + 0.38vw, 21px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
html[data-theme="light"] a { color: var(--accent); }
html[data-theme="light"] a:hover { color: var(--accent-ink); }

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

code, kbd, pre { font-family: var(--font-code); }

p code, li code, td code, dd code, .callout code, .quiz code, h2 code, h3 code, h4 code, .exercise code {
  font-size: 0.86em;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
  padding: 0.08em 0.36em;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  font-size: 0.8em;
  line-height: 1.4;
  padding: 0.05em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: var(--accent-contrast); padding: 8px 14px; border-radius: var(--radius-m); }
.skip-link:focus { top: 10px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 750; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; image-rendering: pixelated; }
.brand-name { font-size: 1.02rem; }

.search-btn {
  margin-left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 340px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.search-btn:hover { border-color: var(--faint); color: var(--text); }
.search-label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--faint); }
.menu-btn { display: none; }

.i-menu, .i-search, .i-theme { display: block; width: 18px; height: 18px; background: currentColor; }
.i-menu { -webkit-mask: var(--icon-menu) center / contain no-repeat; mask: var(--icon-menu) center / contain no-repeat; }
.i-search { width: 16px; height: 16px; -webkit-mask: var(--icon-search) center / contain no-repeat; mask: var(--icon-search) center / contain no-repeat; }
.i-theme { -webkit-mask: var(--icon-theme) center / contain no-repeat; mask: var(--icon-theme) center / contain no-repeat; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-badge[data-live="true"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.live-badge[data-live="true"]::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.xp { display: inline-flex; align-items: center; gap: 8px; }
.xp-level {
  font-family: var(--font-mc);
  font-size: 15px;
  color: var(--xp);
  text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000;
  min-width: 14px;
  text-align: right;
}
.xp-bar {
  position: relative;
  width: 6.6rem;
  height: 9px;
  background: #1b1b1b;
  border: 1px solid #000;
  box-shadow: inset 0 0 0 1px #3c3c3c;
  overflow: hidden;
}
.xp-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0, 0, 0, 0.55) calc(10% - 1px) 10%);
}
.xp-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #b6ff5a 0 35%, var(--xp) 35% 70%, #5cc015 70%);
  transition: width 0.6s ease;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - var(--topbar-h));
}
.layout-home { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
  scrollbar-width: thin;
}
.sidebar-inner { padding: 14px 10px 40px; }

.nav-part { margin-bottom: 4px; }
.nav-part > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-m);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.nav-part > summary::-webkit-details-marker { display: none; }
.nav-part > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex: none;
}
.nav-part[open] > summary::before { transform: rotate(45deg); }
.nav-part > summary:hover { background: var(--surface); }
.nav-part-title { flex: 1; }
.nav-part-count { font-size: 0.75rem; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }

.nav-part ol { list-style: none; margin: 2px 0 8px; padding: 0 0 0 14px; border-left: 1px solid var(--line-soft); margin-left: 13px; }
.nav-part li a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-m);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
}
.nav-part li a:hover { color: var(--text); background: var(--surface); }
.nav-part li a.active { color: var(--text); background: var(--accent-soft); font-weight: 650; }
.nav-check {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border: 1.5px solid var(--line);
  border-radius: 3px;
}
.nav-part li.done .nav-check { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--bg); }

.main { min-width: 0; padding: 2.2rem 2.8rem 5rem; }
.main-home { padding: 0 2.8rem 5rem; }

.page { max-width: var(--content-w); margin: 0 auto; }

.page-head { margin-bottom: 28px; }
.crumbs { margin: 0 0 6px; font-size: 0.88rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-ink); }
.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 1.4rem + 2vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.page-summary { margin: 12px 0 0; font-size: 1.15rem; color: var(--muted); line-height: 1.5; }
.page-meta { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 0; font-size: 0.85rem; color: var(--faint); }
.level { font-weight: 700; }
.level-beginner { color: var(--ok); }
.level-intermediate { color: var(--warn); }
.level-advanced { color: var(--bad); }

.page-body > p.lead { font-size: 1.2rem; line-height: 1.6; color: var(--text); margin-top: 0; }
.page-body > p, .page-body > ul, .page-body > ol, .page-body > h2, .page-body > h3, .page-body > h4,
.page-body > blockquote, .page-head h1, .page-summary, .page-body > .callout, .page-body > .steps { max-width: var(--measure); }

.page-body h2 {
  position: relative;
  margin: 2.4em 0 0.6em;
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-weight: 780;
}
.page-body h3 { position: relative; margin: 1.9em 0 0.5em; font-size: 1.22rem; line-height: 1.3; font-weight: 720; }
.page-body h4 { margin: 1.4em 0 0.4em; font-size: 1.04rem; }

.anchor {
  position: absolute;
  left: -1.1em;
  top: 0;
  width: 1em;
  opacity: 0;
  text-decoration: none;
  color: var(--faint);
}
.anchor::before { content: "#"; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

.page-body p, .page-body ul, .page-body ol { margin: 0 0 1.05em; }
.page-body li { margin: 0.25em 0; }
.page-body li > ul, .page-body li > ol { margin-bottom: 0.3em; }
.page-body strong { font-weight: 720; }
.page-body blockquote { margin: 1.2em 0; padding: 0.2em 1em; border-left: 3px solid var(--line); color: var(--muted); }
.page-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

.table-wrap { overflow-x: auto; margin: 1.2em 0 1.4em; border: 1px solid var(--line); border-radius: var(--radius-m); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.table-wrap th { background: var(--surface); font-weight: 700; color: var(--text); white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td code { white-space: nowrap; }

.gterm {
  text-decoration: underline dotted var(--faint);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  cursor: help;
}
.gterm:hover, .gterm:focus { text-decoration-color: var(--accent); outline: none; }

.menu-path { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px; font-weight: 650; }
.menu-path > span:not(.sep) { padding: 0 6px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); font-size: 0.9em; }
.menu-path .sep { color: var(--faint); }

.copyable { position: relative; padding-right: 1.9em !important; cursor: pointer; }
.copy-mini {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 1.4em;
  height: 1.4em;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.copy-mini span { display: block; width: 100%; height: 100%; background: currentColor; -webkit-mask: var(--icon-copy) center / 75% no-repeat; mask: var(--icon-copy) center / 75% no-repeat; }
.copyable:hover .copy-mini { color: var(--accent-ink); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-accent { color: var(--accent-ink); background: var(--accent-soft); }
.badge-deep { color: var(--deep); background: var(--deep-soft); }

.callout {
  position: relative;
  margin: 1.5em 0;
  padding: 14px 18px 14px 20px;
  border-radius: var(--radius-m);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--callout-color, var(--info));
}
.callout-title {
  margin: 0 0 4px !important;
  font-weight: 760;
  font-size: 0.92rem;
  color: var(--callout-color, var(--info));
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout-title::before {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--callout-color, var(--info));
  -webkit-mask: var(--callout-icon, var(--icon-info)) center / contain no-repeat;
  mask: var(--callout-icon, var(--icon-info)) center / contain no-repeat;
}
.callout-body > :last-child { margin-bottom: 0; }
.callout-tip { --callout-color: var(--ok); --callout-icon: var(--icon-tip); background: var(--ok-soft); }
.callout-note { --callout-color: var(--info); --callout-icon: var(--icon-info); background: var(--info-soft); }
.callout-warning { --callout-color: var(--warn); --callout-icon: var(--icon-warning); background: var(--warn-soft); }
.callout-danger { --callout-color: var(--bad); --callout-icon: var(--icon-danger); background: var(--bad-soft); }
.callout-mc { --callout-color: var(--ok); --callout-icon: var(--icon-block); }
.callout-mc .callout-title { font-family: var(--font-mc); font-weight: 400; letter-spacing: 0.02em; }
.callout-deep { --callout-color: var(--deep); --callout-icon: var(--icon-gear); }
.callout-pc { --callout-color: var(--accent); --callout-icon: var(--icon-pc); background: var(--accent-soft); }

.steps { list-style: none; counter-reset: step; margin: 1.4em 0 1.6em; padding: 0; }
.step { position: relative; counter-increment: step; padding: 0 0 18px 48px; margin: 0 !important; }
.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1.5px solid var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
}
.step::after { content: ""; position: absolute; left: 15.5px; top: 36px; bottom: 4px; width: 1.5px; background: var(--line); }
.step:last-child::after { display: none; }
.step-title { margin: 3px 0 4px !important; font-size: 1.04rem; }
.step-body > :last-child { margin-bottom: 0; }

.tabs { margin: 1.4em 0; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.tab-list { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  padding: 8px 14px;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-btn[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { padding: 16px 18px 4px; }
.tab-panel[hidden] { display: none; }
.tabs > .tab-panel > figure:first-child { margin-top: 0; }

.exercise {
  margin: 2em 0;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: var(--radius-l);
  background: linear-gradient(180deg, var(--accent-soft), transparent 140px), var(--surface);
  padding: 18px 20px 14px;
}
.exercise-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.exercise-label { font-family: var(--font-mc); font-size: 0.82rem; color: var(--accent-ink); }
.exercise-title { margin: 0 !important; font-size: 1.12rem; }
.exercise-body > :last-child { margin-bottom: 10px; }
.exercise details { border-top: 1px solid var(--line-soft); padding: 8px 0 4px; }
.exercise summary { cursor: pointer; font-weight: 700; color: var(--accent-ink); list-style: none; display: flex; align-items: center; gap: 8px; }
.exercise summary::-webkit-details-marker { display: none; }
.exercise summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s ease; }
.exercise details[open] > summary::before { transform: rotate(45deg); }
.solution summary { color: var(--ok); }
.hint-body, .solution-body { padding-top: 8px; }

.quiz { margin: 1em 0 2em; }
.quiz-list { list-style: none; counter-reset: q; padding: 0; margin: 0; }
.quiz-q { counter-increment: q; margin: 0 0 22px !important; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.quiz-prompt { display: flex; gap: 10px; font-weight: 650; }
.quiz-prompt::before { content: counter(q) "."; color: var(--faint); font-variant-numeric: tabular-nums; }
.quiz-prompt > :last-child { margin-bottom: 8px; }
.quiz-options { list-style: none; margin: 4px 0 0 !important; padding: 0; display: grid; gap: 8px; }
.quiz-options li { margin: 0 !important; }
.quiz-opt {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  font: inherit;
  font-size: 0.97rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 9px 12px;
  cursor: pointer;
}
.quiz-opt:hover:not([disabled]) { border-color: var(--accent); }
.quiz-mark { flex: none; width: 18px; height: 18px; margin-top: 3px; border-radius: 50%; border: 1.5px solid var(--line); }
.quiz-opt.picked-right { border-color: var(--ok); background: var(--ok-soft); }
.quiz-opt.picked-right .quiz-mark { border-color: var(--ok); background: var(--ok) var(--icon-check-white) center / 70% no-repeat; }
.quiz-opt.picked-wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-opt.picked-wrong .quiz-mark { border-color: var(--bad); background: var(--bad) var(--icon-cross-white) center / 60% no-repeat; }
.quiz-opt.reveal-right { border-color: var(--ok); }
.quiz-opt[disabled] { cursor: default; }
.quiz-explain { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-m); background: var(--raised); font-size: 0.95rem; }
.quiz-explain > :last-child { margin-bottom: 0; }
.quiz-score { font-weight: 700; color: var(--muted); }

.tree { margin: 1.3em 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); font-family: var(--font-code); font-size: 0.86rem; overflow-x: auto; }
.tree ul { list-style: none; margin: 0 !important; padding: 0 0 0 18px; }
.tree > .tree-root { padding-left: 0; }
.tree li { margin: 0 !important; position: relative; }
.tree-row { display: flex; align-items: baseline; gap: 10px; padding: 2px 0; flex-wrap: wrap; }
.tree-name { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text); }
.tree-name::before { content: ""; flex: none; width: 15px; height: 15px; background: var(--muted); -webkit-mask: var(--icon-file) center / contain no-repeat; mask: var(--icon-file) center / contain no-repeat; }
.tree-folder > .tree-row .tree-name::before { background: var(--warn); -webkit-mask-image: var(--icon-folder); mask-image: var(--icon-folder); }
.tree-file[data-ext="java"] > .tree-row .tree-name::before { background: var(--info); -webkit-mask-image: var(--icon-java); mask-image: var(--icon-java); }
.tree-file[data-ext="yml"] > .tree-row .tree-name::before, .tree-file[data-ext="yaml"] > .tree-row .tree-name::before { background: var(--bad); }
.tree-file[data-ext="kts"] > .tree-row .tree-name::before { background: var(--accent); }
.tree-desc { font-family: var(--font-body); font-size: 0.86rem; color: var(--muted); }

.code, .console {
  margin: 1.4em 0 1.6em;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.code { container-type: inline-size; }
.code-head, .console-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 6px 0 12px;
  background: var(--code-head);
  border-bottom: 1px solid var(--code-border);
}
.code-title { flex: 0 1 auto; min-width: 5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container (max-width: 560px) {
  .code .code-tags { display: none; }
}
@container (max-width: 380px) {
  .code .code-btn { padding: 0 7px; }
}
.code-title, .console-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-code);
  font-size: 0.8rem;
  color: var(--code-fg);
  padding: 8px 0;
}
.code-title::before {
  content: attr(data-lang);
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  border-radius: 4px;
  font-size: 0;
  background: var(--faint);
}
.code-title[data-lang="java"]::before { background: #e76f00 var(--icon-lang-java) center / 70% no-repeat; }
.code-title[data-lang="yaml"]::before { background: #cb4b3e var(--icon-lang-yaml) center / 70% no-repeat; }
.code-title[data-lang="kotlin"]::before { background: #7f52ff var(--icon-lang-kotlin) center / 70% no-repeat; }
.code-title[data-lang="shell"]::before, .code-title[data-lang="powershell"]::before, .code-title[data-lang="cmd"]::before { background: #3c4a5a var(--icon-lang-shell) center / 70% no-repeat; }
.code-tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.code-actions { margin-left: auto; display: inline-flex; gap: 2px; flex: none; padding: 4px 0; }
.code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--code-fg);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.code-btn:hover { background: color-mix(in srgb, var(--code-fg) 12%, transparent); color: var(--code-fg); border-color: var(--code-border); }
.code-btn-run { color: #5fb865; }
.code-btn-run::before { content: ""; width: 0; height: 0; border-left: 8px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.code-btn.copied { color: var(--ok); }

.code-scroll { overflow-x: auto; scrollbar-width: thin; }
.code-pre { margin: 0; padding: 12px 0; font-size: 0.84rem; line-height: 1.62; color: var(--code-fg); tab-size: 4; }
.code-pre code { display: block; min-width: max-content; }
.cl { position: relative; display: flex; align-items: flex-start; padding-right: 16px; }
.cn {
  flex: none;
  width: 3.2em;
  padding-right: 1em;
  text-align: right;
  color: var(--code-gutter);
  user-select: none;
  font-variant-numeric: tabular-nums;
}
.cm { flex: none; width: 2em; display: flex; justify-content: center; user-select: none; }
.cr { flex: none; width: 1.3em; margin-left: -0.6em; margin-right: 0.3em; position: relative; user-select: none; }
.cc { white-space: pre; }
.cl.has-note { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.cl.is-hot { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.note-marker {
  flex: none;
  margin-top: 0.12em;
  width: 1.45em;
  height: 1.45em;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}
.gutter-run {
  position: absolute;
  left: 0.1em;
  top: 0.3em;
  width: 1.1em;
  height: 1.1em;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.gutter-run::before {
  content: "";
  display: block;
  margin: 0.12em 0 0 0.2em;
  border-left: 0.62em solid #5fb865;
  border-top: 0.4em solid transparent;
  border-bottom: 0.4em solid transparent;
}
.gutter-run:hover::before { border-left-color: #7fd685; }

.code-long .code-scroll { max-height: 34em; overflow-y: hidden; position: relative; }
.code-long .code-scroll::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4em;
  background: linear-gradient(transparent, var(--code-bg));
  pointer-events: none;
}
.code-long.expanded .code-scroll { max-height: none; overflow-y: visible; }
.code-long.expanded .code-scroll::after { display: none; }
.code-expand {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--code-border);
  background: var(--code-head);
  color: var(--code-fg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 8px;
  cursor: pointer;
}
.code-expand:hover { color: var(--accent-ink); }

.code-notes {
  list-style: none;
  margin: 0 !important;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--code-border);
  background: var(--surface);
  counter-reset: none;
  font-size: 0.93rem;
  display: grid;
  gap: 8px;
}
html[data-theme="dark"] .code-notes { background: #23262a; }
.code-notes li {
  position: relative;
  margin: 0 !important;
  padding: 2px 6px 2px 34px;
  border-radius: var(--radius-s);
  line-height: 1.55;
  color: var(--text);
}
.code-notes li::before {
  content: attr(data-note);
  position: absolute;
  left: 4px;
  top: 3px;
  width: 1.5em;
  height: 1.5em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.72rem;
  font-weight: 800;
}
.code-notes li.is-hot { background: var(--accent-soft); }
.code-notes li > :last-child { margin-bottom: 0; }

.code-legacy { border-color: color-mix(in srgb, var(--warn) 55%, var(--code-border)); }
.code-bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--code-border)); }

.t-kw { color: var(--t-kw); }
.t-str { color: var(--t-str); }
.t-num { color: var(--t-num); }
.t-ann { color: var(--t-ann); }
.t-type { color: var(--t-type); }
.t-fn { color: var(--t-fn); }
.t-fdecl { color: var(--t-fdecl); }
.t-field { color: var(--t-field); }
.t-const { color: var(--t-field); font-style: italic; }
.t-op, .t-punc { color: var(--code-fg); }
.t-key { color: var(--t-key); }
.t-val { color: var(--code-fg); }
.t-com { color: var(--t-com); font-style: italic; }
.t-tag { color: var(--t-tag); }
.t-bool, .t-null { color: var(--t-kw); }
.t-prompt { color: var(--t-com); user-select: none; }
.t-out { color: var(--code-fg); }
.t-err { color: var(--bad); }
.sym { cursor: help; border-radius: 2px; }
.sym:hover, .sym.is-hot { background: color-mix(in srgb, var(--accent) 22%, transparent); }
[data-kw] { cursor: help; }
.sym-inline { cursor: help; }

.console { background: #121416; border-color: #2b2f34; }
.console-head { background: #1c1f22; border-color: #2b2f34; }
.console-title { color: #c9ccd1; }
.console-title::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #5fb865; box-shadow: 16px 0 0 #f0b640, 32px 0 0 #f06a5f; margin-right: 34px; order: -1; }
.console .code-btn { color: #c9ccd1; margin-left: auto; }
.console-body { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 0.82rem; line-height: 1.6; color: #d4d7dc; }
.con-line { display: block; white-space: pre; }
.con-in { color: #ffffff; }
.con-prompt { color: #5fb865; user-select: none; }
.con-time { color: #7c838b; }
.con-warn { color: #f0c060; }
.con-err { color: #ff7b72; }

.diagram { margin: 1.8em 0; padding: 16px; border: 1px solid var(--line-soft); border-radius: var(--radius-l); background: var(--surface); }
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--font-body); }
.diagram figcaption, .mock figcaption, .figure-img figcaption { margin-top: 10px; font-size: 0.88rem; color: var(--muted); text-align: center; }
.d-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.d-arrowhead { fill: var(--muted); }
.d-box { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.diagram .d-box { fill: var(--bg); }
.d-box-accent { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.d-box-ok { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 1.5; }
.d-box-warn { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.5; }
.d-box-bad { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 1.5; }
.d-box-info { fill: var(--info-soft); stroke: var(--info); stroke-width: 1.5; }
.d-box-deep { fill: var(--deep-soft); stroke: var(--deep); stroke-width: 1.5; }
.d-text { fill: var(--text); font-size: 15px; }
.d-text-muted { fill: var(--muted); font-size: 13px; }
.d-text-strong { fill: var(--text); font-size: 16px; font-weight: 700; }
.d-code { fill: var(--text); font-family: var(--font-code); font-size: 13px; }
.d-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.d-line-accent { fill: none; stroke: var(--accent); stroke-width: 2; }
.d-arrow { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.d-dash { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 5 5; }

.mock { margin: 1.8em 0; }
.mock-frame { border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow-2); }
.mock-missing, .code-missing {
  display: grid;
  place-items: center;
  min-height: 140px;
  padding: 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-m);
  color: var(--faint);
  font-size: 0.9rem;
}

.figure-img { margin: 1.6em 0; text-align: center; }
.figure-img img { image-rendering: pixelated; max-height: 360px; }

.mc { margin: 1.4em 0; }
.mc-fallback { font-family: var(--font-mc); font-size: 0.9rem; padding: 10px 12px; background: rgba(0, 0, 0, 0.75); color: #fff; border-radius: var(--radius-s); }

.page-foot { margin-top: 3.2em; padding-top: 1.6em; border-top: 1px solid var(--line); }
.done-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.done-btn:hover { border-color: var(--ok); }
.done-box { width: 18px; height: 18px; border: 2px solid var(--line); border-radius: 4px; }
.done-btn.is-done { border-color: var(--ok); background: var(--ok-soft); }
.done-btn.is-done .done-box { border-color: var(--ok); background: var(--ok) var(--icon-check-white) center / 75% no-repeat; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  text-decoration: none;
  color: var(--text);
}
.pager a:hover { border-color: var(--accent); color: var(--text); }
.pager-next { text-align: right; grid-column: 2; }
.pager-label { font-size: 0.8rem; color: var(--muted); }
.pager-title { font-weight: 700; }

.practice-slot:empty { display: none; }
.practice-box {
  margin-top: 2.6em;
  padding: 16px 18px;
  border-radius: var(--radius-l);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--line));
  background: var(--surface);
}
.practice-box h2 { margin: 0 0 4px !important; font-size: 1.15rem !important; }
.practice-box p { margin: 0 0 10px !important; color: var(--muted); }
.practice-list { list-style: none; margin: 0 !important; padding: 0; display: grid; gap: 6px; }
.practice-list a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding: 6px 8px; border-radius: var(--radius-m); }
.practice-list a:hover { background: var(--raised); }
.practice-list .lvl { font-family: var(--font-mc); font-size: 0.75rem; color: var(--xp); text-shadow: 1px 1px 0 #000; }
.practice-list .solved { margin-left: auto; color: var(--ok); font-size: 0.8rem; font-weight: 700; }

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 40px 18px 40px 6px;
  font-size: 0.86rem;
}
.toc-title { margin: 0 0 8px; font-weight: 750; color: var(--text); font-size: 0.85rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc li.toc-l3 a { padding-left: 24px; font-size: 0.82rem; }
.toc li a:hover { color: var(--text); }
.toc li a.is-current { color: var(--accent-ink); border-left-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--faint); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--accent-contrast); }
html[data-theme="light"] .btn-primary, html[data-theme="light"] .btn-primary:hover { color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--raised); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 0.85rem; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.input, .textarea, .select {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.textarea { min-height: 140px; font-family: var(--font-code); font-size: 0.86rem; line-height: 1.55; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .field-label { font-weight: 700; font-size: 0.9rem; }
.field-help { font-size: 0.84rem; color: var(--muted); }

.panel { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 750; }
.panel-body { padding: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.on { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }

.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--font-code); }
.empty { padding: 28px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius-l); text-align: center; color: var(--muted); }

.page-tool .page-body, .page-tool { max-width: 72rem; }
body[data-type="tool"] .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
body[data-type="tool"] .toc { display: none; }

.tip-pop {
  position: fixed;
  z-index: 90;
  max-width: min(380px, calc(100vw - 24px));
  padding: 9px 11px 10px;
  border: 2px solid transparent;
  border-radius: 3px;
  background:
    linear-gradient(var(--tooltip-bg), var(--tooltip-bg)) padding-box,
    linear-gradient(180deg, var(--tooltip-border-top), var(--tooltip-border-bottom)) border-box;
  box-shadow: 0 0 0 1px rgba(16, 0, 16, 0.9), 0 14px 36px rgba(0, 0, 0, 0.45);
  color: var(--mc-gray);
  font-size: 0.88rem;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.tip-pop.show { opacity: 1; transform: none; }
.tip-pop.pinned { pointer-events: auto; }
.tip-title { display: block; font-family: var(--font-mc); font-size: 0.95rem; color: var(--mc-white); text-shadow: 2px 2px 0 #3f3f3f; margin-bottom: 2px; word-break: break-word; }
.tip-kind { display: block; font-family: var(--font-mc); font-size: 0.78rem; margin-bottom: 6px; color: var(--mc-blue); text-shadow: 2px 2px 0 #22223f; }
.tip-body { display: block; color: #d6d6d6; font-family: var(--font-body); }
.tip-sig { display: block; margin-top: 7px; font-family: var(--font-code); font-size: 0.76rem; color: var(--mc-dark-gray); word-break: break-word; }
.tip-link { display: block; margin-top: 6px; font-family: var(--font-mc); font-size: 0.74rem; color: var(--mc-dark-gray); }
.tip-pop a { color: var(--mc-aqua); }
.tip-pop[data-kind="class"] .tip-title, .tip-pop[data-kind="interface"] .tip-title, .tip-pop[data-kind="enum"] .tip-title, .tip-pop[data-kind="record"] .tip-title { color: var(--mc-aqua); text-shadow: 2px 2px 0 #153f3f; }
.tip-pop[data-kind="method"] .tip-title, .tip-pop[data-kind="constructor"] .tip-title { color: var(--mc-yellow); text-shadow: 2px 2px 0 #3f3f15; }
.tip-pop[data-kind="field"] .tip-title, .tip-pop[data-kind="constant"] .tip-title { color: var(--mc-purple); text-shadow: 2px 2px 0 #3f153f; }
.tip-pop[data-kind="keyword"] .tip-title { color: var(--mc-gold); text-shadow: 2px 2px 0 #2a1c00; }
.tip-pop[data-kind="user"] .tip-title { color: var(--mc-green); text-shadow: 2px 2px 0 #153f15; }
.tip-pop[data-kind="term"] .tip-title { color: var(--mc-white); }

.toast-host { position: fixed; z-index: 95; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
  padding: 9px 16px;
  border-radius: var(--radius-m);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.18s ease;
}
.toast-ok { background: var(--ok); color: #0c1a0c; }
.toast-bad { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 16px 16px;
  background: rgba(8, 10, 12, 0.55);
  backdrop-filter: blur(3px);
}
.search-overlay.open { display: flex; }
.search-panel {
  width: min(680px, 100%);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.search-field { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search-field .i-search { color: var(--muted); }
.search-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; }
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.search-results li a { display: block; padding: 9px 12px; border-radius: var(--radius-m); text-decoration: none; color: var(--text); }
.search-results li a:hover, .search-results li.sel a { background: var(--accent-soft); }
.sr-title { display: block; font-weight: 700; }
.sr-where { display: block; font-size: 0.8rem; color: var(--muted); }
.sr-snippet { display: block; font-size: 0.86rem; color: var(--muted); margin-top: 2px; }
.sr-snippet mark, .sr-title mark { background: transparent; color: var(--accent-ink); font-weight: 800; }
.search-empty { padding: 22px; text-align: center; color: var(--muted); }
.search-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--faint); }

.glossary-filter { margin: 0 0 1.4em; max-width: 360px; }
.glossary-list { margin: 0 0 1em; }
.glossary-entry { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.glossary-entry dt { font-weight: 760; }
.glossary-entry dd { margin: 2px 0 0; color: var(--muted); }
.glossary-more { margin-left: 6px; font-size: 0.85rem; }

@media (max-width: 1280px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 980px) {
  .xp { display: none; }
  .main, .main-home { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .layout, .layout-home, body[data-type="tool"] .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 50;
    width: min(320px, 88vw);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-2);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(0, 0, 0, 0.4); }
  .search-btn { margin-left: auto; flex: 0 0 auto; }
  .search-btn .search-label, .search-btn kbd { display: none; }
  .topbar-right { margin-left: 0; }
  .grid-2, .grid-3, .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .main, .main-home { padding: 22px 16px 60px; }
  .brand-name { display: none; }
  .live-badge { padding: 0 8px; font-size: 0.75rem; }
  .page-body h2 { font-size: 1.38rem; }
  .code-pre { font-size: 0.78rem; }
  .cn { width: 2.5em; padding-right: 0.7em; }
  .cm { width: 1.7em; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .exercise, .quiz-q { padding-left: 14px; padding-right: 14px; }
  .anchor { display: none; }
  .step { padding-left: 42px; }
}

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

@media print {
  .topbar, .sidebar, .toc, .page-foot, .practice-slot, .code-actions { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .code-long .code-scroll { max-height: none; }
}
