/*
 * styles.css — katab V2
 * Design language: "Sacred Terminal"
 * Dark mineral palette · monospaced precision · invisible UI
 *
 * IMPORTANT: LINE_HEIGHTS in engine.js must match the heights defined here
 * for separator elements (sep-verse: 8px, sep-chapter: 24px, sep-book: 48px)
 * and text lines (--line-h: 36px). The virtual scroller uses those constants
 * for arithmetic positioning — if CSS and JS values diverge, line overlap occurs.
 */

/* ─── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* Surface layers */
  --bg-void:    #040406;
  --bg-deep:    #080810;
  --bg-surface: #0c0c16;
  --bg-raised:  #111120;
  --bg-hover:   #181828;

  /* Text scale */
  --text-primary:   #d8d8e8;
  --text-secondary: #8888a8;
  --text-muted:     #4a4a68;
  --text-accent:    #9d88ff;

  /* Accent purple */
  --accent:        #7c62ff;
  --accent-soft:   rgba(124, 98, 255, 0.15);
  --accent-glow:   rgba(124, 98, 255, 0.35);
  --accent-border: rgba(124, 98, 255, 0.40);

  /* Separator intensities (verse < chapter < book) */
  --verse-sep:   rgba(124, 98, 255, 0.08);
  --chapter-sep: rgba(124, 98, 255, 0.18);
  --book-sep:    rgba(124, 98, 255, 0.35);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-mid:    rgba(255, 255, 255, 0.10);

  /* Fonts */
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
  --font-text: "Noto Sans Phoenician", "Noto Sans Hebrew", sans-serif;

  /* Layout metrics */
  --line-h:   58px;  /* MUST match LINE_HEIGHTS.text in engine.js */
  --script-h: 36px;  /* MUST match LINE_HEIGHTS.script in engine.js */
  --font-sz:  17px;
  --hud-h:    56px;

}

/* ─── Light theme overrides ───────────────────────────────────────────────── */
/*
 * Applied when <html data-theme="light"> is set.
 * All other rules use the tokens defined in :root — only the tokens change,
 * never the structural or layout rules. This means the light theme is
 * automatically consistent with any new component that uses CSS variables.
 */
[data-theme="light"] {
  /* Surface layers — warm off-white stack */
  --bg-void:    #f4f4f8;
  --bg-deep:    #ededf3;
  --bg-surface: #f8f8fc;
  --bg-raised:  #ffffff;
  --bg-hover:   #eeeef6;

  /* Text — near-black with slight blue tint */
  --text-primary:   #1a1a2e;
  --text-secondary: #4a4a72;
  --text-muted:     #8888aa;
  --text-accent:    #5a3ee8;

  /* Accent — slightly deeper purple for contrast on light */
  --accent:        #5a3ee8;
  --accent-soft:   rgba(90, 62, 232, 0.10);
  --accent-glow:   rgba(90, 62, 232, 0.25);
  --accent-border: rgba(90, 62, 232, 0.35);

  /* Separator intensities */
  --verse-sep:   rgba(90, 62, 232, 0.10);
  --chapter-sep: rgba(90, 62, 232, 0.22);
  --book-sep:    rgba(90, 62, 232, 0.40);

  /* Borders */
  --border-subtle: rgba(0, 0, 0, 0.07);
  --border-mid:    rgba(0, 0, 0, 0.12);
}

/* Light-mode HUD glass needs a lighter base */
[data-theme="light"] .hud-panel {
  background: rgba(248, 248, 252, 0.97);
  box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 0 0 1px rgba(90,62,232,0.08);
}

/* Pane scrollbar in light mode */
[data-theme="light"] .pane::-webkit-scrollbar-thumb { background: var(--text-muted); }

/* ─── Papyrus theme — aged parchment ──────────────────────────────────────── */
[data-theme="papyrus"] {
  --bg-void:    #e8dcc8;
  --bg-deep:    #e2d4bc;
  --bg-surface: #ede3d0;
  --bg-raised:  #f4ead6;
  --bg-hover:   #ddd0b8;

  --text-primary:   #2c2416;
  --text-secondary: #5c4e38;
  --text-muted:     #9a8b70;
  --text-accent:    #6b4423;

  --accent:        #8b5e34;
  --accent-soft:   rgba(139, 94, 52, 0.12);
  --accent-glow:   rgba(139, 94, 52, 0.25);
  --accent-border: rgba(139, 94, 52, 0.35);

  --verse-sep:   rgba(139, 94, 52, 0.10);
  --chapter-sep: rgba(139, 94, 52, 0.22);
  --book-sep:    rgba(139, 94, 52, 0.40);

  --border-subtle: rgba(100, 70, 30, 0.12);
  --border-mid:    rgba(100, 70, 30, 0.18);
}

/* Paper texture via CSS — no external images */
[data-theme="papyrus"] html,
[data-theme="papyrus"] body {
  background:
    /* Subtle grain noise */
    repeating-conic-gradient(#d4c4a8 0% 25%, transparent 0% 50%) 0 0 / 3px 3px,
    /* Fiber streaks */
    linear-gradient(175deg, transparent 45%, rgba(180,160,120,0.08) 46%, transparent 47%),
    linear-gradient(  3deg, transparent 48%, rgba(160,140,100,0.06) 49%, transparent 50%),
    /* Warm parchment base */
    linear-gradient(180deg, #ead8be 0%, #e2d0b4 30%, #dcc8a8 70%, #d8c4a2 100%);
}
[data-theme="papyrus"] .pane {
  background:
    /* Fine fiber texture */
    repeating-linear-gradient(
      87deg, transparent, transparent 12px,
      rgba(180,155,110,0.04) 12px, rgba(180,155,110,0.04) 13px
    ),
    /* Aged stain — subtle warm spot */
    radial-gradient(ellipse at 30% 20%, rgba(190,160,100,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 70%, rgba(170,140,90,0.06) 0%, transparent 50%),
    var(--bg-void);
}
[data-theme="papyrus"] .pane::-webkit-scrollbar-thumb { background: #b8a480; }
[data-theme="papyrus"] .hud-panel {
  background: rgba(237, 227, 208, 0.96);
  box-shadow: 0 12px 40px rgba(80,60,20,0.15), 0 0 0 1px rgba(139,94,52,0.12);
}
[data-theme="papyrus"] #status-bar {
  background: #ddd0b8;
  border-top-color: rgba(100,70,30,0.15);
}

/* ─── Codex theme — dark leather study desk ───────────────────────────────── */
[data-theme="codex"] {
  --bg-void:    #1a150e;
  --bg-deep:    #201a12;
  --bg-surface: #261f16;
  --bg-raised:  #30271c;
  --bg-hover:   #3a3024;

  --text-primary:   #d4c8a8;
  --text-secondary: #a0936e;
  --text-muted:     #6a5e44;
  --text-accent:    #c8a84b;

  --accent:        #c8a84b;
  --accent-soft:   rgba(200, 168, 75, 0.12);
  --accent-glow:   rgba(200, 168, 75, 0.25);
  --accent-border: rgba(200, 168, 75, 0.35);

  --verse-sep:   rgba(200, 168, 75, 0.08);
  --chapter-sep: rgba(200, 168, 75, 0.18);
  --book-sep:    rgba(200, 168, 75, 0.35);

  --border-subtle: rgba(200, 168, 75, 0.08);
  --border-mid:    rgba(200, 168, 75, 0.14);
}

[data-theme="codex"] html,
[data-theme="codex"] body {
  background:
    /* Leather grain */
    repeating-conic-gradient(#18120a 0% 25%, transparent 0% 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, #1a150e 0%, #16110a 50%, #1a150e 100%);
}
[data-theme="codex"] .pane {
  background:
    /* Subtle wear pattern */
    radial-gradient(ellipse at 20% 30%, rgba(200,168,75,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 60%, rgba(160,130,50,0.02) 0%, transparent 40%),
    var(--bg-void);
}
[data-theme="codex"] .pane::-webkit-scrollbar-thumb { background: #6a5e44; }
[data-theme="codex"] .hud-panel {
  background: rgba(38, 31, 22, 0.97);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,168,75,0.1);
}
[data-theme="codex"] #status-bar {
  background: #201a12;
  border-top-color: rgba(200,168,75,0.1);
}

/* ─── OLED theme — true black ─────────────────────────────────────────────── */
[data-theme="oled"] {
  --bg-void:    #000000;
  --bg-deep:    #050505;
  --bg-surface: #0a0a0a;
  --bg-raised:  #111111;
  --bg-hover:   #1a1a1a;

  --text-primary:   #e0e0e0;
  --text-secondary: #999999;
  --text-muted:     #555555;
  --text-accent:    #8b7cff;

  --accent:        #6c52ff;
  --accent-soft:   rgba(108, 82, 255, 0.15);
  --accent-glow:   rgba(108, 82, 255, 0.35);
  --accent-border: rgba(108, 82, 255, 0.40);

  --verse-sep:   rgba(108, 82, 255, 0.10);
  --chapter-sep: rgba(108, 82, 255, 0.20);
  --book-sep:    rgba(108, 82, 255, 0.40);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-mid:    rgba(255, 255, 255, 0.15);
}

[data-theme="oled"] .hud-panel {
  background: rgba(5, 5, 5, 0.98);
  box-shadow: 0 12px 40px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.05);
}
[data-theme="oled"] #status-bar {
  background: #000000;
  border-top-color: rgba(255,255,255,0.05);
}
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: hidden; /* Critical for immersive full-screen layout */
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── App shell ───────────────────────────────────────────────────────────── */
#app-shell {
  position: fixed; inset: 0;
  left: var(--tab-w);  /* content starts after full tab width — tabs animate beneath */
  right: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  --split-pos: 50%;
  transition:
    left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    /* Removed grid transitions to allow smooth dragging */
}

#app-shell.split-v { grid-template-columns: var(--split-pos) 4px 1fr; }
#app-shell.split-h { grid-template-rows: var(--split-pos) 4px 1fr; grid-template-columns: 1fr; }

/* ─── Panes ───────────────────────────────────────────────────────────────── */
.pane {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  scroll-behavior: smooth;
}
.pane + .pane { border-left: none; } /* Replaced by gutter */

.gutter {
  background: var(--border-subtle);
  z-index: 100;
  transition: background 0.2s, opacity 0.2s;
}
.gutter.hidden { display: none; }
#app-shell.split-v .gutter {
  cursor: col-resize;
  width: 4px;
  height: 100%;
}
#app-shell.split-h .gutter {
  cursor: row-resize;
  height: 4px;
  width: 100%;
}
.gutter:hover, .gutter.dragging {
  background: var(--accent);
}

.pane::-webkit-scrollbar       { width: 4px; }
.pane::-webkit-scrollbar-track { background: transparent; }
.pane::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

/* Virtual scroll helpers */
.pane-spacer  { width: 1px; pointer-events: none; }
.pane-content { position: absolute; top: 0; left: 0; width: 100%; }

/* ─── Text lines ──────────────────────────────────────────────────────────── */
/*
 * .text-line is applied by the virtual scroller to every rendered content line.
 * Height (--line-h) MUST match LINE_HEIGHTS.text in engine.js.
 */
.text-line {
  display: block;
  padding: 0 52px 0 80px;
  min-height: var(--line-h);
  line-height: 36px;      /* centers script in 36px, not full 58px */
  font-size: var(--font-sz);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  cursor: text;
  position: relative;
  transition: background 0.1s;
  z-index: 0;
}
.text-line:hover { background: rgba(255, 255, 255, 0.015); }

.verse-ref {
  position: absolute;
  left: 0; top: 10px;
  width: 60px;
  text-align: right;
  padding-right: 8px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--text-muted);
  opacity: 0.45;
  user-select: none;
  pointer-events: none;
  letter-spacing: 0.5px;
}

.latin-line {
  display: block;
  padding: 2px 52px 6px 80px;
  font-family: var(--font-mono);
  font-size: 0.78em;
  color: var(--text-muted);
  line-height: 1.4;
  user-select: text;
  cursor: text;
  direction: ltr;
  text-align: left;
  position: absolute;
  left: 0;
  width: 100%;
  transition: background 0.1s;
  z-index: 1;   /* above .text-line (z-index:0) so it receives clicks in its zone */
}
.latin-line:hover { background: rgba(255,255,255,0.015); }
.latin-line[contenteditable="true"] {
  box-shadow: inset 0 0 0 1px var(--accent-border), 0 0 0 3px var(--accent-soft);
  background: rgba(124, 98, 255, 0.06) !important;
  caret-color: var(--accent);
  outline: none;
}

/* ─── Structural separators ───────────────────────────────────────────────── */
/*
 * Separators are standalone <div> elements (NOT text-line).
 * Heights MUST match LINE_HEIGHTS.verse/chapter/book in engine.js.
 * They are absolutely positioned by the scroller (style.top = offset[i]).
 */
.sep-verse {
  position: absolute; left: 0; width: 100%;
  height: 8px;                           /* LINE_HEIGHTS.verse */
  border-top: 1px solid var(--verse-sep);
}

.sep-chapter {
  position: absolute; left: 0; width: 100%;
  height: 24px;                          /* LINE_HEIGHTS.chapter */
  border-top: 2px solid var(--chapter-sep);
}

.sep-book {
  position: absolute; left: 0; width: 100%;
  height: 48px;                          /* LINE_HEIGHTS.book */
  border-top: 3px solid var(--book-sep);
  display: flex; align-items: center; justify-content: center;
}
.sep-book::before {
  content: '✦';
  color: var(--accent);
  font-size: 0.7em;
  letter-spacing: 4px;
  opacity: 0.6;
}

/* ─── Text direction helpers ──────────────────────────────────────────────── */
.dir-rtl { direction: rtl; text-align: right; }
.dir-ltr { direction: ltr; text-align: left;  }

/* ─── Script font assignments ─────────────────────────────────────────────── */
.s-original    { font-family: var(--font-mono); color: var(--text-secondary); font-size: 0.92em; letter-spacing: 0.3px; }
.s-hebrew      { font-family: "Noto Sans Hebrew", sans-serif; }
.s-rashi       { font-family: "Noto Rashi Hebrew", serif; }
.s-phoenician  { font-family: "Noto Sans Phoenician", sans-serif; }
.s-aramaic     { font-family: "Noto Sans Imperial Aramaic", sans-serif; }
.s-samaritan   { font-family: "Noto Sans Samaritan", sans-serif; }
.s-nabataean   { font-family: "Noto Sans Nabataean", sans-serif; }
.s-musnad      { font-family: "Noto Sans Old South Arabian", sans-serif; }
.s-manichaean  { font-family: "Noto Sans Manichaean", sans-serif; }
.s-hatran      { font-family: "Noto Sans Hatran", sans-serif; }
.s-mandaic     { font-family: "Noto Sans Mandaic", sans-serif; }
.s-sogdian     { font-family: "Noto Sans Sogdian", sans-serif; }
.s-avestan     { font-family: "Noto Sans Avestan", sans-serif; }
.s-pahlavi     { font-family: "Noto Sans Inscriptional Pahlavi", sans-serif; }
.s-hanifi      { font-family: "Noto Sans Hanifi Rohingya", sans-serif; }
.s-chorasmian  { font-family: "Noto Sans Chorasmian", sans-serif; }
.s-ugaritic    { font-family: "Noto Sans Ugaritic", sans-serif; font-size: 1.25em; }
.s-syriac      { font-family: "Noto Sans Syriac", sans-serif; }
.s-arabic      { font-family: "Amiri", serif; font-size: 1.15em; }
.s-ethiopic    { font-family: "Noto Sans Ethiopic", sans-serif; }
.s-cuneiform   { font-family: "Noto Sans Cuneiform", sans-serif; font-size: 1.2em; }
/* Proto-Sinaitic uses Egyptian Hieroglyphs — each letter is the actual
 * hieroglyph ancestor per Gardiner/Albright reconstruction (aleph=ox head,
 * beth=house, mem=water, etc.). Unicode has no dedicated Proto-Sinaitic block. */
.s-protosinaitic { font-family: "Noto Sans Egyptian Hieroglyphs", sans-serif; font-size: 1.3em; }

/* ─── HUD (Heads-Up Display) ──────────────────────────────────────────────── */
/*
 * The HUD is invisible by default.
 * On desktop: revealed by hovering the 8px trigger strip at the very top.
 * On mobile:  revealed by tapping the trigger strip (JS sets inline transform).
 */
#hud-trigger {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 8px;
  z-index: 500;
}

/* Pulse animation on trigger — invites user to hover at top edge */
.hud-trigger-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  animation: hud-pulse 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hud-pulse {
  0%, 100% { opacity: 0.25; }
  50%       { opacity: 0.70; }
}
/* Pulse stops once user has interacted with HUD */
.hud-trigger-pulse.hud-seen::after { animation: none; opacity: 0; }

/* "▲ hover for controls" hint text */
#hud-hint {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 498;
  opacity: 0.7;
  transition: opacity 0.5s;
  white-space: nowrap;
}
#hud-hint.hud-seen { opacity: 0; }

/* ─── Status bar ──────────────────────────────────────────────────────────── */
#status-bar {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  background: rgba(8, 8, 16, 0.92);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  z-index: 400;
  backdrop-filter: blur(8px);
  letter-spacing: 0.5px;
}
[data-theme="light"] #status-bar {
  background: rgba(248, 248, 252, 0.95);
}
#status-lines { color: var(--text-secondary); white-space: nowrap; }
.status-flex  { flex: 1; }
#status-hash  {
  color: #c8a84b;
  white-space: nowrap;
  letter-spacing: 0.8px;
  opacity: 0.85;
  cursor: default;
  user-select: all;
  font-size: 0.62rem;
}

/* ── Integrity dot por línea ────────────────────────────────────────────────── */
.integrity-dot {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4caf50;
  opacity: 0.5;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  z-index: 2;
}
.integrity-dot:hover { opacity: 1; transform: translateY(-50%) scale(1.5); }

/* States */
.integrity-dot[data-state="pristine"] { background: #4caf50; }
.integrity-dot[data-state="self"]     { background: #f5c542; width: 8px; height: 8px; opacity: 0.75; }
.integrity-dot[data-state="remote"]   { background: #e53935; width: 8px; height: 8px; opacity: 0.85; }
.integrity-dot[data-state="accepted"] { background: #5c8abf; width: 7px; height: 7px; opacity: 0.6; }

@keyframes dot-pulse {
  0%   { box-shadow: 0 0 6px 2px rgba(245,197,66,0.7); transform: translateY(-50%) scale(1.6); }
  60%  { box-shadow: 0 0 3px 1px rgba(245,197,66,0.3); transform: translateY(-50%) scale(1.2); }
  100% { box-shadow: none; transform: translateY(-50%) scale(1); }
}
.integrity-dot.just-changed {
  animation: dot-pulse 2s ease-out forwards;
}

/* Hash bubble */
.hash-bubble {
  background: var(--bg-raised, #1e1e2e);
  border: 1px solid var(--border-mid, #3a3a4a);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  white-space: nowrap;
}
.hb-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.hb-hash {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: #c8a84b;
  letter-spacing: 0.3px;
  user-select: all;
}
.hb-copy {
  width: 24px !important;
  height: 24px !important;
  font-size: 0.85rem;
  padding: 0 !important;
  cursor: pointer;
}

/* Shrink pane area to leave room for status bar */
#app-shell { bottom: 26px; }  /* status bar height */

#hud {
  position: fixed; top: 0; left: 0;
  width: 100%;
  display: flex; justify-content: center;
  transform: translateY(-100%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 499;
  pointer-events: none;
}

/* CSS-only reveal on desktop hover */
#hud-trigger:hover ~ #hud,
#hud:hover {
  transform: translateY(0);
  pointer-events: auto;
}

.hud-panel {
  background: rgba(8, 8, 16, 0.97);
  backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--border-mid);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 0 16px;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,98,255,0.08);
}

.hud-logo {
  font-family: "Noto Sans Phoenician", sans-serif;
  color: var(--accent);
  font-size: 1.1rem;
  letter-spacing: 2px;
  flex-shrink: 0;
  margin-right: 6px;
}

.hud-spacer { flex: 1; }

/* ─── Shared button & input styles ───────────────────────────────────────────  */
.ibtn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  padding: 6px;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}
/* SVG inside ibtn — inherits stroke colour from currentColor */
.ibtn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  pointer-events: none;
}
.ibtn:hover  { color: var(--text-accent); border-color: var(--accent-border); background: var(--accent-soft); }
.ibtn.active { color: var(--accent);      border-color: var(--accent-border); background: var(--accent-soft); }

/* ─── Script picker (replaces <select>) ─────────────────────────────────── */
.script-picker {
  position: relative;
  flex-shrink: 0;
}

/* The trigger button — wider than a plain ibtn to fit the badge */
.script-picker-btn {
  width: auto;
  padding: 6px 8px;
  gap: 5px;
  font-size: 0.72rem;
}
.script-picker-btn svg { width: 14px; height: 14px; }

.script-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  color: var(--text-accent);
  white-space: nowrap;
}

/* Popover list */
.script-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  z-index: 1000;
  display: none;
  flex-direction: column;
  padding: 4px;
  scrollbar-width: thin;
}
.script-popover.open { display: flex; }
.script-popover::-webkit-scrollbar { width: 3px; }
.script-popover::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.script-option {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 7px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.script-option:hover  { background: var(--accent-soft); color: var(--text-accent); }
.script-option.active { color: var(--accent); background: var(--accent-soft); }



#hud-search {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  padding: 5px 12px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 180px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
#hud-search:focus       { border-color: var(--accent); width: 240px; }
#hud-search::placeholder { color: var(--text-muted); }

/* ─── Source modal ────────────────────────────────────────────────────────── */
/* ── Source drawer ──────────────────────────────────────────────────────────── */
#drawer-source { width: 480px; }
#drawer-source .drawer-body { padding: 16px; }

/* ── Modal styles (shared by remaining modals: share, shortcuts, info) ───── */
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 32px;
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.8);
}
.modal-box::-webkit-scrollbar       { width: 3px; }
.modal-box::-webkit-scrollbar-track { background: transparent; }
.modal-box::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.modal-title {
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-accent);
  margin-bottom: 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }

.source-tabs   { display: flex; gap: 4px; margin-bottom: 20px; }
.stab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.stab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.source-panel        { display: none; }
.source-panel.active { display: block; }

/* Library list */
.library-list { display: flex; flex-direction: column; gap: 0; }

/* Filter bar above the book list */
.lib-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.lib-filter-bar input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
}
.lib-filter-bar input:focus { border-color: var(--accent); }
.lib-filter-bar select {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

/* Scrollable book list area */
.lib-book-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}
.lib-book-list::-webkit-scrollbar       { width: 3px; }
.lib-book-list::-webkit-scrollbar-track { background: transparent; }
.lib-book-list::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

/* Category group header */
.lib-category-hdr {
  font-size: 0.62rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 4px 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

.lib-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
  font-size: 0.82rem;
}
.lib-item:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.lib-item-icon  { color: var(--accent); font-size: 0.85rem; flex-shrink: 0; }
.lib-item-name  { color: var(--text-primary); flex: 1; }
.lib-item-badge {
  color: var(--text-muted);
  font-size: 0.62rem;
  letter-spacing: 1px;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.lib-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px 0;
}

/* Write/Paste textarea */
#text-editor {
  width: 100%;
  min-height: 180px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 14px;
  border-radius: 7px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.6;
}
#text-editor:focus { border-color: var(--accent); }

/* Write tab toolbar */
.write-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.write-sep-btn {
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.write-sep-btn:hover { color: var(--text-accent); border-color: var(--accent-border); background: var(--accent-soft); }
.write-char-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* Write tab live Phoenician preview */
.write-preview {
  min-height: 28px;
  padding: 6px 14px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  font-family: "Noto Sans Phoenician", sans-serif;
  font-size: 1rem;
  color: var(--accent);
  direction: rtl;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.8;
}

/* Upload drop zone */
#drop-zone {
  border: 2px dashed var(--border-mid);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
#drop-zone.drag-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text-accent); }
#drop-zone .dz-icon  { font-size: 2rem; margin-bottom: 10px; color: var(--text-muted); display: block; }
#drop-zone.drag-over .dz-icon { color: var(--accent); }

/* Upload format guide */
.upload-format-guide {
  margin-top: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 14px 16px;
  font-size: 0.75rem;
}
.ufg-title {
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.ufg-row {
  display: flex;
  gap: 12px;
  margin-bottom: 5px;
  align-items: baseline;
}
.ufg-key {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  flex-shrink: 0;
  min-width: 80px;
}
.ufg-val { color: var(--text-secondary); }
.ufg-note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.6;
}
.ufg-note code {
  color: var(--text-accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.7rem;
}

/* Library add guide (bottom of library panel) */
.lib-add-guide {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.lib-add-guide strong { color: var(--text-secondary); }
.lib-add-guide code {
  color: var(--text-accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.7rem;
}
.lib-add-guide em { color: var(--accent); font-style: normal; }
  margin-top: 16px;
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.modal-btn:hover  { opacity: 0.85; }
.modal-btn:active { transform: scale(0.98); }


/* ─── Sidecar — left column ───────────────────────────────────────────────── */
/*
 * Layout:
 *   #sidecar-wrap  — full-height strip, fixed to LEFT edge
 *   #sidecar-tabs  — 40px vertical tab strip, always visible at left
 *   #sidecar       — 320px panel, slides RIGHT (out from under tabs) on hover/pin
 *
 * #app-shell has left:40px so text never hides under the tab strip.
 * When the panel is open it appears between the tab strip and the text —
 * text reflows around it with no overlap.
 *
 * Open states (same logic as before):
 *   #sidecar-wrap:hover #sidecar     → CSS hover (desktop)
 *   #sidecar-wrap.pinned #sidecar    → JS pin on tab click / Define action
 */

#sidecar-wrap {
  position: fixed;
  top: 0; left: 0;           /* LEFT edge */
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  z-index: 700;
  pointer-events: none;
}

/* ── Vertical tab strip ── */
#sidecar-tabs {
  width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 0 20px;
  gap: 2px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-mid);  /* right border — faces the text */
  pointer-events: auto;
  box-shadow: 4px 0 16px rgba(0,0,0,0.4);
  z-index: 1;
  order: -1;                 /* tabs to the left of panel */
}

.sc-vtab {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  position: relative;
  width: 36px;
}
.sc-vtab:hover  { color: var(--text-accent); background: var(--accent-soft); }
.sc-vtab.active { color: var(--accent);      background: var(--accent-soft); }

/* Active indicator — thin stripe on the RIGHT edge of each tab (facing text) */
.sc-vtab.active::after {
  content: '';
  position: absolute;
  right: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* ── Panel body — slides rightward ── */
#sidecar {
  width: 320px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-mid);
  transform: translateX(-100%);              /* hidden: tucked left behind tabs */
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  pointer-events: auto;
  overflow: hidden;
}

/* Reveal */
#sidecar-wrap:hover #sidecar,
#sidecar-wrap.pinned #sidecar {
  transform: translateX(0);
  box-shadow: 8px 0 40px rgba(0,0,0,0.5);
}

/* Thin accent line at top of open panel */
.sc-accent-bar {
  height: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── sc-panel scroll areas ── */
.sc-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.sc-panel.active { display: flex; flex-direction: column; }
.sc-panel::-webkit-scrollbar       { width: 3px; }
.sc-panel::-webkit-scrollbar-track { background: transparent; }
.sc-panel::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

#sidecar-body { flex: 1; }

.sc-idle-hint {
  text-align: center;
  color: var(--text-muted);
  margin-top: 60px;
  font-size: 0.72rem;
  letter-spacing: 2.5px;
  opacity: 0.6;
}


/* Lexicon entry components */
.def-term   { font-size: 1.3rem; color: var(--text-primary); margin-bottom: 4px; font-weight: 500; }
.def-key    {
  font-size: 0.75rem; color: var(--text-muted);
  margin-bottom: 14px; letter-spacing: 1px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* Inline gematria chip — sits in the .def-key row */
.def-gem-chip {
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 1px 7px;
  letter-spacing: 0;
  font-weight: 600;
  white-space: nowrap;
}
.def-gem-sofit { color: var(--text-accent); font-weight: 400; }

.def-entry  { background: var(--bg-raised); border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; padding: 12px 14px; margin-bottom: 10px; }
.def-strong { font-size: 0.7rem; color: var(--accent); letter-spacing: 1px; margin-bottom: 4px; }
.def-lemma  { font-size: 1rem; color: var(--text-primary); margin-bottom: 6px; }
.def-text   { font-size: 0.82rem; line-height: 1.6; color: var(--text-secondary); }

/* Letter breakdown row — appears between gem block and lexicon entries */
.letter-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
}
.letter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 28px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  cursor: default;
  transition: background 0.1s;
}
.letter-chip:hover { background: var(--accent-soft); border-color: var(--accent-border); }
.letter-chip.letter-sofit { border-color: var(--accent-border); }
.lc-char { font-size: 0.85rem; color: var(--text-primary); font-family: var(--font-mono); }
.lc-val  { font-size: 0.65rem; color: var(--accent); font-weight: 600; }
.letter-chip.letter-sofit .lc-val { color: var(--text-accent); }

/* Loading placeholder in sidecar while dict fetch is in flight */
.def-loading {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 12px 0;
  letter-spacing: 1px;
}

/* ─── Drag-and-drop overlay ───────────────────────────────────────────────── */
#drag-overlay {
  position: fixed; inset: 0;
  background: rgba(4,4,6,0.92);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 900;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#drag-overlay.show { opacity: 1; pointer-events: auto; }

.drag-drop-icon { font-size: 3rem; color: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.08); opacity: 1; } }
.drag-drop-text { font-size: 0.9rem; color: var(--text-secondary); letter-spacing: 2px; text-transform: uppercase; }

/* ─── Loader ──────────────────────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0;
  background: var(--bg-void);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  z-index: 9999;
  transition: opacity 0.5s;
}
#loader.fade { opacity: 0; pointer-events: none; }

.loader-glyph {
  font-family: "Noto Sans Phoenician", sans-serif;
  font-size: 2.5rem;
  color: var(--accent);
  letter-spacing: 4px;
  animation: glyph-fade 1.2s ease-in-out infinite alternate;
}
@keyframes glyph-fade { from { opacity: 0.3; } to { opacity: 1; } }
.loader-text { font-size: 0.7rem; letter-spacing: 3px; text-transform: uppercase; color: var(--text-muted); }

/* ─── Inline line editor ──────────────────────────────────────────────────── */
/*
 * When a .text-line is placed into contenteditable mode by the inline editor,
 * it gets a visible editing affordance without breaking the absolute-position
 * layout. The outline uses box-shadow (not outline) to avoid reflow.
 * user-select:text is already set on .text-line, so cursor:text works.
 */
.text-line[contenteditable="true"] {
  box-shadow: inset 0 0 0 1px var(--accent-border), 0 0 0 3px var(--accent-soft);
  background: rgba(124, 98, 255, 0.06) !important;
  caret-color: var(--accent);
  outline: none;
  /* Prevent the virtual scroller from overwriting content while editing */
  /* (handled in JS via _State.editingLineIdx guard, but the style is the signal) */
}


/* ─── Highlight form (in drawer-notes) ────────────────────────────────────── */

.drawer-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-section.hidden { display: none; }
.drawer-section-title {
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.drawer-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* Colour swatches row */
.hl-swatches {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 20px 0 16px;
}
.hl-swatch {
  width: 38px; height: 38px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.hl-swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}
.hl-swatch.selected {
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}

/* Note input row */
.hl-note-row {
  padding: 0 0 18px;
}
.hl-note-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.hl-note-label span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.7;
}
.hl-note-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.hl-note-input:focus { border-color: var(--accent); }
.hl-note-input::placeholder { color: var(--text-muted); }

/* Modal footer (shared pattern) */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}
.modal-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-btn-secondary:hover {
  border-color: var(--accent-border);
  color: var(--text-secondary);
  background: var(--accent-soft);
}

/* Per-line highlight indicator — a coloured left-border on annotated lines.
   Applied as: lineEl.style.setProperty('--hl-color', record.color)
   and class 'has-highlight' added.                                          */
.text-line.has-highlight {
  border-left: 3px solid var(--hl-color, var(--accent));
  padding-left: 65px; /* 68px - 3px border */
}
.text-line.has-highlight::after {
  content: '◈';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6rem;
  color: var(--hl-color, var(--accent));
  opacity: 0.7;
  pointer-events: none;
}

/* ─── Annotation and comment line rendering ──────────────────────────────── */

/* #[n] and #[n,m] positional annotation lines */
.line-annotation {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 3px 52px 3px 80px;
  line-height: 1.5;
  border-left: 2px solid var(--accent-border);
  background: rgba(124, 98, 255, 0.04);
  cursor: default;
  position: relative;
}
.line-annotation:hover { background: rgba(124, 98, 255, 0.08); }

.ann-del-btn {
  position: absolute;
  left: 63px;          /* aligned with the (+) button on the latin-line above */
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.line-annotation:hover .ann-del-btn,
.line-comment:hover    .ann-del-btn { opacity: 0.5; }
.ann-del-btn:hover                  { opacity: 1 !important; color: #e05c5c; }

.line-edit-history {
  border-left-color: #c8a84b;
  background: rgba(200,168,75,0.03);
  opacity: 0.65;
}
.ann-edit-ts   { color: var(--text-muted); font-size: 0.65rem; margin-right: 6px; opacity: 0.6; }
.ann-edit-desc { color: var(--text-secondary); font-style: italic; font-size: 0.75rem; }

.ann-ref {
  color: var(--accent);
  font-size: 0.7rem;
  margin-right: 6px;
  opacity: 0.8;
  user-select: none;
}
.ann-gloss {
  color: var(--text-secondary);
  font-style: italic;
}
.ann-note {
  color: var(--text-muted);
  font-size: 0.73rem;
}

/* # free-form comment lines */
.line-comment {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 3px 52px 3px 80px;
  opacity: 0.6;
  font-style: italic;
  position: relative;
}

/* Character-range highlight mark inside a text-line */
mark.ann-mark {
  background: rgba(124, 98, 255, 0.22);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  text-decoration: underline;
  text-decoration-color: rgba(124, 98, 255, 0.5);
  text-underline-offset: 2px;
  cursor: help;
}
mark.ann-mark:hover {
  background: rgba(124, 98, 255, 0.38);
}

/* ## global-gloss lines — zero height, invisible in scroller */
.line-global-gloss {
  height: 0 !important;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

/* ─── Letter chip — clickable state ─────────────────────────────────────── */
.letter-chip-clickable {
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.letter-chip-clickable:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ─── Substring matrix ───────────────────────────────────────────────────── */
.substr-matrix-wrap {
  margin-top: 18px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}
.substr-matrix-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}
.substr-matrix-hint {
  font-size: 0.65rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  opacity: 0.7;
}
.substr-matrix {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.substr-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.substr-indent {
  flex-shrink: 0;
  display: inline-block;
}
.substr-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s;
  flex-shrink: 0;
  min-width: 28px;
  justify-content: center;
}
.substr-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text-primary);
  transform: translateY(-1px);
}
/* Has a dictionary entry */
.substr-chip.has-dict {
  color: var(--accent);
  border-color: var(--accent-border);
  background: rgba(124, 98, 255, 0.08);
  font-weight: 600;
}
.substr-chip.has-dict:hover {
  background: rgba(124, 98, 255, 0.18);
}
/* Has an existing annotation */
.substr-chip.has-annot {
  border-color: #4ecdc4;
  background: rgba(78, 205, 196, 0.08);
  color: #4ecdc4;
}
.substr-chip.has-annot:hover {
  background: rgba(78, 205, 196, 0.18);
}
/* Full word chip */
.substr-chip.is-fullword {
  border-color: var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-secondary);
}
/* Single char chip that has a dict hit */
.substr-chip.is-single.has-dict {
  font-size: 0.8rem;
  padding: 4px 8px;
}
/* Single char skip (no hit, no annotation) — muted placeholder */
.substr-skip {
  opacity: 0.18;
  pointer-events: none;
  cursor: default;
}
/* Annotation dot inside chip */
.sc-annot-dot {
  font-size: 0.6rem;
  opacity: 0.8;
  margin-left: 1px;
}

/* ─── Letter history panel ───────────────────────────────────────────────── */
.lp-back {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 4px 8px;
}
.lp-back:hover { color: var(--accent); }

.letter-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lp-glyphs {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.lp-glyph {
  font-size: 3.2rem;
  line-height: 1;
  color: var(--text-primary);
}
.lp-phoenician { color: var(--accent); }
.lp-hebrew     { color: var(--text-secondary); }
.lp-key {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.lp-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 1px;
}
.lp-meaning {
  font-size: 0.82rem;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 4px;
}
.lp-gem {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.lp-gem strong {
  color: var(--accent);
  font-size: 1rem;
}
.lp-section-hdr {
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 3px;
}
.lp-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── No-entry message in sidecar ────────────────────────────────────────── */
.def-no-entry {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 12px 0;
  font-style: italic;
}

/* ─── Letter chip — clickable state ─────────────────────────────────────── */
.hidden  { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.status-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 1px;
  transition: color 0.15s;
}
.status-link:hover { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ─── Sidecar tabs ────────────────────────────────────────────────────────── */



.sc-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 48px;
  line-height: 1.8;
}

/* ─── Glossary panel ──────────────────────────────────────────────────────── */
.sc-section-hdr {
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}
.sc-section-hdr:first-child { padding-top: 2px; }

.sc-gloss-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}
.sgi-key   { color: var(--accent); font-family: var(--font-mono); font-size: 0.78rem; flex-shrink: 0; min-width: 64px; }
.sgi-ctx   { color: var(--text-muted); font-size: 0.65rem; flex-shrink: 0; }
.sgi-arrow { color: var(--text-muted); flex-shrink: 0; }
.sgi-tr    { color: var(--text-primary); flex: 1; }
.sgi-edit, .sgi-del {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 5px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.sgi-edit:hover { opacity: 1; color: var(--accent); }
.sgi-del:hover  { opacity: 1; color: #ff6b6b; }

/* ─── Highlights panel ────────────────────────────────────────────────────── */
.sc-hl-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.hl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.hl-item-body { flex: 1; min-width: 0; }
.hl-item-line {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hl-item-line em { color: var(--text-muted); font-style: normal; }
.hl-item-note {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
}

/* ─── Gloss line ──────────────────────────────────────────────────────────── */
.gloss-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 52px 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.gloss-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: background 0.12s;
  min-width: 28px;
}
.gloss-chip:hover    { background: var(--accent-soft); }
.gloss-chip.gloss-empty .gc-tr { color: var(--text-muted); }
.gc-orig {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}
.gc-tr {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── Remaining modals (share, shortcuts) ─────────────────────────────────── */
#share-modal,
#shortcut-modal {
  position: fixed; inset: 0;
  background: rgba(4, 4, 6, 0.88);
  backdrop-filter: blur(8px);
  z-index: 820;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#share-modal.open,
#shortcut-modal.open {
  opacity: 1;
  pointer-events: auto;
}


/* ─── Share modal ─────────────────────────────────────────────────────────── */
.modal-medium { max-width: 580px !important; }

.share-note-textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 9px 12px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.5;
}
.share-note-textarea:focus { border-color: var(--accent); }
.share-note-textarea::placeholder { color: var(--text-muted); }

.share-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.share-url-input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 7px 10px;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-url-input:focus { border-color: var(--accent); color: var(--text-secondary); }

/* ─── Shared note display in sidecar ────────────────────────────────────── */
.sc-share-note {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
  padding: 12px 0;
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 8px 0;
}
.sc-share-from {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 1px;
}

/* ─── Search match highlighting ─────────────────────────────────────────── */
mark.search-mark {
  background: rgba(124, 98, 255, 0.32);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ─── Latin line # comment icon ─────────────────────────────────────────── */
.line-comment-btn {
  position: absolute;
  left: 26px;          /* right of integrity dot */
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.latin-line:hover .line-comment-btn        { opacity: 0.45; }
.line-comment-btn:hover                    { opacity: 1 !important; color: var(--accent); }

/* ─── Sync highlight — companion line word match ─────────────────────────── */
mark.sync-highlight {
  background: rgba(124, 98, 255, 0.25);
  border-radius: 2px;
  color: inherit;
}

/* ─── Keyboard shortcut modal ────────────────────────────────────────────── */
#shortcut-modal .modal-box { max-width: 480px !important; }

.kbd-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: center;
  padding: 8px 0;
}
.kbd-key {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--bg-raised);
  border: 1px solid var(--accent-border);
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
  text-align: center;
}
.kbd-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Status bar info button ──────────────────────────────────────────────── */
.status-info-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  vertical-align: middle;
}
.status-info-btn:hover { opacity: 1; color: var(--accent); }

/* ─── Info / Attribution / License modal ─────────────────────────────────── */
#info-modal {
  position: fixed; inset: 0;
  background: rgba(4, 4, 6, 0.88);
  backdrop-filter: blur(10px);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#info-modal.open { opacity: 1; pointer-events: auto; }

.modal-info {
  width: min(640px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.info-logo {
  font-family: "Noto Sans Phoenician", var(--font-mono), monospace;
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 3px;
}

.info-body {
  overflow-y: auto;
  padding: 4px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.info-body::-webkit-scrollbar { width: 3px; }
.info-body::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.info-section { display: flex; flex-direction: column; gap: 10px; }

.info-section-hdr {
  font-size: 0.65rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
  padding-bottom: 6px;
}

.info-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}
.info-text code {
  font-family: var(--font-mono);
  background: var(--bg-raised);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.78rem;
  color: var(--accent);
}

.info-attr-row {
  border-left: 2px solid var(--accent-border);
  padding-left: 12px;
  margin-bottom: 8px;
}
.info-attr-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.info-attr-detail {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.info-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-border);
  transition: border-color 0.15s;
}
.info-link:hover { border-bottom-color: var(--accent); }

.info-license-box {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-license-box p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}
.info-note {
  font-size: 0.72rem !important;
  color: var(--text-muted) !important;
  font-style: italic;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.info-version {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  letter-spacing: 1px;
}

/* ── AI Chat Panel ── */
#sc-ai { display:flex; flex-direction:column; height:100%; gap:0; padding:0; }
.ai-context-bar { padding:8px 14px; background:var(--bg-raised); border-bottom:1px solid var(--border-subtle); font-family:var(--font-mono); font-size:0.62rem; color:var(--text-muted); letter-spacing:1px; flex-shrink:0; }
.ai-messages { flex:1; overflow-y:auto; padding:12px 14px; display:flex; flex-direction:column; gap:10px; }
.ai-messages::-webkit-scrollbar { width:3px; }
.ai-messages::-webkit-scrollbar-thumb { background:var(--text-muted); border-radius:2px; }
.ai-welcome { color:var(--text-muted); font-size:0.78rem; text-align:center; margin-top:24px; line-height:1.7; }
.ai-message { max-width:100%; border-radius:8px; padding:10px 12px; }
.ai-user { background:var(--accent-soft); border:1px solid var(--accent-border); align-self:flex-end; max-width:85%; }
.ai-ai { background:var(--bg-raised); border:1px solid var(--border-subtle); align-self:flex-start; }
.ai-text { font-size:0.82rem; color:var(--text-secondary); line-height:1.65; white-space:pre-wrap; word-break:break-word; }
.ai-user .ai-text { color:var(--text-accent); }
.ai-accept-btn { margin-top:8px; width:auto; height:auto; padding:4px 12px; font-size:0.72rem; }
.ai-input-row { display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--border-subtle); flex-shrink:0; }
#ai-input { flex:1; background:var(--bg-raised); border:1px solid var(--border-mid); border-radius:6px; color:var(--text-primary); font-family:var(--font-mono); font-size:0.78rem; padding:8px 10px; outline:none; resize:none; transition:border-color 0.15s; line-height:1.5; }
#ai-input:focus { border-color:var(--accent); }
#ai-input::placeholder { color:var(--text-muted); }
#ai-send { width:36px; height:36px; flex-shrink:0; align-self:flex-end; font-size:1rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   FASE 5 — Hemisphere + Drawer system
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Color tokens for tabs ──────────────────────────────────────────────── */
:root {
  --hemi-blue:   #2563eb;
  --hemi-purple: #7c62ff;
  --hemi-gold:   #c8a84b;
  --hemi-grey:   #374151;
  --hemi-vista:  #1e293b;
  --tab-w:     36px;   /* full tab width */
  --tab-h:     42px;   /* tab height */
  --tab-strip: 18px;   /* permanently visible strip — tabs peek, reveal on hover */
}

/* ─── Left / Right edge containers ─────────────────────────────────────── */
#left-edge, #right-edge {
  position: fixed;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 48px 0;
  gap: 3px;
  z-index: 600;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.is-scrolling #left-edge,
.is-scrolling #right-edge {
  opacity: 0.05;
  pointer-events: none;
}
#left-edge  { left: 0; }
#right-edge { right: 0; align-items: flex-end; }

.hemi-gap { height: 14px; }

/* ─── Tab buttons — book-tab / drawer-pull shape ────────────────────────── */
.hemisphere {
  width: var(--tab-w);
  height: var(--tab-h);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.88);
  transition: transform 0.2s cubic-bezier(0.34, 1.3, 0.64, 1),
              box-shadow 0.15s;
  pointer-events: all;
  position: relative;
  flex-shrink: 0;
}

/* Left tabs: rounded on right side only — poke out from left edge */
.hemi-left {
  border-radius: 0 8px 8px 0;
  transform: translateX(calc(var(--tab-strip) - var(--tab-w)));
  box-shadow: 2px 1px 10px rgba(0,0,0,0.45);
}
.hemi-left:hover {
  transform: translateX(0);
  box-shadow: 3px 2px 18px rgba(0,0,0,0.6);
}
.hemi-left.active {
  transform: translateX(0);
  box-shadow: 3px 2px 18px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.2);
}

/* Right tabs: rounded on left side only — poke out from right edge */
.hemi-right {
  border-radius: 8px 0 0 8px;
  transform: translateX(calc(var(--tab-w) - var(--tab-strip)));
  box-shadow: -2px 1px 10px rgba(0,0,0,0.45);
}
.hemi-right:hover {
  transform: translateX(0);
  box-shadow: -3px 2px 18px rgba(0,0,0,0.6);
}
.hemi-right.active {
  transform: translateX(0);
  box-shadow: -3px 2px 18px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.2);
}

/* Color variants */
.hemi-blue   { background: var(--hemi-blue); }
.hemi-purple { background: var(--hemi-purple); }
.hemi-gold   { background: var(--hemi-gold); }
.hemi-grey   { background: var(--hemi-grey); }
.hemi-vista  { background: var(--hemi-vista); border: 1px solid var(--border-mid); }

/* ─── Drawer containers ─────────────────────────────────────────────────── */
#drawers-left, #drawers-right {
  position: fixed;
  top: 0;
  height: 100%;
  z-index: 550;
  pointer-events: none;
}
#drawers-left  { left: 0; }
#drawers-right { right: 0; }

/* ─── Individual drawer panels ──────────────────────────────────────────── */
.drawer {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.drawer.open { pointer-events: all; }

.drawer-left {
  left: var(--tab-strip);
  transform: translateX(calc(-100% - var(--tab-strip)));
}
.drawer-left.open { transform: translateX(0); }

/* Widths */
#drawer-lexicon,
#drawer-glossary,
#drawer-notes,
#drawer-ai     { width: 320px; }
#drawer-vista  { width: 240px; border-right-color: var(--border-subtle); }

/* ─── Drawer header ─────────────────────────────────────────────────────── */
.drawer-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 44px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 2px;
}
.drawer-hdr-purple { border-bottom-color: rgba(124,98,255,0.4); }
.drawer-hdr-gold   { border-bottom-color: rgba(200,168,75,0.4); }
.drawer-hdr-vista  { border-bottom-color: var(--border-subtle); }

.drawer-title {
  color: var(--text-muted);
  letter-spacing: 2px;
}
.drawer-logo {
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 3px;
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.drawer-close:hover { color: var(--text-primary); background: var(--bg-raised); }

/* ─── Drawer body ───────────────────────────────────────────────────────── */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.drawer-body::-webkit-scrollbar       { width: 3px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

/* Lexicon body contains sidecar-body (inherits its styles) */
#drawer-lexicon .drawer-body  { display: flex; flex-direction: column; }
#sidecar-body                 { flex: 1; }

/* AI drawer needs flex column for input row */
.drawer-ai-body { padding: 0; }
.drawer-ai-body .sc-panel { display: flex; flex-direction: column; height: 100%; }

/* ─── Vista drawer content ──────────────────────────────────────────────── */
.drawer-vista-body {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.vista-group {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.vista-group:last-child { border-bottom: none; }
.vista-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
.vista-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* hud-search inside vista drawer */
#drawer-vista #hud-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
#drawer-vista #hud-search:focus { border-color: var(--accent); }
#drawer-vista #hud-search::placeholder { color: var(--text-muted); }

/* script-picker inside drawer */
#drawer-vista .script-picker { position: relative; }
#drawer-vista .script-popover {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 700;
}

/* ─── App-shell left transition when drawers push ───────────────────────── */
#app-shell {
  transition:
    left   0.25s cubic-bezier(0.16, 1, 0.3, 1),
    right  0.25s cubic-bezier(0.16, 1, 0.3, 1),
    grid-template-columns 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    grid-template-rows    0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Drawer shadow (depth) ─────────────────────────────────────────────── */
.drawer-left.open {
  box-shadow: 4px 0 24px rgba(0,0,0,0.35);
}

/* ─── Inline annotation editor ──────────────────────────────────────────── */
.inline-editor-wrap {
  position: absolute;
  left: 0;
  width: 100%;
  padding: 5px 52px 5px 80px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border-top: 1px solid var(--accent-border);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  box-sizing: border-box;
}
.inline-editor-ctx {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0.9;
}
.inline-editor-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent-border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 1px 0 3px;
  outline: none;
  min-width: 0;
  caret-color: var(--accent);
}
.inline-editor-input::placeholder { color: var(--text-muted); opacity: 0.7; }
.inline-editor-global {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  user-select: none;
}
.inline-editor-nota-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
  flex: 0.7;
}
.inline-editor-nota-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
}
.inline-editor-nota-input {
  flex: 1 !important;
}
.inline-editor-hint {
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.5;
  flex-shrink: 0;
  white-space: nowrap;
}
