/* Chat Roots: solid dark grey with an orange-gold accent. No gradients, no textures. */

:root {
  --canvas: #1e1e1e;
  --chrome: #2a2a2a;
  --chrome-2: #333333;
  --chrome-3: #3d3d3d;
  --edge: #464646;
  --text: #ececec;
  --muted: #a7a7a7;
  --faint: #7d7d7d;
  --gold: #e5a23a;
  --gold-hi: #f4bb58;
  --gold-deep: #b97b1c;
  --on-gold: #1e1e1e;
  --danger: #f08a7a;
  --ui: "Bricolage Grotesque Variable", "Segoe UI", system-ui, sans-serif;
  --read: "Literata Variable", Georgia, serif;
  --panel-w: 400px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--canvas); color: var(--text); font: 400 13.5px/1.45 var(--ui); overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app { height: 100vh; display: grid; grid-template-rows: 32px 46px 1fr 26px; }

/* ----------------------------------------------------------------- menu bar */
.menubar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--chrome); border-bottom: 1px solid var(--edge); padding: 0 6px; min-width: 0; }
.menus { display: flex; height: 100%; align-items: stretch; }
.menu { position: relative; display: flex; }
.menu > button { border: 0; background: none; padding: 0 11px; cursor: default; border-radius: 4px; margin: 3px 0; }
.menu > button:hover, .menu.open > button { background: var(--chrome-3); }
.menu.open > button { color: var(--gold-hi); }
.doc-title { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.doc-title strong { color: var(--text); font-weight: 600; }

.dropdown { position: absolute; top: calc(100% + 2px); left: 0; z-index: 40; min-width: 260px; padding: 5px; background: var(--chrome-2); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }
.dropdown [role=menuitem] { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 24px; padding: 6px 10px; border: 0; border-radius: 5px; background: none; text-align: left; cursor: default; white-space: nowrap; }
.dropdown [role=menuitem]:hover:not(:disabled), .dropdown [role=menuitem]:focus { background: var(--gold); color: var(--on-gold); outline: none; }
.dropdown [role=menuitem]:hover:not(:disabled) kbd, .dropdown [role=menuitem]:focus kbd { color: var(--on-gold); }
.dropdown [role=menuitem]:disabled { color: var(--faint); }
.dropdown hr { border: 0; border-top: 1px solid var(--edge); margin: 5px 4px; }
kbd { font: 500 12px/1 var(--ui); color: var(--muted); }

/* ------------------------------------------------------------------ toolbar */
.toolbar { display: flex; align-items: center; gap: 4px; padding: 0 8px; background: var(--chrome); border-bottom: 1px solid var(--edge); overflow-x: auto; scrollbar-width: none; }
.toolbar .sep { width: 1px; height: 24px; background: var(--edge); margin: 0 6px; flex: none; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; white-space: nowrap; flex: none; }
.tool:hover:not(:disabled) { background: var(--chrome-3); }
.tool:disabled { color: var(--faint); cursor: default; }
.tool.icon-only { width: 32px; padding: 0; justify-content: center; }
.tool.primary { background: var(--gold); color: var(--on-gold); font-weight: 600; }
.tool.primary:hover { background: var(--gold-hi); }
.tool.on { background: var(--chrome-3); border-color: var(--edge); }
.tool svg, .btn svg { width: 16px; height: 16px; flex: none; }
.tool-search { position: relative; display: flex; align-items: center; margin-left: auto; flex: none; }
.tool-search svg { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.tool-search input { width: 230px; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--edge); border-radius: 6px; background: var(--canvas); }
.tool-search input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }
.hits { color: var(--muted); margin: 0 4px 0 8px; min-width: 64px; white-space: nowrap; }

/* --------------------------------------------------------------- workspace */
.workspace { display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; background: var(--canvas); }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
#map:focus { outline: none; }
#map:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.splitter { width: 5px; flex: none; cursor: col-resize; background: var(--edge); }
.splitter:hover, .splitter.dragging, .splitter:focus-visible { background: var(--gold); outline: none; }
.panel { width: var(--panel-w); flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--chrome); }
body.panel-hidden .panel, body.panel-hidden .splitter { display: none; }

.empty { position: absolute; inset: 0; margin: auto; width: min(25rem, 86%); height: fit-content; text-align: center; }
.empty h2 { margin: 0 0 6px; font-size: 21px; font-weight: 600; }
.empty p { margin: 0 0 16px; color: var(--muted); }

.map-crumbs { position: absolute; left: 12px; top: 10px; display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 24px); pointer-events: none; }
.map-crumbs button { pointer-events: auto; border: 1px solid var(--edge); background: var(--chrome); border-radius: 14px; padding: 3px 11px; cursor: pointer; }
.map-crumbs button:hover { border-color: var(--gold); color: var(--gold-hi); }
.map-crumbs button[aria-current] { background: var(--gold); color: var(--on-gold); border-color: var(--gold); font-weight: 600; }

/* ---------------------------------------------------------------- the map */
.view3d { position: absolute; inset: 0; display: none; }
body.mode-3d .view3d { display: block; }
body.mode-3d #map { display: none; }
.view3d .scene-tooltip { font: 500 13px/1.4 var(--ui) !important; color: var(--text) !important; background: var(--chrome-2) !important; border: 1px solid var(--edge); border-radius: 6px; padding: 5px 9px !important; max-width: 320px; }

/* connection lines: thickness comes from --w (map units) and --s (eases off when zoomed in) */
.ln { fill: none; stroke: #4f4f4f; stroke-width: calc(var(--w, 1) * var(--s, 1) * 1px); stroke-linecap: round; }
.ln.topic { stroke: #8a6526; }
.ln.loose { stroke-dasharray: 6 6; }
.ln.lit { stroke: var(--gold-hi); }

.c { stroke-width: 1.5px; vector-effect: non-scaling-stroke; cursor: pointer; }
.c.root { fill: var(--gold); stroke: var(--gold-hi); }
.c.d1 { fill: #2f2f2f; stroke: var(--gold); stroke-width: 2.5px; }
.c.d2 { fill: #2c2c2c; stroke: #c98a2c; stroke-width: 2px; }
.c.d3, .c.d4 { fill: #2a2a2a; stroke: #a8742a; }
.c.unsorted { stroke: #8d8d8d; stroke-dasharray: 5 4; }
.c.chat { fill: #262626; stroke: #5c5c5c; stroke-width: 1px; }
.c.chat.noted { stroke: var(--gold); stroke-width: 2px; }
.c:hover { stroke: var(--gold-hi); }
.c.selected { stroke: var(--gold-hi); stroke-width: 3.5px; }
.c.chat.selected { fill: var(--gold); }
.c.dim { opacity: .25; }
.c.match { stroke: var(--gold-hi); stroke-width: 3px; }

.labels text { font-family: var(--ui); pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.lc { fill: #e2e2e2; font-weight: 500; }
.lc.sel { fill: var(--on-gold); font-weight: 650; }
.lc.dim { opacity: .3; }
.lt { fill: var(--gold-hi); font-weight: 650; }
.lr { fill: var(--on-gold); font-weight: 700; }
.tag { fill: var(--gold-hi); font-weight: 650; paint-order: stroke; stroke: #1e1e1e; stroke-width: .3em; stroke-linejoin: round; }
.tag.d1 { fill: var(--gold); }
.dot { fill: var(--gold); pointer-events: none; }
.dropdown .checkable::before { content: ""; display: inline-block; width: 14px; }
.dropdown [aria-checked=true] .checkable::before { content: "✓"; }

/* -------------------------------------------------------------- side panel */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--edge); color: var(--muted); }
.panel-head .kind { font-weight: 600; color: var(--gold); }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 28px; overscroll-behavior: contain; }
.panel-body > section { margin-top: 22px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.meta { margin: 4px 0 0; color: var(--muted); }
.meta a, .note-body a, .hint a { color: var(--gold-hi); text-underline-offset: 3px; }
.hint { color: var(--muted); margin: 0 0 10px; }

.field { display: block; margin-top: 12px; }
.field > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=url], textarea, select {
  width: 100%; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--edge); background: var(--canvas);
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input[type=text]:focus, input[type=url]:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }
input.title { font-size: 20px; font-weight: 650; letter-spacing: -.01em; padding: 4px 7px; margin-left: -8px; width: calc(100% + 16px); border-color: transparent; background: none; }
input.title:hover { border-color: var(--edge); }
input.title:focus { background: var(--canvas); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--edge); background: var(--chrome-2); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--chrome-3); border-color: #5a5a5a; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.btn.gold:hover:not(:disabled) { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); height: 28px; padding: 0 8px; }
.btn.quiet:hover:not(:disabled) { color: var(--text); background: var(--chrome-3); }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: var(--on-gold); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 8px; }
.actions .grow { margin-right: auto; color: var(--faint); font-size: 12px; }
.row { display: flex; gap: 8px; }
.row > :first-child { flex: 1; }

.composer textarea { font: 400 15px/1.55 var(--read); min-height: 84px; }
.notes { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.note { padding: 10px 12px 6px; border-radius: 6px; background: var(--chrome-2); border-left: 3px solid var(--gold); }
.note.by-claude { border-left-color: #9a9a9a; }
.note-head { color: var(--muted); font-size: 12px; }
.note-head strong { color: var(--text); font-weight: 600; }
.note-origin { margin: 3px 0 0; color: var(--faint); font-size: 12px; font-style: italic; }
.note-body { margin-top: 5px; font: 400 15px/1.6 var(--read); overflow-wrap: anywhere; }
.note-body > :first-child { margin-top: 0; }
.note-body > :last-child { margin-bottom: 0; }
.note-body p, .note-body ul, .note-body ol, .note-body blockquote, .note-body pre { margin: 0 0 .7em; }
.note-body h3, .note-body h4, .note-body h5 { font-family: var(--ui); margin: 1em 0 .35em; line-height: 1.25; }
.note-body h3 { font-size: 17px; } .note-body h4 { font-size: 15.5px; } .note-body h5 { font-size: 14px; }
.note-body ul, .note-body ol { padding-left: 1.3em; }
.note-body code { font: 13px/1.4 ui-monospace, Consolas, Menlo, monospace; background: var(--canvas); padding: 1px 5px; border-radius: 4px; }
.note-body pre { background: var(--canvas); padding: 9px 11px; border-radius: 6px; overflow-x: auto; }
.note-body pre code { background: none; padding: 0; }
.note-body blockquote { padding-left: 11px; border-left: 2px solid var(--edge); color: var(--muted); }
.note .actions { margin-top: 2px; }
.none { color: var(--faint); margin: 12px 0 0; }

.items { list-style: none; margin: 0; padding: 0; }
.items li + li { border-top: 1px solid var(--chrome-3); }
.items button.item { all: unset; box-sizing: border-box; display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 7px 4px; cursor: pointer; }
.items button.item:hover { color: var(--gold-hi); }
.items button.item:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; border-radius: 4px; }
.items .sub { color: var(--faint); font-size: 12px; white-space: nowrap; }
.items .kind-topic::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border: 1.5px solid var(--gold); border-radius: 50%; vertical-align: 0; }
.items .kind-chat::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 9px 0 1px; background: #8a8a8a; border-radius: 50%; vertical-align: 1px; }
.items .has-note::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; border-radius: 50%; background: var(--gold); vertical-align: 2px; }

/* ------------------------------------------------------------- status bar */
.statusbar { display: flex; align-items: center; gap: 18px; padding: 0 12px; background: var(--chrome); border-top: 1px solid var(--edge); color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.status-path { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.status-sync::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #6fbf73; margin-right: 6px; vertical-align: 1px; }
.status-sync.claude::before { background: var(--gold); }
.status-sync.offline::before { background: var(--danger); }

/* ---------------------------------------------------------------- dialogs */
.dialog { width: min(34rem, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--edge); border-radius: 10px; background: var(--chrome); color: var(--text); box-shadow: 0 18px 48px rgba(0, 0, 0, .55); }
.dialog::backdrop { background: rgba(10, 10, 10, .6); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 66px); }
.dialog h2 { margin: 0; padding: 14px 18px; font-size: 16px; font-weight: 650; border-bottom: 1px solid var(--edge); }
.dialog .body { padding: 6px 18px 18px; overflow-y: auto; }
.dialog .body > p { margin: 12px 0 0; }
.dialog .foot { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--edge); background: var(--chrome-2); border-radius: 0 0 10px 10px; }
.dialog pre { margin: 10px 0 0; padding: 10px 12px; background: var(--canvas); border: 1px solid var(--edge); border-radius: 6px; font: 12.5px/1.5 ui-monospace, Consolas, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog ol { padding-left: 1.2em; margin: 10px 0 0; }
.dialog ol li + li { margin-top: 6px; }
.choices { display: flex; gap: 6px; margin-top: 4px; }
.choices label { flex: 1; display: flex; align-items: center; justify-content: center; height: 32px; border: 1px solid var(--edge); border-radius: 6px; cursor: pointer; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label:has(input:checked) { background: var(--gold); color: var(--on-gold); border-color: var(--gold); font-weight: 600; }
.choices label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
table.keys { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.keys td { padding: 5px 0; border-bottom: 1px solid var(--chrome-3); }
table.keys td:last-child { text-align: right; }
table.keys kbd { display: inline-block; padding: 3px 7px; border: 1px solid var(--edge); border-bottom-width: 2px; border-radius: 5px; background: var(--chrome-2); color: var(--text); }

.toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; max-width: min(34rem, 90vw); padding: 9px 15px; border-radius: 7px; background: var(--gold); color: var(--on-gold); font-weight: 600; transition: opacity .18s, transform .18s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); }
.stopped { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--canvas); color: var(--muted); font-size: 16px; }

/* ------------------------------------------------------------------- login */
body.login { overflow: auto; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(23rem, 100%); padding: 26px; background: var(--chrome); border: 1px solid var(--edge); border-radius: 12px; }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--gold); }
.login-card p { color: var(--muted); margin: 6px 0 20px; }
.login-card label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12.5px; }
.login-card input { width: 100%; padding: 9px 11px; border-radius: 6px; border: 1px solid var(--edge); background: var(--canvas); }
.login-card .btn { margin-top: 14px; width: 100%; height: 40px; }
.login-card .error { color: var(--danger); margin: 10px 0 0; }

/* ----------------------------------------------------------------- narrow */
@media (max-width: 820px) {
  .tool:not(.text-only) .label { display: none; }
  .tool:not(.icon-only) { padding: 0 8px; }
  .tool-search input { width: 150px; }
  .hits { display: none; }
  .doc-title { display: none; }
  .workspace { flex-direction: column; }
  .splitter { display: none; }
  .panel { width: auto; height: 46vh; border-top: 1px solid var(--edge); }
  #status-counts, #status-zoom { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
