:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --sunken: #f2f3f0;
  --text: #1c2321;
  --muted: #5b6662;
  --faint: #8a9490;
  --line: #e2e5e1;
  --accent: #0f6e6a;
  --accent-soft: #e3f1ef;
  --accent-text: #0b5653;
  --code-bg: #f4f5f2;
  --code-text: #1f2a27;
  --note: #2f6db5;
  --note-bg: #eef4fb;
  --tip: #2a7a3f;
  --tip-bg: #edf7ef;
  --warning: #9a5b00;
  --warning-bg: #fdf5e6;
  --danger: #b3261e;
  --danger-bg: #fcefee;
  --mark: #fff1b8;
  --shadow: 0 20px 50px rgba(20, 30, 28, 0.18), 0 2px 6px rgba(20, 30, 28, 0.08);
  --radius: 10px;
  --top: 56px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615;
    --surface: #181d1c;
    --sunken: #1d2322;
    --text: #e4e9e6;
    --muted: #a3aeaa;
    --faint: #76817d;
    --line: #2a3230;
    --accent: #4fbdb5;
    --accent-soft: #173331;
    --accent-text: #7fd6cf;
    --code-bg: #1c2221;
    --code-text: #dce4e0;
    --note: #7fb1ec;
    --note-bg: #17222f;
    --tip: #79c98d;
    --tip-bg: #162519;
    --warning: #e3b263;
    --warning-bg: #2a2113;
    --danger: #f08a82;
    --danger-bg: #2c1716;
    --mark: #5a4b12;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121615;
  --surface: #181d1c;
  --sunken: #1d2322;
  --text: #e4e9e6;
  --muted: #a3aeaa;
  --faint: #76817d;
  --line: #2a3230;
  --accent: #4fbdb5;
  --accent-soft: #173331;
  --accent-text: #7fd6cf;
  --code-bg: #1c2221;
  --code-text: #dce4e0;
  --note: #7fb1ec;
  --note-bg: #17222f;
  --tip: #79c98d;
  --tip-bg: #162519;
  --warning: #e3b263;
  --warning-bg: #2a2113;
  --danger: #f08a82;
  --danger-bg: #2c1716;
  --mark: #5a4b12;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
kbd {
  font: 600 11px/1 var(--mono);
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
}
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 15px;
}
.menu, .theme {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.menu { display: none; }
.menu:hover, .theme:hover { background: var(--sunken); color: var(--text); }
.search-open {
  flex: 1;
  max-width: 460px;
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 8px 0 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--faint);
  font: inherit; font-size: 14px; cursor: text; text-align: left;
}
.search-open:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.search-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-switch {
  display: flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--sunken);
}
.os-switch button {
  border: 0; background: transparent; color: var(--muted);
  font: 600 13px/1 var(--font); padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.os-switch button:hover { color: var(--text); }
[data-os="linux"] .os-switch [data-os="linux"],
[data-os="macos"] .os-switch [data-os="macos"],
[data-os="windows"] .os-switch [data-os="windows"] {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 0 1px var(--line);
}

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 220px;
  max-width: 1440px;
  margin: 0 auto;
}
.nav {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 20px 12px 40px 16px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.nav-section { margin-bottom: 18px; }
.nav-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint); padding: 0 10px 6px;
}
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 5px 10px; border-radius: 7px;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.nav a:hover { background: var(--sunken); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

.content { padding: 36px 48px 80px; min-width: 0; }
.eyebrow { font-size: 13px; font-weight: 650; color: var(--accent-text); margin-bottom: 6px; }
.page-title { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 10px; text-wrap: balance; }
.lede { font-size: 18px; color: var(--muted); margin: 0 0 28px; max-width: 70ch; text-wrap: pretty; }

.toc {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 36px 16px 40px 8px;
  font-size: 13px;
  scrollbar-width: thin;
}
.toc-title { font-weight: 700; color: var(--text); margin-bottom: 8px; }
.toc ul { 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; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.35; }
.toc li.d3 a { padding-left: 24px; font-size: 12.5px; }
.toc li a:hover { color: var(--text); }
.toc li a.active { color: var(--accent-text); border-left-color: var(--accent); }

/* ---------------------------------------------------------------- prose */
.prose { max-width: 78ch; }
.prose h2 { font-size: 24px; letter-spacing: -0.015em; margin: 44px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); line-height: 1.25; }
.prose h3 { font-size: 18.5px; margin: 30px 0 8px; line-height: 1.3; }
.prose h4 { font-size: 16px; margin: 22px 0 6px; }
.prose h2:first-child { margin-top: 0; border-top: 0; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; padding-right: 0.3em; color: var(--faint); text-decoration: none; opacity: 0; font-weight: 400; }
.prose :is(h2, h3, h4):hover .anchor, .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li { margin: 4px 0; }
.prose li > p { margin-bottom: 6px; }
.prose ol > li::marker { font-weight: 650; color: var(--muted); }
.prose code {
  font: 0.88em/1.5 var(--mono);
  background: var(--code-bg); color: var(--code-text);
  padding: 0.1em 0.35em; border-radius: 5px;
  overflow-wrap: anywhere;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.prose blockquote { margin: 0 0 14px; padding: 2px 16px; border-left: 3px solid var(--line); color: var(--muted); }
.prose img { max-width: 100%; }

.code { margin: 10px 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--line);
  font: 600 11.5px/1 var(--mono); color: var(--faint); text-transform: lowercase;
}
.copy {
  font: 600 12px/1 var(--font); color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 6px 9px; cursor: pointer;
}
.copy:hover { background: var(--surface); border-color: var(--line); color: var(--text); }
.copy.done { color: var(--tip); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.6; color: var(--code-text); overflow-wrap: normal; white-space: pre; }

.table-wrap { overflow-x: auto; margin: 10px 0 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.prose th { background: var(--sunken); font-weight: 650; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

.callout { margin: 14px 0 18px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; font-size: 13px; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 4px; }
.callout.note, .callout.info { background: var(--note-bg); border-color: color-mix(in srgb, var(--note) 30%, transparent); }
.callout.note .callout-title, .callout.info .callout-title { color: var(--note); }
.callout.tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 30%, transparent); }
.callout.tip .callout-title { color: var(--tip); }
.callout.warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.callout.warning .callout-title { color: var(--warning); }
.callout.danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout.danger .callout-title { color: var(--danger); }

/* OS blocks: the system picked at the top shows; the others hide. */
.os-block { margin: 12px 0 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.os-tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
.os-tabs button {
  font: 600 13px/1 var(--font); color: var(--muted);
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px 9px; cursor: pointer; margin-bottom: -1px;
}
.os-tabs button:hover { color: var(--text); }
.os-pane { padding: 12px 16px 2px; }
.os-pane > .code:first-child { margin-top: 2px; }
[data-os="linux"] .os-pane:not([data-os="linux"]),
[data-os="macos"] .os-pane:not([data-os="macos"]),
[data-os="windows"] .os-pane:not([data-os="windows"]) { display: none; }
[data-os="linux"] .os-tabs [data-os="linux"],
[data-os="macos"] .os-tabs [data-os="macos"],
[data-os="windows"] .os-tabs [data-os="windows"] { color: var(--accent-text); border-bottom-color: var(--accent); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; max-width: 78ch; }
.pager a {
  display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text); font-weight: 600; background: var(--surface);
}
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; font-weight: 500; color: var(--faint); margin-bottom: 2px; }
.pager .next { text-align: right; }
.foot { margin-top: 32px; font-size: 13px; color: var(--faint); max-width: 78ch; }

/* ---------------------------------------------------------------- search */
.search { position: fixed; inset: 0; z-index: 50; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 15, 0.45); }
.search-panel {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 80px));
  margin: 7vh auto 0;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-row { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); color: var(--faint); }
.search-row input {
  flex: 1; min-width: 0; height: 56px; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 500 17px/1 var(--font);
}
.search-row input::-webkit-search-cancel-button { display: none; }
.search-close { font: 600 11px/1 var(--mono); color: var(--muted); background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; cursor: pointer; }
.results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.results li a {
  display: block; padding: 10px 12px; border-radius: 9px; text-decoration: none; color: var(--text);
}
.results li[aria-selected="true"] a { background: var(--accent-soft); }
.r-path { font-size: 12px; color: var(--faint); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.r-head { font-weight: 650; font-size: 15px; margin: 2px 0; }
.r-text { font-size: 13.5px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-text mark, .r-head mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: var(--sunken); color: var(--muted); border: 1px solid var(--line); }
.badge.sem { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.results .empty { padding: 28px 16px; color: var(--muted); text-align: center; font-size: 14px; }
.search-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 16px; border-top: 1px solid var(--line); background: var(--sunken);
  font-size: 12px; color: var(--faint);
}
.search-foot kbd { margin-right: 2px; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status.ready::before { background: var(--tip); }
.status.loading::before { background: var(--warning); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.3; } }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--mark); } to { background: transparent; } }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .menu { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed; top: var(--top); left: 0; bottom: 0; z-index: 30;
    width: min(320px, 86vw); height: auto;
    background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  body.nav-open .nav { transform: none; box-shadow: var(--shadow); }
  .content { padding: 24px 16px 64px; }
  .page-title { font-size: 28px; }
  .brand-text, .search-key { display: none; }
  .search-open { max-width: none; }
  .search-label { font-size: 13px; }
  .os-switch button { padding: 8px 7px; font-size: 12px; }
  .anchor { display: none; }
}
@media (max-width: 520px) {
  .top { gap: 6px; padding: 0 10px; }
  .theme { display: none; }
  .search-label { display: none; }
  .search-open { flex: 0 0 38px; padding: 0; justify-content: center; margin-left: auto; }
  .pager { grid-template-columns: 1fr; }
  .search-panel { margin-top: 12px; max-height: calc(100vh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media print {
  .top, .nav, .toc, .pager, .copy, .os-tabs { display: none !important; }
  .layout { display: block; }
  .os-pane { display: block !important; }
  .os-pane::before { content: attr(data-os); font-weight: 700; text-transform: capitalize; }
}

/* Tables keep a readable width and scroll sideways rather than breaking words letter by letter. */
.prose table { min-width: 640px; }
.prose td code, .prose th code { overflow-wrap: normal; word-break: normal; white-space: nowrap; }
.prose td { min-width: 9ch; }
