// SPDX-License-Identifier: LicenseRef-Mesh-Sustainable-Use-License
// Copyright (C) 2026 Bright Interaction AB
@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #06050a;
  --bg-2: #131019;
  --surface: #181521;
  --border: #2a2521;
  --border-strong: #3a342e;
  --fg: #f5f2ec;
  --muted: #a8a199;
  --faint: #6e665c;
  --accent: #f5f2ec;
  --radius: 12px;
  --rail-w: 204px;
  --ease: cubic-bezier(.16,1,.3,1);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
}
#stage.panning { cursor: grabbing; }
#stage.hovering { cursor: pointer; }
#stage3d {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
}
#stage3d[hidden] { display: none; }

/* top bar (offset by the nav rail) */
#bar {
  position: fixed;
  top: 0; left: var(--rail-w); right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(12,10,9,0.92), rgba(12,10,9,0));
  z-index: 10;
  pointer-events: none;
}
#bar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg);
  align-self: center;
}
.brand .name {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand .stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.views {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.view {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.view:hover { color: var(--fg); }
.view.active {
  color: var(--bg);
  background: var(--accent);
}

.search { margin-left: auto; display: flex; align-items: center; }
.search input {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  width: 200px;
  outline: none;
  transition: border-color .15s, width .2s cubic-bezier(.16,1,.3,1);
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--border-strong); width: 260px; }

/* hover / selection card */
.card {
  position: fixed;
  top: 60px; right: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  z-index: 12;
  box-shadow: 0 16px 40px -20px rgba(0,0,0,0.8);
  transition: opacity .12s, transform .12s cubic-bezier(.16,1,.3,1);
}
.card.hidden { opacity: 0; transform: translateY(-4px); pointer-events: none; }
.card .swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 7px;
  vertical-align: middle;
}
.card h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  line-height: 1.25;
}
.card .path {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 12px;
}
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}
.card .meta b { color: var(--fg); font-weight: 600; font-family: var(--mono); }
.card .chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
}
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.card .actions { display: flex; gap: 8px; }
.card a.btn, .card button.btn {
  flex: 1;
  text-align: center;
  font-family: var(--sans);
  font-size: 12px;
  text-decoration: none;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: transform .08s, background .15s;
}
.card button.btn.ghost {
  color: var(--fg);
  background: transparent;
  border-color: var(--border-strong);
}
.card a.btn:active, .card button.btn:active { transform: translateY(1px); }

/* legend */
.legend {
  position: fixed;
  bottom: 44px; left: calc(var(--rail-w) + 16px);
  max-width: 240px;
  background: rgba(28,25,23,0.7);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  z-index: 9;
  font-size: 11px;
  color: var(--muted);
}
.legend.hidden { display: none; }
.legend-head {
  font-family: var(--mono);
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--faint); padding: 0 6px 6px;
}
.legend .row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 4px 6px; margin: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; text-align: left; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.legend .row:hover { background: var(--bg-2); color: var(--fg); }
.legend .row.active { background: var(--bg-2); color: var(--fg); box-shadow: inset 0 0 0 1px var(--border-strong); }
.legend .row i {
  width: 9px; height: 9px; border-radius: 2px; flex: none;
  font-style: normal;
}
.legend .row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* overlay states */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 20;
  transition: opacity .3s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-inner { text-align: center; color: var(--muted); }
.overlay-inner p { font-size: 13px; margin: 16px 0 0; letter-spacing: 0.01em; }
.spinner {
  display: inline-block;
  width: 26px; height: 26px;
  border: 2px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.overlay.done .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login card: opaque cover above everything until a session cookie exists. */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 60;
  padding: 24px;
  transition: opacity .35s var(--ease);
}
.login.hidden { opacity: 0; pointer-events: none; }
.login-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6);
}
.login-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.login-title {
  font: 600 22px/1 var(--sans);
  letter-spacing: -0.02em;
  margin: 4px 0 0;
}
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.login-card input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 11px 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--fg);
  outline: none;
  transition: border-color .15s var(--ease);
}
.login-card input:focus { border-color: var(--border-strong); }
.login-card input::placeholder { color: var(--faint); }
.login-btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  padding: 11px;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 9px;
  cursor: pointer;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
.login-btn:hover { opacity: .9; }
.login-btn:active { transform: translateY(1px) scale(.99); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-err { color: #e0796b; font-size: 12px; margin: 2px 0 0; }

#hint {
  position: fixed;
  bottom: 14px; left: var(--rail-w); right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  pointer-events: none;
  z-index: 8;
}

/* ---- app shell: left nav rail + feature panels ---- */
#rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 16;
}
.rail-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 18px;
}
.rail-brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg); }
.rail-brand .name { font-weight: 600; letter-spacing: -0.02em; font-size: 15px; }
.rail-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-nav .nav {
  width: 100%;
  text-align: left;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  transition: color .15s, background .2s var(--ease);
}
.rail-nav .nav:hover { color: var(--fg); background: var(--bg-2); }
.rail-nav .nav.active { color: var(--fg); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border); }
.rail-foot {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  padding: 10px;
  line-height: 1.7;
}
.rail-foot .sig { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 5px; background: var(--border-strong); }
.rail-foot .sig.on { background: var(--fg); }

/* feature panels cover the canvas (right of the rail) when a section is active */
#graph-chrome { display: contents; }
body.panel-active #graph-chrome,
body.panel-active #stage,
body.panel-active #stage3d { display: none; }

#panel {
  position: fixed;
  top: 0; left: var(--rail-w); right: 0; bottom: 0;
  background: var(--bg);
  overflow-y: auto;
  z-index: 12;
}
#panel[hidden] { display: none; }
.panel-view { display: none; }
.panel-view.active { display: block; }
.panel-inner { max-width: 920px; margin: 0 auto; padding: 56px 40px 80px; }
.panel-h {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--faint);
  font-weight: 600;
  margin: 0 0 6px;
}
.panel-title { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 28px; line-height: 1.1; }
.panel-soon {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.panel-soon b { color: var(--fg); font-weight: 600; }

/* lead paragraph under a panel title: plain-language context for the view. */
.panel-lead {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin: -16px 0 28px;
  max-width: 640px;
}

/* settings accordion: collapsed groups so the page is short by default. */
.set-acc {
  border-top: 1px solid var(--border);
}
.set-acc-sum {
  list-style: none;
  cursor: pointer;
  padding: 18px 28px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: color .15s var(--ease);
}
.set-acc-sum::-webkit-details-marker { display: none; }
.set-acc-sum::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 16px;
  font-size: 18px;
  color: var(--faint);
  transition: transform .2s var(--ease);
}
.set-acc[open] > .set-acc-sum::after { content: "\2212"; } /* minus */
.set-acc-name { font-size: 14px; color: var(--fg); font-weight: 600; }
.set-acc-desc { font-size: 12.5px; color: var(--faint); line-height: 1.5; }
.set-acc-sum:hover .set-acc-name { color: var(--fg); }
.set-acc-body { padding: 6px 0 24px; }

/* "search ->" button beside the graph's filter box. */
.to-search {
  margin-left: 8px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.to-search:hover { color: var(--fg); border-color: var(--border-strong); }

/* empty-state over the graph: shown only when the vault has no notes. */
.empty {
  position: fixed;
  inset: 0;
  left: var(--rail-w);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 15;
  pointer-events: none;
}
.empty.hidden { display: none; }
body.panel-active .empty { display: none; } /* never over a feature panel */
.empty-card {
  pointer-events: auto;
  width: min(420px, 100%);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.empty-h { font: 600 18px/1.2 var(--sans); margin: 0 0 10px; }
.empty-sub { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 20px; }

@media (max-width: 720px) {
  :root { --rail-w: 56px; }
  .rail-brand .name, .rail-nav .nav { font-size: 0; }
  .rail-nav .nav { text-align: center; padding: 11px 0; }
  .rail-foot { display: none; }
  .panel-inner { padding: 40px 20px 64px; }
}

/* ---- settings ---- */
.set-group {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}
.set-group:first-of-type { border-top: 0; }
.set-h {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 18px;
}
.set-row { margin-bottom: 18px; max-width: 560px; }
.set-row label {
  display: block;
  font-size: 13px;
  color: var(--fg);
  margin-bottom: 7px;
}
.set-row input {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s;
}
.set-row input:focus { border-color: var(--border-strong); }
.set-row input:disabled { color: var(--faint); background: var(--bg-2); cursor: not-allowed; }
.set-help { font-size: 11.5px; color: var(--faint); margin: 6px 2px 0; line-height: 1.5; }
.src {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 5px;
  vertical-align: middle;
  margin-left: 4px;
  border: 1px solid var(--border);
  color: var(--faint);
}
.src.env { color: #e8c97a; border-color: #5a4a26; }
.src.file { color: var(--muted); }

.set-status { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.set-status b { color: var(--fg); font-family: var(--mono); }
.set-sigs { display: flex; gap: 6px; }
.set-sigs .chip {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px;
}
.set-sigs .chip.on { color: var(--fg); border-color: var(--border-strong); }

.set-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 12px; padding: 16px 0;
  background: linear-gradient(0deg, var(--bg) 70%, transparent);
}
.set-note { font-size: 11.5px; color: var(--faint); max-width: 60%; }
.btn {
  font-family: var(--sans); font-size: 13px;
  color: var(--bg); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 9px;
  padding: 9px 18px; cursor: pointer;
  transition: transform .08s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { color: var(--fg); background: transparent; border-color: var(--border-strong); }

#mesh-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--fg);
  font-size: 13px; padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 16px 40px -20px rgba(0,0,0,0.8);
  opacity: 0; pointer-events: none; z-index: 30;
  transition: opacity .2s, transform .2s var(--ease);
}
#mesh-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#mesh-toast.ok { border-color: #3a5a3a; }
#mesh-toast.err { border-color: #6a3a3a; }

/* ---- search ---- */
.srch-box { margin-bottom: 22px; }
.srch-box input {
  width: 100%;
  font-family: var(--sans);
  font-size: 17px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 18px;
  outline: none;
  transition: border-color .15s;
}
.srch-box input::placeholder { color: var(--faint); }
.srch-box input:focus { border-color: var(--border-strong); }
.srch-hint, .srch-count { font-size: 12.5px; color: var(--faint); margin: 0 2px 14px; }
.srch-results { display: flex; flex-direction: column; gap: 10px; }
.rcard {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, transform .08s var(--ease);
}
.rcard:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.rc-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.rc-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
.rc-score { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.t0 { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #e8c97a; border: 1px solid #5a4a26; border-radius: 5px; padding: 1px 6px; }
.rc-path { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 7px; word-break: break-all; }
.rc-snip { font-size: 13px; color: var(--muted); line-height: 1.55; }
.rc-snip mark { background: rgba(232,201,122,0.18); color: var(--fg); border-radius: 2px; padding: 0 1px; }
.rc-reason { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 7px; }

/* note reading pane */
.note-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.note-bar .note-path { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 0 auto 0 4px; word-break: break-all; }
.note-body { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 22px 24px; }
.note-md { font-family: var(--mono); font-size: 12.5px; color: var(--fg); white-space: pre-wrap; word-break: break-word; margin: 0; line-height: 1.6; }

/* ---- docs ---- */
.docs-layout { display: flex; gap: 40px; align-items: flex-start; }
.docs-nav { flex: none; width: 180px; position: sticky; top: 56px; display: flex; flex-direction: column; gap: 1px; }
.docs-nav .docs-link {
  text-align: left; font-family: var(--sans); font-size: 13px; color: var(--muted);
  background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
  transition: color .15s, background .15s;
}
.docs-nav .docs-link:hover { color: var(--fg); background: var(--bg-2); }
.docs-nav .docs-link.active { color: var(--fg); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border); }
.docs-content { flex: 1; min-width: 0; }

/* prose: rendered markdown */
.prose { color: var(--fg); font-size: 15px; line-height: 1.7; max-width: 70ch; }
.prose h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 18px; }
.prose h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin: 32px 0 12px; }
.prose h3 { font-size: 15px; font-weight: 600; margin: 22px 0 8px; }
.prose p { color: var(--muted); margin: 0 0 14px; }
.prose a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.prose a:hover { text-decoration-color: var(--fg); }
.prose strong { color: var(--fg); font-weight: 600; }
.prose ul, .prose ol { color: var(--muted); margin: 0 0 14px; padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose code {
  font-family: var(--mono); font-size: 12.5px; color: var(--fg);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.prose pre {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 16px;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: 12.5px; }

@media (max-width: 720px) {
  .docs-layout { flex-direction: column; gap: 18px; }
  .docs-nav { width: 100%; position: static; flex-direction: row; flex-wrap: wrap; }
}

/* ---- Browse button (graph bar) ---- */
.browse-btn {
  font-family: var(--sans); font-size: 12px; color: var(--muted);
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.browse-btn:hover, .browse-btn.active { color: var(--fg); border-color: var(--border-strong); }
.browse-btn.active { background: var(--bg-2); }

/* ---- clusters explorer (left drawer over the graph) ---- */
.explorer {
  position: fixed; top: 52px; left: var(--rail-w); bottom: 0;
  width: 300px; z-index: 14;
  display: flex; flex-direction: column;
  background: rgba(18,16,24,0.94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.explorer.hidden { transform: translateX(-112%); opacity: 0; pointer-events: none; }
body.panel-active .explorer, body.panel-active .note-drawer { display: none; }
.exp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.exp-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); font-weight: 600; }
.exp-x, .nd-x { background: transparent; border: 0; color: var(--faint); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.exp-x:hover, .nd-x:hover { color: var(--fg); }
.exp-filter {
  margin: 0 14px 8px; padding: 8px 11px; font-family: var(--mono); font-size: 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); outline: none;
}
.exp-filter:focus { border-color: var(--border-strong); }
.exp-list { flex: 1; overflow-y: auto; padding: 0 8px 24px; }
.exp-group { border-bottom: 1px solid rgba(255,255,255,0.04); }
.exp-comm { width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 8px; background: transparent; border: 0; cursor: pointer; color: var(--fg); font-size: 13px; text-align: left; }
.exp-comm:hover { background: var(--bg-2); }
.exp-sw { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.exp-clabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-count { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.exp-sub { padding: 0 8px 8px 25px; font-size: 10.5px; color: var(--faint); font-family: var(--mono); line-height: 1.5; }
.exp-notes.hidden { display: none; }
.exp-note { width: 100%; display: flex; align-items: baseline; gap: 7px; padding: 5px 8px 5px 16px; background: transparent; border: 0; cursor: pointer; text-align: left; }
.exp-note:hover { background: var(--bg-2); }
.exp-type { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bg); background: var(--faint); padding: 1px 5px; border-radius: 4px; flex: 0 0 auto; }
.exp-name { color: var(--fg); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.exp-path { color: var(--faint); font-size: 10px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ---- note reader (right drawer; rendered markdown in-app) ---- */
.note-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: clamp(440px, 46vw, 760px); z-index: 40;
  display: flex; flex-direction: column;
  background: rgba(16,14,22,0.97);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  box-shadow: -30px 0 70px -30px rgba(0,0,0,0.75);
  transition: transform .32s var(--ease);
}
.note-drawer.hidden { transform: translateX(102%); }
.nd-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.nd-path { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-body { flex: 1; overflow-y: auto; padding: 24px 32px 64px; }
.nd-body.prose { max-width: none; } /* fill the wider drawer, not the 70ch prose cap */

@media (max-width: 720px) {
  .explorer { left: var(--rail-w); width: calc(100vw - var(--rail-w)); }
  .note-drawer { width: 100vw; }
}

/* ---- API reference ---- */
.api-lead { font-size: 13px; color: var(--muted); margin: 0 0 16px; line-height: 1.6; max-width: 65ch; }
.api-lead a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.api-config { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.api-config-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-2); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.api-config-bar .btn { padding: 5px 12px; font-size: 12px; }
.api-config pre { margin: 0; padding: 14px 16px; font-family: var(--mono); font-size: 12px; color: var(--fg); background: var(--surface); overflow-x: auto; line-height: 1.5; }
.api-contract { margin-bottom: 18px; }
.api-contract summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
.api-contract summary:hover { color: var(--fg); }
.api-contract pre { font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; white-space: pre-wrap; line-height: 1.6; margin: 8px 0 0; }

.tools { display: flex; flex-direction: column; gap: 10px; }
.tool { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; }
.tool-name code { font-family: var(--mono); font-size: 14px; color: var(--fg); background: none; border: 0; padding: 0; font-weight: 600; }
.tool-desc { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.55; }
.tool-params { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; }
.param code { font-family: var(--mono); font-size: 11.5px; color: var(--fg); background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.param .pty { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-left: 4px; }

.eps { display: flex; flex-direction: column; gap: 2px; }
.ep { display: flex; align-items: baseline; gap: 12px; padding: 8px 10px; border-radius: 8px; }
.ep:hover { background: var(--bg-2); }
.ep-m { flex: none; width: 48px; font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-align: center; padding: 2px 0; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.ep-m.m-get { color: #7fb9e8; border-color: #2e4a5e; }
.ep-m.m-post { color: #8fd08f; border-color: #2e5e3a; }
.ep-m.m-put { color: #e8c97a; border-color: #5a4a26; }
.ep-p { font-family: var(--mono); font-size: 12.5px; color: var(--fg); background: none; border: 0; padding: 0; }
.ep-s { font-size: 12px; color: var(--muted); }
.ep-params { color: var(--faint); }

@media (max-width: 640px) {
  .search input { width: 130px; }
  .search input:focus { width: 160px; }
  .card { top: auto; bottom: 44px; left: 16px; right: 16px; width: auto; }
  #hint { display: none; }
}
