:root, [data-theme="dark"] {
  /* SMXi: slate ink + seafoam + periwinkle */
  --bg: #0e141c;
  --bg-2: #15202c;
  --surface: #182433;
  --surface-2: #1e2d3f;
  --border: #2c3f55;
  --text: #e8eef5;
  --muted: #9aadc2;
  --accent: #4eae84;
  --accent-ink: #061510;
  --accent-dim: #439d73;
  --accent-soft: rgba(67, 157, 115, 0.18);
  --secondary: #8895c3;
  --secondary-ink: #12162a;
  --secondary-soft: rgba(136, 149, 195, 0.2);
  --highlight-bg: rgba(67, 157, 115, 0.14);
  --highlight-border: rgba(78, 174, 132, 0.55);
  --highlight-text: #b7ebcf;
  --mark-bg: #ffe566;
  --mark-text: #1a1a12;
  --code-bg: #101820;
  --radius: 10px;
  --radius-chip: 999px;
  --sidebar-w: 380px;
  --nav-rail-w: 280px;
  --nav-rail-w-split: 360px;
  --resize-handle: #243447;
  --active-card-bg: #1a3040;
  --glow: rgba(67, 157, 115, 0.2);
  --glow-secondary: rgba(136, 149, 195, 0.16);
  --grid: rgba(136, 149, 195, 0.05);
  --noise: rgba(255, 255, 255, 0.025);
  --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #f3f5f8;
  --bg-2: #e6ecf2;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: #c5d0dc;
  --text: #3d5a76;
  --muted: #5f758c;
  --accent: #439d73;
  --accent-ink: #f4fff9;
  --accent-dim: #5fb48c;
  --accent-soft: rgba(67, 157, 115, 0.12);
  --secondary: #8895c3;
  --secondary-ink: #ffffff;
  --secondary-soft: rgba(136, 149, 195, 0.16);
  --highlight-bg: #e5f5ec;
  --highlight-border: #439d73;
  --highlight-text: #2a5f46;
  --mark-bg: #ffe566;
  --mark-text: #1a1a12;
  --code-bg: #e8eef4;
  --radius: 10px;
  --radius-chip: 999px;
  --resize-handle: #c5d0dc;
  --active-card-bg: #e8f4ee;
  --glow: rgba(67, 157, 115, 0.14);
  --glow-secondary: rgba(136, 149, 195, 0.14);
  --grid: rgba(61, 90, 118, 0.06);
  --noise: rgba(61, 90, 118, 0.02);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) color-mix(in srgb, var(--surface) 80%, transparent);
}

/* Themed scrollbars */
*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
*::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent-dim) 70%, var(--border));
  border-radius: 999px;
  border: 2px solid var(--bg);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
  border: 2px solid var(--bg);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chip-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@keyframes panel-slide-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes sidebar-settle {
  from { opacity: 0.65; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes btn-pop {
  0% { transform: translateY(0) scale(1); }
  55% { transform: translateY(-2px) scale(1.04); }
  100% { transform: translateY(-2px) scale(1.03); }
}

@keyframes shimmer-sweep {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

/* Smooth morph when opening/closing the doc panel */
::view-transition-group(root) {
  animation-duration: 0.42s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.42s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

.search-panel {
  view-transition-name: search-panel;
}

.doc-panel {
  view-transition-name: doc-panel;
}

::view-transition-old(search-panel),
::view-transition-new(search-panel) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  height: 100%;
  overflow: clip;
}

::view-transition-old(doc-panel),
::view-transition-new(doc-panel) {
  animation-duration: 0.42s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  height: 100%;
  overflow: clip;
}

::view-transition-new(doc-panel) {
  animation-name: panel-slide-in;
}

::view-transition-old(doc-panel) {
  animation-name: panel-slide-in;
  animation-direction: reverse;
  animation-duration: 0.32s;
}

/* Theme toggle: circular wipe from the button; skip panel morphs */
html.theme-transitioning .search-panel,
html.theme-transitioning .doc-panel,
html:active-view-transition-type(theme) .search-panel,
html:active-view-transition-type(theme) .doc-panel {
  view-transition-name: none;
}

html.theme-transitioning::view-transition-old(root),
html.theme-transitioning::view-transition-new(root),
html:active-view-transition-type(theme)::view-transition-old(root),
html:active-view-transition-type(theme)::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

html.theme-transitioning::view-transition-old(root),
html:active-view-transition-type(theme)::view-transition-old(root) {
  z-index: 1;
}

html.theme-transitioning::view-transition-new(root),
html:active-view-transition-type(theme)::view-transition-new(root) {
  z-index: 2;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -8%, var(--glow), transparent 55%),
    radial-gradient(900px 520px at 100% 0%, var(--glow-secondary), transparent 52%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-2) 55%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  transition: background 0.25s, color 0.25s;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 20%, #000 20%, transparent 75%);
  opacity: 0.9;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

#app,
.corner-toggles,
.doc-close-btn {
  position: relative;
  z-index: 1;
}

.corner-toggles {
  position: fixed;
  top: 14px;
  right: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
}
.corner-btn {
  position: static;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  transition:
    border-color 0.18s,
    color 0.18s,
    background 0.2s,
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s;
}
.corner-btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 10px 22px -12px var(--glow);
}
.help-toggle:hover {
  transform: scale(1.1);
}
.help-toggle.is-active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}
.theme-toggle:hover {
  transform: rotate(-18deg) scale(1.1);
}
.theme-toggle:active {
  transform: rotate(-6deg) scale(0.95);
}
.help-toggle:active {
  transform: scale(0.95);
}

/* ---------- main layout (nav + search [+ read pane]) ---------- */
.layout-main {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.layout-main .nav-rail {
  width: var(--nav-rail-w);
  min-width: 200px;
  max-width: 360px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--border);
  /* Let the textured green body atmosphere show through the sidebar */
  background: color-mix(in srgb, var(--bg-2) 45%, transparent);
  backdrop-filter: blur(6px);
  animation: sidebar-settle 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.layout-main .search-panel {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 40px 32px 32px;
}
.layout-main .search-home {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.layout-main .search-panel .search-top,
.layout-main .search-panel .results {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.layout-main .search-top {
  animation: rise-in 0.45s ease-out both;
}

/* Read pane: help + document (hidden until needed) */
.layout-main .read-panel {
  display: none;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 40px 32px 32px;
  flex-direction: column;
}
.layout-main .read-panel .help-view,
.layout-main .read-panel .doc-view {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.layout-main .read-panel.is-hidden,
.layout-main .read-panel[hidden],
.layout-main .nav-rail.is-hidden,
.layout-main .nav-rail[hidden],
.layout-main .search-panel.is-hidden,
.layout-main .search-panel[hidden] {
  display: none !important;
}

/* Help: projects + help (search hidden via JS) */
body.help-open .layout-main .read-panel {
  display: flex;
  flex: 1;
}

/* Document: search becomes left rail; projects hidden; plain reading surface */
body.doc-open .layout-main .nav-rail {
  display: none !important;
}
body.doc-open .layout-main .search-panel {
  flex: 0 0 var(--nav-rail-w-split);
  width: var(--nav-rail-w-split);
  min-width: 260px;
  max-width: 60vw;
  padding: 0;
  border-right: none;
  /* Match old layout-split glass sidebar */
  background: color-mix(in srgb, var(--bg-2) 45%, transparent);
  backdrop-filter: blur(6px);
}
/* Let search-home grow with results so sticky's containing block spans the full list */
body.doc-open .layout-main .search-home {
  flex: none;
  min-height: auto;
  height: auto;
  display: block;
}
body.doc-open .layout-main .search-panel .search-top,
body.doc-open .layout-main .search-panel .results {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}
body.doc-open .layout-main .search-panel .search-top {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  backdrop-filter: blur(10px);
  z-index: 10;
  margin: 0;
  padding: 16px 14px 10px;
}
body.doc-open .layout-main .search-panel .results {
  padding: 0 14px 16px;
}
body.doc-open .layout-main .search-panel header {
  text-align: left;
  margin-bottom: 16px;
}
body.doc-open .layout-main .search-panel header h1 {
  font-size: 1.1rem;
  white-space: nowrap;
}
body.doc-open .layout-main .search-panel .site-title-link {
  white-space: nowrap;
}
body.doc-open .layout-main .search-panel .brand-kicker,
body.doc-open .layout-main .search-panel #siteSubtitle {
  display: none;
}
body.doc-open .layout-main .search-panel .meta-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
body.doc-open .layout-main .search-panel .meta-actions {
  margin-left: 0;
}
body.doc-open .layout-main .search-panel .search-box input {
  padding: 10px 14px 10px 38px;
  font-size: 0.9rem;
}
body.doc-open .layout-main .search-panel .search-box .icon {
  left: 12px;
}
body.doc-open .layout-main .search-panel .result-card {
  padding: 10px 14px;
}

/* Resize handle between search sidebar and reader (doc-open only) */
.resize-handle {
  display: none;
  width: 5px;
  cursor: col-resize;
  background: var(--resize-handle);
  transition: background 0.15s, width 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
body.doc-open .resize-handle {
  display: block;
}
body.doc-open .resize-handle:hover,
body.doc-open .resize-handle.dragging {
  background: var(--accent);
  width: 6px;
}

body.doc-open .layout-main .read-panel {
  display: flex;
  flex: 1;
  /* Solid dark panel — hides grain/green for easier reading (old layout-split) */
  background: var(--bg);
  padding: 32px 40px;
}
body.doc-open .layout-main .read-panel .doc-view {
  /* Fill the pane like old .layout-split .doc-panel (no artificial max-width) */
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
}

.layout-main .doc-list .doc-group {
  animation: chip-in 0.35s ease-out both;
}
.layout-main .doc-list .doc-group:nth-child(1) { animation-delay: 0.02s; }
.layout-main .doc-list .doc-group:nth-child(2) { animation-delay: 0.04s; }
.layout-main .doc-list .doc-group:nth-child(3) { animation-delay: 0.06s; }
.layout-main .doc-list .doc-group:nth-child(4) { animation-delay: 0.08s; }
.layout-main .doc-list .doc-group:nth-child(5) { animation-delay: 0.1s; }
.layout-main .doc-list .doc-group:nth-child(6) { animation-delay: 0.12s; }
.layout-main .doc-list .doc-group:nth-child(n+7) { animation-delay: 0.14s; }

html.no-view-transitions .layout-main .search-panel {
  animation: rise-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Narrow screens */
@media (max-width: 820px) {
  .layout-main {
    flex-direction: column;
  }

  .layout-main .nav-rail {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 32vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .layout-main .search-panel {
    height: auto;
    flex: 1;
    min-height: 0;
    padding: 24px 20px 20px;
  }

  body.doc-open .layout-main {
    flex-direction: column;
  }

  body.doc-open .layout-main .search-panel {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    max-height: 36vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  body.doc-open .resize-handle {
    display: none;
  }

  body.doc-open .layout-main .read-panel {
    flex: 1;
    min-height: 0;
    padding: 20px 16px 28px;
  }

  body.help-open .layout-main .read-panel {
    padding: 24px 20px 20px;
  }
}


header { text-align: center; margin-bottom: 36px; }
.brand-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
}
header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 10px;
}
header p#siteSubtitle {
  color: var(--muted);
  font-size: 1rem;
  max-width: 28rem;
  margin: 0 auto;
}
.site-title-link {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
  background-image: linear-gradient(90deg, var(--accent), var(--secondary));
  background-size: 100% 0.12em;
  background-repeat: no-repeat;
  background-position: 0 92%;
  transition: color 0.15s, background-size 0.2s;
}
.site-title-link:hover {
  color: var(--accent);
  background-size: 100% 0.18em;
}

.search-box { position: relative; margin-bottom: 16px; }
.search-box input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.2s, box-shadow 0.2s, transform 0.2s;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 12px 30px -18px var(--glow);
  background: var(--surface);
}
.search-box input::placeholder { color: var(--muted); }
.search-box .icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s;
}
.search-box:focus-within .icon { color: var(--accent); }

.meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.meta-bar button {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  transition:
    border-color 0.18s,
    color 0.18s,
    background 0.18s,
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.18s;
}
.meta-bar button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 48%, transparent 62%);
  background-size: 220% 100%;
  opacity: 0;
  pointer-events: none;
}
.meta-bar button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 18px -10px var(--glow);
  animation: btn-pop 0.35s ease;
}
.meta-bar button:hover::after {
  opacity: 1;
  animation: shimmer-sweep 0.7s ease;
}
.meta-bar button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}
.meta-bar button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
  animation: none;
}
.meta-bar button:disabled::after { display: none; }
#lastIndexTime {
  font-family: var(--font-mono);
  font-size: 0.72rem !important;
  opacity: 0.75 !important;
}

.results { display: flex; flex-direction: column; gap: 10px; }

.result-card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s;
  border-left: 3px solid transparent;
}
.result-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  border-left-color: var(--accent);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 14px 28px -18px var(--glow);
}
.result-card:active {
  transform: translateY(-1px) scale(0.995);
}
.result-card.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--active-card-bg);
}
.result-card .doc-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 500;
}
.result-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--text);
}
.result-card .snippet { font-size: 0.88rem; color: var(--muted); line-height: 1.55; word-break: break-word; }
.result-card .snippet mark,
.doc-panel mark,
mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 3px;
  padding: 0 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.result-card .location { margin-top: 8px; font-size: 0.75rem; color: var(--muted); opacity: 0.7; font-family: var(--font-mono); }
.result-card .score { float: right; font-size: 0.72rem; color: var(--muted); opacity: 0.5; margin-top: 2px; font-family: var(--font-mono); }

.doc-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}
.nav-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.nav-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px 2px;
}
.nav-rail-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
}
.nav-rail-action {
  flex-shrink: 0;
  margin: 0;
  padding: 2px 0;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.75;
  transition: color 0.15s, opacity 0.15s;
}
.nav-rail-action:hover {
  color: var(--accent);
  opacity: 1;
}
.nav-rail-action:active {
  opacity: 0.9;
}
.nav-rail .doc-list {
  flex: 1 1 auto;
  min-height: 0;
}
.nav-rail .doc-group-toggle {
  font-size: 0.76rem;
  padding: 8px 12px;
  border-radius: 10px;
}
.nav-rail .doc-chip {
  font-size: 0.74rem;
  padding: 5px 11px;
}
.doc-list-pinned {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.doc-list-loading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 6px 2px;
  opacity: 0.75;
}
.doc-group {
  display: block;
  border: none;
  background: transparent;
  overflow: visible;
}
.doc-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  list-style: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.doc-group-toggle::-webkit-details-marker {
  display: none;
}
.doc-group-toggle::marker {
  content: '';
}
.doc-group-toggle:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.doc-group[open] .doc-group-toggle {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}
.doc-group-chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.doc-group[open] .doc-group-chevron {
  transform: rotate(45deg);
  margin-top: -2px;
}
.doc-group-name {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.doc-group-count {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.85;
  padding-left: 4px;
}
/* Doc chips hang under the header — not inside the rounded summary */
.doc-group-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px 6px;
  padding: 0 0 2px 14px;
  border-left: 2px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.doc-chip {
  display: inline-block;
  padding: 6px 13px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color 0.18s,
    color 0.18s,
    background 0.18s,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s;
}
.doc-chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
  transform: translateY(-3px) rotate(-1deg) scale(1.04);
  box-shadow: 0 10px 20px -12px var(--glow);
}
.doc-chip:active {
  transform: translateY(-1px) rotate(0deg) scale(0.98);
  box-shadow: none;
}
.doc-chip.help-chip {
  border-style: dashed;
  color: var(--secondary);
  border-color: color-mix(in srgb, var(--secondary) 55%, var(--border));
}
.doc-chip.help-chip:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--secondary-ink);
  box-shadow: 0 10px 20px -12px var(--glow-secondary);
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }
.loading { opacity: 0.5; pointer-events: none; }

.sidebar-help {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.search-footer {
  flex-shrink: 0;
}
.search-footer .sidebar-help-link {
  display: block;
  width: 100%;
}
.sidebar-help-link {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.84rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition:
    border-color 0.18s,
    color 0.18s,
    background 0.18s,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s;
}
.sidebar-help-link:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 12px 24px -14px var(--glow);
}
.sidebar-help-link:active {
  transform: translateY(0) scale(0.99);
  box-shadow: none;
}

/* ---------- main pane modes: search | help | doc ---------- */
.search-home.is-hidden,
.help-view.is-hidden,
.doc-view.is-hidden,
.help-view[hidden],
.doc-view[hidden] {
  display: none !important;
}
/* Doc mode keeps .search-home visible as the left rail — only help hides it */
body.help-open .search-home {
  display: none !important;
}
body.help-open .help-view {
  display: block !important;
}
body.doc-open .doc-view {
  display: block !important;
}
.help-view,
.doc-view {
  width: 100%;
  animation: rise-in 0.35s ease-out both;
}
.main-view-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
  text-align: left;
}
.main-back-btn {
  appearance: none;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.15s;
}
.main-back-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateX(-2px);
}
.main-view-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}
.main-view-body {
  text-align: left;
  line-height: 1.65;
}
.doc-view-body {
  padding-bottom: 48px;
}
/* legacy aliases */
.help-view-header,
.help-back-btn,
.help-view-title { /* prefer main-* classes */ }
.help-prose {
  text-align: left;
  line-height: 1.65;
}
.help-prose h1 { display: none; }
.help-prose h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.4em 0 0.5em;
}
.help-prose h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.1em 0 0.4em;
}
.help-prose p,
.help-prose ul,
.help-prose ol,
.help-prose table {
  margin: 0 0 0.85em;
}
.help-prose ul,
.help-prose ol {
  padding-left: 1.25em;
}
.help-prose li { margin: 0.25em 0; }
.help-prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.help-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.help-prose th,
.help-prose td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.help-prose th {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

/* ---------- document content (in main pane) ---------- */
.doc-view .doc-section { margin-bottom: 1.5rem; }
.doc-header { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.doc-header h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  flex: 1;
}
.doc-close-btn {
  position: fixed; top: 14px; right: 74px; z-index: 100;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition:
    border-color 0.18s,
    color 0.18s,
    background 0.2s,
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s,
    opacity 0.2s;
}
.doc-close-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary-ink);
  background: var(--secondary);
  transform: rotate(90deg) scale(1.08);
  box-shadow: 0 10px 22px -12px var(--glow-secondary);
}
.doc-close-btn:active {
  transform: rotate(90deg) scale(0.94);
}

.doc-section {
  margin-bottom: 8px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color 0.3s, background 0.3s;
}
body.doc-open .doc-section:not(.highlighted) {
  /* keep sections flat on the plain reading pane */
  background: transparent;
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
}
.doc-section.highlighted {
  border-color: var(--highlight-border);
  background: var(--highlight-bg);
  animation: pulse-ring 1.2s ease-out 1;
}
.doc-section h1, .doc-section h2, .doc-section h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.doc-section h1 { font-size: 1.5rem; }
.doc-section h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.doc-section h3 { font-size: 1.05rem; }
.doc-section .section-body {
  font-size: 0.9rem;
  line-height: 1.7;
  word-break: break-word;
  color: var(--muted);
}
.doc-section .section-body > :first-child { margin-top: 0; }
.doc-section .section-body > :last-child { margin-bottom: 0; }
.doc-section .section-body p { margin: 0 0 12px; }
.doc-section .section-body p:last-child { margin-bottom: 0; }
.doc-section .section-body ul,
.doc-section .section-body ol { margin: 0 0 14px 1.25em; padding: 0; }
.doc-section .section-body li { margin: 0 0 6px; }
.doc-section .section-body li:last-child { margin-bottom: 0; }
.doc-section .section-body li > ul,
.doc-section .section-body li > ol { margin: 6px 0 0; }
.doc-section .section-body code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.84rem;
  font-family: var(--font-mono);
  color: var(--text);
}
.doc-section .section-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
  font-family: var(--font-mono);
}
.doc-section .section-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  white-space: inherit;
}
.doc-section .section-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 0 0 14px;
  color: var(--muted);
  font-style: italic;
}
.doc-section .section-body .table-scroll {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 12px 0 22px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.doc-section .section-body .table-scroll table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  table-layout: auto;
}
.doc-section .section-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text);
}
.doc-section .section-body th,
.doc-section .section-body td {
  border: 1px solid var(--border);
  padding: 0;
  text-align: left;
  vertical-align: top;
  color: var(--text);
  background: var(--surface);
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
.doc-section .section-body th {
  background: color-mix(in srgb, var(--surface-2) 88%, var(--secondary) 12%);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.doc-section .section-body .cell-pad {
  padding: 16px 18px;
  line-height: 1.7;
  min-height: 1.7em;
}
.doc-section .section-body th .cell-pad {
  padding: 14px 18px;
  white-space: nowrap;
  line-height: 1.4;
}
.doc-section .section-body td.cell-wrap .cell-pad {
  white-space: normal;
  min-width: 18rem;
  max-width: 40rem;
}
.doc-section .section-body td.cell-prose {
  width: 55%;
}
.doc-section .section-body td.cell-prose .cell-pad {
  padding: 22px 24px;
  line-height: 1.8;
  font-size: 0.92rem;
  min-width: 22rem;
  max-width: 38rem;
  color: var(--text);
}
.doc-section .section-body td.cell-prose .cell-para {
  margin: 0 0 0.9em;
}
.doc-section .section-body td.cell-prose .cell-para:last-child {
  margin-bottom: 0;
}
.doc-section .section-body td:not(.cell-wrap) .cell-pad {
  white-space: nowrap;
}
.doc-section .section-body td .cell-pad br {
  display: block;
  margin-bottom: 0.85em;
  content: '';
}
.doc-section .section-body tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-2) 55%, var(--surface));
}
.doc-section .section-body tbody tr:hover td {
  background: color-mix(in srgb, var(--highlight-bg) 50%, var(--surface));
}
.doc-section .section-body a {
  color: var(--accent-dim);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
[data-theme="dark"] .doc-section .section-body a { color: var(--accent); }
.doc-section .section-body a:hover { border-bottom-color: var(--accent); }
.doc-section .section-body strong { color: var(--text); }
.doc-section .section-body h4,
.doc-section .section-body h5,
.doc-section .section-body h6 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 14px 0 6px;
  font-weight: 700;
}
.doc-section .section-line-ref {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--muted);
  opacity: 0.4;
  margin-top: 6px;
}

/* Custom HTML documentation container extensions */
.doc-section .section-body .html-render-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  color: var(--text);
  overflow-x: auto;
  word-break: normal;
}
.doc-section .section-body .html-render-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
.doc-section .section-body .html-render-container th,
.doc-section .section-body .html-render-container td {
  border: 1px solid var(--border);
  padding: 8px 12px;
}

/* Mermaid diagrams */
.mermaid-container {
  margin: 16px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  text-align: center;
}
.mermaid-container svg { max-width: 100%; height: auto; }
.mermaid-error { color: #ff6b6b; font-size: 0.82rem; white-space: pre-wrap; }

/* Prevent text selection while dragging */
body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { user-select: none; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
