/* Colours are never written in this file: every one is read through a token.
   Themes live in web/themes/<id>.css and are served joined as /static/themes.css.
   This block holds the structural tokens and fallbacks for the optional colour
   tokens, derived from the required ones. Theme rules use :root[data-theme]
   so they outrank these defaults regardless of load order. See docs/internals/styling-and-themes.md. */
:root {
  --lh: 21px;
  --mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "SF Mono", Menlo, Consolas, ui-monospace, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs: 13.5px;

  --on-accent: #fff;
  --on-badge: var(--bg);
  --on-mark-active: var(--bg);
  --scrim: rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.28);

  --kt: var(--k); --nc: var(--nf); --nb: var(--nf); --nv: var(--fg); --no: var(--m);
  --na: var(--nf); --nt: var(--k); --nd: var(--k); --np: var(--fg); --o: var(--fg);
  --p: var(--dim); --cp: var(--k);
  --gi: var(--s); --gd: var(--err); --gi-bg: transparent; --gd-bg: transparent;
}

* { box-sizing: border-box; }
/* Overlays set display in their own rules, which would otherwise beat the
   hidden attribute and leave an invisible sheet eating every click. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 13px/1.5 var(--ui); overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
::selection { background: var(--sel); }

#app { display: flex; height: 100vh; }



/* ---------- sidebar ---------- */
#side {
  width: 228px; flex: none; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
body.side-hidden #side, body.side-hidden #resizer { display: none; }
.panel { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.panel.active { display: flex; }
.panel-head {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px 7px;
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--dim);
}
.panel-head #root-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-actions { margin-left: auto; flex: none; display: flex; align-items: center; gap: 2px; }
.panel-actions .mini { margin-left: 0; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; }
.panel-actions .mini svg { display: block; }
.mini { margin-left: auto; color: var(--faint); font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.mini:hover { color: var(--fg); background: var(--bg3); }
/* "Show changed files only" toggle: on while the tree is filtered to git changes. */
#btn-changed.active { color: var(--accent-fg); background: var(--bg3); }
.panel-body { flex: 1; overflow: auto; padding-bottom: 16px; }
/* Version and theme, level with the status bar beside it. */
.side-foot {
  flex: none; height: 24px; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; border-top: 1px solid var(--line);
}
.side-foot .mini svg { display: block; }
/* Project links and the theme button, together at the right edge. */
.side-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.side-actions .mini { margin-left: 0; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; }
.side-logo { flex: none; display: flex; align-items: center; padding: 2px 3px; border-radius: 3px; }
.side-logo:hover { background: var(--bg4); }
.side-logo img { height: 13px; width: auto; }

/* ---------- tree ---------- */
.tw { display: block; }
.tr {
  display: flex; align-items: center; gap: 5px; height: 22px; padding-right: 8px;
  white-space: nowrap; cursor: pointer; user-select: none; font-size: 12.5px;
}
.tr:hover { background: var(--bg3); }
.tr.sel { background: var(--sel); }
/* Chevron and file dot are drawn, never typed: no icon font to go missing. */
.tr .ar { width: 12px; height: 12px; flex: none; position: relative; transition: transform .12s ease; }
.tr .ar::before {
  content: ""; position: absolute; left: 3px; top: 2.5px;
  border: 4px solid transparent; border-left-color: var(--faint); border-right-width: 0;
}
.tr.open > .ar { transform: rotate(90deg); }
.tr .ic { width: 7px; height: 7px; flex: none; border-radius: 2px; background: var(--faint); opacity: .75; }
.tr .ic[data-t="code"] { background: var(--nf); }
.tr .ic[data-t="data"] { background: var(--kt); }
.tr .ic[data-t="doc"]  { background: var(--dim); }
.tr .ic[data-t="web"]  { background: var(--nt); }
.tr .ic[data-t="img"]  { background: var(--nc); }
.tr .nm { overflow: hidden; text-overflow: ellipsis; }
.tr.dir .nm { color: var(--fg); }
.tr.file .nm { color: var(--dim); }
.tr.file:hover .nm, .tr.sel .nm { color: var(--fg); }
/* Ignored by .gitignore: listed but dimmed, and left out of search. */
.tr.ignored .nm { color: var(--faint); }
.tr.ignored .ic, .tr.ignored .ar { opacity: .45; }
.tr.ignored:hover .nm, .tr.ignored.sel .nm { color: var(--dim); }
.kids { display: none; }
.kids.open { display: block; }

/* ---------- git status (tree) ---------- */
/* One-letter badge on dirty files; colour by status, no literal colours. */
.tr .gs { margin-left: auto; flex: none; font: 600 10px/1 var(--mono); padding: 0 4px; }
.tr.git-M .nm, .tr.git-M .gs, .tr.git-R .nm, .tr.git-R .gs { color: var(--accent-fg); }
.tr.git-A .nm, .tr.git-A .gs, .tr.git-untracked .nm, .tr.git-untracked .gs { color: var(--gi); }
.tr.git-D .nm, .tr.git-D .gs { color: var(--gd); }
/* Dirty folder: subtle dot after its name. */
.tr.dir.dirty > .nm::after {
  content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 5px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
}
/* "Changed only" filter: hide clean files and folders (dir rows carry an
   authoritative dirty flag from the backend, so even collapsed ones are known). */
#tree.changed-only .tr.file:not(.dirty) { display: none; }
#tree.changed-only .tw:not(:has(.dirty)) { display: none; }

/* ---------- search panel ---------- */
.search-form { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.search-form input, #outline-filter, #right-symbols-filter {
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 8px; font-size: 12.5px; width: 100%;
}
.search-form input:focus, #outline-filter:focus, #right-symbols-filter:focus { border-color: var(--accent); }
#outline-filter { width: calc(100% - 24px); margin: 0 12px 8px; }
.opts { display: flex; gap: 4px; }
.opt {
  font: 600 10.5px/1 var(--mono); padding: 4px 6px; border-radius: 4px;
  color: var(--faint); border: 1px solid transparent;
}
.opt:hover { color: var(--fg); background: var(--bg3); }
.opt.on { color: var(--accent-fg); border-color: var(--accent); background: var(--bg3); }

.rfile { display: flex; align-items: center; gap: 5px; padding: 4px 12px; cursor: pointer; user-select: none; }
.rfile:hover { background: var(--bg3); }
.rfile .ar { color: var(--faint); font-size: 9px; width: 10px; }
.rfile .fp { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.rfile .cnt { margin-left: auto; font: 10px var(--mono); color: var(--faint); background: var(--bg3); border-radius: 8px; padding: 1px 6px; }
.rline {
  display: flex; gap: 8px; padding: 2px 12px 2px 26px; cursor: pointer;
  font: 12px/1.5 var(--mono); white-space: pre; overflow: hidden;
}
.rline:hover { background: var(--bg3); }
.rline.sel { background: var(--sel); }
.rline .rn { color: var(--faint); flex: none; min-width: 3.2em; text-align: right; }
.rfile .ext { font: 9px/1 var(--ui); text-transform: uppercase; letter-spacing: .05em; color: var(--on-badge); background: var(--dim); border-radius: 3px; padding: 3px 4px; flex: none; }
.hint .src { color: var(--accent-fg); }
.hint .warn { color: var(--mark-active); }
.rline .rt { overflow: hidden; text-overflow: ellipsis; color: var(--dim); flex: 1; }
.rline mark { background: var(--mark); color: inherit; border-radius: 2px; }
.hint { padding: 10px 12px; color: var(--faint); font-size: 12px; line-height: 1.6; }

/* ---------- outline ---------- */
.sym { display: flex; align-items: center; gap: 7px; height: 22px; padding-right: 10px; cursor: pointer; font-size: 12.5px; white-space: nowrap; }
.sym:hover { background: var(--bg3); }
.sym.sel { background: var(--sel); }
.sym .kd {
  font: 600 9px/1 var(--mono); text-transform: uppercase; letter-spacing: .03em;
  color: var(--on-badge); background: var(--dim); border-radius: 3px; flex: none;
  min-width: 26px; text-align: center; padding: 4px 3px;
}
.sym .kd[data-k="func"], .sym .kd[data-k="method"], .sym .kd[data-k="fn"],
.sym .kd[data-k="def"], .sym .kd[data-k="defp"] { background: var(--nf); }
.sym .kd[data-k="class"], .sym .kd[data-k="struct"], .sym .kd[data-k="interface"],
.sym .kd[data-k="type"], .sym .kd[data-k="enum"], .sym .kd[data-k="trait"],
.sym .kd[data-k="record"], .sym .kd[data-k="protocol"] { background: var(--nc); }
.sym .kd[data-k="const"], .sym .kd[data-k="var"], .sym .kd[data-k="let"], .sym .kd[data-k="val"] { background: var(--kt); }
.sym .kd[data-k="module"], .sym .kd[data-k="mod"], .sym .kd[data-k="namespace"],
.sym .kd[data-k="defmodule"], .sym .kd[data-k="impl"], .sym .kd[data-k="extension"] { background: var(--nt); }
.sym .sn { overflow: hidden; text-overflow: ellipsis; }
.sym .sl { margin-left: auto; font: 10px var(--mono); color: var(--faint); }

#resizer, #right-resizer { width: 4px; cursor: col-resize; z-index: 5; flex: none; }
#resizer { margin-left: -2px; }
#right-resizer { margin-right: -2px; }
#resizer:hover, #resizer.drag, #right-resizer:hover, #right-resizer.drag { background: var(--accent); }

/* ---------- right-side inspector ---------- */
#right-side {
  width: 320px; flex: none; background: var(--bg2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
body.right-hidden #right-side, body.right-hidden #right-resizer { display: none; }

.inspector-head {
  height: 35px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 0 12px; border-bottom: 1px solid var(--line);
}
.inspector-tabs { display: flex; gap: 4px; }
.inspector-tab {
  font-size: 12px; font-weight: 500; color: var(--faint); padding: 4px 8px; border-radius: 4px;
  cursor: pointer; transition: color .1s, background .1s;
}
.inspector-tab:hover { color: var(--fg); background: var(--bg3); }
.inspector-tab.active { color: var(--accent-fg); background: var(--bg3); font-weight: 600; }
.inspector-head-actions { display: flex; align-items: center; }
.inspector-head-actions button { font-size: 11px; padding: 2px 6px; }

.inspector-pane { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.inspector-pane.active { display: flex; }

.inspector-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px;
}
.inspector-sym-title {
  font-family: var(--mono); font-weight: 600; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inspector-badge {
  font: 10px var(--mono); color: var(--faint); background: var(--bg3);
  border-radius: 8px; padding: 1px 6px; flex: none;
}

/* call trail */
.calls-dir { display: flex; gap: 2px; flex: none; }
.cnode .car { width: 14px; flex: none; text-align: center; font-size: 9px; color: var(--faint); cursor: pointer; }
.cnode .car:hover { color: var(--fg); }
.cnode .car.cyc { cursor: default; font-size: 11px; }
.cnone { padding-block: 1px; padding-right: 10px; font-size: 11px; font-style: italic; color: var(--faint); }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
/* View-mode switches (Markdown Preview/Source, git Diff), pinned to the right
   of the tab bar. The bar pads its end so the last tab can scroll clear of them. */
#view-switches { position: absolute; top: 3px; right: 8px; z-index: 7; display: flex; gap: 6px; }
.view-switch {
  height: 22px; display: flex; gap: 1px;
  padding: 1px; background: var(--bg3); border: 1px solid var(--line); border-radius: 5px;
}
.view-switch button { padding: 0 9px; border-radius: 3px; font-size: 11px; line-height: 18px; color: var(--dim); }
.view-switch button:hover { color: var(--fg); }
.view-switch button.on { background: var(--bg); color: var(--accent-fg); font-weight: 600; }

/* Diff dropdown & view-mode menu */
.diff-seg { position: relative; display: flex; }
.diff-dropdown #diff-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px 0 7px;
}
.diff-dropdown #diff-btn .diff-btn-icon { flex: none; }
.diff-dropdown #diff-btn .diff-caret { flex: none; opacity: .7; transition: transform .15s ease; }
.diff-seg:hover #diff-btn .diff-caret { transform: rotate(180deg); }

.diff-menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 175px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.28));
  padding: 4px; z-index: 50; display: none; flex-direction: column; gap: 1px;
}
.diff-menu::before {
  content: ""; position: absolute; top: -6px; left: 0; right: 0; height: 6px;
}
.diff-seg:hover .diff-menu {
  display: flex; animation: diffMenuIn .1s ease-out;
}
@keyframes diffMenuIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.diff-menu-header {
  padding: 4px 8px 3px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--faint);
  border-bottom: 1px solid var(--line); margin-bottom: 3px;
}
.diff-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border-radius: 4px; border: 0; background: none;
  font-size: 11.5px; line-height: 1.3; color: var(--dim); cursor: pointer; text-align: left;
}
.diff-menu-item:hover { background: var(--bg3); color: var(--fg); }
.diff-menu-item.active { background: var(--bg3); color: var(--accent-fg); font-weight: 500; }
.diff-item-check {
  width: 12px; font-size: 11px; flex: none; text-align: center;
  color: var(--accent); visibility: hidden;
}
.diff-menu-item.active .diff-item-check { visibility: visible; }
.diff-item-content { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.diff-item-title { font-weight: 600; font-size: 11.5px; color: var(--fg); }
.diff-item-desc { font-size: 10px; color: var(--dim); margin-top: 1px; }
.diff-item-badge {
  font-size: 9px; padding: 1px 4px; border-radius: 3px; background: var(--bg4);
  color: var(--dim); margin-left: auto; text-transform: uppercase; letter-spacing: .04em;
}
.diff-menu-item.active .diff-item-badge { background: var(--accent); color: var(--on-accent); }

body.md-tab #tabs { padding-right: 140px; }
body.diff-tab #tabs { padding-right: 150px; }
body.md-tab.diff-tab #tabs { padding-right: 290px; }

#tabs { display: flex; height: 28px; background: var(--bg2); box-shadow: inset 0 -1px 0 var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs:empty { display: none; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; flex: none;
  border-right: 1px solid var(--line); color: var(--dim); cursor: pointer;
  font-size: 11.5px; max-width: 200px; position: relative; user-select: none;
  line-height: 28px; height: 28px;
  box-shadow: inset 0 -1px 0 var(--line);
  transition: background .1s ease, color .1s ease;
}
.tab:hover { background: var(--bg3); color: var(--fg); }
.tab.active {
  background: var(--bg); color: var(--fg); font-weight: 500;
  box-shadow: none;
}
.tab .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The close cross is drawn, not typed: a glyph's ink sits wherever the font puts
   it, which is below centre for x in most UI fonts. */
.tab .x { width: 15px; height: 15px; border-radius: 3px; display: grid; place-items: center; color: var(--faint); flex: none; }
.tab .x svg { width: 9px; height: 9px; display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.tab.active .x { color: var(--dim); }
.tab .x:hover { background: var(--bg4); color: var(--fg); }

#crumbs { display: none !important; }

/* ---------- the editor surface ---------- */
#editor { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
/* The whole surface takes the text cursor, not just the glyphs: past the end of a
   line and below the last one still read as places the caret can go. */
#viewport { position: absolute; inset: 0; overflow: auto; contain: strict; cursor: text; }
#sizer { position: relative; }
#rows { position: absolute; top: 0; left: 0; will-change: transform; }
/* Caret: an overlay positioned by measurement, never a node inside the code. */
#caret {
  position: absolute; top: 0; left: 0; z-index: 1; width: 2px; height: var(--lh);
  background: var(--accent); pointer-events: none; will-change: transform;
}
#caret.blink { animation: caret-blink 1.06s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #caret.blink { animation: none; } }

.row {
  display: flex; height: var(--lh);
  font: var(--fs)/var(--lh) var(--mono);
  font-feature-settings: "calt" 1, "zero" 1, "cv02" 1, "cv08" 1, "ss01" 1;
  font-variant-ligatures: normal;
}
.row.cur { background: var(--cur); }
.row.cur .g { color: var(--fg); }
.g {
  position: sticky; left: 0; z-index: 2; flex: none; text-align: right;
  width: calc(var(--gw, 1) * 1ch + 30px);
  padding: 0 14px 0 16px; color: var(--faint); background: var(--bg);
  user-select: none; cursor: pointer; font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.row.cur .g { background: var(--cur); }
.c { flex: 1; min-width: 0; white-space: pre; tab-size: 4; -moz-tab-size: 4; padding-right: 40px; }
/* Ctrl+A: the whole file is selected, shaded on whichever rows are rendered. */
#rows.all .c { background: var(--sel); }
/* Rows targeted by an open Edit with Agent composer or running edit */
.row.agent-sel,
.row.agent-sel .c { background: var(--sel); }
.row.agent-sel .g { color: var(--accent); font-weight: 600; }
.row.agent-sel.cur,
.row.agent-sel.cur .c { background: var(--sel); }

.diff-row.agent-sel .diff-code,
.diff-side.agent-sel .diff-code { background: var(--sel); }
.diff-row.agent-sel .diff-ln,
.diff-side.agent-sel .diff-ln { color: var(--accent); font-weight: 600; }
.c i { font-style: normal; }

/* Word wrap mode (Alt+Z) */
body.word-wrap .row { height: auto; min-height: var(--lh); }
body.word-wrap .g { align-self: flex-start; height: var(--lh); }
body.word-wrap .c { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }


/* Git gutter (normal file view): a thin bar on the line-number cell, VS Code
   style. Deletions get a small wedge straddling the row's bottom edge. */
.g.gut-add { box-shadow: inset 2px 0 0 var(--gi); }
.g.gut-mod { box-shadow: inset 2px 0 0 var(--accent); }
.row.gut-del .g::after {
  content: ""; position: absolute; left: 0; bottom: -3px; z-index: 3;
  border-left: 4px solid var(--gd);
  border-top: 3px solid transparent; border-bottom: 3px solid transparent;
}

.row mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 1px 0; }
/* The current match is a solid fill, so syntax colours on it are unreadable. */
.row mark.on, .row mark.on * { background: var(--mark-active); color: var(--on-mark-active); }
.row .occ { background: var(--bg4); border-radius: 2px; outline: 1px solid var(--line); }

/* ---------- diff view (Mod+D) ---------- */

/* Ctrl/Cmd-hover turns an identifier into a link, the way an editor does. */
.row .link {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
#viewport.linking, #viewport.linking * { cursor: pointer; }

/* ---------- hover card ---------- */
#hovercard {
  position: absolute; z-index: 30; max-width: min(620px, 72%);
  background: var(--bg3); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: var(--shadow); padding: 0; overflow: hidden;
  pointer-events: auto; animation: hcin .09s ease-out;
}
@keyframes hcin { from { opacity: 0; transform: translateY(-2px); } }
#hovercard .sig {
  font: var(--fs)/1.55 var(--mono); white-space: pre-wrap; word-break: break-word;
  padding: 9px 12px; background: var(--bg); border-bottom: 1px solid var(--line);
  max-height: 190px; overflow: hidden;
}
#hovercard .sig i { font-style: normal; }
#hovercard .sig .k{color:var(--k)} #hovercard .sig .kt{color:var(--kt)}
#hovercard .sig .nf{color:var(--nf)} #hovercard .sig .nc{color:var(--nc)}
#hovercard .sig .nb{color:var(--nb)} #hovercard .sig .nv{color:var(--nv)}
#hovercard .sig .no{color:var(--no)} #hovercard .sig .na{color:var(--na)}
#hovercard .sig .nt{color:var(--nt)} #hovercard .sig .nd{color:var(--nd)}
#hovercard .sig .s{color:var(--s)}  #hovercard .sig .m{color:var(--m)}
#hovercard .sig .o{color:var(--o)}  #hovercard .sig .p{color:var(--p)}
#hovercard .sig .c{color:var(--c);font-style:italic}
#hovercard .doc {
  padding: 9px 12px; font-size: 12.5px; line-height: 1.55; color: var(--dim);
  white-space: pre-wrap; max-height: 200px; overflow: hidden;
}
#hovercard .actions {
  display: flex; gap: 6px; padding: 6px 10px; background: var(--bg2);
  border-top: 1px solid var(--line); align-items: center;
}
#hovercard .actions button {
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
  font: 11px/1 var(--ui); padding: 4px 8px; border-radius: 4px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
#hovercard .actions button:hover {
  background: var(--bg4); color: var(--accent-fg); border-color: var(--accent);
}
#hovercard .actions button .btn-icon {
  font-size: 12px; opacity: 0.85;
}
#hovercard .foot {
  padding: 5px 12px; font: 10px var(--mono); color: var(--faint);
  border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center;
}
#hovercard .foot b { color: var(--dim); font-weight: 600; }

/* ---------- toast notification ---------- */
#toast {
  position: fixed; bottom: 36px; right: 20px; z-index: 1000;
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 6px 14px 6px 10px; border-radius: 7px;
  font: 12px/1.4 var(--ui); font-weight: 500; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none; user-select: none;
  animation: toastIn .16s ease-out;
  transform-origin: bottom right;
}
#toast.toast-hide {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .14s ease-in, transform .14s ease-in;
}
.toast-icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.toast-icon svg { display: block; }
/* --gi/--mark-active are the app's existing green/amber semantics (diff gutters,
   LSP state dot, .hint .warn) -- reused here so success/warn track the active
   theme instead of a fixed colour that can clash with it (or with itself: --s is
   the syntax "string" token, not a status colour, and drifts theme to theme). */
.toast-icon-ok {
  background: color-mix(in srgb, var(--gi) 18%, transparent);
  color: var(--gi);
}
.toast-icon-warn {
  background: color-mix(in srgb, var(--mark-active) 18%, transparent);
  color: var(--mark-active);
}
.toast-chip {
  font: 10px/1.2 var(--mono); color: var(--dim);
  background: var(--bg4); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .04em; flex: none;
}
.toast-msg {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}


/* token colours: the code view, and fenced code in the Markdown preview */
.c .k, .md-code .k{color:var(--k)} .c .kt, .md-code .kt{color:var(--kt)}
.c .nf, .md-code .nf{color:var(--nf)} .c .nc, .md-code .nc{color:var(--nc)}
.c .nb, .md-code .nb{color:var(--nb)} .c .nv, .md-code .nv{color:var(--nv)}
.c .no, .md-code .no{color:var(--no)} .c .na, .md-code .na{color:var(--na)}
.c .nt, .md-code .nt{color:var(--nt)} .c .nd, .md-code .nd{color:var(--nd)}
.c .np, .md-code .np{color:var(--np)} .c .s, .md-code .s{color:var(--s)}
.c .m, .md-code .m{color:var(--m)} .c .o, .md-code .o{color:var(--o)} .c .p, .md-code .p{color:var(--p)}
.c .c, .md-code .c{color:var(--c);font-style:italic} .c .cp, .md-code .cp{color:var(--cp)}
.c .gi, .md-code .gi{color:var(--gi);background:var(--gi-bg)} .c .gd, .md-code .gd{color:var(--gd);background:var(--gd-bg)}
.c .gh, .md-code .gh{color:var(--accent-fg);font-weight:600} .c .ge, .md-code .ge{font-style:italic} .c .gs, .md-code .gs{font-weight:600}
.c .err, .md-code .err{color:var(--err);text-decoration:underline wavy}

/* ---------- diff view (Mod+D): split (default) or unified render of a
   modified file's git diff against HEAD, in its own overlay like the
   Markdown preview -- not virtualized, since a single file's diff is small. */
#diffview { position: absolute; inset: 0; overflow: auto; background: var(--bg); }
#diffcontent { font: var(--fs)/var(--lh) var(--mono); padding-bottom: 40vh; }
.diff-empty { padding: 24px 16px; color: var(--faint); font: 12px/1.4 var(--ui); }
.diff-hunk-head {
  position: sticky; top: 0; z-index: 1; padding: 4px 12px;
  color: var(--accent-fg); background: var(--bg3);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 12px; white-space: pre;
}
.diff-hunk-head:first-child { border-top: none; }
.diff-ln {
  flex: none; width: 48px; padding: 0 10px 0 6px; text-align: right;
  color: var(--faint); user-select: none; font-variant-numeric: tabular-nums;
}
.diff-mk { flex: none; width: 14px; text-align: center; color: var(--faint); user-select: none; }
.diff-code { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; padding-right: 12px; }
.diff-row, .diff-side { display: flex; }
.diff-row.diff-add, .diff-side.diff-add { background: var(--gi-bg); }
.diff-row.diff-add .diff-code, .diff-side.diff-add .diff-mk { color: var(--gi); }
.diff-row.diff-del, .diff-side.diff-del { background: var(--gd-bg); }
.diff-row.diff-del .diff-code, .diff-side.diff-del .diff-mk { color: var(--gd); }
.diff-side.diff-blank { background: var(--bg2); }
/* Split: deletions and additions paired side by side, each half its own mini-row. */
.diff-row-pair { display: flex; }
.diff-side { flex: 1 1 50%; min-width: 0; }
.diff-side-left { border-right: 1px solid var(--line); }

/* ---------- markdown preview ---------- */
#mdview { position: absolute; inset: 0; overflow: auto; background: var(--bg); }
.md {
  max-width: 860px; margin: 0 auto; padding: 40px clamp(20px, 6%, 56px) 40vh;
  font: 15px/1.7 var(--ui); color: var(--fg); overflow-wrap: break-word;
}
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md dl, .md table, .md details, .md blockquote, .md .md-pre { margin: 0 0 16px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 32px 0 16px; font-weight: 600; line-height: 1.3; }
.md h1 { font-size: 2em; letter-spacing: -.01em; }
.md h2 { font-size: 1.5em; }
.md h1, .md h2 { padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.25em; }
.md h4 { font-size: 1.05em; }
.md h5 { font-size: .95em; }
.md h6 { font-size: .9em; color: var(--dim); }
.md a { color: var(--accent-fg); text-decoration: none; }
.md a:hover { text-decoration: underline; text-underline-offset: 3px; }
.md strong, .md b { font-weight: 600; }
.md hr { height: 1px; margin: 28px 0; border: 0; background: var(--line); }
.md ul, .md ol { padding-left: 2em; }
.md li + li, .md li > ul, .md li > ol { margin-top: 4px; }
.md li > ul, .md li > ol, .md li > p { margin-bottom: 0; }
.md li:has(> input[type="checkbox"]), .md li:has(> p > input[type="checkbox"]) { list-style: none; }
.md input[type="checkbox"] { margin: 0 .5em 0 -1.4em; vertical-align: -1px; accent-color: var(--accent); }
.md blockquote { padding: 0 1em; color: var(--dim); border-left: 3px solid var(--line); }
.md blockquote > :last-child { margin-bottom: 0; }
.md code, .md samp, .md tt { font-family: var(--mono); font-size: .86em; }
.md :not(pre) > code { padding: .15em .4em; border-radius: 4px; background: var(--bg3); }
.md kbd { font-size: .78em; }
.md .md-pre { position: relative; }
.md pre {
  margin: 0; padding: 14px 16px; overflow: auto; tab-size: 4; -moz-tab-size: 4;
  font: 13px/1.6 var(--mono); font-feature-settings: "calt" 1, "zero" 1;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
}
.md pre code { font: inherit; white-space: pre; }
.md pre i { font-style: normal; }
/* The fence's language sits in the corner and gives way to the copy button on hover. */
.md-pre[data-lang]::before {
  content: attr(data-lang); position: absolute; top: 8px; right: 12px; pointer-events: none;
  font: 10.5px/1 var(--mono); letter-spacing: .04em; color: var(--faint); transition: opacity .12s;
}
.md-pre:hover::before { opacity: 0; }
.md-copy {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 5px;
  display: grid; place-items: center; color: var(--dim);
  background: var(--bg3); border: 1px solid var(--line); opacity: 0; transition: opacity .12s;
}
.md-pre:hover .md-copy, .md-copy:focus-visible { opacity: 1; }
.md-copy:hover { color: var(--fg); border-color: var(--accent); }
.md-copy svg { display: block; }
.md table { display: block; width: max-content; max-width: 100%; overflow: auto; border-collapse: collapse; font-size: .94em; }
.md th, .md td { padding: 6px 13px; border: 1px solid var(--line); }
.md th { font-weight: 600; background: var(--bg2); }
.md img { max-width: 100%; vertical-align: middle; }
.md [align="center"] { text-align: center; }
.md [align="right"] { text-align: right; }
.md img[align="right"] { float: right; margin-left: 16px; }
.md img[align="left"] { float: left; margin-right: 16px; }
.md summary { cursor: pointer; }
.md details[open] > summary { margin-bottom: 8px; }
.md dt { font-weight: 600; }
.md dd { margin: 0 0 8px 1.5em; }
.md mark { background: var(--mark); color: inherit; border-radius: 2px; }
.md mark.md-hit.on, .md mark.md-hit.on * { background: var(--mark-active); color: var(--on-mark-active); }
.md .footnotes { margin-top: 40px; font-size: .88em; color: var(--dim); }
/* GitHub alerts: > [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] */
.md-alert { --alert: var(--accent); }
.md-alert-tip { --alert: var(--gi); }
.md-alert-important { --alert: var(--nc); }
.md-alert-warning { --alert: var(--mark-active); }
.md-alert-caution { --alert: var(--err); }
.md blockquote.md-alert { padding: 8px 16px; color: var(--fg); border-left-color: var(--alert); }
.md .md-alert-title { margin: 0 0 4px; font-weight: 600; color: var(--alert); }

#imgview { position: absolute; inset: 0; display: grid; place-items: center; overflow: auto; padding: 32px; }
#imgview img { max-width: 100%; image-rendering: pixelated; box-shadow: var(--shadow); background: repeating-conic-gradient(var(--bg3) 0 25%, transparent 0 50%) 0 0/16px 16px; }

#empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); }
.empty-inner { text-align: center; color: var(--faint); }
.empty-logo { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin-bottom: 28px; }
.empty-logo img { width: 130px; height: auto; }
/* Logo variants: the dark one by default, the light one on light themes. */
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark,
:root[data-theme="catppuccin-latte"] .logo-dark,
:root[data-theme="gruvbox-light"] .logo-dark,
:root[data-theme="solarized-light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light,
:root[data-theme="catppuccin-latte"] .logo-light,
:root[data-theme="gruvbox-light"] .logo-light,
:root[data-theme="solarized-light"] .logo-light { display: block; }
.empty-inner dl { display: grid; grid-template-columns: auto auto; gap: 9px 16px; align-items: center; font-size: 12.5px; }
.empty-inner dt { text-align: right; display: flex; gap: 3px; justify-content: flex-end; }
.empty-inner dd { margin: 0; text-align: left; color: var(--dim); }
kbd {
  font: 10.5px/1 var(--mono); padding: 4px 6px; border: 1px solid var(--line);
  border-radius: 4px; background: var(--bg3); color: var(--dim);
}

/* ---------- find bar ---------- */
#findbar {
  position: absolute; top: 8px; right: 22px; z-index: 20; display: flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 5px 4px 10px; box-shadow: var(--shadow);
}
#find-input { width: 190px; font-size: 12.5px; }
#find-count { font: 11px var(--mono); color: var(--faint); min-width: 4.5em; text-align: right; }
#findbar button { width: 22px; height: 22px; border-radius: 4px; color: var(--dim); display: grid; place-items: center; font-size: 12px; }
#findbar button:hover { background: var(--bg4); color: var(--fg); }

/* ---------- agent edit composer ----------
   #agentbox stacks one box per edit currently in flight or being composed,
   newest closest to the corner it grows from. */
#agentbox {
  position: absolute; bottom: 10px; right: 22px; z-index: 22; width: 360px; max-width: calc(100% - 32px);
  display: flex; flex-direction: column-reverse; gap: 8px;
}
#agentbox[hidden] { display: none; }
.agent-box {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; box-shadow: var(--shadow);
}
.agent-head { display: flex; align-items: center; gap: 6px; font: 11.5px var(--mono); color: var(--fg); }
.agent-foot { display: flex; align-items: center; gap: 6px; font: 11px var(--mono); color: var(--faint); }
.agent-head .grow { flex: 1; min-width: 0; }
.agent-ref { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.agent-close { color: var(--faint); width: 18px; height: 18px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.agent-close:hover:not(:disabled) { background: var(--bg4); color: var(--fg); }
.agent-close:disabled { opacity: .35; cursor: default; }

/* Dedicated metadata row in composer: harness & model dropdowns */
.agent-meta {
  display: flex; align-items: center; gap: 6px;
  padding: 1px 0 2px;
}
.agent-meta-label {
  font: 600 10px/1 var(--ui); letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); flex: none;
}
.agent-harness-select,
.agent-model-select {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 4px;
  font: 11px/1.2 var(--mono); padding: 3px 6px; outline: none;
  cursor: pointer; transition: border-color .15s ease;
}
.agent-harness-select {
  flex: none; max-width: 42%; font-weight: 600; color: var(--accent);
}
.agent-model-select {
  flex: 1; min-width: 0; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.agent-harness-select:hover:not(:disabled),
.agent-model-select:hover:not(:disabled) {
  border-color: var(--accent);
}
.agent-harness-select:focus,
.agent-model-select:focus {
  border-color: var(--accent);
}
.agent-harness-select:disabled,
.agent-model-select:disabled {
  opacity: .5; cursor: default;
}

.agent-input {
  width: 100%; resize: vertical; min-height: 54px;
  font: 12.5px var(--mono); color: var(--fg); line-height: 1.45;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 7px;
}
.agent-input:focus { outline: none; border-color: var(--accent); }
.agent-compose { display: flex; flex-direction: column; gap: 6px; }

.agent-pick { display: flex; flex-direction: column; gap: 4px; }
.agent-pick .hint { padding: 0 0 2px; font: 11px var(--ui); color: var(--faint); }
.agent-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 5px 7px; border-radius: 4px; text-align: left; width: 100%;
  background: var(--bg); border: 1px solid var(--line);
}
.agent-opt:hover { border-color: var(--accent); }
.agent-opt.on { border-color: var(--accent); }
.agent-opt-name { font: 12px var(--ui); color: var(--fg); font-weight: 600; }
.agent-opt-cmd {
  font: 10.5px var(--mono); color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.agent-opt-wrap { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.agent-model-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 4px 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; font: 11px var(--ui); color: var(--dim);
}
.agent-model-label { font-weight: 500; font-size: 11px; }
.agent-note { font: 10px var(--mono); color: var(--dim); overflow-wrap: anywhere; }
.agent-hint { flex: 1; }
.agent-err {
  display: flex; flex-direction: column; gap: 3px;
  font: 11px/1.4 var(--mono); background: var(--bg);
  border: 1px solid var(--err); border-radius: 4px; padding: 6px 8px;
  max-height: 220px; overflow-y: auto;
}
.agent-err[hidden] { display: none; }
.agent-err-msg { color: var(--err); white-space: pre-wrap; overflow-wrap: anywhere; }
.agent-err-label { margin-top: 4px; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.agent-err-out {
  margin: 0; font: inherit; color: var(--dim);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.agent-err:empty { display: none; }
.agent-box.busy .agent-input { opacity: .6; }
.agent-box.busy .agent-meta select { opacity: .5; }
.agent-box.busy .agent-hint {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent-fg); font-weight: 500;
}
.agent-box.busy .agent-hint::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mark-active); animation: pulse 1.1s ease-in-out infinite;
  flex: none;
}
.agent-send {
  padding: 3px 10px; border-radius: 4px; font: 11px var(--ui); font-weight: 600;
  background: var(--accent); color: var(--bg);
}
.agent-send:hover { opacity: .88; }
.agent-cancel {
  padding: 3px 9px; border-radius: 4px; font: 11px var(--ui); font-weight: 600;
  background: transparent; border: 1px solid var(--err); color: var(--err);
  cursor: pointer; transition: all .15s ease;
}
.agent-cancel:hover { background: var(--err); color: #fff; }
/* .footer-btn sets display, which would otherwise win over the hidden attribute. */
.footer-btn[hidden] { display: none; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.85); } }

/* ---------- status ---------- */
#status { height: 24px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 10px; background: var(--bg2); border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--faint); user-select: none; white-space: nowrap; overflow: hidden; }
/* Nothing shrinks or wraps: an overflowing bar is what tells fitStatus() to shed detail. */
#status > * { flex: none; }
#status > .grow { flex: 1; }
/* Shed in steps as the bar narrows; the classes accumulate, so each step keeps the ones before. */
#status.fit-1 .footer-kbd,
#status.fit-2 #st-size,
#status.fit-3 .metric-label,
#status.fit-4 [data-action="wrap"], #status.fit-4 [data-action="help"], #status.fit-4 .sel-chip, #status.fit-4 #sel-stats,
#status.fit-5 #st-metrics,
#status.fit-6 #st-lsp { display: none; }
#footer-actions { display: flex; align-items: center; gap: 3px; }
.footer-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; height: 18px; border-radius: 3px;
  font: 11px var(--ui); color: var(--fg); opacity: 0.82;
  transition: opacity .12s, background .12s, color .12s;
}
.footer-btn:hover {
  opacity: 1; background: var(--bg4); color: var(--accent-fg);
}
.footer-btn.active {
  color: var(--accent-fg); background: var(--bg4); opacity: 1;
}
.footer-btn-icon {
  padding: 0 4px; display: inline-flex; align-items: center; justify-content: center;
}
.footer-btn-icon svg { display: block; }
.footer-btn-label { font-weight: 500; font-size: 11px; }
.footer-kbd {
  display: inline-flex; align-items: center; gap: 1px;
  font: 9.5px var(--mono); color: var(--faint);
  background: var(--bg); border: 1px solid var(--line);
  padding: 0 3px; border-radius: 3px; line-height: 12px;
}
.footer-btn:hover .footer-kbd {
  color: var(--fg); border-color: var(--accent);
}
.status-sep { width: 1px; height: 12px; background: var(--line); flex: none; }

/* Selection mode: the left of the bar swaps to actions on the selected code.
   The accent edge and chip make the swap noticeable at the bottom of the screen. */
#footer-sel { display: none; align-items: center; gap: 8px; min-width: 0; }
#status.selecting { border-top-color: var(--accent); }
#status.selecting #footer-sel { display: flex; animation: sel-in .12s ease-out; }
#status.selecting > #footer-actions,
#status.selecting > #footer-actions + .status-sep,
#status.selecting > #st-size { display: none; }
@keyframes sel-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #status.selecting #footer-sel { animation: none; } }
.sel-chip {
  flex: none; font: 600 9.5px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase;
  color: var(--on-accent); background: var(--accent); padding: 3px 6px; border-radius: 3px;
}
#sel-stats { display: none; white-space: nowrap; }
#status.selecting #sel-stats { display: inline-flex; }
#footer-sel .footer-btn { flex: none; }

/* Right-click menu on a selection: the footer's actions at the pointer. */
#sel-menu {
  position: fixed; z-index: 70; min-width: 190px;
  display: flex; flex-direction: column; gap: 1px; padding: 4px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  user-select: none;
}
#sel-menu[hidden] { display: none; }
.sel-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 5px 8px; border-radius: 4px; text-align: left;
  font: 12px var(--ui); color: var(--fg);
}
.sel-menu-item:hover { background: var(--bg4); color: var(--accent-fg); }
.sel-menu-item:hover .footer-kbd { color: var(--fg); border-color: var(--accent); }
#st-lsp { display: flex; align-items: center; gap: 5px; }
#st-lsp::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint); flex: none;
}
#st-lsp[data-state="ready"]::before { background: var(--gi); }
#st-lsp[data-state="indexing"]::before,
#st-lsp[data-state="starting"]::before { background: var(--mark-active); animation: pulse 1.1s ease-in-out infinite; }
#st-lsp[data-state="failed"]::before { background: var(--gd); }
#st-lsp[data-state="missing"], #st-lsp[data-state="failed"] { cursor: pointer; }
#st-lsp[data-state="missing"]:hover, #st-lsp[data-state="failed"]:hover { color: var(--accent-fg); }

/* ---------- language server setup (calls pane) ---------- */
.lsp-setup { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.55; color: var(--dim); }
.lsp-setup p { margin: 0; }
.lsp-setup b { color: var(--fg); font-weight: 600; }
.lsp-setup code { font: 11px var(--mono); color: var(--fg); }
.lsp-server { border: 1px solid var(--line); border-radius: 6px; background: var(--bg); overflow: hidden; }
.lsp-name { padding: 5px 10px; font: 600 11.5px var(--mono); color: var(--fg); border-bottom: 1px solid var(--line); }
.lsp-opt { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.lsp-opt + .lsp-opt { border-top: 1px solid var(--line); }
.lsp-opt code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lsp-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.lsp-need { font-size: 11px; color: var(--faint); white-space: nowrap; }
.lsp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lsp-btn {
  font: 11px/1 var(--ui); padding: 4px 8px; border-radius: 4px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--bg2); color: var(--fg);
}
.lsp-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-fg); }
.lsp-btn.primary, .lsp-btn.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lsp-btn:disabled { opacity: .5; cursor: default; }
.lsp-job { padding: 6px 10px; border-top: 1px solid var(--line); font-size: 11.5px; }
.lsp-job.err, .lsp-reason { color: var(--err); }
.lsp-job pre {
  margin: 6px 0 0; max-height: 160px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font: 10.5px/1.45 var(--mono); color: var(--dim);
}
#status span:empty:not(.grow) { display: none; }
.status-metrics {
  display: inline-flex; align-items: center; gap: 6px;
  font: 11px var(--mono); color: var(--fg); opacity: 0.88;
  padding: 1px 6px; border-radius: 3px; background: var(--bg3);
  border: 1px solid var(--line); cursor: pointer; user-select: none;
  transition: border-color .15s ease, opacity .15s ease;
}
.metric-divider { color: var(--faint); }
.status-metrics:hover, .status-metrics:focus-visible { opacity: 1; border-color: var(--accent); }

#metrics-menu {
  position: fixed; z-index: 70; min-width: 220px;
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  user-select: none; animation: toastIn .18s ease-out;
}
#metrics-menu[hidden] { display: none; }
.metrics-title {
  font: 600 11px/1.2 var(--ui); color: var(--fg);
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
  letter-spacing: .02em; text-transform: uppercase;
}
.metrics-grid {
  display: flex; flex-direction: column; gap: 5px;
}
.metrics-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  font: 11.5px/1.4 var(--ui);
}
.metrics-label {
  color: var(--dim);
}
.metrics-val {
  font: 11.5px/1.4 var(--mono); color: var(--fg); font-weight: 500;
}
.status-ver {
  font: 11px var(--mono); color: var(--dim); cursor: pointer;
  padding: 1px 4px; border-radius: 3px;
}
.status-ver:hover { color: var(--accent-fg); background: var(--bg4); }

/* ---------- palette ---------- */
#overlay {
  position: fixed; inset: 0; background: var(--scrim);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; justify-content: center; padding-top: 9vh; z-index: 100;
}
#palette {
  width: min(680px, 92vw); max-height: 74vh; background: var(--bg3);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.pal-input { display: flex; align-items: center; gap: 8px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
#pal-mode { font: 600 10px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--on-badge); background: var(--accent); border-radius: 4px; padding: 4px 7px; flex: none; }
#pal-mode:empty { display: none; }
#pal { flex: 1; font-size: 14.5px; font-family: var(--mono); }
#pal-list { overflow: auto; flex: 1; padding: 4px 0; }
#pal-hint { padding: 8px 18px; border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); }
#pal-hint:empty { display: none; }
.pi { display: flex; align-items: baseline; gap: 10px; padding: 7px 18px; cursor: pointer; white-space: nowrap; border-radius: 6px; margin: 1px 6px; }
.pi.sel { background: var(--sel); }
.pi .pn { font-size: 13.5px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 48%; }
.pi .pp { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.pi .pr { margin-left: auto; font: 10.5px var(--mono); color: var(--faint); flex: none; }
.pi b { color: var(--accent-fg); font-weight: 600; }
.pi.sel .pp { color: var(--dim); }

/* ---------- help sheet ---------- */
#helpsheet {
  position: fixed; inset: 0; background: var(--scrim);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 110; display: grid; place-items: center;
}
.help-card { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 24px 28px; max-height: 82vh; overflow: auto; }
.help-header { display: flex; align-items: baseline; gap: 8px; margin: 0 0 16px; }
.help-header h2 { margin: 0; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.help-version { font: 11px var(--mono); color: var(--accent-fg); background: var(--bg4); padding: 2px 6px; border-radius: 4px; }
#empty-ver { font: 12px var(--mono); color: var(--accent-fg); opacity: 0.8; padding-bottom: 3px; }
.help-grid { display: grid; grid-template-columns: repeat(2, auto auto); gap: 8px 18px; align-items: center; font-size: 12.5px; }
.help-grid dt { display: flex; gap: 3px; justify-content: flex-end; align-items: center; }
.key-or { color: var(--faint); margin: 0 3px; font-size: 11px; }
.help-grid dd { margin: 0 22px 0 0; color: var(--dim); }

#measure { position: absolute; visibility: hidden; font: var(--fs)/var(--lh) var(--mono); white-space: pre; top: -999px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--bg4) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- match minimap ---------- */
#minimap-hits { position: absolute; top: 0; right: 0; bottom: 0; width: 12px; pointer-events: auto; z-index: 6; }
#minimap-hits:empty { pointer-events: none; }
#minimap-hits i { position: absolute; right: 2px; width: 8px; height: 2px; background: var(--mark-active); border-radius: 1px; opacity: .85; }

body.hide-lines .g { display: none !important; }
.c, .diff-code, .md pre code { tab-size: var(--tab-size, 4); }

/* Caret styles */
body.cursor-block #caret { width: var(--cw, 8.5px) !important; opacity: 0.65; }
body.cursor-underline #caret { width: var(--cw, 8.5px) !important; height: 2px !important; margin-top: calc(var(--lh) - 2px); }
body.cursor-blink-solid #caret { animation: none !important; }
body.cursor-blink-smooth #caret.blink { animation: caret-blink-smooth 1s ease-in-out infinite; }
@keyframes caret-blink-smooth { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Line highlight */
body.no-line-highlight .row.cur, body.no-line-highlight .row.cur .g { background: transparent !important; }

/* Scroll beyond last line */
body.no-scroll-beyond #sizer { padding-bottom: 0 !important; }

/* Git gutter */
body.hide-git-gutter .g-git, body.hide-git-gutter [class*="git-"] { display: none !important; }

.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 120; display: grid; place-items: center;
}

/* ---------- settings modal ---------- */
.settings-dialog {
  width: min(1180px, 95vw);
  height: min(840px, 92vh);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg3);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.settings-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-title-group h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.settings-path-badge {
  font: 11px var(--mono);
  color: var(--dim);
  background: var(--bg4);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-path-badge:hover {
  color: var(--accent-fg);
  background: var(--sel);
}
.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-mode-switch {
  display: inline-flex;
  background: var(--bg4);
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}
.settings-mode-switch button {
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 3px;
  color: var(--dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.settings-mode-switch button:hover {
  color: var(--fg);
}
.settings-mode-switch button.active {
  background: var(--accent);
  color: var(--on-badge);
  font-weight: 600;
}
.settings-close-btn {
  font-size: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  border-radius: 4px;
}
.settings-close-btn:hover {
  color: var(--fg);
  background: var(--bg4);
}

.settings-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.settings-search-icon {
  color: var(--dim);
  flex: none;
}
#settings-search {
  flex: 1;
  font-size: 13px;
  color: var(--fg);
  padding: 4px 0;
  background: transparent;
  border: 0;
  outline: none;
}
#settings-search::placeholder {
  color: var(--faint);
}

.settings-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.settings-nav {
  width: 220px;
  flex: none;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 8px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.settings-nav-item {
  text-align: left;
  padding: 7px 16px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color 0.12s, background 0.12s;
}
.settings-nav-item:hover {
  color: var(--fg);
  background: var(--bg3);
}
.settings-nav-item.active {
  color: var(--accent-fg);
  background: var(--bg3);
  border-left-color: var(--accent);
  font-weight: 600;
}

.settings-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

.settings-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
  transition: border-color 0.15s;
}
.settings-card.is-modified {
  border-left: 3px solid var(--accent);
}
.settings-card-left {
  flex: 1;
  min-width: 0;
}
.settings-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.settings-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
}
.settings-card-key {
  font: 11px var(--mono);
  color: var(--dim);
}

/* Badges & Tags */
.settings-tag {
  display: inline-flex;
  align-items: center;
  font: 11px var(--mono);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg4);
  color: var(--dim);
  border: 1px solid transparent;
}
.settings-tag.tag-cat {
  background: var(--sel);
  color: var(--accent-fg);
  font-family: var(--ui);
  font-weight: 500;
  font-size: 10.5px;
}
.settings-tag.tag-type {
  background: var(--bg2);
  color: var(--faint);
  border: 1px solid var(--line);
  font-size: 10px;
}
.settings-tag.tag-current {
  background: var(--sel);
  color: var(--fg);
  border: 1px solid var(--accent);
}
.settings-tag.tag-current b {
  color: var(--accent-fg);
  margin-left: 3px;
}
.settings-tag.tag-default {
  color: var(--dim);
}
.settings-tag.tag-default code {
  font-family: var(--mono);
  color: var(--fg);
  margin-left: 2px;
}
.settings-tag.tag-modified {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-fg);
  font-weight: 600;
  border: 1px solid var(--accent);
}
.settings-tag.tag-range,
.settings-tag.tag-step {
  font-size: 10.5px;
  background: var(--bg2);
  border: 1px solid var(--line);
}
.settings-tag.tag-range b,
.settings-tag.tag-step b {
  color: var(--fg);
  margin-left: 2px;
}

/* Apt / Allowed Values bar */
.settings-apt-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0;
  font-size: 11.5px;
}
.settings-apt-label {
  font-size: 11px;
  color: var(--faint);
  font-family: var(--ui);
  margin-right: 2px;
}
.settings-apt-pills {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.settings-pill-tag {
  font: 11px var(--mono);
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg2);
  color: var(--dim);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}
.settings-pill-tag:hover {
  background: var(--bg4);
  color: var(--fg);
  border-color: var(--accent);
}
.settings-pill-tag.active {
  background: var(--accent);
  color: var(--on-badge);
  border-color: var(--accent);
  font-weight: 600;
}

.settings-card-desc {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.4;
  margin-bottom: 6px;
}
.settings-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  margin-top: 4px;
}
.settings-default-hint {
  color: var(--faint);
}
.settings-default-hint code {
  font-family: var(--mono);
  color: var(--dim);
  background: var(--bg4);
  padding: 1px 4px;
  border-radius: 3px;
}
.settings-reset-btn {
  font-size: 11px;
  color: var(--accent-fg);
  background: var(--bg4);
  padding: 2px 7px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s;
}
.settings-reset-btn:hover {
  background: var(--sel);
}

.settings-card-right {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 140px;
}

/* Controls */
.settings-input {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  font: 12.5px var(--mono);
  color: var(--fg);
  width: 220px;
}
.settings-input:focus {
  border-color: var(--accent);
}
.settings-input-num {
  width: 90px;
}
.settings-select {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  font: 12px var(--ui);
  color: var(--fg);
  min-width: 140px;
  cursor: pointer;
  outline: none;
}
.settings-select:focus {
  border-color: var(--accent);
}

/* VS Code style toggle switch */
.settings-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.settings-slider {
  position: absolute;
  inset: 0;
  background-color: var(--bg4);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: .15s ease;
}
.settings-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--dim);
  border-radius: 50%;
  transition: .15s ease;
}
.settings-switch input:checked + .settings-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}
.settings-switch input:checked + .settings-slider:before {
  transform: translateX(16px);
  background-color: var(--on-badge);
}

/* JSON view */
.settings-json-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}
.settings-json-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
}
.settings-json-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-btn-primary {
  background: var(--accent);
  color: var(--on-badge);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}
.settings-btn-primary:hover {
  opacity: 0.9;
}
.settings-btn-secondary {
  background: var(--bg4);
  color: var(--fg);
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.settings-btn-secondary:hover {
  background: var(--line);
}
.settings-error-banner {
  padding: 8px 18px;
  background: rgba(220, 38, 38, 0.15);
  color: var(--err, #ef4444);
  font-size: 12px;
  border-bottom: 1px solid rgba(220, 38, 38, 0.3);
}
.settings-error-banner.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--s, #22c55e);
  border-bottom-color: rgba(34, 197, 94, 0.3);
}
#settings-raw-editor {
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  font: 13px/1.5 var(--mono);
  color: var(--fg);
  background: var(--bg);
  border: 0;
  outline: none;
  resize: none;
  tab-size: 2;
}

