/* Caffeine documentation site. Warm "espresso" palette, system fonts, no frameworks. */

:root {
  --bg: #fbf8f4;
  --bg-soft: #f4eee7;
  --surface: #ffffff;
  --text: #2a211b;
  --text-soft: #54463b;
  --muted: #7d6e62;
  --border: #e8dfd5;
  --border-strong: #d6c9bb;
  --accent: #b84a14;
  --accent-strong: #98390b;
  --accent-soft: rgba(184, 74, 20, 0.1);
  --on-accent: #ffffff;
  --code-bg: #f6f1ea;
  --code-inline: #efe7dd;
  --shadow: 0 1px 2px rgba(42, 33, 27, 0.06), 0 8px 28px rgba(42, 33, 27, 0.08);
  --note: #2f6fb0;
  --tip: #2d8a5a;
  --warning: #b9770e;
  --danger: #c0392b;
  --hl-keyword: #a23c8f;
  --hl-string: #3e7d32;
  --hl-number: #b84a14;
  --hl-comment: #8c8076;
  --hl-title: #2563a8;
  --hl-type: #0e7490;
  --hl-attr: #8a5a00;
  --radius: 12px;
  --header-h: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110f;
    --bg-soft: #1a1613;
    --surface: #1d1916;
    --text: #efe7de;
    --text-soft: #cfc3b6;
    --muted: #a09284;
    --border: #2e2722;
    --border-strong: #41372f;
    --accent: #f2a65a;
    --accent-strong: #ffc17f;
    --accent-soft: rgba(242, 166, 90, 0.12);
    --on-accent: #1a1209;
    --code-bg: #191512;
    --code-inline: #2a231e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 32px rgba(0, 0, 0, 0.45);
    --note: #6fb0ee;
    --tip: #5cc790;
    --warning: #eab04a;
    --danger: #ef7766;
    --hl-keyword: #e08be0;
    --hl-string: #9ccf80;
    --hl-number: #f2a65a;
    --hl-comment: #8b7f74;
    --hl-title: #7db7f2;
    --hl-type: #5fd0e0;
    --hl-attr: #e6c071;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14110f;
  --bg-soft: #1a1613;
  --surface: #1d1916;
  --text: #efe7de;
  --text-soft: #cfc3b6;
  --muted: #a09284;
  --border: #2e2722;
  --border-strong: #41372f;
  --accent: #f2a65a;
  --accent-strong: #ffc17f;
  --accent-soft: rgba(242, 166, 90, 0.12);
  --on-accent: #1a1209;
  --code-bg: #191512;
  --code-inline: #2a231e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 32px rgba(0, 0, 0, 0.45);
  --note: #6fb0ee;
  --tip: #5cc790;
  --warning: #eab04a;
  --danger: #ef7766;
  --hl-keyword: #e08be0;
  --hl-string: #9ccf80;
  --hl-number: #f2a65a;
  --hl-comment: #8b7f74;
  --hl-title: #7db7f2;
  --hl-type: #5fd0e0;
  --hl-attr: #e6c071;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, video, svg { max-width: 100%; }
img, video { height: auto; }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-soft);
}
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }

/* ── Top bar ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1560px; margin: 0 auto; height: 100%; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; color: var(--text); }
.logo-mark { width: 30px; height: 30px; flex: none; }
.tabs { display: flex; gap: 2px; margin-left: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 7px 12px; border-radius: 8px; color: var(--text-soft); font-size: 0.92rem; font-weight: 500; white-space: nowrap; }
.tab:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; color: var(--text-soft);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.menu-btn { display: none; }
.theme-btn .icon-moon { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .icon-moon { display: inline; }
}
.search-btn {
  display: flex; align-items: center; gap: 10px; min-width: 230px; height: 38px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted); cursor: pointer;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-soft); }
.search-label { flex: 1; text-align: left; font-size: 0.9rem; }
.langs { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.lang { padding: 3px 9px; border-radius: 7px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.lang:hover { color: var(--text); text-decoration: none; }
.lang.active { background: var(--accent); color: var(--on-accent); }

/* ── Layout ──────────────────────────────────────────────────────── */

.layout {
  max-width: 1560px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 276px minmax(0, 1fr) 232px; gap: 40px;
  min-height: calc(100vh - var(--header-h) - 80px);
}
.layout-landing { grid-template-columns: 276px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: 26px 8px 40px 0; font-size: 0.92rem; scrollbar-width: thin;
}
.nav-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin: 0 0 12px 10px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.nav-dir > ul { display: none; margin: 2px 0 6px 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-dir.open > ul { display: block; }
.nav-dir.top > .nav-dir-row .nav-link,
.nav-dir.top > .nav-dir-row .nav-dir-label { font-weight: 650; color: var(--text); }
.nav-dir-row { display: flex; align-items: center; }
.nav-link, .nav-dir-label {
  flex: 1; display: block; padding: 5px 10px; border-radius: 8px; color: var(--text-soft); line-height: 1.4;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.nav-link:hover, .nav-dir-label:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-toggle { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; }
.nav-toggle:hover { background: var(--accent-soft); }
.nav-toggle svg { transition: transform 0.15s; }
.nav-dir.open > .nav-dir-row > .nav-toggle svg { transform: rotate(90deg); }

.main { padding: 30px 0 70px; min-width: 0; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.toc { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 30px 0 40px; font-size: 0.86rem; scrollbar-width: thin; }
.toc-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 3px 0 3px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.4; }
.toc li.l3 a { padding-left: 28px; font-size: 0.82rem; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ── Document typography ─────────────────────────────────────────── */

.doc { max-width: 820px; }
.doc-title { font-size: 2.35rem; line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 18px; font-weight: 750; }
.doc h2, .doc h3, .doc h4, .doc h5 { position: relative; line-height: 1.25; letter-spacing: -0.015em; margin: 2.2em 0 0.6em; }
.doc h2 { font-size: 1.55rem; padding-top: 0.9em; border-top: 1px solid var(--border); font-weight: 700; }
.doc h3 { font-size: 1.22rem; font-weight: 650; }
.doc h4 { font-size: 1.05rem; font-weight: 650; }
.doc .anchor { position: absolute; left: -1.1em; padding-right: 0.3em; opacity: 0; color: var(--muted); font-weight: 400; }
.doc h2:hover .anchor, .doc h3:hover .anchor, .doc h4:hover .anchor, .doc .anchor:focus { opacity: 1; }
.doc p, .doc li { color: var(--text); }
.doc > p, .doc li { overflow-wrap: anywhere; }
.doc ul, .doc ol { padding-left: 1.5em; }
.doc li + li { margin-top: 0.3em; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }
.doc blockquote { margin: 1.2em 0; padding: 4px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text-soft); }
.doc blockquote p { color: inherit; }
.doc code { font-family: var(--mono); font-size: 0.86em; background: var(--code-inline); padding: 0.12em 0.4em; border-radius: 6px; }
.doc img { border-radius: 10px; }
.doc a.ext::after { content: "↗"; font-size: 0.75em; margin-left: 2px; opacity: 0.6; }
.doc dl { margin: 1em 0; }
.doc dt { font-weight: 650; margin-top: 0.8em; }
.doc dd { margin: 0.2em 0 0 1.2em; color: var(--text-soft); }
.doc mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; padding: 0 3px; border-radius: 4px; }

.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 20px; font-size: 0.85rem; color: var(--muted); }
.doc-meta p { flex-basis: 100%; margin: 6px 0 0; color: var(--text-soft); font-size: 0.95rem; }
.doc-badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 650;
  letter-spacing: 0.02em; background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border);
}
.doc-badge--stable { background: color-mix(in srgb, var(--tip) 14%, transparent); color: var(--tip); border-color: color-mix(in srgb, var(--tip) 35%, transparent); }
.doc-badge--reference, .doc-badge--generated { background: color-mix(in srgb, var(--note) 14%, transparent); color: var(--note); border-color: color-mix(in srgb, var(--note) 35%, transparent); }
.doc-badge--beta, .doc-badge--planned { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.doc-badge--historical, .doc-badge--experimental { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.doc-lede { font-size: 1.14rem; line-height: 1.6; color: var(--text-soft); margin: 0 0 1.6em; }

.doc-callout { margin: 1.4em 0; padding: 4px 18px; border-left: 4px solid var(--note); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--note) 9%, var(--surface)); }
.doc-callout p { margin: 0.7em 0; }
.doc-callout--tip { border-color: var(--tip); background: color-mix(in srgb, var(--tip) 9%, var(--surface)); }
.doc-callout--warning { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.doc-callout--danger { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }

.doc-figure, .doc figure { margin: 1.8em 0; text-align: center; }
.doc-figure img, .doc figure img { border: 1px solid var(--border); box-shadow: var(--shadow); cursor: zoom-in; background: var(--surface); }
.doc figcaption, .doc-caption { margin-top: 10px; font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
.doc-video { width: 100%; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.doc table { border-collapse: collapse; width: 100%; font-size: 0.93rem; margin: 0; }
.doc > table { margin: 1.4em 0; border: 1px solid var(--border); border-radius: 12px; display: block; overflow-x: auto; }
.doc th, .doc td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.doc th { background: var(--bg-soft); font-weight: 650; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.doc details { margin: 1.2em 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.doc summary { cursor: pointer; padding: 12px 16px; font-weight: 600; }
.doc details[open] > summary { border-bottom: 1px solid var(--border); }
.doc details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.doc details > :last-child { margin-bottom: 16px; }

/* ── Code ────────────────────────────────────────────────────────── */

.code-block { margin: 1.4em 0; border: 1px solid var(--border); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-soft) 70%, transparent); }
.code-lang { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.code-copy { border: 1px solid var(--border); background: var(--surface); border-radius: 7px; padding: 2px 10px; font-size: 0.75rem; color: var(--text-soft); cursor: pointer; }
.code-copy:hover { color: var(--accent); border-color: var(--accent); }
.code-copy.done { color: var(--tip); border-color: var(--tip); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 0.86rem; line-height: 1.6; }
.code-block code, .code-block pre code { font-family: var(--mono); background: none; padding: 0; font-size: inherit; color: var(--text); }
pre.mermaid { margin: 1.6em 0; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-x: auto; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-comment, .hljs-quote, .hljs-deletion { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: var(--hl-title); }
.hljs-built_in, .hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: var(--hl-attr); }
.hljs-meta, .hljs-name { color: var(--hl-keyword); }

/* ── Doc footer, pager ───────────────────────────────────────────── */

.doc-foot { max-width: 820px; margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--border); font-size: 0.88rem; }
.edit-link { color: var(--muted); }
.pager { max-width: 820px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pager strong { color: var(--accent); font-weight: 600; }
.pager-next { text-align: right; grid-column: 2; }

/* ── Cards and landings ──────────────────────────────────────────── */

.landing-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 28px; max-width: 820px; }
.landing-icon, .card-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); flex: none; }
.landing-head .doc-lede { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.card h3 { margin: 0 0 6px; font-size: 1.12rem; letter-spacing: -0.01em; }
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 0.92rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-icon { margin-bottom: 14px; }
.card-links { list-style: none; margin: 0 0 14px; padding: 0; font-size: 0.9rem; }
.card-links li { padding: 3px 0; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.8rem; }
.card-foot a { color: var(--muted); display: inline-grid; }
.card:hover .card-foot a { color: var(--accent); }

/* ── Home ────────────────────────────────────────────────────────── */

body[data-page="home"] main { display: block; }
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); background:
  radial-gradient(900px 480px at 85% -10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
  radial-gradient(700px 400px at -10% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%); }
.hero-inner { max-width: 1320px; margin: 0 auto; padding: 72px 24px 64px; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 52px; align-items: center; }
.kicker { display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; }
.hero h1 { font-size: clamp(2.4rem, 4.8vw, 3.8rem); line-height: 1.05; letter-spacing: -0.035em; margin: 18px 0 16px; font-weight: 800; }
.hero-lede { font-size: 1.15rem; color: var(--text-soft); max-width: 560px; margin: 0 0 26px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.95rem; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.hero-code { max-width: 560px; margin: 0; }
.hero-code pre { font-size: 0.8rem; }
.hero-shot { margin: 0; }
.hero-shot img { display: block; width: 100%; border-radius: 14px; border: 1px solid var(--border-strong); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28); }
.band { max-width: 1320px; margin: 0 auto; padding: 64px 24px; }
.band-alt { max-width: none; background: var(--bg-soft); border-block: 1px solid var(--border); }
.band-alt > * { max-width: 1272px; margin-left: auto; margin-right: auto; }
.band-title { font-size: 1.85rem; letter-spacing: -0.025em; margin: 0 0 28px; font-weight: 750; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.feature { padding: 22px 22px 24px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.feature-index { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); font-weight: 700; }
.feature h3 { margin: 8px 0 6px; font-size: 1.15rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.cards-home { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.band-foot { margin: 28px 0 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tour { display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); gap: 40px; align-items: center; }
.tour-copy p { color: var(--text-soft); font-size: 1.05rem; }
.tour-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tour-shots figure { margin: 0; }
.tour-shots figure:first-child { grid-column: 1 / -1; }
.tour-shots img { width: 100%; display: block; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.notfound { max-width: 640px; margin: 0 auto; padding: 120px 24px; text-align: center; }
.notfound h1 { font-size: 2.4rem; letter-spacing: -0.03em; }
.notfound p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); color: var(--muted); font-size: 0.86rem; }
.site-footer-inner { max-width: 1560px; margin: 0 auto; padding: 22px 20px; display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* ── Search and lightbox ─────────────────────────────────────────── */

.search-modal[hidden] { display: none; }
.search-modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center; padding: 10vh 16px 16px; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 7, 5, 0.55); backdrop-filter: blur(3px); }
.search-panel { position: relative; width: min(680px, 100%); max-height: 72vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4); overflow: hidden; }
.search-input-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 1.05rem; color: var(--text); }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.search-results li a:hover, .search-results li.sel a { background: var(--accent-soft); text-decoration: none; }
.search-results .r-title { font-weight: 650; display: flex; gap: 10px; align-items: baseline; }
.search-results .r-group { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.search-results .r-snip { display: block; margin-top: 2px; font-size: 0.86rem; color: var(--muted); line-height: 1.45; }
.search-results mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; }
.search-tip { margin: 0; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
.search-empty { padding: 24px 14px; color: var(--muted); text-align: center; }

.lightbox { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(10, 7, 5, 0.86); cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 90vh; border-radius: 10px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); background: var(--surface); }
.lightbox p { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #e8dfd5; font-size: 0.9rem; margin: 0; padding: 0 24px; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1240px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 960px) {
  .hero-inner, .tour { grid-template-columns: 1fr; }
  .hero-inner { padding: 44px 20px; }
  .menu-btn { display: inline-grid; }
  .tabs { display: none; }
  .search-label, .search-btn kbd { display: none; }
  .search-btn { min-width: 38px; width: 38px; justify-content: center; padding: 0; }
  .layout, .layout-landing { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar {
    position: fixed; z-index: 60; top: var(--header-h); left: 0; bottom: 0; width: min(320px, 86vw); height: auto;
    padding: 20px 14px 40px; background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(10, 7, 5, 0.4); z-index: 55; }
  .doc-title { font-size: 1.9rem; }
  .doc .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .topbar, .sidebar, .toc, .site-footer, .pager, .doc-foot, .code-copy { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
}
