/* ── Theme Variables ─────────────────────────────────────── */

:root {
  color-scheme: light dark;
}

[data-theme="light"] {
  color-scheme: light;
  --color-bg:                  #fcfeff;
  --color-surface:             rgba(252,254,255,0.96);
  --color-surface-alt:         #f5f9ff;
  --color-surface-card:        rgba(255,255,255,0.70);
  --color-surface-card-strong: rgba(255,255,255,0.92);
  --color-surface-interactive: rgba(15,23,42,0.07);
  --color-border:              rgba(15,23,42,0.14);
  --color-border-accent:       rgba(239,75,88,0.32);
  --color-text:                #0b1220;
  --color-text-secondary:      #2e405c;
  --color-text-muted:          #5f7290;
  --color-primary:             #ef4b58;
  --color-primary-hover:       #de3f4d;
  --color-secondary:           #008f87;
  --color-danger:              #c0392b;
  --color-code-bg:             rgba(15,23,42,0.06);
  --color-code-text:           #c43645;
  --shadow-primary:            rgba(239,75,88,0.20);
  --shadow-secondary:          rgba(0,143,135,0.15);
  --hero-gradient-start:       #c93342;
  --hero-gradient-end:         #ef4b58;
  --nebula-1:                  rgba(239,75,88,0.05);
  --nebula-2:                  rgba(0,143,135,0.04);
  --stars-opacity:             0.08;
  --color-diff-add:            rgba(0,200,80,0.12);
  --color-diff-remove:         rgba(220,50,50,0.10);
  --color-diff-hunk:           rgba(0,0,0,0.06);
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg:                  #050810;
  --color-surface:             rgba(10,15,26,0.96);
  --color-surface-alt:         #111827;
  --color-surface-card:        rgba(10,15,26,0.65);
  --color-surface-card-strong: rgba(10,15,26,0.85);
  --color-surface-interactive: rgba(255,255,255,0.07);
  --color-border:              rgba(136,146,176,0.15);
  --color-border-accent:       rgba(255,77,77,0.30);
  --color-text:                #f0f4ff;
  --color-text-secondary:      #8892b0;
  --color-text-muted:          #5a6480;
  --color-primary:             #ff4d4d;
  --color-primary-hover:       #e63946;
  --color-secondary:           #00e5cc;
  --color-danger:              #ff5252;
  --color-code-bg:             rgba(255,255,255,0.05);
  --color-code-text:           #00e5cc;
  --shadow-primary:            rgba(255,77,77,0.25);
  --shadow-secondary:          rgba(0,229,204,0.15);
  --hero-gradient-start:       #f0f4ff;
  --hero-gradient-end:         #00e5cc;
  --nebula-1:                  rgba(255,77,77,0.10);
  --nebula-2:                  rgba(0,229,204,0.07);
  --stars-opacity:             0.55;
  --color-diff-add:            rgba(0,200,80,0.18);
  --color-diff-remove:         rgba(220,50,50,0.18);
  --color-diff-hunk:           rgba(255,255,255,0.08);
}

[data-theme="emerald"] {
  color-scheme: dark;
  --color-bg:                  #060f0b;
  --color-surface:             rgba(10,20,15,0.96);
  --color-surface-alt:         #1a3d2e;
  --color-surface-card:        rgba(10,20,15,0.65);
  --color-surface-card-strong: rgba(10,20,15,0.85);
  --color-surface-interactive: rgba(255,255,255,0.06);
  --color-border:              rgba(122,184,154,0.15);
  --color-border-accent:       rgba(80,200,120,0.30);
  --color-text:                #e0ede8;
  --color-text-secondary:      #9fc9b0;
  --color-text-muted:          #5e8b72;
  --color-primary:             #50c878;
  --color-primary-hover:       #6dd694;
  --color-secondary:           #3ecfcf;
  --color-danger:              #ff5252;
  --color-code-bg:             rgba(255,255,255,0.05);
  --color-code-text:           #a3e7bb;
  --shadow-primary:            rgba(80,200,120,0.25);
  --shadow-secondary:          rgba(62,207,207,0.15);
  --hero-gradient-start:       #e0ede8;
  --hero-gradient-end:         #50c878;
  --nebula-1:                  rgba(80,200,120,0.10);
  --nebula-2:                  rgba(62,207,207,0.07);
  --stars-opacity:             0.50;
  --color-diff-add:            rgba(80,200,100,0.18);
  --color-diff-remove:         rgba(220,60,60,0.18);
  --color-diff-hunk:           rgba(255,255,255,0.07);
}

[data-theme="catppuccin-mocha"] {
  color-scheme: dark;
  --color-bg:                  #181825;
  --color-surface:             rgba(24,24,37,0.96);
  --color-surface-alt:         #45475a;
  --color-surface-card:        rgba(30,30,46,0.65);
  --color-surface-card-strong: rgba(30,30,46,0.87);
  --color-surface-interactive: rgba(255,255,255,0.06);
  --color-border:              rgba(88,91,112,0.35);
  --color-border-accent:       rgba(203,166,247,0.30);
  --color-text:                #cdd6f4;
  --color-text-secondary:      #bac2de;
  --color-text-muted:          #7f849c;
  --color-primary:             #cba6f7;
  --color-primary-hover:       #d8bafe;
  --color-secondary:           #89dceb;
  --color-danger:              #f38ba8;
  --color-code-bg:             rgba(255,255,255,0.04);
  --color-code-text:           #f38ba8;
  --shadow-primary:            rgba(203,166,247,0.20);
  --shadow-secondary:          rgba(137,220,235,0.15);
  --hero-gradient-start:       #cdd6f4;
  --hero-gradient-end:         #cba6f7;
  --nebula-1:                  rgba(203,166,247,0.08);
  --nebula-2:                  rgba(137,220,235,0.06);
  --stars-opacity:             0.45;
  --color-diff-add:            rgba(166,227,161,0.20);
  --color-diff-remove:         rgba(243,139,168,0.20);
  --color-diff-hunk:           rgba(255,255,255,0.07);
}

[data-theme="catppuccin-latte"] {
  color-scheme: light;
  --color-bg:                  #f0f2f5;
  --color-surface:             rgba(239,241,245,0.96);
  --color-surface-alt:         #dce0e8;
  --color-surface-card:        rgba(255,255,255,0.72);
  --color-surface-card-strong: rgba(255,255,255,0.92);
  --color-surface-interactive: rgba(76,79,105,0.07);
  --color-border:              rgba(76,79,105,0.18);
  --color-border-accent:       rgba(136,57,239,0.28);
  --color-text:                #4c4f69;
  --color-text-secondary:      #5c5f77;
  --color-text-muted:          #8c8fa1;
  --color-primary:             #8839ef;
  --color-primary-hover:       #7527d7;
  --color-secondary:           #04a5e5;
  --color-danger:              #d20f39;
  --color-code-bg:             rgba(76,79,105,0.07);
  --color-code-text:           #d20f39;
  --shadow-primary:            rgba(136,57,239,0.18);
  --shadow-secondary:          rgba(4,165,229,0.15);
  --hero-gradient-start:       #4c4f69;
  --hero-gradient-end:         #8839ef;
  --nebula-1:                  rgba(136,57,239,0.05);
  --nebula-2:                  rgba(4,165,229,0.04);
  --stars-opacity:             0.07;
  --color-diff-add:            rgba(64,160,43,0.14);
  --color-diff-remove:         rgba(210,15,57,0.12);
  --color-diff-hunk:           rgba(0,0,0,0.06);
}

[data-theme="catppuccin-frappe"] {
  color-scheme: dark;
  --color-bg:                  #232634;
  --color-surface:             rgba(35,38,52,0.96);
  --color-surface-alt:         #414559;
  --color-surface-card:        rgba(41,44,60,0.65);
  --color-surface-card-strong: rgba(41,44,60,0.87);
  --color-surface-interactive: rgba(255,255,255,0.06);
  --color-border:              rgba(81,87,109,0.40);
  --color-border-accent:       rgba(202,158,230,0.30);
  --color-text:                #c6d0f5;
  --color-text-secondary:      #b5bfe2;
  --color-text-muted:          #737994;
  --color-primary:             #ca9ee6;
  --color-primary-hover:       #d8b4fe;
  --color-secondary:           #85c1dc;
  --color-danger:              #e78284;
  --color-code-bg:             rgba(255,255,255,0.04);
  --color-code-text:           #e78284;
  --shadow-primary:            rgba(202,158,230,0.20);
  --shadow-secondary:          rgba(133,193,220,0.15);
  --hero-gradient-start:       #c6d0f5;
  --hero-gradient-end:         #ca9ee6;
  --nebula-1:                  rgba(202,158,230,0.08);
  --nebula-2:                  rgba(133,193,220,0.06);
  --stars-opacity:             0.45;
  --color-diff-add:            rgba(166,227,161,0.18);
  --color-diff-remove:         rgba(231,130,132,0.18);
  --color-diff-hunk:           rgba(255,255,255,0.07);
}

[data-theme="arctic"] {
  color-scheme: dark;
  --color-bg:                  #070d14;
  --color-surface:             rgba(8,16,28,0.96);
  --color-surface-alt:         #0f2035;
  --color-surface-card:        rgba(8,16,28,0.65);
  --color-surface-card-strong: rgba(8,16,28,0.85);
  --color-surface-interactive: rgba(255,255,255,0.06);
  --color-border:              rgba(100,180,255,0.14);
  --color-border-accent:       rgba(80,160,255,0.28);
  --color-text:                #ddeeff;
  --color-text-secondary:      #7fb8e8;
  --color-text-muted:          #3d6f99;
  --color-primary:             #5aacf7;
  --color-primary-hover:       #7dc0ff;
  --color-secondary:           #38d9f5;
  --color-danger:              #ff6b6b;
  --color-code-bg:             rgba(255,255,255,0.05);
  --color-code-text:           #7de8ff;
  --shadow-primary:            rgba(90,172,247,0.20);
  --shadow-secondary:          rgba(56,217,245,0.15);
  --hero-gradient-start:       #ddeeff;
  --hero-gradient-end:         #5aacf7;
  --nebula-1:                  rgba(90,172,247,0.08);
  --nebula-2:                  rgba(56,217,245,0.06);
  --stars-opacity:             0.50;
  --color-diff-add:            rgba(0,200,120,0.16);
  --color-diff-remove:         rgba(220,50,80,0.14);
  --color-diff-hunk:           rgba(255,255,255,0.07);
}

/* ── Font Variables ──────────────────────────────────────── */

:root {
  --font-display: "Clash Display", system-ui, sans-serif;
  --font-body:    "Satoshi", system-ui, sans-serif;
  --font-mono:    "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  --ease-out:     cubic-bezier(.16,1,.3,1);
  --ease-spring:  cubic-bezier(.34,1.56,.64,1);
  --dur-fast:     120ms;
  --dur-normal:   200ms;
}

/* ── Reset & Base ────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.02em;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  transition: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.theme-loaded body {
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection {
  background: var(--color-primary);
  color: var(--color-bg);
}

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

/* ── Background Effects ──────────────────────────────────── */

.bg-stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--stars-opacity);
  background-image:
    radial-gradient(2px 2px at 20px  30px, rgba(255,255,255,.9), transparent),
    radial-gradient(2px 2px at 40px  70px, rgba(255,255,255,.6), transparent),
    radial-gradient(1px 1px at 90px  40px, rgba(255,255,255,.7), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 160px 120px,rgba(255,255,255,.8), transparent),
    radial-gradient(2px 2px at 200px 60px, rgba(255,255,255,.6), transparent),
    radial-gradient(1px 1px at 250px 150px,rgba(255,255,255,.5), transparent),
    radial-gradient(2px 2px at 300px 40px, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 60px  160px,rgba(255,255,255,.6), transparent),
    radial-gradient(2px 2px at 180px 190px,rgba(255,255,255,.3), transparent);
  background-size: 350px 210px;
  animation: bg-twinkle 8s ease-in-out infinite alternate;
}

@keyframes bg-twinkle {
  from { opacity: calc(var(--stars-opacity) * 0.6); }
  to   { opacity: var(--stars-opacity); }
}

.bg-nebula {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, var(--nebula-1), transparent 55%),
    radial-gradient(ellipse 60% 60% at 80% 30%, var(--nebula-2), transparent 55%),
    radial-gradient(ellipse 90% 60% at 50% 90%, var(--nebula-1), transparent 55%);
}

/* ── Top Navigation ──────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-decoration: none;
  background: linear-gradient(135deg, var(--hero-gradient-start), var(--hero-gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-logo:hover { text-decoration: none; opacity: 0.85; }

.nav-link {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
.nav-link:hover { color: var(--color-text); text-decoration: none; }

.nav-icon-link {
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  line-height: 0;
  margin-right: auto;
}
.nav-icon-link:hover { color: var(--color-text); text-decoration: none; }

/* Sign-in call-to-action pill (injected via NavExtras on hosted tier) */
.nav-sign-in {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  background: var(--color-surface-interactive);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-sign-in:hover {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 50%, transparent);
  color: var(--color-primary);
  text-decoration: none;
}

/* Reset button-as-nav-link (e.g. sign out form button) */
button.nav-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
  display: block;
}

.nav-avatar-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent, #6366f1);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  border: 1px solid var(--color-border);
}

/* ── Nav capacity dot ───────────────────────────────────── */

.nav-avatar-wrap { position: relative; display: inline-block; line-height: 0; }
.nav-avatar-wrap::after {
  content: "";
  position: absolute;
  bottom: 1px; right: 1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 2px solid var(--color-bg);
  display: none;
}
.nav-avatar-wrap.cap-warn::after { display: block; background: #f59e0b; }
.nav-avatar-wrap.cap-full::after { display: block; background: var(--color-danger, #ef4444); }

/* ── Nav dropdown (profile menu) ──────────────────────────── */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
}

.nav-dropdown-trigger:focus-visible {
  outline: 2px solid var(--color-accent, #6366f1);
  outline-offset: 2px;
}

.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-width: 148px;
  padding: 4px 0;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .12);
}

.nav-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  color: var(--color-text);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  background: var(--color-surface-interactive);
}

/* ── Theme Picker ────────────────────────────────────────── */

.theme-picker {
  position: relative;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
}
.theme-btn:hover {
  border-color: var(--color-border-accent);
  color: var(--color-text);
  box-shadow: 0 4px 16px var(--shadow-primary);
}

.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}

.chevron-icon {
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.theme-btn[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background: var(--color-surface-card-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2), 0 4px 16px var(--shadow-primary);
  z-index: 200;
  animation: menu-in 0.15s cubic-bezier(.4,0,.2,1);
}
.theme-menu[hidden] { display: none; }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}
.theme-option:hover {
  background: var(--color-surface-interactive);
  color: var(--color-text);
}
.theme-option.active {
  background: var(--color-surface-interactive);
  color: var(--color-primary);
}

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

.page {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: calc(100vh - 56px);
}

.content-wrapper {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 1.5rem;
  display: flex;
  justify-content: center;
}

.content-inner {
  width: 100%;
  max-width: 820px;
}

/* ── TOC Panel ───────────────────────────────────────────── */

.toc-panel {
  width: 220px;
  flex-shrink: 0;
  padding: 2.5rem 0 2.5rem 1rem;
  position: relative;
  z-index: 1;
}

.toc-sticky {
  position: sticky;
  top: calc(56px + 1rem);
  max-height: calc(100vh - 56px - 2rem);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  font-family: var(--font-display);
}

.toc-list { list-style: none; }

.toc-item {
  line-height: 1.4;
  margin-bottom: 0.3rem;
}

.toc-item a {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  text-decoration: none;
  display: block;
  padding: 0.12rem 0.5rem;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.toc-item a:hover {
  color: var(--color-text);
  border-left-color: var(--color-primary);
}

.toc-item.toc-h2 { padding-left: 0.75rem; }
.toc-item.toc-h3 { padding-left: 1.5rem; }

/* ── Splash / Home Page ──────────────────────────────────── */

.splash {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}

/* Hero */

.hero {
  text-align: center;
  margin-bottom: 64px;
  animation: fade-up 0.8s ease-out both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}


.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--color-primary) 50%, var(--hero-gradient-end) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 6s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 18px;
  animation: fade-up 0.8s ease-out 0.15s both;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
  animation: fade-up 0.8s ease-out 0.30s both;
}

.hero-links {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  animation: fade-up 0.8s ease-out 0.45s both;
}
.hero-link {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  transition: color 0.15s, border-color 0.15s;
}
.hero-link:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
  text-decoration: none;
}

/* ── Search Form ─────────────────────────────────────────── */

.search-form {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
  animation: fade-up 0.8s ease-out 0.6s both;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  -webkit-border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  -webkit-box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--shadow-primary);
}

.search-btn {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--color-bg);
  background: var(--color-primary);
  border: none;
  border-radius: 999px;
  -webkit-border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  -webkit-box-shadow: none;
  transition: background 0.15s, opacity 0.15s;
}

.search-btn:hover {
  background: var(--color-primary-hover);
}

/* Section headers */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
}

.section-title .accent {
  color: var(--color-primary);
}

.doc-count {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  padding: 3px 10px;
  border-radius: 999px;
}

/* Steps */

.steps {
  margin-bottom: 56px;
  animation: fade-up 0.8s ease-out 0.45s both;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.step-card {
  padding: 22px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.25s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-border-accent);
  box-shadow: 0 12px 40px var(--shadow-primary);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  text-transform: uppercase;
}

.step-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}

.step-desc {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  flex: 1;
}

.step-desc code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Code blocks (in steps) */

.code-block {
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-card-strong);
  overflow: hidden;
  font-size: 0.8rem;
}

.code-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(0,0,0,0.06);
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.code-dot:nth-child(1) { background: #ff5f57; }
.code-dot:nth-child(2) { background: #febc2e; }
.code-dot:nth-child(3) { background: #28c840; }

.code-fname {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.code-body {
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.65;
}

.code-body code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  background: none;
}

.tok-key  { color: var(--color-primary); }
.tok-str  { color: var(--color-secondary); }
.tok-fn   { color: var(--color-text); font-weight: 600; }
.tok-punc { color: var(--color-text-muted); }

/* Documents section on splash */

.docs-section {
  animation: fade-up 0.8s ease-out 0.6s both;
}

/* ── Document List ────────────────────────────────────────── */

.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 0 0.75rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.doc-row td { border-bottom: 1px solid var(--color-border); padding: 0.6rem 0.75rem; }
.doc-row:hover td { background: var(--color-surface-interactive); }
.doc-table-title a { color: var(--color-text); text-decoration: none; font-weight: 500; }
.doc-table-title a:hover { color: var(--color-primary); }
.doc-table-author { color: var(--color-text-muted); font-size: 0.85rem; }
.doc-table-date { color: var(--color-text-muted); font-size: 0.85rem; white-space: nowrap; }
.doc-table-vis { white-space: nowrap; }

/* ── Load more ───────────────────────────────────────────── */

.load-more {
  text-align: center;
  padding: 1.25rem 0 0.5rem;
}
.load-more-btn {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.4rem 1.25rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.load-more-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-border-accent);
  background: var(--color-surface-card);
  text-decoration: none;
}

/* ── Empty State ─────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 56px 2rem;
  animation: fade-up 0.8s ease-out 0.6s both;
}

.empty-icon {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.empty-desc code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* ── Document View ───────────────────────────────────────── */

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.page-header p {
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.doc-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.doc-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.doc-header .doc-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ── Visibility badge ────────────────────────────────────── */

.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.3em 0.7em;
  border-radius: 999px;
  border: none;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.doc-badge svg { flex-shrink: 0; }
.doc-badge--public {
  background: #1d6fef;
  color: #fff;
}
.doc-badge--unlisted {
  background: #b45309;
  color: #fff;
}
.doc-badge--private {
  background: #dc2626;
  color: #fff;
}

/* ── TTL countdown ───────────────────────────────────────── */

.ttl-countdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: default;
}
.ttl-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  z-index: 20;
}
.ttl-countdown:hover .ttl-tooltip { opacity: 1; visibility: visible; }

/* ── Markdown Body ───────────────────────────────────────── */

.markdown-body {
  font-size: 1rem;
  line-height: 1.7;
  letter-spacing: 0;
  color: var(--color-text);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-family: var(--font-display);
  color: var(--color-text);
  line-height: 1.3;
  letter-spacing: -0.035em;
  margin: 1.75em 0 0.6em;
  font-weight: 600;
}

.markdown-body h1 {
  font-size: 1.75em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.3em;
}

.markdown-body h2 {
  font-size: 1.4em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.25em;
}

.markdown-body h3 { font-size: 1.15em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body p { margin: 0.9em 0; }

.markdown-body a { color: var(--color-primary); }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 0.18em 0.42em;
  border-radius: 5px;
}

.markdown-body pre {
  background: var(--color-surface-card-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25em 0;
  font-size: 0.875em;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.markdown-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 0.5em 1em;
  margin: 1.25em 0;
  color: var(--color-text-muted);
  background: var(--color-surface-card);
  border-radius: 0 8px 8px 0;
}

.markdown-body blockquote p { margin: 0; }

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.75em;
  margin: 0.75em 0;
}

.markdown-body li { margin: 0.25em 0; }

.markdown-body li input[type="checkbox"] {
  margin-right: 0.4em;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25em 0;
  font-size: 0.9em;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.9em;
  text-align: left;
}

.markdown-body th {
  background: var(--color-surface-card);
  font-family: var(--font-display);
  font-weight: 600;
}

.markdown-body tr:nth-child(even) td {
  background: var(--color-surface-card);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2em 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 10px;
}

/* Chroma background follows the card surface — specificity (0,2,1) beats Chroma's injected (0,2,0) */
.markdown-body pre.chroma {
  background: var(--color-surface-card-strong);
  border-radius: 12px;
  position: relative;
}

/* ── Copy button ─────────────────────────────────────────── */

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--color-surface-card);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1.4;
}
.markdown-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* ── Mermaid diagrams ────────────────────────────────────── */

.mermaid {
  margin: 1.5rem 0;
  padding: 1.25rem 1rem;
  background: var(--color-surface-card-strong);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow-x: auto;
  text-align: center;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ── Document footer ─────────────────────────────────────── */

.doc-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.doc-footer a { color: var(--color-text-muted); text-decoration: underline; }
.doc-footer a:hover { color: var(--color-primary); }
.doc-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.visibility-select {
  background: color-mix(in srgb, var(--color-text-muted) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-text-muted) 30%, transparent);
  border-radius: 4px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 3px 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.visibility-select:hover {
  background: color-mix(in srgb, var(--color-text-muted) 20%, transparent);
  border-color: color-mix(in srgb, var(--color-text-muted) 60%, transparent);
  color: var(--color-text);
}
.vis-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.vis-confirm-overlay[hidden] { display: none; }
.vis-confirm-modal {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
}
.vis-confirm-modal p { margin: 0 0 0.5rem; font-weight: 500; }
.vis-confirm-sub { color: var(--color-text-muted); font-size: 0.9rem; font-weight: 400 !important; }
.vis-confirm-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }
.vis-confirm-actions button {
  background: color-mix(in srgb, var(--color-text-muted) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-text-muted) 30%, transparent);
  border-radius: 4px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  padding: 5px 14px;
}
.vis-confirm-btn--primary {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: #fff !important;
}
.delete-btn {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-danger) 35%, transparent);
  border-radius: 4px;
  color: var(--color-danger);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 3px 10px;
  transition: background 0.15s, border-color 0.15s;
  vertical-align: middle;
}
.delete-btn:hover {
  background: color-mix(in srgb, var(--color-danger) 20%, transparent);
  border-color: color-mix(in srgb, var(--color-danger) 65%, transparent);
}

/* ── Error page ──────────────────────────────────────────── */

.error-page {
  text-align: center;
  padding-top: 6rem;
}
.error-code {
  font-size: 6rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.15;
  font-family: var(--font-display);
}
.error-message {
  color: var(--color-text-muted);
  margin-top: 1rem;
  font-size: 1.05rem;
}
.error-back {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.error-back:hover { text-decoration: underline; }

/* ── Delete Modal ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 1.75rem;
  max-width: 360px;
  width: calc(100% - 3rem);
  transform: scale(0.95) translateY(8px);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
}
.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}
.modal-body {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.modal-btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: all 0.15s ease;
}
.modal-btn--cancel {
  background: transparent;
  color: var(--color-text-secondary);
}
.modal-btn--cancel:hover {
  background: var(--color-surface-card);
  border-color: var(--color-border-accent);
}
.modal-btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.modal-btn--danger:hover {
  opacity: 0.85;
}

/* ── How-it-works disclosure ─────────────────────────────── */

.how-it-works-details {
  margin-bottom: 2rem;
}
.how-it-works-summary {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  user-select: none;
}
.how-it-works-summary::-webkit-details-marker { display: none; }
.how-it-works-summary::before {
  content: '▶';
  font-size: 0.65em;
  transition: transform 0.2s ease;
  display: inline-block;
}
.how-it-works-details[open] .how-it-works-summary::before {
  transform: rotate(90deg);
}
.steps--inline {
  margin-top: 1rem;
}

/* ── Copy link button ────────────────────────────────────── */

.doc-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}
.doc-header-top h1 {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
  margin-top: 0.25rem;
}
.copy-link-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-border-accent);
  background: var(--color-surface-card);
}

/* ── Heading anchors ─────────────────────────────────────── */

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  position: relative;
}
.heading-anchor {
  opacity: 0;
  margin-left: 0.4em;
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 0.8em;
  text-decoration: none;
  transition: opacity 0.15s;
  vertical-align: middle;
}
.markdown-body h1:hover .heading-anchor,
.markdown-body h2:hover .heading-anchor,
.markdown-body h3:hover .heading-anchor,
.markdown-body h4:hover .heading-anchor,
.markdown-body h5:hover .heading-anchor,
.markdown-body h6:hover .heading-anchor { opacity: 1; }

/* ── TOC active state ────────────────────────────────────── */

.toc-item a.toc-active {
  color: var(--color-primary);
  font-weight: 500;
  border-left-color: var(--color-primary);
}

/* ── Breadcrumb truncation ───────────────────────────────── */

.doc-breadcrumb span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

/* ── Compact Hero ────────────────────────────────────────── */

.hero--compact {
  margin-bottom: 40px;
}
.hero--compact .hero-title {
  font-size: clamp(2rem, 8vw, 3.5rem);
}
.hero--compact .hero-desc {
  display: none;
}

/* ── Breadcrumb ──────────────────────────────────────────── */

.doc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}
.doc-breadcrumb a {
  color: var(--color-text-muted);
}
.doc-breadcrumb a:hover {
  color: var(--color-primary);
}
.doc-breadcrumb-sep {
  opacity: 0.4;
}

/* ── Mobile TOC ──────────────────────────────────────────── */

.toc-mobile {
  display: none;
  margin-bottom: 1.5rem;
}
.toc-mobile-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.toc-mobile-toggle:hover {
  border-color: var(--color-border-accent);
}
.toc-mobile-drawer {
  display: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: var(--color-surface-card);
}
.toc-mobile-drawer.open {
  display: block;
}
.toc-mobile-drawer .toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-mobile-drawer .toc-item {
  padding: 0.25rem 0;
}
.toc-mobile-drawer .toc-h2 { padding-left: 0.75rem; }
.toc-mobile-drawer .toc-h3 { padding-left: 1.5rem; }
.toc-mobile-drawer a {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}
.toc-mobile-drawer a:hover {
  color: var(--color-primary);
}

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

@media (max-width: 900px) {
  .toc-panel { display: none; }
  .toc-mobile { display: block; }
  .steps-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .nav { padding: 0 1rem; gap: 0.75rem; }
  .nav-hide-mobile { display: none; }
  .splash { padding: 40px 16px 60px; }
  .hero-title { font-size: clamp(2.5rem, 16vw, 3.5rem); }
  .search-form { flex-direction: column; align-items: stretch; }
  .search-btn { width: 100%; }
  .copy-btn { opacity: 1; }
  .content-wrapper { padding: 1.5rem 1rem; }
  .doc-header h1 { font-size: 1.5rem; }
  .steps-grid { grid-template-columns: 1fr; }
  .theme-btn span:nth-child(2) { display: none; }
}

/* ── Revision browser ────────────────────────────────────── */

.rev-browser-wrapper { max-width: 100%; }

.rev-browser {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1.5rem;
  min-height: 400px;
}

.rev-list {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  max-height: 70vh;
}

.rev-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.12s;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.rev-row:hover { background: var(--color-surface-interactive); }
.rev-row.active { background: color-mix(in srgb, var(--color-primary) 10%, transparent); }
.rev-row.active .rev-num { color: var(--color-primary); }

.rev-num { font-weight: 600; font-size: 0.8rem; }
.rev-time { color: var(--color-text-muted); font-size: 0.75rem; }
.rev-delta { display: flex; gap: 0.4rem; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.rev-add    { color: #22a05a; }
.rev-remove { color: var(--color-danger); }
.rev-nodelta { color: var(--color-text-muted); }

.rev-preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rev-preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  flex-wrap: wrap;
}

.rev-preview-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  flex: 1;
}

.rev-preview-actions { display: flex; gap: 0.5rem; }

.rev-action-btn {
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  background: var(--color-surface-card);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.rev-action-btn:hover { background: var(--color-surface-interactive); border-color: var(--color-border-accent); }
.rev-action-btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.rev-action-btn--primary:hover { opacity: 0.85; background: var(--color-primary); }

.rev-diff-body {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 1rem;
  font-size: 0.78rem;
  line-height: 1.5;
  font-family: var(--font-mono, ui-monospace, monospace);
  background: var(--color-surface-card);
  color: var(--color-text);
  white-space: pre;
}
.rev-diff-body--full {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin-top: 1.5rem;
}

/* Diff line colouring */
/* Every line is a span; all must be block so there are no \n gaps between them. */
.rev-diff-body span { display: block; }
.diff-add    { background: var(--color-diff-add); border-left: 3px solid rgba(34,197,94,0.7); padding-left: 2px; }
.diff-remove { background: var(--color-diff-remove); border-left: 3px solid rgba(239,68,68,0.7); padding-left: 2px; }
.diff-hunk   { color: var(--color-text-muted); }
.diff-header { color: var(--color-text-muted); font-weight: 600; }
.rev-diff-empty { color: var(--color-text-muted); font-style: italic; }

/* Revision banner */
.rev-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.rev-banner-label { font-weight: 600; color: var(--color-primary); }
.rev-banner-time  { color: var(--color-text-muted); flex: 1; }
.rev-banner-actions { display: flex; gap: 0.5rem; }

/* Mobile bottom sheet */
.rev-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}
.rev-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: 12px 12px 0 0;
  z-index: 201;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.rev-sheet-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.rev-sheet-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.rev-sheet-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.rev-sheet [aria-selected="true"] { background: color-mix(in srgb, var(--color-primary) 10%, transparent); }
.rev-sheet .rev-diff-body { overflow-x: auto; overflow-y: auto; }

@media (max-width: 640px) {
  .rev-browser { grid-template-columns: 1fr; }
  .rev-preview-panel { display: none; }
  .rev-list { border-right: none; max-height: none; }
  .rev-browser { min-height: 0; }
}

/* ── Limit modal ─────────────────────────────────────────── */

.limit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.limit-modal {
  background: var(--color-surface-card-strong);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  position: relative;
  color: var(--color-text);
}

.limit-modal-dismiss {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0.25rem;
}

.limit-modal-dismiss:hover { color: var(--color-text); }

.limit-modal-msg {
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.limit-modal-cta {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.limit-modal-cta:hover { background: var(--color-primary-hover); }
