/* ============================================================
   Deep Dives — design system
   ============================================================ */

:root {
  /* type scale */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* layout */
  --topbar-h: 56px;
  --sidebar-w: 296px;
  --toc-w: 240px;
  --content-max: 820px;

  /* transitions */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
  --t-slow: 260ms ease;
}

/* ============================================================
   Theme tokens
   ============================================================ */

:root,
[data-theme="dark"] {
  /* dark */
  --bg: #0a0b0f;
  --bg-elev: #11131a;
  --bg-elev-2: #161922;
  --bg-hover: #1a1e29;
  --bg-active: #20253229;

  --text: #e5e7ec;
  --text-strong: #f5f6f8;
  --text-muted: #9aa3b0;
  --text-subtle: #6b7280;

  --border: #232733;
  --border-strong: #2e3340;
  --divider: #1a1d26;

  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-bg: rgba(167, 139, 250, 0.12);
  --accent-border: rgba(167, 139, 250, 0.35);

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  --code-bg: #0e1119;
  --code-border: #1d212c;
  --inline-code-bg: #1a1e29;
  --inline-code-fg: #c4b5fd;

  --kbd-bg: #1a1e29;
  --kbd-border: #2e3340;
  --kbd-fg: #e5e7ec;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);

  --scrollbar-thumb: #2a2f3c;
  --scrollbar-thumb-hover: #3a4153;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #fafbfc;
  --bg-elev-2: #f4f5f8;
  --bg-hover: #eef0f4;
  --bg-active: #e6e8ef;

  --text: #1a1d24;
  --text-strong: #0b0d12;
  --text-muted: #565d6b;
  --text-subtle: #8b919c;

  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --divider: #ecedf1;

  --accent: #6d28d9;
  --accent-strong: #5b21b6;
  --accent-bg: rgba(109, 40, 217, 0.08);
  --accent-border: rgba(109, 40, 217, 0.25);

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --code-bg: #f6f7f9;
  --code-border: #e3e6eb;
  --inline-code-bg: #ece9fb;
  --inline-code-fg: #5b21b6;

  --kbd-bg: #f4f5f8;
  --kbd-border: #cdd2da;
  --kbd-fg: #1a1d24;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.12);

  --scrollbar-thumb: #cdd2da;
  --scrollbar-thumb-hover: #a5acba;

  color-scheme: light;
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }

/* the `hidden` HTML attribute must always win over our class-level `display:` rules */
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-base), color var(--t-base);
}

::selection { background: var(--accent-bg); color: var(--text-strong); }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* skip link */
.skip-link {
  position: absolute;
  top: -40px; left: 0;
  background: var(--accent);
  color: white;
  padding: var(--s-2) var(--s-4);
  z-index: 2000;
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { top: 0; outline: none; }

/* reading progress */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(to right, var(--accent), var(--accent-strong));
  z-index: 1100;
  transition: width 100ms linear;
}

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-strong);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  font-weight: 800;
  font-size: 16px;
  border-radius: var(--r-md);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-weight: 700; font-size: var(--text-md); letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-top: 2px; }

.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}

.sidebar-toggle { display: none; }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  height: 36px;
  min-width: 280px;
  padding: 0 var(--s-3);
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.search-trigger:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.search-trigger span { flex: 1; text-align: left; }

.kbd, kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--kbd-fg);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.kbd-mod { font-size: 12px; }

/* ============================================================
   Layout
   ============================================================ */

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

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: var(--s-4) 0 var(--s-6);
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: 0 var(--s-3);
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: var(--s-4) var(--s-3) var(--s-2);
  user-select: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all var(--t-fast);
  cursor: pointer;
}
.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--accent-bg);
  color: var(--accent-strong);
  border-color: var(--accent-border);
}
.sidebar-link.active .sidebar-num {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.sidebar-num {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.sidebar-link-title { flex: 1; min-width: 0; }
.sidebar-link-title .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-link-title .meta {
  font-size: 10px;
  color: var(--text-subtle);
  font-weight: 500;
  margin-top: 1px;
}

.sidebar-footer {
  margin-top: var(--s-6);
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--divider);
  display: flex;
  gap: var(--s-5);
  font-size: var(--text-xs);
  color: var(--text-subtle);
}
.sidebar-stat .num {
  display: block;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

/* ============================================================
   Content
   ============================================================ */

.content-wrapper {
  display: grid;
  grid-template-columns: 1fr var(--toc-w);
  min-width: 0;
}

.content {
  padding: var(--s-10) var(--s-12);
  max-width: calc(var(--content-max) + 96px);
  min-width: 0;
}
.content:focus { outline: none; }

.content-body, .prose { animation: fadein 220ms ease; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--s-12) 0;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  padding: var(--s-5);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: var(--r-md);
  color: var(--text);
}

/* ============================================================
   TOC pane
   ============================================================ */

.toc-pane {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--s-10) var(--s-5);
  border-left: 1px solid var(--border);
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: var(--s-3);
}

.toc-nav { display: flex; flex-direction: column; }
.toc-nav a {
  display: block;
  padding: 6px var(--s-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-left: 2px solid var(--divider);
  text-decoration: none;
  line-height: 1.4;
  transition: all var(--t-fast);
}
.toc-nav a:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.toc-nav a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-nav a.lvl-3 { padding-left: var(--s-6); font-size: 11px; }
.toc-nav a.lvl-4 { padding-left: 32px; font-size: 11px; opacity: 0.85; }

/* ============================================================
   Page nav (prev / next)
   ============================================================ */

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-top: var(--s-12);
  padding-top: var(--s-6);
  border-top: 1px solid var(--divider);
}
.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
  transition: all var(--t-fast);
}
.page-nav-link:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  text-decoration: none;
}
.page-nav-link .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.page-nav-link .title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}
.page-nav-link.next { text-align: right; }
.page-nav-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.4;
}

.content-footer {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--divider);
  font-size: var(--text-xs);
  color: var(--text-subtle);
}
.content-footer code {
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
}

/* ============================================================
   Prose — markdown rendering
   ============================================================ */

.prose {
  color: var(--text);
  line-height: 1.7;
  max-width: var(--content-max);
}
.prose > * + * { margin-top: 1em; }

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.prose h1 {
  font-size: var(--text-4xl);
  margin: 0 0 var(--s-6);
  letter-spacing: -0.03em;
}
.prose h2 {
  font-size: var(--text-2xl);
  margin-top: var(--s-12);
  padding-top: var(--s-6);
  border-top: 1px solid var(--divider);
}
.prose h3 { font-size: var(--text-xl); margin-top: var(--s-8); }
.prose h4 { font-size: var(--text-lg); margin-top: var(--s-6); }
.prose h5, .prose h6 { font-size: var(--text-md); margin-top: var(--s-5); }

.prose h2:first-child, .prose h1 + h2 { border-top: none; padding-top: 0; margin-top: var(--s-6); }

.heading-anchor {
  margin-left: 8px;
  opacity: 0;
  color: var(--text-subtle);
  font-weight: 400;
  text-decoration: none;
  transition: opacity var(--t-fast), color var(--t-fast);
  font-size: 0.85em;
}
.heading-anchor:hover { color: var(--accent); }
.prose h1:hover .heading-anchor,
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor { opacity: 1; }

.prose p { margin: 0 0 1em; }
.prose strong { color: var(--text-strong); font-weight: 700; }
.prose em { font-style: italic; color: var(--text-strong); }

.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin: 0.3em 0; }
.prose li > ul, .prose li > ol { margin-top: 0.3em; }

.prose blockquote {
  margin: 1em 0;
  padding: var(--s-3) var(--s-5);
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
  border: none;
  height: 1px;
  background: var(--divider);
  margin: var(--s-8) 0;
}

/* inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  border-radius: 4px;
  word-break: break-word;
}

/* code blocks */
.code-block {
  position: relative;
  margin: 1.2em 0;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--s-3);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--code-border);
  font-size: var(--text-xs);
}
.code-block-lang {
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  font-weight: 600;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--s-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all var(--t-fast);
}
.copy-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.copy-btn.copied { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.copy-btn svg { width: 12px; height: 12px; }

.prose pre {
  margin: 0;
  padding: var(--s-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  background: transparent;
}
.prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
}

/* mermaid */
.mermaid-wrap {
  margin: 1.2em 0;
  padding: var(--s-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  text-align: center;
}
.mermaid-wrap svg { max-width: 100%; height: auto; }

/* tables */
.prose .table-wrap { overflow-x: auto; margin: 1.2em 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.prose th, .prose td {
  padding: 10px var(--s-3);
  text-align: left;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}
.prose th {
  background: var(--bg-elev-2);
  font-weight: 700;
  color: var(--text-strong);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: var(--bg-hover); }

/* images */
.prose img { max-width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--border); }

/* links inside prose */
.prose a { font-weight: 500; }
.prose a:visited { color: var(--accent); }

/* ============================================================
   Search modal
   ============================================================ */

.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1500;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  animation: backdrop-in 160ms ease;
}
[data-theme="light"] .search-backdrop { background: rgba(15, 23, 42, 0.35); }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.search-modal {
  width: min(640px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
  animation: modal-in 200ms ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-md);
  padding: var(--s-2) 0;
}
.search-input-wrap input::placeholder { color: var(--text-subtle); }

.kbd-esc {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  background: var(--kbd-bg);
  color: var(--kbd-fg);
  border: 1px solid var(--kbd-border);
  border-radius: 4px;
  cursor: pointer;
}

.search-status {
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-bottom: 1px solid var(--divider);
}
.search-status.hidden { display: none; }

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-2);
}
.search-result {
  display: block;
  padding: var(--s-3) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.search-result:hover, .search-result.active {
  background: var(--bg-hover);
  text-decoration: none;
}
.search-result.active { border-color: var(--accent-border); background: var(--accent-bg); }
.search-result .doc-name {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.search-result .heading {
  font-size: var(--text-sm);
  color: var(--text-strong);
  font-weight: 600;
  margin: 2px 0;
}
.search-result .snippet {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result mark {
  background: rgba(167, 139, 250, 0.25);
  color: var(--text-strong);
  border-radius: 2px;
  padding: 0 2px;
}
[data-theme="light"] .search-result mark {
  background: rgba(109, 40, 217, 0.18);
}

.search-empty {
  padding: var(--s-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.search-footer {
  display: flex;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-elev-2);
}
.search-footer .hint { display: inline-flex; align-items: center; gap: 4px; }
.search-footer kbd { font-size: 10px; padding: 1px 5px; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px var(--s-4);
  background: var(--text-strong);
  color: var(--bg);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  z-index: 1600;
  animation: toast-in 200ms ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
  .toc-pane { display: none; }
  .content-wrapper { grid-template-columns: 1fr; }
  .content { padding: var(--s-8) var(--s-8); }
}

@media (max-width: 880px) {
  :root { --sidebar-w: 280px; }
  .sidebar-toggle { display: inline-grid; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    height: calc(100vh - var(--topbar-h));
    z-index: 999;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--shadow-md);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .search-trigger { min-width: 0; flex: 1; }
  .search-trigger span { display: none; }
  .search-trigger .kbd { display: none; }
  .brand-text { display: none; }
  .content { padding: var(--s-6) var(--s-5); }
  .prose h1 { font-size: var(--text-3xl); }
  .prose h2 { font-size: var(--text-xl); }
}

@media print {
  .topbar, .sidebar, .toc-pane, .page-nav, .content-footer, #reading-progress { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .content-wrapper { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: 100%; }
  .prose { color: black; }
  .code-block { page-break-inside: avoid; }
}
