/* MSL Guide — site styles.
   Built on PaperDesign's structure (8px unit, one container radius, hairlines
   over shadows, one muted accent) with MSL's own identity: the melon. */

:root {
  --paper-line: color-mix(in srgb, var(--ink) 5%, transparent);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* One undertone (a faint melon-rind green), four neutral steps. */
  --canvas: #f4f5f4;
  --raised: #fcfdfc;
  --sunken: #eef0ee;
  --line: #e2e5e2;
  --line-strong: #cdd2ce;
  --ink: #1a1e1c;
  --ink-2: #545c58;
  --ink-3: #858c88;

  /* The accent is the rind; the flesh is its quieter companion. */
  --accent: #2f6b4a;
  --accent-muted: #e2eee6;
  --accent-ink: #24573b;
  --flesh: #b5763f;

  --hover: rgba(26, 30, 28, 0.045);
  --press: rgba(26, 30, 28, 0.085);
  --scrim: rgba(20, 24, 22, 0.32);
  --shadow-1: 0 1px 2px rgba(20, 24, 22, 0.06);
  --shadow-2: 0 12px 32px rgba(20, 24, 22, 0.16), 0 0 0 1px rgba(20, 24, 22, 0.06);

  /* Semantic colours sit below the accent's saturation, never above. */
  --c-note: #4d6788;
  --c-tip: #44785a;
  --c-important: #92702e;
  --c-warning: #a35b3c;
  --c-danger: #a5453d;
  --c-aside: #6a706c;

  --radius: 4px;
  --top: 52px;
  --side: 272px;
  --toc: 224px;

  --fast: 100ms;
  --mid: 180ms;
  --slow: 260ms;
  --ease-in: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.4, 0, 1, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #151716;
    --raised: #1a1c1b;
    --sunken: #121413;
    --line: #2a2e2c;
    --line-strong: #3a3f3c;
    --ink: #e5e8e6;
    --ink-2: #a3aba7;
    --ink-3: #737b77;
    --accent: #8fc8a4;
    --accent-muted: #22332a;
    --accent-ink: #a9d8ba;
    --flesh: #d9a372;
    --hover: rgba(229, 232, 230, 0.05);
    --press: rgba(229, 232, 230, 0.09);
    --scrim: rgba(0, 0, 0, 0.5);
    --shadow-1: none;
    --shadow-2: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(229, 232, 230, 0.08);
    --c-note: #93abc9;
    --c-tip: #8fbf9f;
    --c-important: #cfb070;
    --c-warning: #d6967a;
    --c-danger: #df8b82;
    --c-aside: #a3aba7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #151716;
  --raised: #1a1c1b;
  --sunken: #121413;
  --line: #2a2e2c;
  --line-strong: #3a3f3c;
  --ink: #e5e8e6;
  --ink-2: #a3aba7;
  --ink-3: #737b77;
  --accent: #8fc8a4;
  --accent-muted: #22332a;
  --accent-ink: #a9d8ba;
  --flesh: #d9a372;
  --hover: rgba(229, 232, 230, 0.05);
  --press: rgba(229, 232, 230, 0.09);
  --scrim: rgba(0, 0, 0, 0.5);
  --shadow-1: none;
  --shadow-2: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(229, 232, 230, 0.08);
  --c-note: #93abc9;
  --c-tip: #8fbf9f;
  --c-important: #cfb070;
  --c-warning: #d6967a;
  --c-danger: #df8b82;
  --c-aside: #a3aba7;
  color-scheme: dark;
}

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 24px); }
body {
  margin: 0;
  background: var(--raised);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
a { color: var(--accent); }
img { max-width: 100%; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }

.skip {
  position: fixed; left: 8px; top: -48px; z-index: 50;
  background: var(--ink); color: var(--raised); padding: 8px 16px; border-radius: var(--radius);
  text-decoration: none; font-size: 14px;
}
.skip:focus { top: 8px; }

kbd {
  font: 500 12px/1 var(--font);
  font-feature-settings: "tnum";
  color: var(--ink-2);
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  padding: 3px 5px 2px;
  white-space: nowrap;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 24px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  width: calc(var(--side) - 40px);
  color: var(--ink); text-decoration: none;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
.brand img { display: block; }
.search-trigger {
  display: flex; align-items: center; gap: 8px;
  height: 32px; width: min(400px, 100%);
  padding: 0 6px 0 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3); font-size: 13.5px; text-align: left;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease-in), background-color var(--fast) var(--ease-in);
}
.search-trigger span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-trigger kbd { border-radius: 999px; padding: 4px 7px 3px; border-bottom-width: 1px; }
.search-trigger:hover { border-color: var(--line-strong); color: var(--ink-2); }
.search-trigger:active { background: var(--press); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top-link {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
  transition: background-color var(--fast) var(--ease-in);
}
.top-link:hover { background: var(--hover); color: var(--ink); }
.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  background: none; border: 0; border-radius: var(--radius);
  color: var(--ink-2); cursor: pointer;
  transition: background-color var(--fast) var(--ease-in);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { background: var(--press); }
.icon-btn svg { width: 18px; height: 18px; }
.nav-toggle { display: none; margin-left: -8px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* ------------------------------------------------------------ layout */

.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--toc);
  min-height: calc(100vh - var(--top));
}
.is-home .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
main { min-width: 0; padding: 40px 48px 0; display: flex; flex-direction: column; }
.doc { width: 100%; max-width: 728px; margin: 0 auto; flex: 1; }

/* ------------------------------------------------------------ sidebar */

.sidebar {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  background: var(--canvas);
  border-right: 1px solid var(--line);
  font-size: 13.5px;
}
.side-scroll { height: 100%; overflow-y: auto; padding: 16px 12px 48px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.side-home {
  display: flex; align-items: center; gap: 8px;
  min-height: 32px; padding: 6px 8px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.side-home svg { color: var(--ink-3); }
.side-part {
  margin: 20px 8px 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3);
}
.chapter summary {
  display: flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 6px 8px; border-radius: var(--radius);
  list-style: none; cursor: pointer; user-select: none;
  color: var(--ink); font-weight: 500;
}
.chapter summary::-webkit-details-marker { display: none; }
.chapter summary svg { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--fast) var(--ease-in); }
.chapter[open] > summary svg { transform: rotate(90deg); }
.ch-name { flex: 1; }
.chapter summary .cat-dot { width: 6px; height: 6px; margin: 0 2px; }
.ch-count { font: 500 11px/1 var(--mono); color: var(--ink-3); }
.chapter ul { list-style: none; margin: 2px 0 8px 15px; padding: 0 0 0 8px; border-left: 1px solid var(--line); }
.chapter li a {
  display: block; padding: 5px 8px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; line-height: 1.4;
}
.side-home:hover, .chapter summary:hover, .chapter li a:hover { background: var(--hover); color: var(--ink); }
.side-home:active, .chapter summary:active, .chapter li a:active { background: var(--press); }
.chapter li a.current, .side-home.current { background: var(--accent-muted); color: var(--accent-ink); font-weight: 500; }
.chapter li a.current { position: relative; }
.chapter li a.current::before { content: ""; position: absolute; left: -9px; top: 6px; bottom: 6px; width: 1px; background: var(--accent); }

/* ------------------------------------------------------------ article head */

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 16px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.doc h1, .home h1, .lost h1 {
  margin: 0 0 8px;
  font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.022em;
  text-wrap: balance;
}
.lead { margin: 0; font-size: 18px; line-height: 1.5; color: var(--ink-2); letter-spacing: -0.006em; text-wrap: pretty; }
.doc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 16px; font-size: 12.5px; color: var(--ink-3); }
.doc-meta > span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); vertical-align: middle; margin: -2px 16px 0 -10px; }
.doc-head { padding-bottom: 24px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }

.toc-inline { display: none; margin: -16px 0 32px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.toc-inline summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; list-style: none; font-weight: 500; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary span { margin-left: auto; color: var(--ink-3); font-size: 12.5px; font-weight: 400; }
.toc-inline summary svg { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--fast) var(--ease-in); }
.toc-inline[open] summary svg { transform: rotate(90deg); }
.toc-inline summary:hover { background: var(--hover); }
.toc-inline ul { list-style: none; margin: 0; padding: 4px 12px 12px 34px; }
.toc-inline li { padding: 3px 0; }
.toc-inline li.l3 { padding-left: 0; }
.toc-inline a { color: var(--ink-2); text-decoration: none; }
.toc-inline a:hover { color: var(--accent); }

/* ------------------------------------------------------------ prose */

.prose { font-size: 16px; line-height: 1.65; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose li { word-break: keep-all; }
.prose p { margin: 0 0 16px; text-wrap: pretty; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color var(--fast) var(--ease-in); }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { font-weight: 600; }
.prose h2, .prose h3, .prose h4 { position: relative; color: var(--ink); text-wrap: balance; }
.prose h2 { margin: 48px 0 12px; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -0.016em; }
.prose h3 { margin: 40px 0 8px; font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -0.012em; }
.prose h4 { margin: 24px 0 8px; font-size: 16px; line-height: 1.4; font-weight: 600; }
.prose .anchor {
  margin-left: 8px; padding: 0 4px; border-radius: var(--radius);
  color: var(--ink-3); text-decoration: none; font-weight: 400;
  opacity: 0; transition: opacity var(--fast) var(--ease-in);
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
.prose .anchor:hover { color: var(--accent); background: var(--hover); }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 6px 0; padding-left: 4px; }
.prose li::marker { color: var(--ink-3); }
.prose ol li::marker { font: 500 14px var(--mono); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.prose em { font-style: italic; }

.prose code {
  font: 0.86em/1 var(--mono);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px 5px;
  overflow-wrap: anywhere;
}
.prose a code { color: inherit; }

figure.code { position: relative; margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); overflow: hidden; }
figure.code figcaption {
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2); background: var(--canvas);
}
.prose pre { margin: 0; padding: 14px 16px; overflow-x: auto; background: var(--sunken); }
.prose > pre { margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius); }
.prose pre code { display: block; background: none; border: 0; padding: 0; font: 13.5px/1.6 var(--mono); overflow-wrap: normal; white-space: pre; }
.copy {
  position: absolute; right: 8px; top: 8px;
  height: 24px; padding: 0 8px;
  font-size: 12px; color: var(--ink-2);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; opacity: 0;
  transition: opacity var(--fast) var(--ease-in), background-color var(--fast) var(--ease-in);
}
figure.code:has(figcaption) .copy { top: 5px; }
figure.code:hover .copy, .copy:focus-visible, .copy.done { opacity: 1; }
.copy:hover { color: var(--ink); border-color: var(--line-strong); }
.copy.done { color: var(--accent); }
@media (hover: none) { .copy { opacity: 1; } }

.table-wrap { margin: 24px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.prose th {
  text-align: left; vertical-align: bottom;
  padding: 8px 16px; background: var(--canvas);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.prose td { padding: 10px 16px; vertical-align: top; border-top: 1px solid var(--line); }
.prose tbody tr:first-child td { border-top: 0; }
.prose tbody tr:hover td { background: var(--hover); }
.prose td:first-child { font-weight: 500; }
.prose td code { white-space: nowrap; }

/* Callouts — six kinds, one shape. */
.callout {
  --c: var(--c-note);
  margin: 24px 0; padding: 12px 16px 14px;
  background: color-mix(in srgb, var(--c) 6%, var(--raised));
  border: 1px solid color-mix(in srgb, var(--c) 26%, var(--line));
  border-radius: var(--radius);
  font-size: 15px; line-height: 1.6;
}
.callout.tip { --c: var(--c-tip); }
.callout.important { --c: var(--c-important); }
.callout.warning { --c: var(--c-warning); }
.callout.danger { --c: var(--c-danger); }
.callout.aside { --c: var(--c-aside); background: var(--canvas); border-color: var(--line); }
.callout-kind {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em; color: var(--c);
  text-transform: capitalize;
}
.callout-kind::before {
  content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.callout { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 7.25v4M8 4.75v.01'/%3E%3C/svg%3E"); }
.callout.tip { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5h4M6.5 14.5h3M8 1.75a4.25 4.25 0 0 0-2.4 7.76c.4.28.65.72.65 1.2v.04h3.5v-.04c0-.48.25-.92.65-1.2A4.25 4.25 0 0 0 8 1.75Z'/%3E%3C/svg%3E"); }
.callout.important { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 14.25V2.5M4 2.75h8l-1.75 3 1.75 3H4'/%3E%3C/svg%3E"); }
.callout.warning, .callout.danger { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.13 2.5 1.6 12.25a1 1 0 0 0 .87 1.5h11.06a1 1 0 0 0 .87-1.5L8.87 2.5a1 1 0 0 0-1.74 0ZM8 6.25v3.25M8 11.75v.01'/%3E%3C/svg%3E"); }
.callout.aside { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.75 3.25h10.5v7.5h-6l-3 2.5v-2.5h-1.5Z'/%3E%3C/svg%3E"); }
.callout p { margin: 4px 0 0; }
.callout .callout-title { margin-top: 6px; font-weight: 600; color: var(--ink); }
.callout code { background: color-mix(in srgb, var(--c) 8%, var(--raised)); }

/* Feature cards — a dot of colour each, quieter than the accent. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.card { --tint: var(--ink-3); padding: 14px 16px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 15px; font-weight: 600; letter-spacing: -0.006em; }
.card h4::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tint); flex: none; }
.card p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.tint-green { --tint: #6f9e7e; } .tint-rind { --tint: #7c9a5c; } .tint-teal { --tint: #5f9294; }
.tint-indigo { --tint: #6c7aa8; } .tint-purple { --tint: #8b77a3; } .tint-orange { --tint: #c08a5a; } .tint-red { --tint: #b36e66; }

/* Shortcut lists */
.shortcuts { display: grid; grid-template-columns: max-content 1fr; margin: 16px 0 24px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; }
.shortcuts dt, .shortcuts dd { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); }
.shortcuts dt { background: var(--canvas); border-right: 1px solid var(--line); }
.shortcuts kbd { font-size: 13px; padding: 4px 6px 3px; }
.shortcuts dt:first-of-type, .shortcuts dt:first-of-type + dd { border-top: 0; }

/* ------------------------------------------------------------ article foot */

.related { margin-top: 48px; }
.related h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
.related ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.related li a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 40px; padding: 8px; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 15px;
  transition: background-color var(--fast) var(--ease-in);
}
.related li a svg { color: var(--ink-3); transition: transform var(--fast) var(--ease-in), color var(--fast) var(--ease-in); }
.related li a:hover { background: var(--hover); color: var(--accent); }
.related li a:hover svg { color: var(--accent); transform: translateX(2px); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 48px 0 0; }
.pager a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
  transition: border-color var(--fast) var(--ease-in), background-color var(--fast) var(--ease-in);
}
.pager a:hover { border-color: var(--line-strong); background: var(--hover); }
.pager a:active { background: var(--press); }
.pager-next { text-align: right; align-items: flex-end; }
.pager-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.pager-title { font-weight: 600; font-size: 15px; color: var(--accent); }
.pager-chapter { font-size: 12.5px; color: var(--ink-3); }

.site-footer { max-width: 728px; width: 100%; margin: 64px auto 0; padding: 24px 0 40px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.is-home .site-footer { max-width: 1040px; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------ on this page */

.toc { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 40px 24px 40px 8px; font-size: 13px; scrollbar-width: none; }
.toc-title { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a {
  display: block; margin-left: -1px; padding: 4px 0 4px 12px;
  border-left: 1px solid transparent;
  color: var(--ink-3); text-decoration: none; line-height: 1.4;
  transition: color var(--fast) var(--ease-in);
}
.toc li.l3 a { padding-left: 24px; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--accent-ink); border-left-color: var(--accent); }
.toc-top { display: inline-block; margin-top: 16px; color: var(--ink-3); text-decoration: none; font-size: 12.5px; }
.toc-top:hover { color: var(--ink); }

/* ------------------------------------------------------------ graph paper */

/* Every article and chapter page sits on the same graph paper as the home
   page: a band behind the title that fades out before the text starts. */
.is-article .shell, .is-chapter .shell { position: relative; }
.is-article .shell::before, .is-chapter .shell::before {
  content: ""; position: absolute; top: 0; left: var(--side); right: 0; height: 360px; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--paper-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--paper-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent);
  mask-image: linear-gradient(to bottom, #000 35%, transparent);
}
.is-article main > *, .is-chapter main > * { position: relative; }

/* ------------------------------------------------------------ chapter pages */

.chapter-eyebrow { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }
.chapter-eyebrow .ch-num { font: 500 13px/1 var(--mono); color: var(--cat); }
.chapter-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); counter-reset: none; }
.chapter-list a {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 16px; align-items: start; gap: 12px;
  padding: 14px 8px; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
  transition: background-color var(--fast) var(--ease-in);
}
.chapter-list a:hover { background: var(--hover); }
.chapter-list a:active { background: var(--press); }
.chapter-list a > svg { margin-top: 4px; color: var(--ink-3); transition: transform var(--fast) var(--ease-in), color var(--fast) var(--ease-in); }
.chapter-list a:hover > svg { color: var(--accent); transform: translateX(2px); }
.cl-n { font: 500 13px/1.6 var(--mono); color: var(--cat); text-align: right; }
.cl-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cl-title { font-size: 16px; font-weight: 600; letter-spacing: -0.008em; }
.chapter-list a:hover .cl-title { color: var(--accent); }
.cl-blurb { font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.chapter-empty { padding: 32px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; color: var(--ink-2); }
.chapter-empty p { margin: 4px 0; font-size: 14.5px; }
.chapter-empty .cl-title { color: var(--ink); }
.chapter .ch-overview a { color: var(--ink-3); }
.chapter .ch-overview a.current { color: var(--accent-ink); }

/* ------------------------------------------------------------ home */

.home { width: 100%; max-width: 1040px; margin: 0 auto; flex: 1; }
.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px;
  margin: -40px -48px 0; padding: 48px 48px 0;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
/* Faint graph paper behind the title, fading out before the content. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--paper-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--paper-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.hero-text { position: relative; z-index: 1; min-width: 0; padding-bottom: 48px; max-width: 600px; }
.hero-logo { display: block; margin-bottom: 16px; }
.home h1 { font-size: 30px; }
.hero .lead { max-width: 520px; }
.hero-search {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 520px; height: 44px; margin-top: 24px;
  padding: 0 8px 0 16px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--ink-3); font-size: 15px; text-align: left; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast) var(--ease-in);
}
.hero-search span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hero-search kbd { border-radius: 999px; padding: 5px 8px 4px; border-bottom-width: 1px; }
.hero-search:hover { border-color: var(--ink-3); color: var(--ink-2); }
.hero .mascot { position: relative; z-index: 1; display: block; width: 152px; height: auto; margin-right: 16px; align-self: end; }

/* "Last updated" watermark: plain quiet text, like the Windows activation
   notice. It never takes clicks. */
.watermark {
  margin-top: 20px; padding-left: 10px; border-left: 2px solid var(--line-strong);
  font-size: 12.5px; line-height: 1.45; color: var(--ink-3);
  opacity: 0.8; pointer-events: none; user-select: none;
}
.watermark p { margin: 0; }
.watermark .wm-note { font-weight: 600; color: var(--ink-2); }
/* With room to spare it sits in the hero's empty corner, left of the mascot. */
@container (min-width: 1000px) {
  .hero-text { position: static; }
  .hero .watermark { position: absolute; right: 232px; bottom: 28px; margin: 0; }
}

.part-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }

/* The home page sizes its tiles by its own width, not the window's, so the
   grid stays orderly whether the sidebar is showing or not. */
.home { container-type: inline-size; }

.first-steps { margin: 40px 0 48px; }
.first-steps .part-title { margin-bottom: 16px; }
.steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@container (min-width: 440px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@container (min-width: 860px) { .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.step {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); background: var(--raised);
  transition: border-color var(--fast) var(--ease-in), background-color var(--fast) var(--ease-in);
}
.step:hover { border-color: var(--line-strong); background: var(--hover); }
.step:active { background: var(--press); }
.step-n {
  display: grid; place-items: center; width: 22px; height: 22px; margin-bottom: 8px;
  border-radius: 50%; background: var(--accent-muted); color: var(--accent-ink);
  font: 600 12px/1 var(--mono);
}
.step-title { font-weight: 600; font-size: 15px; letter-spacing: -0.006em; }
.step-blurb { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
/* Narrow: the steps become a compact numbered list. */
@container (max-width: 439px) {
  .step { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 12px; row-gap: 2px; padding: 12px 14px; }
  .step-n { grid-row: span 2; margin: 0; }
}

/* ---- topic colours: muted, all below the accent's saturation */
:root {
  --cat-basics: #5f9a6e; --cat-app: #5a7eac; --cat-apps: #8a72b0; --cat-shell: #4c9295; --cat-instances: #c07f45;
  --cat-upkeep: #ad8d2c; --cat-security: #ad5f7d; --cat-trouble: #b65947; --cat-reference: #858c88; --cat-extras: #86964a; --cat-other: #858c88;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cat-basics: #7fbf91; --cat-app: #89a9d4; --cat-apps: #b09bd4; --cat-shell: #7bbdbd; --cat-instances: #dda26c;
    --cat-upkeep: #d2b55a; --cat-security: #d489a5; --cat-trouble: #dd8a75; --cat-reference: #9aa29e; --cat-extras: #b6c27c; --cat-other: #9aa29e;
  }
}
:root[data-theme="dark"] {
  --cat-basics: #7fbf91; --cat-app: #89a9d4; --cat-apps: #b09bd4; --cat-shell: #7bbdbd; --cat-instances: #dda26c;
  --cat-upkeep: #d2b55a; --cat-security: #d489a5; --cat-trouble: #dd8a75; --cat-reference: #9aa29e; --cat-extras: #b6c27c; --cat-other: #9aa29e;
}
.t-basics { --cat: var(--cat-basics); } .t-app { --cat: var(--cat-app); } .t-apps { --cat: var(--cat-apps); }
.t-shell { --cat: var(--cat-shell); } .t-instances { --cat: var(--cat-instances); } .t-upkeep { --cat: var(--cat-upkeep); }
.t-security { --cat: var(--cat-security); } .t-trouble { --cat: var(--cat-trouble); } .t-reference { --cat: var(--cat-reference); }
.t-extras { --cat: var(--cat-extras); } .t-other { --cat: var(--cat-other); }
.cat-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cat, var(--ink-3)); }

/* A chip that names a topic and opens the colour key. */
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px 0 8px; margin: 0;
  background: none; border: 1px solid transparent; border-radius: 999px;
  font-size: 12px; color: var(--ink-3); cursor: pointer;
  transition: background-color var(--fast) var(--ease-in), border-color var(--fast) var(--ease-in), color var(--fast) var(--ease-in);
}
.cat-chip:hover { background: color-mix(in srgb, var(--cat) 10%, transparent); border-color: color-mix(in srgb, var(--cat) 30%, transparent); color: var(--ink); }
.cat-chip:active { background: color-mix(in srgb, var(--cat) 18%, transparent); }
.cat-chip[aria-expanded="true"] { border-color: var(--cat); color: var(--ink); }
.doc-meta .cat-chip { margin: -4px 0 -4px -8px; }

/* ---- the chapter tiles */
.chapters { margin-bottom: 24px; scroll-margin-top: calc(var(--top) + 16px); }
.chapters-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }
.filter-status { margin: 0; font-size: 13px; color: var(--ink-3); }
.filter-status button { padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--ink-2); font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background-color var(--fast) var(--ease-in), border-color var(--fast) var(--ease-in);
}
.chip:hover { border-color: var(--line-strong); background: var(--hover); color: var(--ink); }
.chip:active { background: var(--press); }
.chip[aria-pressed="true"] { border-color: var(--cat, var(--accent)); background: color-mix(in srgb, var(--cat, var(--accent)) 12%, var(--raised)); color: var(--ink); font-weight: 500; }

/* Rows of equal height; inside each row the header, blurb, list and footer
   line up across tiles (subgrid), so a row reads as one ordered band. */
.chapter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container (min-width: 600px) { .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 920px) { .chapter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (min-width: 1240px) { .chapter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.chapter-card {
  display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0;
  padding: 16px 16px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised);
  scroll-margin-top: calc(var(--top) + 16px);
  transition: border-color var(--fast) var(--ease-in);
}
@supports not (grid-template-rows: subgrid) { .chapter-card { display: flex; flex-direction: column; } .chapter-card ul { flex: 1; } }
.chapter-card[hidden] { display: none; }
.chapter-card:hover { border-color: var(--line-strong); }
.chapter-card:target { border-color: var(--cat); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 18%, transparent); }
.chapter-card header { display: flex; align-items: baseline; gap: 8px; }
.chapter-card .ch-num { font: 500 12px/1 var(--mono); color: var(--cat); }
.chapter-card h3 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.chapter-card h3 a { color: inherit; text-decoration: none; }
.chapter-card h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.chapter-card li.none { padding: 4px 8px; font-size: 14px; color: var(--ink-3); font-style: italic; }
.chapter-card .ch-count { font: 400 12px/1 var(--font); color: var(--ink-3); white-space: nowrap; }
.chapter-card > p { margin: 6px 0 10px; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.chapter-card ul { list-style: none; margin: 0 -8px; padding: 8px 0; border-top: 1px solid var(--line); align-self: start; }
.chapter-card li a {
  display: block; padding: 4px 8px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.chapter-card li a:hover { background: var(--hover); color: var(--accent); }
.chapter-card li a:active { background: var(--press); }
.js .chapter-card:not(.expanded) li.extra { display: none; }
.chapter-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -8px; padding-top: 6px; border-top: 1px solid var(--line); align-self: end; }
.more { display: none; height: 24px; padding: 0 8px; border: 0; border-radius: var(--radius); background: none; color: var(--accent); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.js .more { display: inline-flex; align-items: center; }
.more:hover { background: var(--hover); }
.js .chapter-card.few .more { display: none; }
/* Narrow: three articles per tile, and the topic chips scroll sideways. */
@container (max-width: 599px) {
  .js .chapter-card:not(.expanded) li.p { display: none; }
  .js .chapter-card.few .more { display: inline-flex; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 0 16px 4px; scrollbar-width: none; scroll-padding-inline: 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

/* ---- the colour key: a transient popover anchored to its chip by a beak */
.legend {
  position: absolute; z-index: 45; width: min(360px, calc(100vw - 16px));
  padding: 12px 8px 8px; background: var(--raised); border-radius: var(--radius); box-shadow: var(--shadow-2);
  animation: rise var(--mid) var(--ease-in);
}
.legend[hidden] { display: none; }
.legend .beak { position: absolute; top: -4px; left: var(--beak-x, 24px); width: 8px; height: 4px; margin-left: -4px; background: var(--raised); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.legend.above .beak { top: auto; bottom: -4px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.legend-title { margin: 0 8px 2px; font-size: 13px; font-weight: 600; }
.legend-hint { margin: 0 8px 8px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.legend ul { list-style: none; margin: 0; padding: 0; max-height: min(420px, 56vh); overflow-y: auto; }
.legend-row { display: flex; gap: 10px; padding: 7px 8px; border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.legend-row .cat-dot { margin-top: 6px; }
.legend-row:hover { background: var(--hover); }
.legend-row.current { background: color-mix(in srgb, var(--cat) 12%, transparent); }
.legend-text { display: flex; flex-direction: column; min-width: 0; }
.legend-name { font-size: 13.5px; font-weight: 600; }
.legend-about { font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
.legend-ch { font-size: 11.5px; line-height: 1.4; color: var(--ink-3); margin-top: 2px; }

/* ---- touch: Comfortable density, so rows are easy to hit with a thumb */
@media (pointer: coarse) {
  .side-home, .chapter summary { min-height: 40px; }
  .chapter li a { padding: 9px 8px; }
  .chapter-card li a { padding: 8px; }
  .toc-inline li { padding: 6px 0; }
  .cat-chip, .more { height: 32px; }
  .chip { height: 32px; }
}

/* ---- phone: tables become stacked cards */
@media (max-width: 640px) {
  .prose table.stack thead { display: none; }
  .prose table.stack, .prose table.stack tbody { display: block; }
  .prose table.stack tr { display: block; padding: 12px 16px; border-top: 1px solid var(--line); }
  .prose table.stack tbody tr:first-child { border-top: 0; }
  .prose table.stack td { display: block; padding: 0; border: 0; }
  .prose table.stack td:first-child { margin-bottom: 4px; }
  .prose table.stack td + td { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }
  .prose table.stack.labelled td + td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 1px;
  }
  .prose tbody tr:hover td { background: none; }
  .prose td code { white-space: normal; }
  .table-wrap { overflow-x: visible; }
}

.lost { max-width: 560px; margin: 64px auto; text-align: center; flex: 1; }
.lost .mascot { width: 120px; height: auto; margin-bottom: 24px; }
.lost-actions { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; height: 32px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--sunken);
  color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--raised); }
.btn-primary:hover { background: var(--accent-ink); }

/* ------------------------------------------------------------ search palette */

.palette { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade var(--mid) var(--ease-in); }
.palette-box {
  position: relative; width: 100%; max-width: 600px; max-height: 76vh;
  display: flex; flex-direction: column;
  background: var(--raised); border-radius: var(--radius); box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: rise var(--mid) var(--ease-in);
}
.palette-field { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.palette-field svg { width: 18px; height: 18px; }
.palette-field input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  font: 400 17px var(--font); color: var(--ink); letter-spacing: -0.01em;
}
.palette-field input::placeholder { color: var(--ink-3); }
.palette-field input::-webkit-search-cancel-button { display: none; }
.palette-field kbd { cursor: pointer; }
.palette-results { overflow-y: auto; padding: 8px; overscroll-behavior: contain; scrollbar-width: thin; }
.palette-group { margin: 8px 8px 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.02em; }
.palette-group:first-child { margin-top: 4px; }
.result {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.result svg { margin-top: 2px; color: var(--ink-3); }
.result-title { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-title .sep { color: var(--ink-3); font-weight: 400; margin: 0 4px; }
.result-path { grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.result-path .cat-dot { width: 6px; height: 6px; }
.result-snippet { grid-column: 2; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result mark { background: none; color: var(--accent-ink); font-weight: 600; }
.result:hover { background: var(--hover); }
.result.active { background: var(--accent-muted); }
.result.active svg { color: var(--accent); }
.palette-empty { padding: 24px 16px 28px; text-align: center; color: var(--ink-2); font-size: 14px; }
.palette-empty p { margin: 4px 0; }
.palette-foot { flex: none; display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--canvas); font-size: 12px; color: var(--ink-3); }
.palette-foot kbd { font-size: 10.5px; padding: 2px 4px 1px; margin-right: 4px; }
.palette-foot .count { margin-left: auto; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1240px) {
  .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
  .toc-inline { display: block; }
}
@media (max-width: 1100px) {
}
@media (max-width: 900px) {
  :root { --top: 52px; }
  .shell, .is-home .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: grid; }
  .is-article .shell::before, .is-chapter .shell::before { left: 0; }
  .brand { width: auto; }
  .top-link span { display: none; }
  .search-trigger { margin-left: auto; width: auto; flex: 0 1 260px; }
  .sidebar {
    position: fixed; z-index: 40; top: var(--top); left: 0; bottom: 0; height: auto;
    width: min(320px, 86vw);
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--slow) var(--ease-out), visibility 0s linear var(--slow);
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--slow) var(--ease-in); box-shadow: var(--shadow-2); }
  .nav-open::after { content: ""; position: fixed; inset: var(--top) 0 0; z-index: 35; background: var(--scrim); animation: fade var(--mid) var(--ease-in); }
  main { padding: 32px 24px 0; }
  .hero { margin: -32px -24px 0; padding: 40px 24px 0; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 8px 0 16px; gap: 8px; }
  .search-trigger { flex: 0 0 32px; width: 32px; padding: 0; justify-content: center; border-radius: 50%; }
  .search-trigger span, .search-trigger kbd { display: none; }
  main { padding: 24px 16px 0; }
  .doc h1, .home h1 { font-size: 26px; }
  .lead { font-size: 17px; }
  .hero { grid-template-columns: minmax(0, 1fr); margin: -24px -16px 0; padding: 32px 16px 0; }
  .hero .mascot { display: none; }
  .is-article .shell::before, .is-chapter .shell::before { height: 280px; }
  .chapter-list a { grid-template-columns: 22px minmax(0, 1fr); padding: 12px 4px; }
  .chapter-list a > svg { display: none; }
  .hero-text { padding-bottom: 32px; }
  .hero-search kbd { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager span:empty { display: none; }
  .shortcuts { grid-template-columns: 1fr; }
  .shortcuts dt { border-right: 0; }
  .shortcuts dd { border-top: 0; padding-top: 0; background: var(--canvas); }
  .palette { padding: 8px; }
  .palette-box { max-height: calc(100vh - 16px); }
  .palette-foot .hint { display: none; }
}

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

@media print {
  .topbar, .sidebar, .toc, .toc-inline, .pager, .site-footer, .copy { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
}
