/* ==========================================================================
   BibleHelpMe · "Lumen" design system
   Night sky + golden light. Scripture set in Cormorant Garamond; UI in Inter.
   Two themes: night (default) and dawn. Toggled via <html data-theme="">.
   ========================================================================== */

:root {
  --font-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --gold: #e9b949;
  --gold-bright: #f6d379;
  --gold-deep: #c99a2e;
  --ember: #f0a848;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --topbar-h: 64px;
  --bnav-h: 60px;

  --ease: cubic-bezier(.22, .8, .3, 1);
}

html[data-theme="night"] {
  color-scheme: dark;
  --bg-0: #05070e;
  --bg-1: #0a1020;
  --bg-2: #0e1730;
  --ink: #f1e9d6;
  --ink-soft: #cfd2c9;
  --muted: #929db4;
  --line: rgba(233, 185, 73, .14);
  --line-soft: rgba(226, 232, 255, .08);
  --glass: rgba(13, 21, 41, .58);
  --glass-strong: rgba(10, 16, 33, .82);
  --glass-soft: rgba(15, 24, 46, .38);
  --accent-ink: #14100a;
  --gold-text: #f2cd6f;
  --halo: rgba(233, 185, 73, .18);
  --shadow: 0 18px 50px rgba(2, 4, 12, .55);
  --user-bubble: linear-gradient(135deg, rgba(233,185,73,.16), rgba(233,185,73,.07));
  --scroll-thumb: rgba(233, 185, 73, .25);
}

html[data-theme="dawn"] {
  color-scheme: light;
  --bg-0: #f5efe2;
  --bg-1: #f9f4e9;
  --bg-2: #efe6d2;
  --ink: #241f14;
  --ink-soft: #433b2a;
  --muted: #7d7355;
  --line: rgba(154, 116, 28, .22);
  --line-soft: rgba(80, 62, 20, .1);
  --glass: rgba(255, 252, 244, .72);
  --glass-strong: rgba(255, 252, 244, .92);
  --glass-soft: rgba(255, 252, 244, .5);
  --accent-ink: #201607;
  --gold-text: #8a6410;
  --halo: rgba(201, 154, 46, .2);
  --shadow: 0 16px 40px rgba(96, 74, 22, .16);
  --user-bubble: linear-gradient(135deg, rgba(201,154,46,.18), rgba(201,154,46,.08));
  --scroll-thumb: rgba(154, 116, 28, .3);
}

/* ----------------------------------------------------------- base ----- */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg-0);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
svg use { pointer-events: none; }
::selection { background: rgba(233, 185, 73, .35); }

body::before {
  content: "";
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(120% 90% at 75% -10%, var(--bg-2) 0%, transparent 55%),
    radial-gradient(100% 80% at 10% 100%, var(--bg-2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 55%, var(--bg-0));
}

#lumen-field { position: fixed; inset: 0; z-index: -2; pointer-events: none; }

.veil {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 0%, var(--halo) 0%, transparent 70%);
  opacity: .5;
  animation: veilBreath 14s ease-in-out infinite alternate;
}
@keyframes veilBreath { from { opacity: .32; } to { opacity: .6; } }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 200;
  background: var(--gold); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 8px; }

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

/* ------------------------------------------------------- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- glass ------ */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.glass-soft {
  background: var(--glass-soft);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
}

/* --------------------------------------------------------- topbar ------ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) clamp(14px, 4vw, 32px) 0;
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(180deg, var(--bg-0) 0%, transparent 140%);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--accent-ink);
  background: radial-gradient(120% 120% at 30% 20%, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 0 18px var(--halo), 0 0 46px var(--halo);
  animation: markGlow 5s ease-in-out infinite alternate;
}
@keyframes markGlow {
  from { box-shadow: 0 0 12px var(--halo), 0 0 30px var(--halo); }
  to   { box-shadow: 0 0 22px var(--halo), 0 0 60px var(--halo); }
}
.brand-word { font-family: var(--font-serif); font-weight: 600; font-size: 24px; letter-spacing: .01em; }
.brand-word em { font-style: normal; color: var(--gold-text); }

.topnav { display: flex; gap: 6px; margin-left: auto; }
.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  color: var(--muted); font-weight: 500; font-size: 14.5px;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.nav-btn:hover { color: var(--ink); }
.nav-btn.active {
  color: var(--gold-text);
  background: var(--user-bubble);
  border: 1px solid var(--line);
}
.nav-btn:not(.active) { border: 1px solid transparent; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  transition: color .2s, border-color .2s, transform .2s var(--ease);
}
.icon-btn:hover { color: var(--gold-text); border-color: var(--line); transform: translateY(-1px); }
#theme-toggle { margin-left: 6px; }
html[data-theme="night"] .ic-moon { display: none; }
html[data-theme="dawn"] .ic-sun { display: none; }

/* ----------------------------------------------------------- views ----- */
main { position: relative; z-index: 1; }
.view {
  display: none;
  min-height: 100dvh;
  padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
}
.view.active { display: block; animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================== GUIDE ================================= */
.view-guide.active { display: flex; flex-direction: column; height: 100dvh; }
.guide-scroll {
  flex: 1; overflow-y: auto;
  padding: 20px clamp(14px, 4vw, 32px) 16px;
  scroll-behavior: smooth;
}
.guide-hero {
  max-width: 720px; margin: clamp(16px, 7vh, 84px) auto 24px;
  text-align: center;
}
.hero-kicker {
  color: var(--gold-text); text-transform: uppercase;
  letter-spacing: .32em; font-size: 11.5px; font-weight: 600;
  margin-bottom: 18px;
}
.hero-title {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(44px, 8vw, 76px); line-height: 1.04;
  letter-spacing: .005em;
  background: linear-gradient(160deg, var(--ink) 30%, var(--gold-text) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  margin-bottom: 18px;
}
.hero-sub { color: var(--muted); font-size: clamp(15px, 2.4vw, 17.5px); margin-bottom: 34px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass-soft);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--ink-soft); font-size: 14px;
  transition: transform .25s var(--ease), border-color .25s, color .25s, box-shadow .25s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--gold); color: var(--gold-text); box-shadow: 0 6px 22px var(--halo); }

.thread { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; animation: msgIn .4s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.msg-user { justify-content: flex-end; }
.msg-avatar {
  flex: 0 0 34px; width: 34px; height: 34px; margin-top: 4px;
  border-radius: 50%; display: grid; place-items: center;
  color: var(--gold-text);
  background: var(--glass); border: 1px solid var(--line);
  box-shadow: 0 0 14px var(--halo);
}
.msg-bubble {
  max-width: min(86%, 620px);
  padding: 14px 18px; border-radius: var(--radius-lg);
  border: 1px solid var(--line-soft);
  background: var(--glass-soft);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 15.5px;
  overflow-wrap: break-word;
}
.msg-user .msg-bubble {
  background: var(--user-bubble);
  border-color: var(--line);
  border-bottom-right-radius: 8px;
}
.msg-guide .msg-bubble { border-top-left-radius: 8px; }
.msg-bubble p { margin: 0 0 .8em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h2, .msg-bubble h3 {
  font-family: var(--font-serif); color: var(--gold-text);
  font-size: 1.25em; margin: .9em 0 .45em; font-weight: 600;
}
.msg-bubble ul, .msg-bubble ol { margin: 0 0 .8em 1.2em; }
.msg-bubble li { margin-bottom: .35em; }
.msg-bubble blockquote {
  font-family: var(--font-serif); font-size: 1.16em; font-style: italic;
  border-left: 2px solid var(--gold); padding: 2px 0 2px 14px;
  margin: .8em 0; color: var(--ink);
}
.msg-bubble strong { color: var(--gold-text); font-weight: 600; }
.msg-bubble .stream-cursor {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); margin-left: 4px; vertical-align: baseline;
  box-shadow: 0 0 10px var(--gold);
  animation: cursorPulse 1s ease-in-out infinite;
}
@keyframes cursorPulse { 50% { opacity: .35; transform: scale(.8); } }

.ref-link {
  color: var(--gold-text); font-weight: 600;
  border-bottom: 1px dashed var(--gold);
  padding: 0 1px; border-radius: 3px;
  transition: background .2s, color .2s;
  cursor: pointer;
}
.ref-link:hover { background: var(--halo); }

.typing { display: inline-flex; gap: 6px; padding: 6px 2px; }
.typing i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 8px var(--halo);
  animation: typingWave 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typingWave { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

.thread-end { height: 8px; }

.composer-wrap {
  padding: 10px clamp(14px, 4vw, 32px) calc(14px + env(safe-area-inset-bottom));
  max-width: 820px; margin: 0 auto; width: 100%;
}
.passage-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 10px 6px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--user-bubble); color: var(--gold-text);
  font-size: 13px; font-weight: 500;
}
.passage-chip-x { display: grid; place-items: center; color: inherit; opacity: .7; }
.passage-chip-x:hover { opacity: 1; }
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 10px 10px 20px;
  transition: border-color .25s, box-shadow .25s;
}
.composer:focus-within { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 10px 40px var(--halo); }
#composer-input {
  flex: 1; background: none; border: 0; outline: 0; resize: none;
  font-size: 16px; line-height: 1.5; color: var(--ink);
  max-height: 160px; padding: 8px 0;
}
#composer-input::placeholder { color: var(--muted); }
.send-btn {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  color: var(--accent-ink);
  background: radial-gradient(120% 120% at 30% 20%, var(--gold-bright), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 4px 18px var(--halo);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.send-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 26px var(--halo); }
.send-btn:disabled { opacity: .45; transform: none; cursor: default; }
.composer-tools { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; }
.lens-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.lens-select {
  background: transparent; border: 1px solid var(--line-soft); border-radius: 999px;
  color: var(--ink-soft); font-size: 13px; padding: 5px 12px;
  max-width: 220px;
}
.lens-select option { color: #1a1a1a; background: #f5efe2; }
.composer-spacer { flex: 1; }
.text-btn { color: var(--muted); font-size: 13px; transition: color .2s; }
.text-btn:hover { color: var(--gold-text); }

/* =============================== READ ================================= */
.view-read { padding-bottom: calc(40px + var(--bnav-h)); }
.read-toolbar {
  max-width: 860px; margin: 18px auto 0;
  padding: 12px 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px);
  z-index: 30;
  margin-left: clamp(14px, calc((100vw - 860px)/2), 50vw);
  margin-right: clamp(14px, calc((100vw - 860px)/2), 50vw);
}
.read-selects { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.read-toolbar select {
  background: var(--glass-strong); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 8px 12px; font-size: 14.5px; color: var(--ink);
  max-width: 190px;
}
.seg { display: inline-flex; border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; }
.seg-center { margin: 14px auto 0; }
.seg-btn { padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.seg-btn.active { background: var(--user-bubble); color: var(--gold-text); }
.read-search { position: relative; flex: 1; min-width: 200px; }
.read-search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
#read-search-input {
  width: 100%; background: var(--glass-strong);
  border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 9px 12px 9px 36px; font-size: 16px; color: var(--ink); outline: 0;
  transition: border-color .2s;
}
#read-search-input:focus { border-color: var(--gold); }

.search-results {
  max-width: 860px; margin: 12px auto 0; padding: 8px;
  max-height: 420px; overflow-y: auto;
  margin-left: clamp(14px, calc((100vw - 860px)/2), 50vw);
  margin-right: clamp(14px, calc((100vw - 860px)/2), 50vw);
}
.sr-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-md);
  transition: background .2s;
}
.sr-item:hover { background: var(--user-bubble); }
.sr-ref { color: var(--gold-text); font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.sr-text { color: var(--ink-soft); font-size: 14.5px; }
.sr-empty { padding: 16px; color: var(--muted); text-align: center; font-size: 14.5px; }

.reader {
  max-width: 860px; margin: 20px auto 40px; padding: clamp(22px, 5vw, 56px);
  margin-left: clamp(14px, calc((100vw - 860px)/2), 50vw);
  margin-right: clamp(14px, calc((100vw - 860px)/2), 50vw);
}
.reader-head { text-align: center; margin-bottom: 28px; }
.reader-title {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(32px, 5vw, 44px); color: var(--ink);
}
.reader-title::after {
  content: "✦"; display: block; color: var(--gold);
  font-size: 14px; margin-top: 10px; text-shadow: 0 0 12px var(--halo);
}
.reader-translation { color: var(--muted); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; margin-top: 8px; }
.serif { font-family: var(--font-serif); }
.reader-body {
  font-size: clamp(19px, 2.5vw, 22px); line-height: 1.75; color: var(--ink);
  max-width: 640px; margin: 0 auto;
}
.reader-body .verse { cursor: pointer; border-radius: 6px; transition: background .25s; padding: 1px 2px; }
.reader-body .verse:hover { background: var(--halo); }
.reader-body .verse.hl { background: var(--user-bubble); box-shadow: 0 0 0 1px var(--line); }
.reader-body .vnum {
  color: var(--gold-text); font-size: .62em; font-weight: 700;
  vertical-align: super; margin: 0 3px 0 6px; font-family: var(--font-ui);
  letter-spacing: 0;
}
.reader-body .vgap { color: var(--muted); font-size: .8em; font-style: italic; }
.reader-body .dropcap::first-letter {
  font-size: 3.1em; float: left; line-height: .82;
  padding: 4px 10px 0 0; color: var(--gold-text);
  font-weight: 600;
}
.reader-loading { padding: 30px 0; }
.shimmer {
  height: 16px; border-radius: 8px; margin: 14px auto; max-width: 620px;
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--halo) 50%, var(--line-soft) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s linear infinite;
}
.shimmer.short { max-width: 380px; }
@keyframes shimmer { from { background-position: -600px 0; } to { background-position: 600px 0; } }

.reader-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.reader-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line-soft); color: var(--ink-soft);
  font-size: 14px; font-weight: 500;
  transition: border-color .2s, color .2s, transform .2s var(--ease), box-shadow .2s;
  background: var(--glass-soft);
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold-text); transform: translateY(-1px); box-shadow: 0 6px 20px var(--halo); }
.ghost-btn.gold { color: var(--gold-text); border-color: var(--line); }
.ghost-btn:disabled { opacity: .4; pointer-events: none; }

/* =============================== DAILY ================================ */
.view-daily { padding-bottom: calc(40px + var(--bnav-h)); }
.daily-wrap { max-width: 760px; margin: 0 auto; padding: 26px clamp(14px, 4vw, 32px) 40px; text-align: center; }
.daily-date { color: var(--muted); font-size: 13px; letter-spacing: .22em; text-transform: uppercase; margin-top: 14px; }
.daily-heading {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(34px, 6vw, 52px); margin: 6px 0 24px;
  background: linear-gradient(160deg, var(--ink) 30%, var(--gold-text) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.daily-card { padding: clamp(26px, 5vw, 48px); position: relative; overflow: hidden; }
.daily-card::before {
  content: ""; position: absolute; inset: -40%;
  background: radial-gradient(45% 35% at 50% 0%, var(--halo), transparent 70%);
  pointer-events: none;
}
.daily-ornament { color: var(--gold); font-size: 18px; margin-bottom: 18px; text-shadow: 0 0 14px var(--halo); }
.daily-verse {
  font-size: clamp(24px, 4vw, 34px); line-height: 1.45; font-weight: 500;
  quotes: "\201C" "\201D";
}
.daily-verse::before { content: open-quote; color: var(--gold-text); }
.daily-verse::after { content: close-quote; color: var(--gold-text); }
.daily-ref { color: var(--gold-text); font-weight: 600; margin-top: 16px; letter-spacing: .06em; }
.daily-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.reflection { margin-top: 22px; padding: clamp(22px, 4vw, 36px); text-align: left; }
.reflection-title {
  font-family: var(--font-serif); color: var(--gold-text); font-weight: 600;
  font-size: 21px; margin-bottom: 12px; text-align: center;
}
.reflection-body { font-size: 15.5px; color: var(--ink-soft); }
.reflection-body p { margin-bottom: .8em; }
.reflection-body em { font-family: var(--font-serif); font-size: 1.15em; color: var(--gold-text); }

/* ============================== LIBRARY =============================== */
.view-library { padding-bottom: calc(40px + var(--bnav-h)); }
.library-wrap { max-width: 760px; margin: 0 auto; padding: 26px clamp(14px, 4vw, 32px) 40px; }
.library-heading {
  font-family: var(--font-serif); font-weight: 500; text-align: center;
  font-size: clamp(34px, 6vw, 48px); margin-top: 10px;
}
.library-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 24px; }
.lib-tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.lib-tab {
  padding: 8px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--muted); border: 1px solid transparent;
  transition: color .2s, border-color .2s, background .2s;
}
.lib-tab.active { color: var(--gold-text); border-color: var(--line); background: var(--user-bubble); }
.lib-list { display: flex; flex-direction: column; gap: 12px; }
.lib-card { padding: 18px 20px; text-align: left; position: relative; }
.lib-card .serif { font-size: 18px; line-height: 1.55; }
.lib-card-ref { color: var(--gold-text); font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.lib-card-meta { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.lib-card-row { display: flex; align-items: flex-start; gap: 12px; }
.lib-card-main { flex: 1; cursor: pointer; }
.lib-card-actions { display: flex; gap: 4px; }
.lib-empty { text-align: center; color: var(--muted); padding: 46px 20px; font-size: 15px; }
.lib-empty .serif { font-size: 20px; color: var(--ink-soft); margin-bottom: 8px; }
.lib-add { margin: 0 auto 16px; display: flex; }

/* ============================ BOTTOM NAV ============================== */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: none;
  padding: 6px clamp(8px, 4vw, 20px) calc(6px + env(safe-area-inset-bottom));
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line-soft);
}
.bnav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px; color: var(--muted); font-size: 11px; font-weight: 500;
  border-radius: 12px; transition: color .2s;
}
.bnav-btn.active { color: var(--gold-text); }
.bnav-btn.active svg { filter: drop-shadow(0 0 8px var(--halo)); }

/* ============================== SHEET ================================= */
.sheet-backdrop, .modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(3, 5, 11, .6);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fadeIn .3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(680px, 100%);
  max-height: 82dvh;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -18px 60px rgba(2, 4, 12, .5);
  animation: sheetUp .38s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetUp { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-handle { width: 44px; height: 4px; border-radius: 4px; background: var(--line); margin: 10px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 0; }
.sheet-title { font-family: var(--font-serif); font-size: 26px; font-weight: 600; color: var(--gold-text); }
.sheet-body { padding: 14px 22px 6px; overflow-y: auto; }
.sheet-version { margin-bottom: 18px; }
.sheet-version-label { color: var(--muted); font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 6px; }
.sheet-verse-text { font-family: var(--font-serif); font-size: 19px; line-height: 1.6; }
.sheet-verse-text .vnum { color: var(--gold-text); font-size: .6em; font-weight: 700; vertical-align: super; margin-right: 4px; font-family: var(--font-ui); }
.sheet-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
}

/* ============================== MODAL ================================= */
.modal-backdrop { display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(760px, 100%); max-height: min(86dvh, 900px);
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  animation: modalIn .35s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 12px;
}
.modal-title { font-family: var(--font-serif); font-size: 27px; font-weight: 600; color: var(--gold-text); }
.modal-body { padding: 4px 26px 26px; overflow-y: auto; font-size: 15.5px; }
.modal-body h2 {
  font-family: var(--font-serif); color: var(--gold-text); font-weight: 600;
  font-size: 22px; margin: 1.2em 0 .5em;
}
.modal-body h2:first-child { margin-top: .2em; }
.modal-body p { margin-bottom: .85em; color: var(--ink-soft); }
.modal-body ul, .modal-body ol { margin: 0 0 .9em 1.3em; color: var(--ink-soft); }
.modal-body li { margin-bottom: .4em; }
.modal-body blockquote {
  font-family: var(--font-serif); font-size: 1.15em; font-style: italic;
  border-left: 2px solid var(--gold); padding-left: 14px; margin: .9em 0; color: var(--ink);
}
.modal-body strong { color: var(--gold-text); }
.modal-loading { padding: 20px 0 30px; }

/* quiz */
.quiz-progress { display: flex; gap: 6px; justify-content: center; margin-bottom: 20px; }
.quiz-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-soft); transition: background .3s, box-shadow .3s; }
.quiz-dot.done { background: var(--gold); box-shadow: 0 0 8px var(--halo); }
.quiz-dot.now { background: var(--gold-bright); box-shadow: 0 0 10px var(--gold); }
.quiz-q { font-family: var(--font-serif); font-size: 21px; line-height: 1.4; margin-bottom: 18px; color: var(--ink); text-align: center; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin: 0 auto; }
.quiz-opt {
  padding: 13px 18px; border-radius: var(--radius-md); text-align: left;
  border: 1px solid var(--line-soft); background: var(--glass-soft);
  transition: border-color .2s, background .2s, transform .15s var(--ease);
  font-size: 15px;
}
.quiz-opt:hover { border-color: var(--gold); transform: translateY(-1px); }
.quiz-opt.correct { border-color: #7fc76a; background: rgba(110, 190, 90, .14); }
.quiz-opt.wrong { border-color: #d96b6b; background: rgba(217, 107, 107, .12); animation: shake .35s; }
.quiz-opt:disabled { pointer-events: none; opacity: .9; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.quiz-explain {
  margin: 16px auto 0; max-width: 520px; padding: 12px 16px;
  border-radius: var(--radius-md); background: var(--user-bubble);
  border: 1px solid var(--line); font-size: 14px; color: var(--ink-soft);
  animation: fadeIn .3s;
}
.quiz-next { margin: 20px auto 0; display: flex; }
.quiz-score { text-align: center; padding: 24px 0 10px; }
.quiz-score-big { font-family: var(--font-serif); font-size: 56px; color: var(--gold-text); text-shadow: 0 0 24px var(--halo); }
.quiz-score-note { color: var(--ink-soft); margin-top: 10px; font-size: 16px; }

/* note editor */
.note-editor { display: flex; flex-direction: column; gap: 12px; }
.note-editor input, .note-editor textarea {
  width: 100%; background: var(--glass-soft); border: 1px solid var(--line-soft);
  border-radius: var(--radius-md); padding: 12px 14px; color: var(--ink);
  outline: 0; font-size: 16px; transition: border-color .2s;
}
.note-editor textarea { min-height: 140px; resize: vertical; }
.note-editor input:focus, .note-editor textarea:focus { border-color: var(--gold); }
.note-editor-row { display: flex; gap: 10px; justify-content: flex-end; }

.primary-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  color: var(--accent-ink);
  background: radial-gradient(120% 120% at 30% 20%, var(--gold-bright), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 6px 20px var(--halo);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px var(--halo); }

/* ============================== TOASTS ================================ */
.toasts {
  position: fixed; z-index: 120; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + var(--bnav-h) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 11px 20px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  color: var(--ink); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn .35s var(--ease);
}
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

.noscript-msg { position: fixed; inset: 30% 20px auto; text-align: center; color: var(--ink); font-size: 18px; z-index: 300; }

/* =========================== RESPONSIVE =============================== */
@media (max-width: 899px) {
  .topnav { display: none; }
  .bottomnav { display: flex; }
  .topbar { justify-content: space-between; }
  .view { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  .view-guide.active { height: 100dvh; }
  .composer-wrap { padding-bottom: calc(10px + var(--bnav-h) + env(safe-area-inset-bottom)); }
  .msg-bubble { max-width: 92%; font-size: 15px; }
  .msg-avatar { display: none; }
  .guide-hero { margin-top: 3vh; }
  .hero-title { font-size: clamp(38px, 11vw, 56px); margin-bottom: 14px; }
  .hero-sub { margin-bottom: 24px; }
  .chip { padding: 9px 14px; font-size: 13.5px; }
  .reader { padding: 26px 18px; }
  .reader-nav { justify-content: center; }
  .sheet-actions { padding-bottom: calc(14px + var(--bnav-h) + env(safe-area-inset-bottom)); }
  .brand-word { font-size: 21px; }
  .hero-title br { display: none; }
  .br-wide { display: none; }
}
@media (min-width: 900px) {
  .toasts { bottom: 28px; }
}

/* ================================ SKY ================================= */
.view-sky.active { display: flex; flex-direction: column; height: 100dvh; }
.sky-head { text-align: center; padding: 18px clamp(14px, 4vw, 32px) 10px; }
.sky-title {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(28px, 5vw, 42px);
  background: linear-gradient(160deg, var(--ink) 30%, var(--gold-text) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.sky-progress { color: var(--gold-text); font-size: 14px; font-weight: 600; margin-top: 4px; }
.sky-hint { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.sky-stage { position: relative; flex: 1; min-height: 0; }
#sky-canvas { position: absolute; inset: 0; touch-action: none; cursor: grab; }
#sky-canvas:active { cursor: grabbing; }
.sky-card {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 20px;
  max-width: min(94vw, 480px);
  animation: toastIn .3s var(--ease);
}
.sky-card-title { font-family: var(--font-serif); font-size: 20px; font-weight: 600; color: var(--gold-text); white-space: nowrap; }
.sky-card-sub { color: var(--muted); font-size: 12.5px; }
.sky-reset {
  position: absolute; top: 12px; right: 12px;
  background: var(--glass-strong);
}

/* "Where do I begin?" — the newcomer's door, always in reach. */
.begin-btn {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 14px; padding: 11px 22px;
  border-radius: 999px; font-size: 15px; font-weight: 600;
  color: var(--accent-ink);
  background: radial-gradient(120% 120% at 30% 20%, var(--gold-bright), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 6px 22px var(--halo);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.begin-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px var(--halo); }

.era-banner {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--gold-text); font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow);
}

.guide-sheet { max-height: 88dvh; }
.guide-tabs {
  display: flex; gap: 6px; padding: 10px 20px 0;
  overflow-x: auto; scrollbar-width: none;
}
.guide-tabs::-webkit-scrollbar { display: none; }
.guide-tab {
  padding: 9px 16px; border-radius: 999px; white-space: nowrap;
  font-size: 14.5px; font-weight: 600; color: var(--ink-soft);
  border: 1px solid transparent;
}
.guide-tab.active { color: var(--gold-text); background: var(--user-bubble); border-color: var(--line); }
.guide-body {
  padding: 16px 22px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.guide-lede {
  font-family: var(--font-serif); font-size: 18px; line-height: 1.6;
  color: var(--ink-soft); margin-bottom: 18px; text-align: center;
}
.guide-card {
  display: block; width: 100%; text-align: left;
  padding: 18px 20px; margin-bottom: 12px;
  border-radius: var(--radius-lg);
  background: var(--card-solid); border: 1px solid var(--line-soft);
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.guide-card:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 10px 30px var(--halo); }
.guide-card.primary { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.guide-card-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.guide-numeral {
  font-family: var(--font-serif); font-size: 20px; font-weight: 600;
  color: var(--gold-text); min-width: 34px;
}
.guide-card-title { font-family: var(--font-serif); font-size: 21px; font-weight: 600; color: var(--ink); }
.guide-kind {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-text); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px;
}
.guide-span { color: var(--muted); font-size: 13px; }
.guide-blurb { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 8px 0 12px; }
.guide-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.guide-open {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--accent-ink);
  background: radial-gradient(120% 120% at 30% 20%, var(--gold-bright), var(--gold) 60%, var(--gold-deep));
}
.guide-secondary {
  padding: 8px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--line-soft); color: var(--ink-soft);
}
.guide-secondary:hover { border-color: var(--gold); color: var(--gold-text); }
.guide-note { color: var(--muted); font-size: 13px; }

/* the chronological ribbon */
.era-row { display: flex; gap: 14px; align-items: flex-start; }
.era-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; padding-top: 4px; }
.era-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 12px var(--halo);
}
.era-line { width: 2px; flex: 1; min-height: 42px; background: linear-gradient(var(--gold), transparent); opacity: .5; }
.era-when {
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold-text); margin-bottom: 3px;
}
.guide-card.era { margin-bottom: 0; }
.era-item { display: flex; gap: 14px; }
.era-books { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.era-active { border-color: var(--gold) !important; box-shadow: 0 0 0 1px var(--gold) inset, 0 10px 30px var(--halo) !important; }

/* journey steps */
.journey-steps { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.journey-step {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: var(--radius-md);
  transition: background .2s;
}
.journey-step:hover { background: var(--user-bubble); }
.journey-num {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; align-self: center;
  font-size: 11.5px; font-weight: 700; color: var(--gold-text);
  border: 1px solid var(--line);
}
.journey-step.read .journey-num { background: var(--gold); color: var(--accent-ink); border-color: var(--gold); }
.journey-ref { font-weight: 600; color: var(--ink); font-size: 15px; }
.journey-note { color: var(--muted); font-size: 13.5px; font-style: italic; }
.sky-help {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; margin-left: 8px;
  border-radius: 50%; border: 1px solid var(--line);
  color: var(--gold-text); font-size: 12px; font-weight: 700;
  vertical-align: middle;
  transition: box-shadow .2s, transform .2s var(--ease);
}
.sky-help:hover { box-shadow: 0 0 12px var(--halo); transform: scale(1.08); }

/* Ephemeral whispers — a docent murmuring what the lights mean.
   A soft glass scrim keeps them legible over whatever drifts beneath. */
html[data-theme="night"] { --whisper-scrim: rgba(6, 9, 18, .78); }
html[data-theme="dawn"] { --whisper-scrim: rgba(252, 248, 238, .85); }
.sky-whisper {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(10px);
  bottom: clamp(98px, 13vh, 150px);
  max-width: min(88vw, 620px);
  padding: 12px 24px; border-radius: 20px;
  background: var(--whisper-scrim);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--line-soft);
  text-align: center; pointer-events: none;
  font-family: var(--font-serif); font-style: italic;
  font-size: clamp(17px, 2.6vw, 21px); line-height: 1.55;
  color: var(--ink);
  text-shadow: 0 0 14px var(--halo);
  opacity: 0;
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.sky-whisper.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* When a star is focused, the edges hush and the eye is drawn inward. */
.sky-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 58% at 50% 46%, transparent 55%, var(--sky-vignette));
  opacity: 0; transition: opacity .8s var(--ease);
}
.sky-stage.focused::after { opacity: 1; }
html[data-theme="night"] { --sky-vignette: rgba(3, 5, 11, .62); }
html[data-theme="dawn"] { --sky-vignette: rgba(228, 216, 190, .66); }
.sky-attrib {
  position: absolute; left: 12px; bottom: calc(8px + env(safe-area-inset-bottom));
  color: var(--muted); font-size: 10.5px; opacity: .6; pointer-events: none;
}
@media (max-width: 899px) {
  .view-sky.active { height: calc(100dvh - var(--bnav-h)); }
  .sky-card { bottom: 14px; }
}

/* ======================= SHEET STUDY (threads etc) ==================== */
.sheet-study { padding: 0 22px; overflow-y: auto; max-height: 34dvh; flex-shrink: 0; }
.study-label {
  display: flex; align-items: center; gap: 7px;
  color: var(--gold-text); font-size: 11.5px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  margin: 4px 0 10px;
}
.threads-block, .original-block { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-bottom: 14px; }
.threads-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.thread-chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); color: var(--gold-text);
  background: var(--user-bubble);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.thread-chip:hover { transform: translateY(-1px); box-shadow: 0 5px 16px var(--halo); }
.original-body { font-size: 14.5px; color: var(--ink-soft); }
.original-body p { margin-bottom: .7em; }
.original-body strong { color: var(--gold-text); }

/* =============================== SELAH ================================ */
.selah {
  position: fixed; inset: 0; z-index: 150;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; padding: 32px;
  background: radial-gradient(90% 90% at 50% 40%, var(--bg-2) 0%, var(--bg-0) 70%);
  animation: fadeIn .6s var(--ease);
  text-align: center;
}
.selah-ring {
  position: relative; width: 130px; height: 130px;
  display: grid; place-items: center;
}
.selah-ring::before, .selah-ring::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: .5;
  animation: selahBreathe 10s ease-in-out infinite;
}
.selah-ring::after { inset: -18px; opacity: .22; animation-delay: .3s; }
.selah-ring-core {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle, var(--gold-bright), var(--gold) 65%, transparent 75%);
  box-shadow: 0 0 30px var(--halo), 0 0 70px var(--halo);
  animation: selahBreathe 10s ease-in-out infinite;
}
@keyframes selahBreathe {
  0%, 100% { transform: scale(.72); }
  38%, 52% { transform: scale(1); }
}
.selah-breath { position: relative; height: 20px; width: 200px; color: var(--muted); font-size: 13px; letter-spacing: .28em; text-transform: uppercase; }
.selah-breath span { position: absolute; inset: 0; }
.selah-in { animation: selahIn 10s ease-in-out infinite; }
.selah-out { animation: selahOut 10s ease-in-out infinite; }
@keyframes selahIn { 0%, 8% { opacity: 0; } 18%, 40% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes selahOut { 0%, 50% { opacity: 0; } 60%, 88% { opacity: 1; } 96%, 100% { opacity: 0; } }
.selah-text {
  max-width: 640px; font-size: clamp(24px, 4.5vw, 36px); line-height: 1.5;
  color: var(--ink); min-height: 2.4em;
}
.selah-text .selah-line { opacity: 0; animation: selahLine 1.8s var(--ease) forwards; display: block; }
@keyframes selahLine { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.selah-ref { color: var(--gold-text); font-weight: 600; letter-spacing: .06em; }
.selah-close { position: absolute; top: calc(18px + env(safe-area-inset-top)); right: 18px; }

/* ============================== PALETTE =============================== */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(3, 5, 11, .55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(60px, 14vh, 140px) 16px 16px;
  animation: fadeIn .2s var(--ease);
}
.palette { width: min(620px, 100%); overflow: hidden; }
.palette-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
}
#palette-input { flex: 1; background: none; border: 0; outline: 0; font-size: 17px; color: var(--ink); }
.palette-input-row kbd {
  font-family: var(--font-ui); font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--line-soft); border-radius: 5px; padding: 2px 6px;
}
.palette-results { max-height: min(50vh, 420px); overflow-y: auto; padding: 8px; }
.pal-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; padding: 11px 12px; border-radius: var(--radius-md);
  color: var(--ink-soft); font-size: 14.5px;
}
.pal-item svg { color: var(--gold-text); flex: 0 0 auto; }
.pal-item.sel, .pal-item:hover { background: var(--user-bubble); color: var(--ink); }
.pal-ref { color: var(--gold-text); font-weight: 600; margin-right: 4px; }
.pal-snip { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ============================ ON THE HEART ============================ */
.heart-level { color: var(--gold-text); font-size: 12px; letter-spacing: .1em; }
.heart-due {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--user-bubble); border: 1px solid var(--line);
  color: var(--gold-text); font-size: 11.5px; font-weight: 600; margin-left: 8px;
}
.heart-practice { text-align: center; }
.heart-verse {
  font-family: var(--font-serif); font-size: clamp(20px, 3.5vw, 26px);
  line-height: 1.65; margin: 18px auto 6px; max-width: 560px; color: var(--ink);
}
.heart-hidden {
  color: var(--gold); letter-spacing: 2px;
  border-bottom: 1.5px solid var(--gold); border-radius: 2px;
  opacity: .8; padding: 0 1px;
}
.heart-ref { color: var(--gold-text); font-weight: 600; margin: 10px 0 4px; }
.heart-round { color: var(--muted); font-size: 12.5px; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 8px; }
.heart-controls { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.heart-done { padding: 26px 0 8px; }
.heart-done .quiz-score-big { font-size: 44px; }

/* ====================== LIBRARY READABILITY =========================== */
/* A quiet veil behind the Library so the lights recede and words lead. */
.view-library { position: relative; }
.view-library::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(90% 75% at 50% 30%, var(--page-dim-strong), var(--page-dim));
}
html[data-theme="night"] {
  --page-dim: rgba(5, 7, 14, .25);
  --page-dim-strong: rgba(5, 7, 14, .78);
}
html[data-theme="dawn"] {
  --page-dim: rgba(246, 241, 230, .3);
  --page-dim-strong: rgba(246, 241, 230, .82);
}
.library-heading::after {
  content: "✦"; display: block; color: var(--gold);
  font-size: 15px; margin-top: 12px; text-shadow: 0 0 14px var(--halo);
}
/* Solid, high-contrast text for every age of eyes — readable first. */
html[data-theme="night"] { --card-solid: rgba(17, 25, 47, .94); }
html[data-theme="dawn"] { --card-solid: rgba(255, 253, 247, .96); }
.library-sub { font-size: 15.5px; margin: 14px 0 26px; color: var(--ink-soft); }
.lib-tab { font-size: 15.5px; padding: 11px 20px; color: var(--ink-soft); font-weight: 600; }
.lib-tab:hover { color: var(--ink); border-color: var(--line-soft); }
.lib-tab.active { color: var(--gold-text); }
.lib-card {
  background: var(--card-solid);
  border-color: var(--line);
  padding: 21px 23px;
  box-shadow: var(--shadow), inset 2px 0 0 rgba(233, 185, 73, .45);
  transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
}
.lib-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 14px 40px var(--halo), var(--shadow), inset 2px 0 0 rgba(233, 185, 73, .6);
}
.lib-card .serif { font-size: 20.5px; line-height: 1.62; color: var(--ink); }
.lib-card-ref { font-size: 15px; font-weight: 700; }
.lib-card-meta { font-size: 13.5px; margin-top: 12px; color: var(--ink-soft); }
.lib-empty {
  font-size: 16.5px; padding: 54px 24px; color: var(--ink-soft);
  background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.lib-empty .serif { font-size: 24px; margin-bottom: 10px; color: var(--ink); }
.lib-port-note { font-size: 13.5px; color: var(--ink-soft); }
.heart-due { font-size: 12.5px; }
.sheet-note-text { font-size: 15px; color: var(--ink); }

/* ========================== STUDENT'S DESK ============================ */
.reader-body .verse.lit {
  background: linear-gradient(0deg, transparent 6%, var(--halo) 12%, var(--halo) 88%, transparent 94%);
  border-radius: 6px;
  box-shadow: 0 0 14px var(--halo);
}
.note-mark {
  color: var(--gold-text); margin-left: 4px;
  display: inline-block; vertical-align: super; line-height: 0;
  filter: drop-shadow(0 0 5px var(--halo));
}
.sheet-note {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; margin-bottom: 8px;
  border-radius: var(--radius-md);
  background: var(--user-bubble); border: 1px solid var(--line-soft);
}
.sheet-note-text { flex: 1; font-size: 14px; color: var(--ink-soft); }
.guide-saved-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; margin-bottom: 14px;
  border-radius: var(--radius-md);
  background: var(--user-bubble); border: 1px solid var(--line);
  color: var(--gold-text); font-size: 12.5px; font-weight: 600;
}
.lib-port {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.lib-port-note {
  width: 100%; text-align: center; color: var(--muted);
  font-size: 12.5px; margin-top: 8px;
}

/* ======================== BOTH-TRANSLATIONS MODE ====================== */
.reader-body .verse-pair { display: block; margin-bottom: .9em; }
.reader-body .verse-web {
  display: block; font-size: .78em; line-height: 1.6; color: var(--muted);
  font-style: italic; padding-left: 26px; margin-top: 2px;
}

/* ======================== REDUCED MOTION ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================ PRINT =================================== */
@media print {
  #lumen-field, .veil, .topbar, .bottomnav, .composer-wrap, .reader-nav { display: none !important; }
  body { background: #fff; color: #000; }
}
