/* ==========================================================================
   VerseFlow — design tokens
   ========================================================================== */

:root {
  color-scheme: dark;

  --ink-0: #07080e;
  --ink-1: #0b0d16;
  --ink-2: #10131f;
  --ink-3: #161a29;

  --bg: var(--ink-0);
  --surface: rgba(255, 255, 255, 0.038);
  --surface-2: rgba(255, 255, 255, 0.065);
  --surface-3: rgba(255, 255, 255, 0.095);
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #e9ecf6;
  --text-dim: #a3a9c0;
  --text-faint: #6d7392;

  --accent: #7b6cff;
  --accent-soft: rgba(123, 108, 255, 0.16);
  --accent-line: rgba(123, 108, 255, 0.45);
  --cyan: #3ddad7;
  --gold: #e5b567;
  --rose: #ff6f91;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 40px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 34px 90px -24px rgba(0, 0, 0, 0.85);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --topbar-h: 60px;
  --sidebar-w: 268px;
  --dock-h: 64px;
  --verse-size: 1.0625rem;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard,
    "Segoe UI Variable Text", "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Iropke Batang", Batang, "Songti SC", Georgia,
    "Times New Roman", serif;

  --ease: cubic-bezier(0.22, 0.9, 0.28, 1);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f4ef;
  --ink-1: #fffefb;
  --ink-2: #fbf9f4;
  --ink-3: #f1eee6;

  --surface: rgba(28, 24, 18, 0.035);
  --surface-2: rgba(28, 24, 18, 0.06);
  --surface-3: rgba(28, 24, 18, 0.095);
  --line: rgba(35, 30, 22, 0.11);
  --line-strong: rgba(35, 30, 22, 0.2);

  --text: #1c1a22;
  --text-dim: #575466;
  --text-faint: #8a8698;

  --accent: #5a45e0;
  --accent-soft: rgba(90, 69, 224, 0.11);
  --accent-line: rgba(90, 69, 224, 0.42);
  --cyan: #12878a;
  --gold: #a3742a;
  --rose: #cc3a63;

  --shadow-sm: 0 2px 8px rgba(60, 50, 30, 0.09);
  --shadow-md: 0 14px 36px -14px rgba(60, 50, 30, 0.28);
  --shadow-lg: 0 30px 80px -26px rgba(60, 50, 30, 0.38);
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* Components below set `display`, which would otherwise out-specify the UA
   rule behind the `hidden` attribute and leave invisible overlays on top of
   the reader swallowing clicks. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

kbd {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ==========================================================================
   Ambient background
   ========================================================================== */

.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora span {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.34;
  animation: drift 34s var(--ease) infinite alternate;
}
.aurora span:nth-child(1) { width: 46vw; height: 46vw; left: -12vw; top: -14vw; background: radial-gradient(circle, #6d5efc 0%, transparent 68%); }
.aurora span:nth-child(2) { width: 40vw; height: 40vw; right: -10vw; top: 12vh; background: radial-gradient(circle, #1f9c9a 0%, transparent 68%); animation-delay: -12s; }
.aurora span:nth-child(3) { width: 38vw; height: 38vw; left: 32vw; bottom: -18vw; background: radial-gradient(circle, #b8577f 0%, transparent 68%); animation-delay: -22s; }

[data-theme="light"] .aurora span { opacity: 0.16; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(4vw, 6vh, 0) scale(1.18); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora span { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   Top bar
   ========================================================================== */

.topbar {
  position: relative;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none; padding-right: 4px; }
.brand-mark { width: 26px; height: 26px; stroke: var(--accent); stroke-width: 1.9; }
.brand-name { font-size: 16px; font-weight: 500; letter-spacing: -0.02em; color: var(--text-dim); white-space: nowrap; }
.brand-name b { font-weight: 700; color: var(--text); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  transition: background 0.16s, color 0.16s, transform 0.16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: var(--r-sm); }
.icon-btn.sm svg { width: 17px; height: 17px; }

.nav-toggle { display: none; }

.omni {
  flex: 1;
  min-width: 0;
  max-width: 620px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-faint);
  text-align: left;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.omni:hover { border-color: var(--line-strong); background: var(--surface-2); }
.omni:focus-visible { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.omni svg { width: 17px; height: 17px; }
.omni-hint { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omni-hint em { font-style: normal; color: var(--text-faint); opacity: 0.62; }
.omni kbd { flex: none; }

.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.chip-btn {
  display: flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}
.chip-btn:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.chip-btn svg { width: 15px; height: 15px; }

#themeToggle .ico-moon { display: none; }
[data-theme="light"] #themeToggle .ico-sun { display: none; }
[data-theme="light"] #themeToggle .ico-moon { display: block; }

/* ==========================================================================
   Shell
   ========================================================================== */

.shell {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-h));
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink-1) 55%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.side-tabs { display: flex; gap: 4px; padding: 12px 12px 8px; }
.side-tab {
  flex: 1;
  height: 32px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  color: var(--text-faint);
  transition: background 0.16s, color 0.16s;
}
.side-tab:hover { color: var(--text-dim); background: var(--surface); }
.side-tab.is-active { background: var(--accent-soft); color: var(--accent); }
[data-theme="light"] .side-tab.is-active { color: var(--accent); }

.side-filter {
  position: relative;
  margin: 0 12px 10px;
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 11px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid transparent;
  transition: border-color 0.16s, background 0.16s;
}
.side-filter:focus-within { border-color: var(--accent-line); background: var(--surface-2); }
.side-filter svg { width: 15px; height: 15px; color: var(--text-faint); }
.side-filter input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  font-size: 13px;
}
.side-filter input::placeholder { color: var(--text-faint); }
.side-filter input::-webkit-search-cancel-button { display: none; }

.book-list { flex: 1; overflow-y: auto; padding: 0 8px 20px; scrollbar-gutter: stable; }

.book-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-dim);
  text-align: left;
  transition: background 0.13s, color 0.13s;
}
.book-item:hover { background: var(--surface-2); color: var(--text); }
.book-item.is-current { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.book-item.is-current .book-abbr { color: var(--accent); border-color: var(--accent-line); }
.book-abbr {
  flex: none;
  display: grid; place-items: center;
  min-width: 30px; height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 11px; font-weight: 600;
  color: var(--text-faint);
  font-feature-settings: "tnum";
}
.book-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-chaps { flex: none; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.book-empty { padding: 24px 12px; text-align: center; font-size: 13px; color: var(--text-faint); }

.chapter-panel {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--ink-1) 92%, transparent);
  backdrop-filter: blur(18px);
  animation: slideIn 0.24s var(--ease);
}
@keyframes slideIn { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.chapter-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.chapter-panel-head strong { font-size: 14px; font-weight: 600; }

.chapter-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 5px;
  padding: 12px;
  align-content: start;
}
.chapter-cell {
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  transition: background 0.13s, color 0.13s, transform 0.13s var(--ease);
}
.chapter-cell:hover { background: var(--surface-3); color: var(--text); transform: translateY(-1px); }
.chapter-cell.is-current { background: var(--accent); color: #fff; font-weight: 700; }

/* ── Reader ──────────────────────────────────────────────────────────────── */

/* A near-opaque plate over the aurora: the ambience stays visible at the
   edges, but scripture is never read through a colour wash. */
.reader {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}

.reader-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(10px);
}

.crumb { display: flex; align-items: center; gap: 4px; min-width: 0; }
.crumb-btn {
  display: flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 9px 0 11px;
  border-radius: var(--r-sm);
  font-size: 15px; font-weight: 650; letter-spacing: -0.015em;
  color: var(--text);
  transition: background 0.15s;
}
.crumb-btn:hover { background: var(--surface-2); }
.crumb-btn svg { width: 14px; height: 14px; color: var(--text-faint); }
#crumbChapter { font-weight: 500; color: var(--text-dim); }

.reader-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }

.grid-wrap { flex: 1; overflow: auto; scroll-behavior: smooth; position: relative; }

/* Column headers stay pinned while the verses scroll. */
.col-head {
  position: sticky; top: 0; z-index: 12;
  display: grid;
  grid-template-columns: var(--num-w) var(--grid-cols);
  gap: 0 var(--col-gap, 26px);
  padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.col-chip { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.col-chip b {
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text);
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.col-chip span { font-size: 11.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-chip .col-drop {
  margin-left: auto; flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--text-faint);
  opacity: 0; transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.col-chip:hover .col-drop { opacity: 1; }
.col-chip .col-drop:hover { background: var(--surface-3); color: var(--rose); }
.col-chip .col-drop svg { width: 13px; height: 13px; }

.verse-grid { padding: 6px 24px 8vh; }

/* Every verse is one grid row spanning all translations, which keeps the
   columns locked together without any scroll-sync scripting. */
.verse-row {
  display: grid;
  grid-template-columns: var(--num-w) var(--grid-cols);
  gap: 0 var(--col-gap, 26px);
  padding: 7px 10px 7px 0;
  margin: 0 -10px;
  border-radius: var(--r-md);
  scroll-margin-top: 96px;
  transition: background 0.14s;
  cursor: pointer;
  position: relative;
}
.verse-row:hover { background: var(--surface); }
.verse-row.is-selected { background: var(--accent-soft); }
.verse-row.is-selected::before {
  content: "";
  position: absolute; left: -10px; top: 5px; bottom: 5px;
  width: 3px; border-radius: 99px;
  background: var(--accent);
}

@keyframes pulseTarget {
  0%   { background: color-mix(in srgb, var(--gold) 34%, transparent); }
  100% { background: transparent; }
}
.verse-row.is-target { animation: pulseTarget 2.6s var(--ease) forwards; }
.verse-row.is-target .verse-num { color: var(--gold); }

.verse-gutter {
  display: flex; align-items: flex-start; justify-content: flex-end;
  gap: 3px;
  padding-top: 0.2em;
  user-select: none;
}
.verse-num {
  font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  min-width: 1.6em; text-align: right;
  transition: color 0.14s;
}
.verse-row:hover .verse-num { color: var(--accent); }
.verse-row.is-selected .verse-num { color: var(--accent); }

.xref-btn {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.xref-btn svg { width: 12px; height: 12px; }
.verse-row:hover .xref-btn { opacity: 1; }
.xref-btn:hover, .xref-btn.is-open { opacity: 1; color: var(--cyan); background: var(--surface-3); }
.xref-btn[data-empty="1"] { opacity: 0 !important; pointer-events: none; }

.verse-cell {
  min-width: 0;
  font-family: var(--serif);
  font-size: var(--verse-size);
  line-height: 1.78;
  letter-spacing: -0.003em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.verse-cell[data-lang="en"], .verse-cell[data-lang="es"] { letter-spacing: 0; word-break: normal; }
.verse-cell[data-lang="zh"] { word-break: break-all; line-height: 1.85; }
.verse-cell:empty::after { content: "—"; color: var(--text-faint); opacity: 0.4; }
.verse-cell mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* The tall tail keeps `scrollIntoView({ block: "center" })` able to centre
   even the last verse of a chapter. */
.chapter-foot { display: flex; justify-content: space-between; gap: 12px; padding: 8px 24px 34vh; }
.foot-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px; color: var(--text-dim);
  transition: border-color 0.16s, background 0.16s, color 0.16s, transform 0.16s var(--ease);
}
.foot-btn:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); transform: translateY(-2px); }
.foot-btn b { font-weight: 600; color: var(--text); }
.foot-btn.right { margin-left: auto; }

.reader-empty { flex: 1; display: grid; place-items: center; padding: 40px; text-align: center; color: var(--text-faint); font-size: 14px; }

/* ── Selection dock ──────────────────────────────────────────────────────── */

.dock {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 14px;
  max-width: min(94vw, 860px);
  padding: 10px 10px 10px 18px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--ink-2) 82%, transparent);
  backdrop-filter: blur(26px) saturate(1.6);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  box-shadow: var(--shadow-lg);
  animation: dockIn 0.3s var(--ease);
}
[data-theme="light"] .dock { background: color-mix(in srgb, #fff 88%, transparent); }
@keyframes dockIn { from { transform: translate(-50%, 22px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.dock-count { display: flex; align-items: baseline; gap: 4px; flex: none; }
.dock-count b { font-size: 19px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.dock-count span { font-size: 12px; color: var(--text-faint); }
.dock-ref {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 12px; border-left: 1px solid var(--line);
}
.dock-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg-btn {
  padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text-dim); }
.seg-btn.is-active { background: var(--surface-3); color: var(--text); }

.ghost-btn {
  padding: 9px 13px; border-radius: var(--r-md);
  font-size: 12.5px; color: var(--text-faint);
  transition: background 0.15s, color 0.15s;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }

.primary-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), #9d7bff);
  color: #fff;
  font-size: 13px; font-weight: 650;
  box-shadow: 0 6px 18px -6px var(--accent);
  transition: transform 0.16s var(--ease), box-shadow 0.16s, filter 0.16s;
  white-space: nowrap;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -8px var(--accent); filter: brightness(1.06); }
.primary-btn:active { transform: translateY(0) scale(0.98); }
.primary-btn svg { width: 15px; height: 15px; }
.primary-btn kbd { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.9); }

/* ── Cross-reference popup ───────────────────────────────────────────────── */

.xref-pop {
  position: fixed;
  z-index: 70;
  width: 336px;
  max-height: min(60vh, 460px);
  display: flex; flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--ink-3) 97%, transparent);
  backdrop-filter: blur(26px) saturate(1.5);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.16s var(--ease);
}
[data-theme="light"] .xref-pop { background: color-mix(in srgb, #fff 98%, transparent); }
@keyframes popIn { from { transform: translateY(6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.xref-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 14px 9px;
  border-bottom: 1px solid var(--line);
}
.xref-title { font-size: 12.5px; font-weight: 650; color: var(--text); }
.xref-src { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); }

.xref-body { flex: 1; overflow-y: auto; padding: 5px; }

.xref-item {
  display: block; width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background 0.13s;
}
.xref-item:hover { background: var(--surface-2); }
.xref-item .xr-ref { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--cyan); margin-bottom: 2px; }
.xref-item .xr-ref svg { width: 11px; height: 11px; opacity: 0; transition: opacity 0.13s; margin-left: auto; }
.xref-item:hover .xr-ref svg { opacity: 0.7; }
.xref-item .xr-text {
  font-family: var(--serif);
  font-size: 12.5px; line-height: 1.6; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: keep-all;
}
.xref-loading, .xref-none { padding: 18px; text-align: center; font-size: 12px; color: var(--text-faint); }

.xref-foot { padding: 8px 13px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--text-faint); text-align: center; }
.xref-foot b { color: var(--text-dim); font-weight: 600; }

/* ── Overlays: palette & sheets ──────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 90;
  display: grid;
  background: rgba(4, 5, 10, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.18s var(--ease);
  padding: 16px;
}
[data-theme="light"] .overlay { background: rgba(40, 34, 24, 0.34); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#omniOverlay { align-items: start; justify-items: center; padding-top: min(14vh, 120px); }
#transOverlay, #helpOverlay { place-items: center; }

.palette {
  width: min(680px, 100%);
  max-height: min(70vh, 620px);
  display: flex; flex-direction: column;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--ink-2) 94%, transparent);
  backdrop-filter: blur(30px) saturate(1.6);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: sheetIn 0.22s var(--ease);
}
[data-theme="light"] .palette, [data-theme="light"] .sheet { background: color-mix(in srgb, #fff 96%, transparent); }
@keyframes sheetIn { from { transform: translateY(-14px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }

.palette-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.palette-input svg { width: 19px; height: 19px; color: var(--text-faint); }
.palette-input input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 17px; letter-spacing: -0.01em; }
.palette-input input::placeholder { color: var(--text-faint); }
.palette-badge {
  flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 4px 8px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
}
.palette-badge:empty { display: none; }

.palette-results { flex: 1; overflow-y: auto; padding: 7px; min-height: 0; }

.pal-group { padding: 10px 12px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }

.pal-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background 0.1s;
}
.pal-item:hover, .pal-item.is-active { background: var(--surface-2); }
.pal-item.is-active { box-shadow: inset 0 0 0 1px var(--accent-line); }
.pal-icon {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); color: var(--accent);
}
.pal-icon svg { width: 15px; height: 15px; }
.pal-main { flex: 1; min-width: 0; }
.pal-title { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: baseline; gap: 7px; }
.pal-title small { font-size: 11px; font-weight: 500; color: var(--text-faint); }
.pal-sub {
  display: block; /* spans do not clip; blockify so the ellipsis works */
  font-family: var(--serif);
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}
.pal-sub mark { background: color-mix(in srgb, var(--gold) 32%, transparent); color: var(--text); border-radius: 3px; }
.pal-enter { flex: none; font-size: 10px; color: var(--text-faint); opacity: 0; }
.pal-item.is-active .pal-enter { opacity: 1; }
.pal-empty { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13px; line-height: 1.7; }
.pal-empty code { font-size: 12px; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-dim); }

.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-faint); flex-wrap: wrap; }
.palette-foot span { display: flex; align-items: center; gap: 4px; }

/* Sheets */
.sheet {
  width: min(700px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--ink-2) 96%, transparent);
  backdrop-filter: blur(30px);
  box-shadow: var(--shadow-lg);
  animation: sheetIn 0.22s var(--ease);
}
.sheet.narrow { width: min(540px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.sheet-sub { margin: 0 0 18px; font-size: 13px; color: var(--text-faint); line-height: 1.6; }

.trans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 9px; }

.trans-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.16s, background 0.16s, transform 0.16s var(--ease);
}
.trans-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.trans-card.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.trans-tick {
  flex: none; display: grid; place-items: center;
  width: 19px; height: 19px; margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  color: transparent;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.trans-tick svg { width: 12px; height: 12px; stroke-width: 2.6; }
.trans-card.is-on .trans-tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.trans-info { min-width: 0; flex: 1; }
.trans-label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 650; }
.trans-lang { font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-faint); }
.trans-full { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trans-order {
  position: absolute; top: 10px; right: 12px;
  font-size: 10px; font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-note { font-size: 11.5px; color: var(--text-faint); }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 11px 18px; margin: 4px 0 22px; align-items: baseline; }
.keys dt { display: flex; gap: 3px; align-items: center; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.keys dd { margin: 0; font-size: 13px; color: var(--text-dim); }
.keys dd code, .keys dd b { color: var(--text); }
.keys dd code { font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }

.credits { border-top: 1px solid var(--line); padding-top: 16px; }
.credits h3 { margin: 0 0 9px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); }
.credits ul { margin: 0 0 10px; padding-left: 17px; }
.credits li, .credits p { font-size: 12.5px; color: var(--text-dim); line-height: 1.75; margin: 0; }
.credits a { color: var(--accent); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--dock-h) + 42px); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 17px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--ink-3) 92%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  font-size: 13px; font-weight: 500;
  animation: toastIn 0.26s var(--ease);
  white-space: nowrap;
}
[data-theme="light"] .toast { background: color-mix(in srgb, #fff 94%, transparent); }
.toast svg { width: 16px; height: 16px; color: var(--cyan); }
.toast.is-out { animation: toastOut 0.24s var(--ease) forwards; }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-8px); opacity: 0; } }

/* ── Boot / loading ──────────────────────────────────────────────────────── */

.boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg);
  font-size: 13px; color: var(--text-faint);
  transition: opacity 0.35s var(--ease);
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  animation: bootPulse 1.4s var(--ease) infinite;
}
@keyframes bootPulse {
  0%, 100% { transform: scale(1) rotate(0deg); border-radius: 12px; opacity: 1; }
  50% { transform: scale(0.82) rotate(45deg); border-radius: 50%; opacity: 0.6; }
}

.skeleton { display: grid; gap: 14px; padding: 26px 24px; }
.skeleton div {
  height: 15px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton div:nth-child(3n) { width: 72%; }
.skeleton div:nth-child(3n+1) { width: 92%; }
@keyframes shimmer { to { background-position: -400% 0; } }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .omni-hint em { display: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: grid; }
  .brand-name { display: none; }

  .sidebar {
    position: fixed; z-index: 80;
    top: var(--topbar-h); bottom: 0; left: 0;
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform 0.28s var(--ease);
    background: color-mix(in srgb, var(--ink-1) 97%, transparent);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .sidebar-scrim { position: fixed; inset: var(--topbar-h) 0 0; z-index: 70; background: rgba(0, 0, 0, 0.5); animation: fade 0.2s; }

  .verse-grid, .col-head, .chapter-foot { padding-left: 16px; padding-right: 16px; }
  .reader-head { padding: 10px 14px; }

  .dock { left: 12px; right: 12px; bottom: 12px; transform: none; max-width: none; flex-wrap: wrap; gap: 10px; padding: 12px; }
  @keyframes dockIn { from { transform: translateY(22px); opacity: 0; } to { transform: none; opacity: 1; } }
  .dock-ref { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; }
  .dock-actions { margin-left: auto; }
  .toast-wrap { bottom: calc(var(--dock-h) + 78px); }

  .xref-pop { width: min(340px, calc(100vw - 24px)); }
}

/* Side-by-side columns stop being readable well before phone width, so each
   verse stacks its translations instead — still one row per verse, still
   perfectly aligned, just vertically. */
@media (max-width: 760px) {
  .col-head { display: none; }

  .verse-row {
    grid-template-columns: var(--num-w) minmax(0, 1fr);
    gap: 0 8px;
    padding: 12px 10px;
  }
  .verse-cell { grid-column: 2; }
  .verse-cell + .verse-cell {
    margin-top: 11px;
    padding-top: 11px;
    border-top: 1px dashed var(--line);
  }
  .grid-wrap:not([data-cols="1"]) .verse-cell::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-family: var(--sans);
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
}

@media (max-width: 620px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .omni-hint { display: none; }
  .omni { flex: none; width: 40px; padding: 0; justify-content: center; }
  .omni kbd { display: none; }
  .chip-btn span { display: none; }
  .chip-btn { padding: 0 12px; }
  .seg { display: none; }
  .palette-foot span:nth-child(n+3) { display: none; }
}

@media print {
  .topbar, .sidebar, .dock, .aurora, .col-head, .reader-head, .chapter-foot, .boot, .overlay, .xref-pop { display: none !important; }
  body { overflow: visible; background: #fff; color: #000; }
  .shell { display: block; height: auto; }
  .grid-wrap { overflow: visible; }
}
