/* GE-120 Manual Explorer 2.0 — the design_reference machine-panel look.
 * Palette and geometry from design_reference/Manual Reader.dc.html (1a–1g, 2a–2b).
 * Fonts: the mockup's Archivo / IBM Plex Mono if installed locally, else system stacks —
 * never a CDN (charter). */

:root {
  --bg: #E9E6DE;         --panel: #F7F5EF;      --page: #FBFAF6;
  --ink: #1E3448;        --ink2: #33424E;       --muted: #5B6B76;  --muted2: #41525F; --faint: #8A97A0;
  --blue: #2E5170;       --blue-btn: #24425C;   --blue-hov: #3A5F80;
  --accent: #AECAC6;     --accent-deep: #7FA3A0;
  --rail: #DCE7E4;       --rail-line: #B9CFCB;  --rail-hov: #CFDEDA;
  --light: #F0F4F2;      --steel: #8FB0BC;
  --stripe: #F0EEE6;     --alt: #E9E6DC;        --hair: #D6D2C4;
  --danger: #A05A4A;
  --pin-idle: .7;        /* resting opacity of a marker dot over the page — the one knob */
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-family: var(--sans); color: var(--ink); overflow: hidden; }
::selection { background: var(--accent); }
button { font-family: var(--mono); cursor: pointer; }
input { font-family: inherit; color: var(--ink); }
[hidden] { display: none !important; }

#app { height: 100vh; display: flex; flex-direction: column; }

/* ============ toolbar ============ */
#toolbar {
  min-height: 56px; background: var(--blue); border-bottom: 3px solid var(--ink);
  display: flex; align-items: stretch; flex-wrap: wrap; flex: none; user-select: none;
}
/* the mobile-only hamburger — Contents drawer toggle; desktop has the rail buttons instead */
#btnMenu { display: none; border: none; background: var(--blue); color: var(--light);
  font-size: 18px; padding: 0 14px; border-right: 1px solid rgba(174,202,198,.25); }
#btnMenu:hover, #btnMenu.on { background: var(--blue-hov); }
#btnMenu.on { box-shadow: inset 0 -3px 0 var(--accent); }
#brandBox { display: flex; align-items: center; gap: 10px; padding: 0 18px; cursor: pointer;
  border-right: 1px solid rgba(174,202,198,.25); }
#brandBox:hover { background: var(--blue-hov); }
.brand-dot { width: 10px; height: 10px; background: var(--accent); flex: none; }
.brand-text { line-height: 1.15; }
#brandTitle { color: var(--light); font-weight: 600; font-size: 14px; letter-spacing: .3px; white-space: nowrap; }
#brandSub { color: var(--steel); font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.tb-group { display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.tb-bordered { border-left: 1px solid rgba(174,202,198,.25); }
.tb-spacer { flex: 1; }
.tb-toggle, .tb-btn, #btnSearch {
  height: 32px; border: 1px solid var(--ink); background: var(--blue-btn); color: var(--accent);
  font-size: 11px; letter-spacing: 1px; padding: 0 12px;
}
.tb-btn { width: 36px; padding: 0; color: #DCE7E4; font-size: 15px; }
.tb-btn:hover, .tb-toggle:hover { background: var(--blue-hov); }
.tb-btn:disabled { opacity: .35; cursor: default; }
#btnFav { font-size: 20px; }
#btnFav.on { color: var(--accent); }
.tb-btn:disabled:hover { background: var(--blue-btn); }
.tb-toggle.on { background: var(--blue-hov); color: var(--light); box-shadow: inset 0 -2px 0 var(--accent); }
.tb-count { display: inline-block; margin-left: 7px; padding: 1px 4px; background: var(--accent);
  color: var(--ink); font-size: 9px; letter-spacing: 0; }
.page-box { height: 32px; display: flex; align-items: center; gap: 6px; background: var(--light);
  border: 1px solid var(--ink); padding: 0 10px; font-family: var(--mono); font-size: 13px; }
#pageInput { width: 44px; border: none; outline: none; background: transparent; text-align: right;
  font-family: var(--mono); font-size: 13px; font-weight: 600; }
#pageTotal { color: var(--faint); }
#zoomLabel { font-family: var(--mono); font-size: 12px; color: #DCE7E4; width: 44px; text-align: center; }
#btnSearch { background: var(--accent); color: var(--ink); font-size: 12px; padding: 0 14px;
  box-shadow: inset 0 -2px 0 var(--accent-deep); display: flex; align-items: center; gap: 8px; }
#btnSearch:hover { background: #BFD4D0; }
#btnSearch .kbd { color: var(--muted2); font-size: 10px; }

/* ============ body / rails / page ============ */
#body { flex: 1; display: flex; min-height: 0; }
#contentsRail { width: 250px; flex: none; background: var(--rail); border-right: 2px solid var(--rail-line);
  overflow: auto; padding: 12px 0; }
.rail-head { padding: 4px 16px 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--muted2); }
.toc-vol { display: flex; align-items: center; gap: 8px; padding: 9px 14px 6px 13px; margin-top: 8px;
  cursor: pointer; border-left: 3px solid transparent; font-family: var(--mono); font-size: 10px;
  letter-spacing: 1px; color: var(--muted2); }
.toc-vol:first-child { margin-top: 0; }
.toc-vol:hover { background: var(--rail-hov); }
.toc-vol.cur { border-left-color: var(--blue); color: var(--ink); }
.toc-vol .b { background: var(--ink); color: var(--accent); padding: 2px 6px; flex: none; min-width: 26px; text-align: center; }
.toc-vol.cur .b { background: var(--blue); }
.toc-vol .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.toc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 14px 7px 16px; cursor: pointer; border-left: 3px solid transparent; }
.toc-row:hover { background: var(--rail-hov); }
.toc-row.active { background: var(--rail-hov); border-left-color: var(--blue); }
.toc-row .t { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-row .p { font-family: var(--mono); font-size: 10px; color: var(--muted); flex: none; }
.toc-row .approx { color: #B8860B; }
#thumbsRail { width: 124px; flex: none; background: var(--rail); border-right: 2px solid var(--rail-line);
  overflow: auto; }
#thumbStrip { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
.thumb { position: relative; cursor: pointer; flex: none; width: 104px; height: 106px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--rail-line); }
.thumb.active { border: 2px solid var(--blue); box-shadow: 0 2px 6px rgba(30,52,72,.25); }
.thumb .n { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 9px; color: var(--faint); background: rgba(247,245,239,.7); }
.thumb.active .n { color: var(--blue); font-weight: 600; }
.thumb canvas { display: block; max-width: 96px; max-height: 90px; width: auto; height: auto; }

#canvasWrap { flex: 1; overflow: auto; position: relative; padding: 28px 16px 60px;
  outline: none; overflow-anchor: none; }
/* "safe" centring: once a zoomed page is wider than the viewport it aligns to the start instead,
   so the left half stays reachable by scrolling (plain `center` overflows it out of reach). */
#pageColumn { display: flex; flex-direction: column; align-items: safe center; gap: 24px; }
.pageBox { position: relative; background: var(--page); flex: none;
  box-shadow: 0 3px 14px rgba(30,52,72,.22); }
.pageBox canvas { display: block; }
.pageBox .pageNum { position: absolute; top: 2px; right: -38px; font-family: var(--mono);
  font-size: 10px; color: var(--faint); user-select: none; }
.pageBox.pending::after { content: "p." attr(data-page) " …"; position: absolute; top: 44%;
  left: 50%; transform: translate(-50%,-50%); font-family: var(--mono); font-size: 11px;
  letter-spacing: 2px; color: var(--faint); animation: pulse 1.2s infinite; }
#pageLoading { position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%);
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px; color: var(--faint);
  animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* pdf.js text layer (selection only). TextLayer JS does NOT inline-style the spans: it emits
 * custom properties (--font-height, --scale-x, --rotate, --min-font-size) and expects the
 * official text_layer CSS — the rules below, lifted from it — to turn them into font-size and
 * transform. Without them every span renders at a default 16px, unscaled and UNROTATED, so its
 * hit-box sits nowhere near the printed word (vertical labels worst of all) and selection
 * misses what the eye sweeps. 1.0 shipped these via the stock viewer's viewer.css. */
.textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1;
  letter-spacing: normal; word-spacing: normal; text-size-adjust: none;
  forced-color-adjust: none; transform-origin: 0 0; z-index: 2;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
  --scale-round-x: 1px;
  --scale-round-y: 1px; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre;
  cursor: text; transform-origin: 0 0; }
.textLayer > :not(.markedContent),
.textLayer .markedContent span:not(.markedContent) { z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
/* Rotated pages (rotation runs / PDF /Rotate): TextLayer positions spans in UNROTATED page
 * space and stamps data-main-rotation on the layer, expecting these viewer.css rules to swing
 * the whole layer around with the canvas — without them every span on a rotated page lands in
 * the wrong place. */
.textLayer[data-main-rotation="90"] { transform: rotate(90deg) translateY(-100%); }
.textLayer[data-main-rotation="180"] { transform: rotate(180deg) translate(-100%, -100%); }
.textLayer[data-main-rotation="270"] { transform: rotate(270deg) translateX(-100%); }
/* Selection over the scan must TINT, not paint: the spans are invisible glyph boxes over the
 * canvas, so an opaque swatch (the UI-wide --accent one) hides the very words being selected. */
.textLayer ::selection { background: rgba(46, 81, 112, .25); }

/* marker pins — the scan is the ground truth, so a marker is only a quiet dot over it: 40%
 * opacity, named on hover (or when its MARKERS-rail row is hovered: .hot), clicked to edit.
 * Unpinned markers (no x/y — the migrated chapter/board index is nearly all of them) stack as
 * the same dot in the top-right margin. */
.pinLayer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.marginStack { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex;
  flex-direction: column; gap: 7px; align-items: flex-end; pointer-events: none; }
.pin { position: relative; cursor: pointer; pointer-events: auto; z-index: 1; }
.pinLayer .pin { position: absolute; transform: translate(-50%, -50%); }
/* A ring, not a blob: on a speckled 1960s scan a soft filled dot reads as dust, while a crisp
 * closed contour reads as an instrument — so it stays findable at --pin-idle. The outer halo
 * keeps it legible over black ink; hover/hot lights it up like a panel lamp. */
.pin-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--page);
  border: 2px solid var(--blue); box-shadow: 0 0 0 1.5px rgba(251, 250, 246, .9);
  opacity: var(--pin-idle); transition: opacity .12s, background .12s; }
.pin:hover, .pin.hot { z-index: 4; }
.pin:hover .pin-dot, .pin.hot .pin-dot { opacity: 1; background: var(--accent); }
.pin-name { display: none; position: absolute; top: 50%; left: 15px; transform: translateY(-50%);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--ink); color: var(--accent); font-family: var(--mono); font-size: 9px;
  letter-spacing: 1px; padding: 3px 7px; pointer-events: none; }
.pin.flip .pin-name { left: auto; right: 15px; }
.pin:hover .pin-name, .pin.hot .pin-name { display: block; }

/* ============ markers rail (the readable list the page no longer shows) ============ */
#markersRail { width: 250px; flex: none; background: var(--rail); border-right: 2px solid var(--rail-line);
  display: flex; flex-direction: column; overflow: hidden; }
.mk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 12px 14px 10px 16px; flex: none; white-space: nowrap; }
#mkCount { color: var(--muted); letter-spacing: .5px; }
#markerList { flex: 1; overflow: auto; }
.mk-row { display: flex; align-items: flex-start; gap: 9px; padding: 8px 12px 8px 14px; cursor: pointer;
  border-left: 3px solid transparent; border-top: 1px solid var(--rail-line); }
.mk-row:hover { background: var(--rail-hov); border-left-color: var(--blue); }
.mk-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--blue); flex: none; margin-top: 4px; }
.mk-dot.pinned { background: var(--blue); }
.mk-t { flex: 1; min-width: 0; }
.mk-t b { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.mk-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.mk-tag { font-family: var(--mono); font-size: 9px; color: var(--muted2); background: var(--light);
  border: 1px solid var(--rail-line); padding: 1px 5px; }
.mk-edit { flex: none; font-size: 12px; color: var(--faint); opacity: 0; }
.mk-row:hover .mk-edit { opacity: 1; }
#mkNew { flex: none; border: none; border-top: 2px solid var(--rail-line); background: var(--light);
  color: var(--blue); font-size: 10px; letter-spacing: 1px; padding: 11px 10px; }
#mkNew:hover { background: var(--rail-hov); }

/* ============ status bar ============ */
#statusbar { height: 28px; background: var(--ink); display: flex; align-items: center; gap: 24px;
  padding: 0 18px; flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  color: var(--steel); user-select: none; }
#stMsg, #stSave { color: var(--accent); }
#stHelp { cursor: pointer; }
#stHelp:hover { color: var(--accent); }
/* the clickable toast (clipboard copy on http needs its own gesture) — a panel lamp, not text */
#stMsg .st-action { background: var(--accent); border: 1px solid var(--ink); color: var(--ink);
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; padding: 2px 9px;
  cursor: pointer; animation: pulse 2s infinite; }
#stMsg .st-action:hover { background: #BFD4D0; animation: none; }
.mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.mode-dot.on { background: var(--accent); }

/* ============ search popover ============ */
#searchPop { position: fixed; z-index: 50; width: 480px; max-width: 96vw; background: var(--panel);
  border: 2px solid var(--ink); box-shadow: 0 14px 36px rgba(30,52,72,.35);
  display: flex; flex-direction: column; }
.sp-head { display: flex; align-items: center; gap: 10px; background: var(--blue); padding: 10px 14px; flex: none; }
.sp-glass { color: var(--accent); font-size: 15px; }
#searchInput { flex: 1; background: var(--light); border: 1px solid var(--ink); padding: 7px 10px;
  font-family: var(--mono); font-size: 13px; outline: none; min-width: 0; }
.sp-esc { color: var(--steel); font-family: var(--mono); font-size: 10px; cursor: pointer; user-select: none; }
#searchResults { flex: 1; overflow: auto; max-height: 60vh; }
.sp-sect { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--muted2); }
.sp-sq { width: 8px; height: 8px; flex: none; }
.sp-live { color: var(--accent-deep); animation: pulse 1.2s infinite; }
.sp-count { color: var(--accent-deep); }
.sp-row { padding: 8px 14px; border-top: 1px solid #E3E0D4; cursor: pointer; }
.sp-row:hover, .sp-row.first { background: var(--rail); }
.sp-row .line1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sp-row .nm { font-weight: 600; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row .nm b, .sp-ft b, .chip b { background: var(--accent); color: var(--ink); font-style: normal; }
.sp-row .where { font-family: var(--mono); font-size: 11px; color: var(--blue); font-weight: 600; white-space: nowrap; }
.sp-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--accent-deep); color: var(--muted2); font-family: var(--mono);
  font-size: 11px; padding: 3px 8px; }
.chip.hit { background: var(--blue); color: var(--light); border-color: var(--blue); box-shadow: 0 0 0 2px var(--accent); }
.chip.hit b { color: var(--accent); background: transparent; }
.chip.tag { cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip .cnt { color: var(--steel); }
.sp-bytag { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.sp-expand { margin: 4px 14px 10px; border: 1px solid var(--blue); }
.sp-expand-head { display: flex; align-items: center; gap: 8px; background: var(--blue); padding: 7px 10px;
  color: var(--light); font-family: var(--mono); font-size: 11px; }
.sp-expand-head .n { color: var(--steel); font-size: 10px; }
.sp-exrow { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px;
  background: #fff; border-top: 1px solid var(--hair); cursor: pointer; }
.sp-exrow:hover { background: var(--rail); }
.sp-exrow .t { display: flex; flex-direction: column; gap: 1px; }
.sp-exrow .t b { font-size: 12.5px; font-weight: 600; }
.sp-exrow .t span { font-size: 10.5px; color: var(--muted); }
.sp-ftwrap { border-top: 2px solid var(--ink); background: var(--stripe); }
.sp-ft { display: flex; justify-content: space-between; gap: 10px; padding: 7px 14px; font-size: 12px; cursor: pointer; }
.sp-ft:nth-child(even) { background: var(--alt); }
.sp-ft:hover { background: #E0DDD2; }
.sp-ft .src { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.sp-ftmore { font-family: var(--mono); font-size: 10.5px; color: var(--accent-deep); }
.sp-empty { padding: 22px 16px; font-family: var(--mono); font-size: 11px; color: var(--faint); line-height: 1.8; }
/* the ↑/↓-walked result — must win over .sp-ft's own zebra striping */
#searchResults .ksel { background: var(--rail-hov) !important; box-shadow: inset 3px 0 0 var(--blue); }
.sp-foot { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 9px 14px;
  border-top: 2px solid var(--ink); background: var(--panel); font-family: var(--mono); font-size: 10px; color: var(--faint); }
#searchNew { height: 30px; padding: 0 12px; background: var(--light); border: 1px solid var(--blue);
  color: var(--blue); font-size: 11px; }
#searchNew:hover { background: var(--rail); }

/* ============ orientation panel ============ */
#orientPanel { position: fixed; top: 64px; right: 16px; width: 340px; z-index: 60; background: var(--panel);
  border: 2px solid var(--ink); box-shadow: 0 10px 24px rgba(30,52,72,.3); }
.op-head { background: var(--blue); color: var(--light); font-family: var(--mono); font-size: 11px;
  letter-spacing: 2px; padding: 9px 14px; display: flex; justify-content: space-between; }
.op-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--hair); }
.op-alt { background: var(--rail); }
.op-label { display: flex; flex-direction: column; }
.op-label b { font-weight: 600; font-size: 13px; }
.op-label span { font-size: 11px; color: var(--muted); }
.op-btns { display: flex; gap: 6px; }
.op-btns button { width: 34px; height: 30px; background: var(--blue-btn); color: #DCE7E4;
  border: 1px solid var(--ink); font-size: 14px; }
.op-btns button:hover { background: var(--blue-hov); }
.op-reset { height: 30px; padding: 0 12px; background: var(--light); color: var(--blue);
  border: 1px solid var(--blue); font-size: 11px; }
.op-rules { border-top: 2px solid var(--ink); background: var(--stripe); padding: 10px 14px; }
.op-rules-head { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--muted2); margin-bottom: 6px; }
#ruleRows div { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px;
  color: var(--ink2); padding: 3px 0; }

/* ============ context menu / selection chip ============ */
#ctxMenu { position: fixed; z-index: 70; background: var(--ink); border: 1px solid #14283A;
  box-shadow: 0 10px 24px rgba(0,0,0,.4); min-width: 210px; }
.ctx-item { padding: 9px 14px; color: var(--light); font-size: 12.5px; cursor: pointer;
  display: flex; gap: 8px; align-items: center; border-top: 1px solid #33536E; }
.ctx-item:first-child { border-top: none; }
.ctx-item:hover { background: var(--blue); }
.ctx-item .ico { color: var(--accent); }
#selChip { position: fixed; z-index: 45; display: flex; align-items: center; gap: 6px; }
#selChip .find { background: var(--blue); color: var(--light); font-family: var(--mono); font-size: 10px;
  letter-spacing: 1px; padding: 5px 9px; box-shadow: 0 2px 6px rgba(30,52,72,.35); cursor: pointer; }
#selChip .find:hover { background: var(--blue-hov); }
#selChip .mk { background: var(--light); border: 1px solid var(--blue); color: var(--blue);
  font-family: var(--mono); font-size: 10px; padding: 5px 9px; cursor: pointer; }

/* ============ marker editor ============ */
#editorBack, #libraryBack { position: fixed; inset: 0; background: rgba(30,52,72,.35); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
#editor { width: 440px; max-width: 96vw; max-height: 92vh; overflow: auto; background: var(--panel);
  border: 2px solid var(--ink); box-shadow: 0 10px 24px rgba(30,52,72,.4); }
.ed-head { background: var(--blue); display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; color: var(--light); font-family: var(--mono); font-size: 11px; letter-spacing: 2px; }
.ed-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ed-field { display: flex; flex-direction: column; gap: 4px; }
.ed-field > span { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; color: var(--muted2); }
.ed-field input { background: #fff; border: 1px solid var(--ink); padding: 8px 10px; font-size: 13px;
  outline: none; width: 100%; }
#edName { font-weight: 600; }
.mono { font-family: var(--mono) !important; }
.ed-cols { display: flex; gap: 12px; }
.ed-cols .ed-field { flex: 1; }
.ed-cols .wide { flex: 1.6; }
.ed-xy { display: flex; gap: 6px; align-items: center; }
.ed-xy input { width: 56px; padding: 8px 6px; }
#edPick { height: 34px; padding: 0 10px; background: var(--accent); border: 1px solid var(--ink);
  font-size: 10px; letter-spacing: 1px; box-shadow: inset 0 -2px 0 var(--accent-deep); }
#edPick:hover { background: #BFD4D0; }
.ed-tags { background: #fff; border: 1px solid var(--ink); padding: 8px 10px; display: flex; gap: 6px;
  flex-wrap: wrap; align-items: center; }
.ed-tag { background: var(--rail); border: 1px solid var(--accent-deep); font-family: var(--mono);
  font-size: 11px; padding: 3px 8px; display: inline-flex; gap: 6px; align-items: center; }
.ed-tag span { cursor: pointer; color: var(--muted); }
#edTagInput { border: none !important; outline: none; font-family: var(--mono); font-size: 11px;
  min-width: 70px; flex: 1; padding: 0 !important; width: auto !important; }
.ed-foot { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 2px solid var(--ink);
  background: var(--stripe); }
.ed-foot button { height: 34px; padding: 0 16px; font-size: 11px; letter-spacing: 1px; }
#edDelete { border: 1px solid var(--danger); color: var(--danger); background: transparent; }
#edCancel { border: 1px solid var(--muted); color: var(--muted); background: transparent; }
#edSave { background: var(--blue); border: 1px solid var(--ink); color: var(--light);
  box-shadow: inset 0 -2px 0 var(--accent); }
#edSave:hover { background: var(--blue-hov); }
#pickBanner { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--ink); color: var(--accent); font-family: var(--mono); font-size: 11px;
  letter-spacing: 1px; padding: 9px 16px; box-shadow: 0 6px 18px rgba(0,0,0,.35); animation: pulse 2s infinite; }

/* ============ keyboard help ============ */
#helpBack { position: fixed; inset: 0; background: rgba(30,52,72,.35); z-index: 85;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
#helpPanel { width: 680px; max-width: 96vw; max-height: 92vh; overflow: auto; background: var(--panel);
  border: 2px solid var(--ink); box-shadow: 0 14px 36px rgba(30,52,72,.4); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; padding: 2px 16px 16px; }
.help-sect { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--muted2);
  padding: 16px 0 5px; border-bottom: 1px solid var(--hair); margin-bottom: 4px; }
.help-row { display: flex; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 12.5px; }
.help-row .keys { flex: none; min-width: 118px; display: flex; gap: 4px; flex-wrap: wrap; }
kbd { font-family: var(--mono); font-size: 10px; color: var(--ink2); background: var(--light);
  border: 1px solid var(--ink); border-bottom-width: 2px; padding: 1px 6px; white-space: nowrap; }
@media (max-width: 720px) { .help-cols { grid-template-columns: 1fr; } }

/* ============ library ============ */
#library { width: 560px; max-width: 96vw; max-height: 88vh; overflow: auto; background: var(--panel);
  border: 2px solid var(--ink); box-shadow: 0 14px 36px rgba(30,52,72,.4); }
.lib-head { background: var(--blue); color: var(--light); font-family: var(--mono); font-size: 11px;
  letter-spacing: 2px; padding: 10px 14px; display: flex; justify-content: space-between;
  position: sticky; top: 0; }
.lib-set { padding: 12px 14px 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--muted2); }
.lib-set span { color: var(--faint); letter-spacing: .5px; }
.lib-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer;
  border-top: 1px solid #E3E0D4; }
.lib-row:hover { background: var(--rail); }
.lib-badge { font-family: var(--mono); font-size: 10px; background: var(--ink); color: var(--accent);
  padding: 3px 7px; flex: none; min-width: 34px; text-align: center; }
.lib-row .t { flex: 1; min-width: 0; }
.lib-row .t b { display: block; font-size: 13px; font-weight: 600; }
.lib-row .t span { font-size: 11px; color: var(--muted); display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.lib-row .p { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.lib-row .resume { font-family: var(--mono); font-size: 10px; color: var(--blue); white-space: nowrap; }

/* ============ mobile ============ */
@media (max-width: 720px) {
  #toolbar { min-height: 44px; }
  #btnMenu { display: block; }
  #brandBox { padding: 0 10px; }
  #brandSub { max-width: 140px; }
  .tb-group { padding: 0 6px; gap: 4px; }
  .tb-btn { width: 32px; }
  #btnContents, #btnThumbs, #btnMarkers, #zoomLabel, #btnSearch .kbd { display: none; }
  /* thumbs/markers rails are desktop furniture; CONTENTS becomes the hamburger's drawer,
     overlaying the page inside #body so it lands under the toolbar however many rows it wraps to */
  #thumbsRail, #markersRail { display: none !important; }
  #body { position: relative; }
  #contentsRail { position: absolute; top: 0; left: 0; bottom: 0; width: min(82vw, 300px);
    z-index: 30; box-shadow: 6px 0 18px rgba(30,52,72,.3); }
  #canvasWrap { padding: 10px 4px 40px; }
  #searchPop { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: auto !important; max-height: 72vh; border-width: 3px 0 0 0; }
  #searchResults { max-height: none; }
  #orientPanel { left: 8px; right: 8px; width: auto; }
  #statusbar { display: none; }
}
/* no space left: the zoom pair goes (native pinch still zooms), the page controls stay */
@media (max-width: 560px) {
  #btnZoomOut, #btnZoomIn { display: none; }
}
