:root {
  --bg: #faf9f7; --panel: #ffffff; --ink: #2b2a28; --muted: #8a8580;
  --accent: #8d2f23; --accent-soft: #f6e8e5; --border: #e5e1db;
  --mark: #ffe9a8; --ok: #3a7d44;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  display: flex; flex-direction: column; font-size: 15px;
}
header {
  display: flex; align-items: baseline; gap: 14px; padding: 10px 18px 0;
}
header h1 { font-size: 18px; margin: 0; letter-spacing: .5px; }
header h1 span { color: var(--accent); }
#stats { color: var(--muted); font-size: 12px; }
#controls {
  display: flex; gap: 8px; padding: 10px 18px; align-items: center; flex-wrap: wrap;
}
#q {
  flex: 1; min-width: 280px; font-size: 17px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
  font-family: inherit;
}
#q:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
select, #chapters, button {
  font-size: 14px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel); color: var(--ink); font-family: inherit;
}
#chapters { width: 130px; }
button { cursor: pointer; }
#go { background: var(--accent); color: #fff; border-color: var(--accent); padding: 8px 18px; }
main { flex: 1; display: flex; min-height: 0; padding: 0 18px 14px; position: relative; }   /* relative = containing block for the drag grips + drop-zone overlay */
/* Split.js inserts these draggable bars between the <main> columns. The lib ships
   no CSS of its own, so the look is ours: a slim track that lights up on hover.
   The gutters ARE the column spacing — don't add a `gap` on <main>, it would double up. */
.gutter { background: var(--border); border-radius: 5px; transition: background .15s; }
.gutter:hover { background: var(--accent); }
.gutter.gutter-horizontal { cursor: col-resize; }
.gutter.gutter-vertical { cursor: row-resize; }
/* a column that stacks TWO panels top→bottom: a flex column whose children's heights are driven by the inner
   vertical Split (flex-basis). min-height:0 on the children lets them shrink below content (the overflow:auto
   panels need this, same role min-width:0 plays for the horizontal columns). */
.colstack { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.colstack > * { min-height: 0; }
/* a labeled drag HEADER bar capping each panel (absolute child of <main>, so it survives realize()'s reparenting +
   the #results innerHTML churn). Drag it to rearrange the panel; the panels reserve top padding so it never overlaps. */
.panelbar { position: absolute; z-index: 40; height: 26px; box-sizing: border-box;
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0; cursor: grab; user-select: none; transition: background .12s, color .12s; }
.panelbar:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging .panelbar { pointer-events: none; }            /* bars stay VISIBLE during a drag (they reflow with the panels) — just suppress the hover highlight */
#scriptpanel, #results, #detail { padding-top: 26px; }       /* reserve space for the absolute .panelbar header */
body.solo #scriptpanel, body.solo #results, body.solo #detail { padding-top: 0; }   /* a solo window has no bar */
.dragsrc { opacity: .55; }                                  /* the panel currently being dragged, dimmed */
/* the drop OUTLINE: shows exactly where the dragged panel will land (panelTargetRect = real proportions). Nothing
   in the layout moves until release; only this box tracks + fades, so a rearrange is previewed, never a surprise. */
.dropzone { position: absolute; z-index: 50; pointer-events: none; border-radius: 10px; opacity: 0;
  background: color-mix(in srgb, var(--accent) 13%, transparent); border: 2px solid var(--accent);
  transition: left .15s ease, top .15s ease, width .15s ease, height .15s ease, opacity .12s ease; }
#scriptpanel {
  flex: 0 0 30%; min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
#scripthead {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
#scripthead .lbl { font-size: 12px; color: var(--muted); flex: 1; }
.uploadbtn {
  background: var(--accent); color: #fff; border-color: var(--accent);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
#scriptlist { flex: 1; overflow-y: auto; padding: 6px 8px; }
.cue { padding: 5px 8px; border-radius: 6px; cursor: pointer; line-height: 1.7; }
.cue:hover { background: #fdf8ef; }
.cuespk {
  color: var(--ink); font-size: 12px; font-weight: 600; margin-right: 6px;
  border-radius: 3px; padding: 0 4px; cursor: pointer;
}
.cuespk.unknown { background: var(--border); }        /* unknown speaker only: neutral chip so you still see who's talking */
/* hover indicator: known speakers get it on the inner name mark; unknown chips
   (no inner mark) get it on the chip itself — never both, or you see a double box */
.cuespk.unknown:hover { outline: 2px solid var(--accent); }
/* the NAME inside the label still gets the blue mark.term.name on top; the OS/VO tag stays plain */
.mdot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;            /* indicator only, not a button */
}
.mdot.m-strong { background: var(--ok); }       /* verbatim line in the novel */
.mdot.m-loose { background: #d9a441; }           /* partial / paraphrase */
#scriptlegend {
  font-size: 11px; color: var(--muted); padding: 6px 10px;
  border-bottom: 1px solid var(--border); line-height: 1.9;
}
#scriptlegend .sw { padding: 0 4px; border-radius: 3px; color: var(--ink); }
#scriptlegend .sw.gold { background: var(--mark); }
#scriptlegend .sw.peach { background: #ffd6c4; }
#scriptlegend .sw.name { background: #d8e6ff; }
#scriptlegend .sw.draft { background: transparent; border-bottom: 2px dashed #c9a23a; border-radius: 0; }
#scriptlegend .mdot { cursor: default; }
#scriptlist mark.term {
  background: var(--mark); border-radius: 3px; padding: 0 1px; cursor: pointer;
}
#scriptlist mark.term.coined { background: #ffd6c4; }   /* coined LotM word (vs reworded sense) */
#scriptlist mark.term.name { background: #d8e6ff; }     /* character / place name */
/* unreviewed (candidate) terms: NO solid fill, a dashed underline instead -- so a vetted
   (confirmed) term reads as a filled highlight and a raw mined suggestion as a dashed draft.
   The underline keeps the category colour (gold default / blue name / peach coined). */
#scriptlist mark.term.cand { background: transparent; border-bottom: 2px dashed #c9a23a; border-radius: 0; }
#scriptlist mark.term.cand.name { border-bottom-color: #6f9bff; }
#scriptlist mark.term.cand.coined { border-bottom-color: #e08a5a; }
#scriptlist mark.term:hover { outline: 2px solid var(--accent); }
#results { flex: 1; overflow-y: auto; min-width: 0; }
#detail {
  flex: 0 0 42%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  display: none; flex-direction: column; min-width: 0;
}
#detail.open { display: flex; }
/* glossary review panel: a fixed overlay below the header, deliberately decoupled
   from the main flex layout so it can't disturb the search/reader columns. */
#glossary {
  display: none; position: fixed; inset: 58px 18px 18px; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 44px rgba(0,0,0,.18); flex-direction: column; overflow: hidden;
}
#glossary.open { display: flex; }
#glossary .ghead { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#gsearch { width: 180px; padding: 4px 9px; border-radius: 6px; font-size: 13px; font-family: inherit;
           border: 1px solid var(--border); background: var(--panel); color: var(--ink); }
#gsearch:focus { outline: none; border-color: var(--accent); }
/* floating "add to glossary" chip over a script selection (positioned in JS; `hidden` toggles it) */
#addgloss { position: fixed; z-index: 50; padding: 5px 10px; font-size: 12px; font-family: inherit;
            cursor: pointer; background: var(--accent); color: #fff; border: none; border-radius: 6px;
            box-shadow: 0 3px 12px rgba(0,0,0,.22); white-space: nowrap; }
/* inline add-word popover: opens at the selection when the chip is clicked */
#addglosspop { position: fixed; z-index: 51; display: flex; align-items: center; gap: 8px;
               padding: 6px 9px; font-size: 13px; font-family: inherit; background: var(--panel);
               color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
               box-shadow: 0 4px 16px rgba(0,0,0,.22); white-space: nowrap; }
#addglosspop .zh { font-weight: 600; }
#addglosspop .en input { width: 150px; font: inherit; padding: 3px 6px; border: 1px solid var(--border);
                         border-radius: 5px; background: var(--bg); color: var(--ink); }
#addglosspop .en input:focus { outline: none; border-color: var(--accent); }
/* the author display:flex above overrides the `hidden` attribute's display:none, so restore it */
#addglosspop[hidden] { display: none; }
#addglosspop .hint { font-size: 11px; color: var(--muted); }
.gtab { cursor: pointer; padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--muted); border: 1px solid transparent; }
.gtab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--border); }
#glist { flex: 1; overflow-y: auto; }
.gterm { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--border); }
.gterm .zh { font-size: 16px; font-weight: 600; min-width: 88px; }
.gterm .en { flex: 1; cursor: text; min-width: 0; }
.gterm .en input { width: 100%; font: inherit; padding: 2px 4px; }
/* Chinese-alias cell: shows a term's alternate surface forms (e.g. a censored name); click to edit */
.gterm .aka { cursor: text; font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 64px; }
.gterm .aka.noalias { opacity: .55; }   /* NOT named .empty — that class is the list placeholder and carries margin-top:40vh */
.gterm .aka input { width: 120px; font: inherit; padding: 2px 4px; }
.gterm .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.gterm .cat { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--border); }
.gterm .acts { display: flex; gap: 4px; }
/* keyboard-focused review row (↑/↓ navigation) */
.gterm.focused { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
/* keyboard-shortcut hint bar at the foot of the glossary panel */
.gfoot { padding: 6px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.gfoot kbd { font: inherit; background: var(--border); border-radius: 3px; padding: 0 4px; }
/* table-of-contents browser: same fixed-overlay shape as the glossary panel */
#toc {
  display: none; position: fixed; inset: 58px 18px 18px; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 44px rgba(0,0,0,.18); flex-direction: column; overflow: hidden;
}
#toc.open { display: flex; }
#toc .ghead { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#toccount { font-size: 12px; color: var(--muted); white-space: nowrap; }
#tocsearch { width: 220px; padding: 4px 9px; border-radius: 6px; font-size: 13px; font-family: inherit;
             border: 1px solid var(--border); background: var(--panel); color: var(--ink); }
#tocsearch:focus { outline: none; border-color: var(--accent); }
#toclist { flex: 1; overflow-y: auto; }
.tocrow { display: flex; align-items: baseline; gap: 12px; padding: 7px 14px;
          border-bottom: 1px solid var(--border); cursor: pointer; }
.tocrow:hover { background: var(--accent-soft); }
.tocrow .tnum { font-size: 12px; color: var(--muted); min-width: 56px; white-space: nowrap; }
.tocrow .tzh { font-weight: 600; min-width: 0; white-space: nowrap; }
.tocrow .ten { flex: 1; font-size: 13px; color: var(--muted); min-width: 0;
               overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-h {
  font-size: 13px; color: var(--muted); margin: 14px 2px 6px; text-transform: uppercase;
  letter-spacing: .8px;
}
.summary { font-size: 13px; color: var(--muted); margin: 8px 2px; }
.chapgroup, .card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 10px; overflow: hidden;
}
.chapgroup > .chead {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #f4f1ec; cursor: pointer; gap: 8px;
}
.chead b { color: var(--accent); white-space: nowrap; }
.chead .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead .n { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hit { padding: 10px 12px; border-top: 1px solid var(--border); cursor: pointer; }
.hit:hover, .card:hover { background: #fdf8ef; }
.hit .ctx { color: var(--muted); font-size: 13px; margin: 3px 0; }
.hit .txt { line-height: 1.65; }
/* reverse results: Chinese answer is the headline, English match is the muted evidence */
.txt.zh { line-height: 1.7; white-space: pre-line; }
.ctx.en { color: var(--muted); font-size: 13px; margin-top: 4px; }
mark { background: var(--mark); padding: 0 1px; border-radius: 2px; }
.badge {
  display: inline-block; font-size: 11px; border-radius: 10px; padding: 1px 8px;
  background: var(--accent-soft); color: var(--accent); margin-right: 6px; vertical-align: 1px;
}
.badge.dim { background: #eee9e2; color: var(--muted); }
.card { padding: 10px 12px; cursor: pointer; }
.card .meta { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.card .meta b { color: var(--accent); }
.card .txt { line-height: 1.65; white-space: pre-line; }
.notice {
  background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; font-size: 13px;
  margin: 8px 0;
}
/* detail pane */
#dhead {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
#dhead .title { flex: 1; font-weight: 600; }
#dhead .title b { color: var(--accent); }
#dhead button { padding: 4px 10px; font-size: 13px; }
#dbody { flex: 1; display: flex; min-height: 0; }
.pane { flex: 1; overflow-y: auto; padding: 14px 18px; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--border); }
.pane h3 {
  font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px;
  margin: 0 0 10px; position: sticky; top: -14px; background: var(--panel); padding: 4px 0;
}
.pane p { line-height: 1.8; margin: 0 0 .9em; }
.pane p.flash { background: var(--mark); border-radius: 4px; padding: 2px 4px; }
.pane p.enflash { background: #fdf3d6; border-radius: 4px; padding: 2px 4px; }
/* the English paragraph whose selection drove an English→Chinese jump */
.pane p.ensel { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
/* the Chinese paragraph whose selection drove a Chinese→English jump (the reverse) */
.pane p.zhsel { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
/* the specific Chinese word/phrase a selection resolved to (within the flashed section) */
.pane mark.wordmark { background: var(--accent); color: #fff; border-radius: 3px; padding: 0 2px; }
#enpane { cursor: text; }  /* hint that the English is selectable to find the Chinese */
.alignnote { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; margin-top: 40vh; }
#results .empty { margin-top: 30vh; }
.spin { color: var(--muted); font-size: 13px; }
/* pinyin-on-selection bar — slim fixed strip pinned to the bottom of the viewport,
   populated whenever a selection (anywhere) contains a Chinese character. Passive:
   it only displays, it never searches or jumps. */
#pinyinbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: none;
  align-items: center; gap: 12px; padding: 8px 14px;
  background: var(--accent-soft); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,.06); font-family: inherit;
}
#pinyinbar.show { display: flex; }
#pinyinpairs {
  flex: 1; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: flex-end;
  overflow-x: auto; min-width: 0;
}
/* one char/pinyin pair: pinyin stacked above its character */
#pinyinpairs .pypair {
  display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15;
}
#pinyinpairs .pypair .py { font-size: 12px; color: var(--accent); }
#pinyinpairs .pypair .ch { font-size: 17px; color: var(--ink); }
#pinyinfull {
  font-size: 13px; color: var(--ink); white-space: nowrap; max-width: 40%;
  overflow: hidden; text-overflow: ellipsis;
}
#pinyincopy {
  font-size: 12px; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer;
}
#pinyinclose {
  font-size: 16px; line-height: 1; padding: 2px 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
}
#pinyinclose:hover { color: var(--ink); }
/* a char with alternate readings: dotted underline + pointer signals "click to choose";
   the chosen reading shows highlighted while its picker is open */
#pinyinpairs .pypair.has-alts { cursor: pointer; }
#pinyinpairs .pypair.has-alts .py { border-bottom: 1px dotted var(--accent); }
#pinyinpairs .pypair.edited .py { color: var(--ok); font-weight: 600; }  /* user overrode the prediction */
#pinyinpairs .pypair.active .py { background: var(--mark); border-radius: 3px; }
/* floating reading-picker for a polyphonic character */
#pyalts {
  position: fixed; z-index: 60; display: none; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.14);
  padding: 4px; max-height: 220px; overflow-y: auto; min-width: 72px;
}
#pyalts.show { display: block; }
#pyalts .alt {
  display: block; width: 100%; text-align: left; padding: 5px 12px; font-size: 14px;
  border: none; background: transparent; color: var(--ink); cursor: pointer; border-radius: 5px;
}
#pyalts .alt:hover { background: var(--accent-soft); }
#pyalts .alt.cur { color: var(--accent); font-weight: 600; }
/* Layout control menu: a COMPACT fixed panel (decoupled from the flex layout like the
   other overlays, so opening it never disturbs the columns). */
#layoutmenu {
  display: none; position: fixed; top: 56px; right: 18px; width: 264px; z-index: 60;
  max-height: calc(100vh - 76px); overflow: auto; resize: both; min-width: 224px; min-height: 200px;   /* drag by the header, resize from the corner */
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 44px rgba(0,0,0,.18); flex-direction: column;
}
#layoutmenu.open { display: flex; }
#layoutmenu .ghead { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: move; }
.lmbody { padding: 9px 12px 11px; display: flex; flex-direction: column; gap: 9px; }
.lmrow { display: flex; gap: 6px; }
.lmlabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lmbody button { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 13px; font-family: inherit; }
.lmbody button:hover:not(:disabled) { border-color: var(--accent); }
.lmbody button:disabled { opacity: .4; cursor: default; }
/* compact undo/redo as icon buttons up in the panel header (saves a whole body row) */
.ghead .hicon { border: none; background: none; font-size: 15px; line-height: 1; color: var(--ink);
  cursor: pointer; padding: 1px 4px; }
.ghead .hicon:disabled { opacity: .3; cursor: default; }
.ghead .hicon:hover:not(:disabled) { color: var(--accent); }
#presetList { display: flex; flex-direction: column; gap: 2px; }
.presetrow { display: flex; align-items: center; gap: 5px; padding: 2px 6px; border-radius: 6px; }
.presetrow:hover { background: var(--bg); }
.presetrow.active { background: var(--accent-soft); }
.presetrow .pname { flex: 1; cursor: pointer; font-size: 13px; min-width: 0; }
.presetrow.active .pname { color: var(--accent); font-weight: 600; }
.presetrow .picon { border: none; background: none; padding: 2px 4px; font-size: 12px; opacity: .55; cursor: pointer; }
.presetrow .picon:hover { opacity: 1; }
.presetrow .pname input, #presetName { font: inherit; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--ink); }
#presetName { flex: 1; min-width: 0; }
.lmreset { display: flex; align-items: center; gap: 8px; }                 /* one compact row */
.lmreset label { flex: 1; font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
#resetCommit { padding: 4px 10px; }
/* mini layout wireframe (preset rows + Recent gallery): the script + detail columns are filled
   bands so their widths read at a glance; the dashed line is the reader's zh|en split. A neutral
   ink-wash (not accent) so it never clashes with the active-preset row's accent highlight. */
.thumb { display: block; }
.thumb-screen { fill: var(--panel); }
.thumb-col { fill: var(--ink); fill-opacity: 0.16; }
.thumb-rdr { stroke: var(--ink); stroke-opacity: 0.32; stroke-width: 1; stroke-dasharray: 2 1.5; }
.thumb-frame { fill: none; stroke: var(--border); stroke-width: 1.2; }
.thumb-pop { fill: #f5c764; stroke: #b9831a; stroke-width: 0.5; }   /* a popped panel = a detached mini-window (body) */
.thumb-pop-bar { fill: #b9831a; }                                  /* ...its title bar */
.thumb-poplabel { fill: #4a3208; font-size: 8px; font-weight: 700; text-anchor: middle; }   /* S / R / B */
.pthumb { flex: 0 0 auto; display: inline-flex; }
.pthumb .thumb { width: 30px; height: 19px; }
/* History TREE: your layout changes as a click-to-jump graph. Dots = states, ring = where you are,
   amber = pinned (protected from trimming). Scrolls when the tree outgrows the panel. */
.histwrap { max-height: 150px; overflow: auto; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); padding: 4px; }
.histsvg { display: block; }
.hedge { stroke: var(--border); stroke-width: 1.5; }
.hedge.on { stroke: var(--accent); stroke-width: 2.5; }        /* the line you're on right now */
.hnode { fill: var(--panel); stroke: var(--muted); stroke-width: 1.5; cursor: pointer; }
.hnode:hover { stroke: var(--accent); }
.hnode.on { stroke: var(--accent); }                           /* a state on your current line */
.hnode.pin { fill: #f0b429; stroke: #b9831a; }                 /* pinned = amber (kept) */
.hnode.cur { fill: var(--accent); stroke: var(--accent); }
.hnode.cur.pin { fill: #f0b429; stroke: var(--accent); stroke-width: 3; }   /* current AND pinned */
.hnode.gone { stroke: #d08a2a; stroke-dasharray: 3 2; }        /* next to be trimmed when history fills */
.hedge.pin { stroke: #d8a72b; stroke-width: 2; }               /* an edge inside a kept (pinned) subtree */
.hpindot { fill: #6b4708; pointer-events: none; }              /* marks the exact dot you pinned (its subtree is amber) */
.histlegend { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.histlegend span { display: inline-flex; align-items: center; gap: 5px; }
.histlegend i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.lg-cur { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lg-pin { background: #f0b429; border: 1px solid #b9831a; }
.lg-gone { background: var(--panel); border: 1.5px dashed #d08a2a; }
.lg-count { color: var(--ink); font-weight: 600; }
.histfoot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.histpin { padding: 3px 12px; flex: 1; }
.histpin.on { background: #f0b429; border-color: #b9831a; color: #5a3d08; }
.histhead { display: flex; align-items: center; gap: 6px; }
.histclear { margin-left: auto; font: inherit; font-size: 11px; text-transform: none; letter-spacing: 0;
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 1px 4px; }
.histclear:hover { color: var(--danger, #c0392b); text-decoration: underline; }
.histhint { font-size: 11px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
/* toast: a brief confirmation with an Undo affordance, bottom-center */
#lmtoast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: var(--panel); padding: 8px 14px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.28); display: flex; align-items: center; gap: 10px; }
#lmtoast[hidden] { display: none; }
#lmtoast button { font: inherit; background: none; border: 1px solid var(--panel); color: var(--panel);
  border-radius: 5px; padding: 2px 9px; cursor: pointer; }
/* === pop-out panels: open a panel in its OWN browser window (?panel=script|results|reader) so it
   can sit on a second monitor. Pure frontend (window.open + BroadcastChannel) → works for the
   translator over Tailscale, no install. === */
.panelpop { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 1px 5px; line-height: 1; }
.panelpop:hover { color: var(--accent); }
#poppedChips { display: flex; gap: 6px; }
.poppedchip { font: inherit; font-size: 12px; background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--ink); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
#soloDock { display: none; font: inherit; font-size: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; cursor: pointer; }
body.solo #soloDock { display: block; width: fit-content; margin: 6px 10px 6px auto; }   /* in-flow strip at the top → never covers the panel */
/* hide a column in the brain while it's popped out (the reader uses #detail's own display:none) */
body.popped-script #scriptpanel, body.popped-results #results { display: none !important; }
/* "solo" view: hide all chrome + the other two columns; fill with the one popped panel */
body.solo header, body.solo #controls, body.solo #glossary, body.solo #toc, body.solo #layoutmenu,
body.solo .panelpop { display: none !important; }
body.solo main { margin: 0; padding: 0; }
body.solo #scriptpanel, body.solo #results, body.solo #detail { display: none !important; }
body.solo-script #scriptpanel { display: flex !important; flex-direction: column !important; flex: 1 1 100% !important; }
body.solo-results #results { display: block !important; flex: 1 1 100% !important; padding: 10px 14px; }
body.solo-reader #detail { display: flex !important; flex-direction: column !important; flex: 1 1 100% !important; }
body.solo #close { display: none !important; }   /* in a view the fixed dock-back button replaces it */
