/*
 * styles.css — KatabAPP-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:  36px;   /* MUST match LINE_HEIGHTS.text  in engine.js */
  --font-sz: 17px;
  --hud-h:   56px;
  --bubble-r: 8px;
}

/* ─── 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); }
*, *::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;
  right: 40px; /* always clear the sidecar tab strip */
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  transition:
    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);
}

#app-shell.split-v { grid-template-columns: 1fr 1fr; }
#app-shell.split-h { grid-template-rows: 1fr 1fr; grid-template-columns: 1fr; }

/* ─── Panes ───────────────────────────────────────────────────────────────── */
.pane {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  scroll-behavior: smooth;
}
.pane + .pane { border-left: 1px solid var(--border-subtle); }
#app-shell.split-h .pane + .pane { border-left: none; border-top: 1px solid var(--border-subtle); }

.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;
  min-height: var(--line-h);
  line-height: var(--line-h);
  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;
}
.text-line:hover { background: rgba(255, 255, 255, 0.015); }

/* ─── 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; }
.s-protosinaitic { font-family: "Noto Sans Phoenician", sans-serif; opacity: 0.85; }

/* ─── 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-corpus { color: var(--text-muted); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.status-sep    { color: var(--border-mid); }
.status-flex   { flex: 1; }
.status-hint   {
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0.6;
  font-size: 0.6rem;
  letter-spacing: 1px;
}

/* 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 20px;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,98,255,0.08);
}

.hud-sep {
  width: 1px; height: 20px;
  background: var(--border-mid);
  flex-shrink: 0;
}

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

.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); }

.hud-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.hud-select:focus { border-color: var(--accent); }

#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-modal {
  position: fixed; inset: 0;
  background: rgba(4,4,6,0.92);
  backdrop-filter: blur(8px);
  z-index: 800;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#source-modal.open { opacity: 1; pointer-events: auto; }

.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); }

/* ─── Action bubble ───────────────────────────────────────────────────────── */
#bubble {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--bubble-r);
  padding: 6px 8px;
  display: flex; align-items: center; gap: 6px;
  z-index: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6), 0 0 0 1px var(--accent-glow);
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  transform: translateY(6px);
  font-size: 0.78rem;
  white-space: nowrap;
}
#bubble.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

.bbtn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  transition: all 0.12s;
}
.bbtn:hover { background: var(--accent-soft); border-color: var(--accent-border); color: var(--text-accent); }

#bubble-sep { width: 1px; height: 14px; background: var(--border-mid); }
/* Standard gematria — always visible */
#bubble-gem-std   { color: var(--accent); font-weight: 600; padding: 0 2px; font-size: 0.78rem; min-width: 24px; text-align: center; }
/* Slash separator + sofit value — hidden when standard === sofit */
#bubble-gem-slash { color: var(--text-muted); font-size: 0.72rem; padding: 0 1px; }
#bubble-gem-sft   { color: var(--text-accent); font-weight: 600; padding: 0 2px; font-size: 0.78rem; min-width: 24px; text-align: center; }
#bubble-key { color: var(--text-muted); font-size: 0.72rem; padding: 0 4px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; }

/* ─── Sidecar peek panel ──────────────────────────────────────────────────── */

/*
 * Layout:
 *   #sidecar-wrap  — full-height strip flush to right edge, width = tabs+panel
 *   #sidecar-tabs  — 40px vertical tab strip, always in viewport
 *   #sidecar       — 320px panel body, hidden by default (translateX(100%))
 *
 * Open states:
 *   #sidecar-wrap:hover #sidecar     → CSS hover (desktop)
 *   #sidecar-wrap.pinned #sidecar    → JS toggles .pinned on tab click
 *
 * The wrap itself is pointer-events:none except on the tab strip and open panel,
 * so hovering the reading area never accidentally peeks the panel.
 */

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

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

.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 — left edge accent stripe (right after rotate) */
.sc-vtab.active::after {
  content: '';
  position: absolute;
  right: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* ── Panel body ── */
#sidecar {
  width: 320px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-mid);
  transform: translateX(100%);
  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;
  order: -1; /* panel left of tabs */
}

/* Open via hover (desktop) */
#sidecar-wrap:hover #sidecar {
  transform: translateX(0);
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
}
/* Open via pin (tab click or Define action) */
#sidecar-wrap.pinned #sidecar {
  transform: translateX(0);
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
}

/* Thin accent line at the very top of the 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 lives inside sc-lexicon */
#sidecar-body { flex: 1; }

/* ── Idle hint inside lexicon panel ── */
.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: 16px; letter-spacing: 1px; }
.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); }

/* Gematria display block */
.gem-display {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: center;
}
.gem-label { font-size: 0.65rem; letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase; }
.gem-value { font-size: 2rem; color: var(--accent); font-weight: 600; margin: 4px 0; }
.gem-word  { font-size: 0.8rem; color: var(--text-secondary); }

/* Sofit badge inline with standard value when they differ */
.gem-sofit-badge {
  font-size: 1.1rem;
  color: var(--text-accent);
  font-weight: 400;
  margin-left: 4px;
}

/* 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) */
}

/* Edit button in bubble — accent colour to distinguish from Copy/Define */
.bbtn-edit {
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}
.bbtn-edit:hover {
  background: var(--accent-soft) !important;
}

/* Highlight button in bubble (Cherry-pick 4) */
.bbtn-highlight {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0;
}
.bbtn-highlight:hover {
  color: var(--text-accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* ─── Highlight annotation modal (Cherry-pick 4) ──────────────────────────── */

#highlight-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;
}
#highlight-modal.open {
  opacity: 1;
  pointer-events: auto;
}

/* 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: 49px; /* 52px - 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 52px;
  line-height: 1.5;
  border-left: 2px solid var(--accent-border);
  background: rgba(124, 98, 255, 0.04);
  cursor: default;
}
.line-annotation:hover { background: rgba(124, 98, 255, 0.08); }

.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;
  opacity: 0.6;
  font-style: italic;
}

/* 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;
}

/* ─── Translate modal ─────────────────────────────────────────────────────── */
#translate-modal,
#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;
}
#translate-modal.open,
#share-modal.open,
#shortcut-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.tr-word-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.tr-word-key {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent);
}
.tr-word-note {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.tr-global-row {
  padding-bottom: 14px;
}
.tr-global-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.tr-global-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px; height: 14px;
}

/* Translate button in bubble */
.bbtn-translate {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.bbtn-translate:hover {
  color: var(--text-accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* ─── 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;
}

/* ─── 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;
}
