/*
 * Palette: "dark, corrected". A wiki is read for minutes at a time, so the
 * ground sits off pure black, muted text is bright enough for prose rather
 * than just for labels, and borders are solid instead of low-alpha.
 *
 * v2 adds ambient depth (aurora washes + dot grid) and per-section hues on
 * the homepage; article pages keep the quieter reading surface.
 */
:root {
  --bg: #0b0e13;
  --bg-elevated: #141922;
  --bg-card: rgba(23, 29, 39, 0.72);
  --bg-card-hover: rgba(30, 38, 51, 0.85);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e9edf3;
  --text-muted: #9aa6b5;
  --accent: #5aa9ee;
  --accent-2: #8b7cf6;
  --accent-3: #34d399;
  --accent-strong: #3f96e0;
  --accent-soft: rgba(90, 169, 238, 0.14);
  --accent-on: #08141f;
  --warm: #e8a33d;
  --stale: #f0879a;
  --stale-bg: rgba(240, 135, 154, 0.13);
  --code-bg: #151b24;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg: #f7f9fc;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.82);
  --bg-card-hover: #ffffff;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f141b;
  --text-muted: #5b6472;
  --accent: #0284c7;
  --accent-2: #7c5cf0;
  --accent-3: #0e9f6e;
  --accent-strong: #026aa7;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --accent-on: #ffffff;
  --warm: #b3690f;
  --stale: #b4384f;
  --stale-bg: #fdecef;
  --code-bg: #f0f3f7;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Inline SVG icons inherit currentColor; contexts size them. */
.icon { display: inline-block; width: 16px; height: 16px; vertical-align: -0.125em; }

/* ---- ambient background (homepage): aurora washes + fading dot grid ----
   Static pre-blurred gradients on purpose: an animated blur() this size pegs
   the GPU on modest machines. */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(148, 163, 184, 0.13) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 30%, transparent 75%);
}
.blob { position: absolute; border-radius: 50%; opacity: 0.55; }
.blob-1 { width: 720px; height: 720px; left: -200px; top: -300px; background: radial-gradient(circle, rgba(90, 169, 238, 0.34), transparent 60%); }
.blob-2 { width: 640px; height: 640px; right: -180px; top: -160px; background: radial-gradient(circle, rgba(139, 124, 246, 0.26), transparent 60%); }
.blob-3 { width: 560px; height: 560px; left: 40%; top: 300px; background: radial-gradient(circle, rgba(52, 211, 153, 0.13), transparent 60%); }
:root[data-theme="light"] .blob { opacity: 0.35; }

/* ---- site header ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

/* The documented project's package.json version, stamped by `init`. */
.brand-version {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  letter-spacing: 0.01em;
  direction: ltr;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

/* The logo file is whatever the wiki author dropped in — square mark or wide
   wordmark — so it gets a fixed height and keeps its own aspect ratio. */
.brand-logo {
  height: 30px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  flex-shrink: 0;
}
[dir="rtl"] .header-actions { margin-left: 0; margin-right: auto; }

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

.search-box {
  flex: 1;
  max-width: 400px;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}
.search-box .icon-search {
  position: absolute;
  inset-inline-start: 0.65rem;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 0.5rem 0.8rem;
  padding-inline-start: 2.1rem;
  padding-inline-end: 2.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd {
  position: absolute;
  inset-inline-end: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  pointer-events: none;
}
.search-box:focus-within .search-kbd { display: none; }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.search-results a:hover { background: var(--accent-soft); text-decoration: none; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle .icon { width: 16px; height: 16px; }
/* Show the theme you'd switch to, not the one you're on. */
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  align-items: center;
  flex-shrink: 0;
}
.nav-toggle .icon { width: 18px; height: 18px; }
.nav-toggle:hover { border-color: var(--border-strong); }

/* ---- layout (page view) ---- */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 57px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 65%, var(--bg));
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.sidebar-group { margin-bottom: 1.25rem; }
.sidebar-group h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.sidebar-group h4 .icon { width: 13px; height: 13px; flex-shrink: 0; }
.sidebar-group ul { list-style: none; margin: 0; padding: 0; }
.sidebar-group li a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}
.sidebar-group li a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar-group li a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { padding: 2rem 3rem 4rem; max-width: 860px; }

.stale-banner {
  background: var(--stale-bg);
  color: var(--stale);
  border: 1px solid var(--stale);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.fallback-banner {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.locale-switcher {
  display: flex;
  gap: 0.3rem;
}
.locale-switcher a {
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.locale-switcher a.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

[dir="rtl"] .layout { direction: rtl; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }

/* ---- homepage hero ---- */

.hero-page { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem 5rem; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3rem;
  padding: 4.5rem 0 3.2rem;
}

.hero-copy { max-width: 600px; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
}
.hero-eyebrow .dot, .wiki-footer .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-3);
  box-shadow: 0 0 8px var(--accent-3);
  flex-shrink: 0;
}
.hero h1 {
  font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0 0 1rem;
  background: linear-gradient(92deg, var(--text) 25%, var(--accent) 60%, var(--accent-2) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p.lede {
  color: var(--text-muted);
  font-size: 1.08rem;
  margin: 0 0 1.5rem;
  max-width: 54ch;
}

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 650;
  font-size: 0.94rem;
  padding: 0.68rem 1.3rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 30px -10px var(--accent);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -10px var(--accent); }
.btn-ghost {
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Stat chips: real numbers, straight from the build. */
.hero-stats { display: flex; gap: 1.9rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.stat span { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat b em { font-style: normal; color: var(--accent-3); }
/* A commit-hash sync marker reads as code, not prose. */
.stat b code, .wiki-footer code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08em 0.4em;
  direction: ltr;
  unicode-bidi: isolate;
}

/* The mark: the wiki's logo (or the bundled Wiki Pilot mark), static. */
.hero-mark-wrap { position: relative; flex-shrink: 0; width: 200px; height: 200px; display: grid; place-items: center; }
.hero-mark {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.hero-mark img { max-width: 100%; max-height: 100%; object-fit: contain; }
.hero-mark-glow { position: absolute; inset: 12%; border-radius: 50%; background: var(--accent); filter: blur(60px); opacity: 0.25; z-index: -1; }

/* ---- section label between hero and cards ---- */

.grid-label { display: flex; align-items: baseline; gap: 0.8rem; margin: 0 0 1.1rem; }
.grid-label h2 { font-size: 1.05rem; font-weight: 750; letter-spacing: -0.01em; margin: 0; }
.grid-label .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }
[dir="rtl"] .grid-label .rule { background: linear-gradient(270deg, var(--border-strong), transparent); }

/* ---- section cards: the ENTIRE card is a link ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}

.section-card {
  --hue: var(--accent);
  position: relative;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-card);
  padding: 1.5rem 1.5rem 1.3rem;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.section-card:hover {
  border-color: color-mix(in srgb, var(--hue) 55%, var(--border));
  transform: translateY(-4px);
  box-shadow: 0 22px 44px -18px color-mix(in srgb, var(--hue) 45%, transparent);
}
/* Cursor-tracking glow (client.js sets --mx/--my on mousemove). */
.section-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--hue) 12%, transparent), transparent 65%);
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.section-card:hover::before { opacity: 1; }
/* Top edge highlight in the card's hue. */
.section-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hue) 75%, transparent), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.section-card:hover::after { opacity: 1; }

/* The stretched link: whole card clickable, while the page list below sits on
   a higher z-index so its own links keep working. */
.card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-link:focus-visible { outline: 2px solid var(--hue); outline-offset: 2px; }

.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--hue) 88%, #fff 6%), color-mix(in srgb, var(--hue) 65%, #000 12%));
  box-shadow: 0 8px 18px -8px var(--hue);
  transition: transform 0.2s ease;
}
.section-card:hover .section-card-icon { transform: scale(1.08) rotate(-3deg); }
.section-card-icon .icon { width: 20px; height: 20px; }

.page-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
}

.section-card h2 {
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text);
}
.section-card h2 .icon-arrow-right {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}
.section-card:hover h2 .icon-arrow-right { transform: translateX(4px); color: var(--hue); }
[dir="rtl"] .section-card h2 .icon-arrow-right { transform: scaleX(-1); }
[dir="rtl"] .section-card:hover h2 .icon-arrow-right { transform: scaleX(-1) translateX(-4px); }

.section-card > p { color: var(--text-muted); font-size: 0.88rem; margin: 0 0 0.85rem; line-height: 1.55; }

.section-card ul { list-style: none; margin: 0; padding: 0; position: relative; z-index: 2; }
.section-card li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.86rem;
  transition: background 0.15s ease, color 0.15s ease, padding 0.15s ease;
}
.section-card li a::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.section-card li a:hover {
  background: color-mix(in srgb, var(--hue) 10%, transparent);
  color: var(--hue);
  padding-inline-start: 0.7rem;
  text-decoration: none;
}
.section-card li a:hover::before { background: var(--hue); box-shadow: 0 0 6px var(--hue); }
.section-card li a.more-pages { font-size: 0.78rem; color: var(--text-muted); }

/* Per-section hues, assigned by position (cycles through six). */
.card-grid > :nth-child(6n + 1) { --hue: #5aa9ee; }
.card-grid > :nth-child(6n + 2) { --hue: #8b7cf6; }
.card-grid > :nth-child(6n + 3) { --hue: #34d399; }
.card-grid > :nth-child(6n + 4) { --hue: #e8a33d; }
.card-grid > :nth-child(6n + 5) { --hue: #f472b6; }
.card-grid > :nth-child(6n + 6) { --hue: #22d3ee; }

/* ---- homepage footer strip ---- */

.wiki-footer {
  margin-top: 3.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.wiki-footer .fresh { display: inline-flex; align-items: center; gap: 0.45rem; }
.wiki-footer .dot { width: 8px; height: 8px; }
.wiki-footer a { color: var(--text-muted); border-bottom: 1px dotted var(--border-strong); }
.wiki-footer a:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 760px) {
  .hero { flex-direction: column-reverse; text-align: center; padding-top: 2.2rem; gap: 2rem; }
  .hero-actions, .hero-stats { justify-content: center; }
  .hero-copy { max-width: none; }
  .hero-mark-wrap { width: 150px; height: 150px; }
}

/* ---- chat widget ---- */

.chat-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 10px 26px -6px var(--accent-soft), 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-fab svg { width: 22px; height: 22px; }

.chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 340px;
  max-height: 460px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}
.chat-panel.open { display: flex; }

.chat-header {
  padding: 0.7rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 120px;
}
.chat-msg {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  max-width: 90%;
  white-space: pre-wrap;
}
.chat-msg-user {
  background: var(--accent-soft);
  align-self: flex-end;
}
.chat-msg-assistant {
  background: var(--bg);
  align-self: flex-start;
}

.chat-form {
  display: flex;
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  gap: 0.4rem;
}
.chat-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.chat-form button {
  border: none;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.page-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 1.75rem;
}

article h1 { font-size: 1.9rem; margin-bottom: 0.3rem; }
article h2 { font-size: 1.35rem; margin-top: 2.2rem; }
article h3 { font-size: 1.1rem; margin-top: 1.6rem; }
article p, article li { color: var(--text); }
article code, .page-meta code, .sidebar-group a {
  unicode-bidi: isolate;
}

article code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}
article pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
}
article pre code { background: none; padding: 0; }
article pre.mermaid { background: var(--bg-elevated); }

/* ```lang title="path/to/file.ts" — captions a snippet with its source file. */
article .code-figure { margin: 1rem 0; }
article .code-figure figcaption {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.5rem 0.9rem;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--border);
  unicode-bidi: isolate;
  direction: ltr;
  overflow-x: auto;
}
article .code-figure pre { margin: 0; border-radius: 0 0 10px 10px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .main { padding: 1.25rem; }
  .search-box { max-width: 220px; }
  .search-kbd { display: none; }

  /* The sidebar becomes a slide-over panel driven by the header's menu button. */
  body.has-sidebar .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 57px;
    bottom: 0;
    left: 0;
    width: min(300px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 45;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  [dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
    border-right: none;
    border-left: 1px solid var(--border);
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
}
