:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --border: #e7e2da;
  --subtle: #f2efe9;
  --accent: #2b5ea7;
  --accent-soft: rgba(43, 94, 167, 0.12);
  --hebrew: #0f6b4f;
  --warn-bg: #fff7e6;
  --warn: #8a5300;
  --error-bg: #fdf0ef;
  --error: #9b2c22;
  --pop-bg: #1c1917;
  --pop-text: #faf8f5;
  --read-size: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hebrew-font: "SBL Hebrew", "Ezra SIL", "Taamey Frank CLM", "Frank Ruehl CLM", "Times New Roman", serif;
  --greek-font: "SBL Greek", "Gentium Plus", "Galatia SIL", "Palatino Linotype", serif;
  color-scheme: light;
}
.dark {
  --bg: #15171a;
  --card: #1d2024;
  --text: #ece8e1;
  --muted: #a29b92;
  --border: #33373d;
  --subtle: #262a2f;
  --accent: #8fb4ec;
  --accent-soft: rgba(143, 180, 236, 0.16);
  --hebrew: #6fd3ae;
  --warn-bg: #3a2c12;
  --warn: #f3c77a;
  --error-bg: #3b1d1a;
  --error: #f3b2aa;
  --pop-bg: #0b0c0e;
  --pop-text: #ece8e1;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--card); padding: 0.5rem 1rem; z-index: 100; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.55rem 0.9rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 0.45rem; align-items: center; font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.passage { display: flex; gap: 0.4rem; }
.search { flex: 1; min-width: 12rem; }
.search input { width: 100%; }
.tools { display: flex; gap: 0.3rem; margin-left: auto; }
select, input, textarea {
  font: inherit; font-size: 0.92rem; color: var(--text); background: var(--subtle);
  border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.45rem 0.6rem;
}
textarea { width: 100%; min-height: 6rem; resize: vertical; }
#bookSelect { max-width: 10.5rem; }
.icon-btn, .btn {
  border: 1px solid var(--border); background: var(--subtle); border-radius: 0.5rem;
  padding: 0.4rem 0.65rem; cursor: pointer; line-height: 1.2; font-size: 0.9rem;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dark .btn-primary { color: #0b1220; }
.btn:disabled, .icon-btn:disabled { opacity: 0.45; cursor: default; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 0.6rem 1rem; font-size: 0.9rem; text-align: center; }

/* ---------- Shell: three columns on wide screens ---------- */
.shell { flex: 1; display: grid; grid-template-columns: 17rem minmax(0, 1fr) 24rem; gap: 0; min-height: 0; }
.side { background: var(--card); overflow-y: auto; height: calc(100vh - 3.6rem); position: sticky; top: 3.6rem; }
.side.left { border-right: 1px solid var(--border); padding: 0.9rem; }
.side.right { border-left: 1px solid var(--border); padding: 1rem 1.1rem 2rem; }
.main { min-width: 0; padding: 1.5rem clamp(1rem, 4vw, 3rem) 4rem; outline: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 45; }
.only-narrow, .only-mid { display: none !important; }
.side .drawer-display { display: none; margin-top: 0; }

@media (max-width: 1199px) {
  .shell { grid-template-columns: minmax(0, 1fr) 22rem; }
  .side.left { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(20rem, 88vw); z-index: 50; transform: translateX(-105%); transition: transform 0.2s; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .side.left.open { transform: none; }
  .only-narrow#menuBtn { display: inline-block !important; }
}
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side.right {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; max-height: 78vh; z-index: 50;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 1rem 1rem 0 0;
    transform: translateY(105%); transition: transform 0.2s; box-shadow: 0 -10px 30px rgba(0,0,0,.25);
  }
  .side.right.open { transform: none; }
  .only-narrow { display: flex !important; }
  .only-mid { display: inline-block !important; }
  .tools .icon-btn:not(#studyBtn) { display: none; }
  .side .drawer-display { display: flex; }
  .passage { flex: 1; min-width: 0; }
  .passage select { flex: 1; min-width: 0; }
  #bookSelect { max-width: none; }
  .sheet-handle { justify-content: flex-end; position: sticky; top: -1rem; background: var(--card); padding: 0.25rem 0; z-index: 2; }
  .brand-text { display: none; }
  .topbar { gap: 0.4rem; }
  .search { order: 5; flex-basis: 100%; }
  .main { padding: 1rem 1rem 4rem; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none !important; } }

/* ---------- Left panel ---------- */
.nav-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.nav-tabs button { border: 1px solid var(--border); background: var(--subtle); border-radius: 999px; padding: 0.3rem 0.7rem; cursor: pointer; font-size: 0.82rem; }
.nav-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.dark .nav-tabs button[aria-selected="true"] { color: #0b1220; }
.side h2, .side h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1rem 0 0.45rem; }
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem; }
.book-grid button, .chapter-grid button {
  text-align: left; background: none; border: 0; padding: 0.3rem 0.4rem; border-radius: 0.35rem; cursor: pointer; font-size: 0.88rem;
}
.book-grid button:hover, .chapter-grid button:hover, .list a:hover { background: var(--subtle); }
.book-grid button.current { background: var(--accent-soft); font-weight: 600; }
.chapter-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.2rem; margin: 0.3rem 0 0.6rem; }
.chapter-grid button { text-align: center; }
.chapter-grid button.current { background: var(--accent); color: #fff; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--border); padding: 0.45rem 0.2rem; font-size: 0.88rem; display: flex; gap: 0.5rem; align-items: flex-start; }
.list li > a, .list li > .grow { flex: 1; text-decoration: none; color: var(--text); min-width: 0; }
.list .meta { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; overflow-wrap: anywhere; }
.swatch { width: 0.9rem; height: 0.9rem; border-radius: 0.2rem; flex: none; margin-top: 0.2rem; border: 1px solid var(--border); }
.empty { color: var(--muted); font-size: 0.88rem; padding: 0.6rem 0; }

/* ---------- Reader ---------- */
.reader-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 0.8rem; margin-bottom: 1rem; }
.reader-head h1 { font-family: var(--serif); font-size: 2rem; margin: 0; font-weight: 600; }
.reader-opts { display: flex; gap: 0.6rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.reader-opts label { display: flex; gap: 0.3rem; align-items: center; cursor: pointer; }
.verses { font-family: var(--serif); font-size: var(--read-size); line-height: 1.85; max-width: 44rem; }
.verse { position: relative; padding: 0.1rem 0.4rem 0.1rem 2.4rem; border-radius: 0.4rem; margin: 0 -0.4rem; }
.verse.target { background: var(--accent-soft); }
.verse.selected { box-shadow: inset 3px 0 0 var(--accent); }
.vnum {
  position: absolute; left: 0.2rem; top: 0.35rem; width: 1.9rem; text-align: right;
  font-family: var(--sans); font-size: 0.72em; font-weight: 700; color: var(--accent);
  background: none; border: 0; padding: 0.1rem 0.2rem; cursor: pointer; border-radius: 0.3rem;
}
.vnum:hover { background: var(--accent-soft); }
.vmarks { font-family: var(--sans); font-size: 0.7em; margin-left: 0.3rem; color: var(--muted); }
.superscription { display: block; font-size: 0.9em; color: var(--muted); font-style: normal; margin-bottom: 0.2rem; }
.w { cursor: pointer; border-radius: 0.2rem; transition: background-color 0.1s; }
.w.linked { text-decoration: underline dotted color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 0.28em; text-decoration-thickness: 1px; }
.w:hover, .w.hl { background: var(--accent-soft); }
.w.active { background: var(--accent-soft); outline: 1px solid var(--accent); }
.w.supplied { font-style: italic; }
.w.divine { font-variant: small-caps; text-transform: lowercase; letter-spacing: 0.02em; }
.w.divine::first-letter { text-transform: uppercase; }
.w.corrected { text-decoration: underline wavy color-mix(in srgb, var(--warn) 70%, transparent); text-underline-offset: 0.3em; }
.hl-bg { border-radius: 0.2rem; }
.interlinear { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; margin: 0.2rem 0 0.6rem; direction: ltr; }
.interlinear.rtl { direction: rtl; }
.il { display: flex; flex-direction: column; align-items: center; font-family: var(--sans); font-size: 0.72rem; color: var(--muted); padding: 0.15rem 0.25rem; border-radius: 0.3rem; background: var(--subtle); }
.il .f { font-size: 1.15rem; color: var(--text); }
.il.H .f, .il.A .f { font-family: var(--hebrew-font); }
.il.G .f { font-family: var(--greek-font); }
.il.A { outline: 1px dashed var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 0.75rem; max-width: 44rem; margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.2rem; }
.loading { color: var(--muted); padding: 2rem 0; }
.error-box { background: var(--error-bg); color: var(--error); border-radius: 0.6rem; padding: 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Verse menu */
.menu { position: absolute; z-index: 30; background: var(--card); border: 1px solid var(--border); border-radius: 0.7rem; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 0.5rem; font-family: var(--sans); font-size: 0.88rem; width: min(19rem, calc(100vw - 2rem)); }
.menu .row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }
.menu .colors { display: flex; gap: 0.3rem; align-items: center; margin: 0.3rem 0 0.4rem; flex-wrap: wrap; }
.menu .colors button { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; }
.menu .colors input[type=color] { width: 1.9rem; height: 1.9rem; padding: 0; border: 0; background: none; }

/* ---------- Study panel ---------- */
.study-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.8rem; }
.study-tabs button { flex: 1; border: 1px solid var(--border); background: var(--subtle); border-radius: 0.5rem; padding: 0.4rem; cursor: pointer; font-size: 0.85rem; }
.study-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.dark .study-tabs button[aria-selected="true"] { color: #0b1220; }
.word-head { background: var(--accent-soft); border-radius: 0.6rem; padding: 0.8rem; margin-bottom: 0.8rem; }
.word-head .eng { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; }
.word-head .ref { font-size: 0.82rem; color: var(--muted); }
.orig { border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.75rem; margin-bottom: 0.7rem; }
.orig .script { font-size: 1.9rem; line-height: 1.4; color: var(--hebrew); }
.orig .script.H, .orig .script.A { font-family: var(--hebrew-font); direction: rtl; text-align: right; }
.orig .script.G { font-family: var(--greek-font); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; font-size: 0.88rem; margin: 0.4rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.sid { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.status { font-size: 0.82rem; border-radius: 0.4rem; padding: 0.45rem 0.6rem; margin: 0.5rem 0 0; }
.status.ok { background: var(--accent-soft); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.sec { border-top: 1px solid var(--border); padding-top: 0.6rem; margin-top: 0.8rem; }
.sec > h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.4rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.sec .src { font-size: 0.74rem; color: var(--muted); margin-top: 0.35rem; }
.sec p { margin: 0.3rem 0; font-size: 0.92rem; line-height: 1.55; }
.def { font-size: 0.9rem; line-height: 1.55; background: var(--subtle); border-radius: 0.5rem; padding: 0.6rem 0.7rem; }
.def.clamp { max-height: 12rem; overflow: hidden; position: relative; }
.def.clamp::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3rem; background: linear-gradient(transparent, var(--subtle)); }
.sense { border-left: 3px solid var(--border); padding-left: 0.6rem; margin: 0.4rem 0; font-size: 0.9rem; }
.sense.here { border-left-color: var(--accent); }
.tag { display: inline-block; font-size: 0.72rem; border-radius: 999px; padding: 0.05rem 0.45rem; background: var(--subtle); border: 1px solid var(--border); margin-left: 0.3rem; }
.renderings { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.renderings span { background: var(--subtle); border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.82rem; }
.gram { font-size: 0.86rem; margin: 0.25rem 0; }
.gram code { font-size: 0.78rem; background: var(--subtle); padding: 0.05rem 0.3rem; border-radius: 0.25rem; }
.occ li { display: block; }
.occ a { text-decoration: none; color: var(--text); }
.occ .r { font-weight: 600; color: var(--accent); margin-right: 0.35rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0; }

/* Popover */
.popover {
  position: fixed; z-index: 60; max-width: min(21rem, calc(100vw - 16px)); pointer-events: none;
  background: var(--pop-bg); color: var(--pop-text); border-radius: 0.7rem; padding: 0.7rem 0.85rem;
  box-shadow: 0 10px 25px rgba(0,0,0,.3); font-size: 0.84rem; line-height: 1.45;
}
.popover .p-script { font-size: 1.35rem; color: #7ee0b8; }
.popover .p-script.H, .popover .p-script.A { font-family: var(--hebrew-font); direction: rtl; }
.popover .p-script.G { font-family: var(--greek-font); }
.popover .p-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; border-bottom: 1px solid #3a3530; padding-bottom: 0.3rem; margin-bottom: 0.35rem; }
.popover .p-id { font-family: ui-monospace, Menlo, monospace; font-size: 0.75rem; color: #b9cdf0; }
.popover .p-k { color: #a8a097; }
.popover .p-warn { color: #f3c77a; font-size: 0.78rem; margin-top: 0.3rem; }

/* ---------- Views ---------- */
.view-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.view-head h1 { font-family: var(--serif); font-size: 1.7rem; margin: 0; }
.results { list-style: none; padding: 0; margin: 0; max-width: 46rem; }
.results li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.results a.r { font-weight: 600; text-decoration: none; margin-right: 0.4rem; }
.results .t { font-family: var(--serif); font-size: calc(var(--read-size) * 0.92); line-height: 1.6; }
mark { background: #fde68a; color: inherit; border-radius: 0.15rem; padding: 0 0.05rem; }
.dark mark { background: #7c5d10; }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; font-size: 0.88rem; }
.prose { max-width: 46rem; line-height: 1.65; }
.prose h2 { font-family: var(--serif); margin-top: 1.6rem; }
.prose table { border-collapse: collapse; font-size: 0.88rem; width: 100%; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 0.7rem; padding: 1rem; }
.card h3 { margin: 0 0 0.4rem; font-size: 1rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.card .t { font-family: var(--serif); font-size: calc(var(--read-size) * 0.95); line-height: 1.6; }
.plan-day { display: flex; gap: 0.6rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.progress { height: 0.5rem; background: var(--subtle); border-radius: 999px; overflow: hidden; margin: 0.4rem 0 1rem; }
.progress > div { height: 100%; background: var(--accent); }
.dict-body { font-family: var(--serif); font-size: calc(var(--read-size) * 0.95); line-height: 1.7; max-width: 46rem; }

.footer { font-size: 0.75rem; color: var(--muted); text-align: center; padding: 0.7rem 1rem; border-top: 1px solid var(--border); background: var(--card); line-height: 1.5; }
@media (max-width: 899px) { .footer { padding-bottom: 1.2rem; } }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--pop-bg); color: var(--pop-text); padding: 0.6rem 1rem; border-radius: 0.6rem; z-index: 80; font-size: 0.9rem; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

@media print {
  .topbar, .side, .pager, .reader-opts, .vnum, .footer { display: none !important; }
  .shell { display: block; }
  .verse { padding-left: 0; }
}

/* ---------- Bible Quest ---------- */
.questnav { display: flex; gap: 0.2rem; overflow-x: auto; padding: 0.3rem 0.6rem; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 3.6rem; z-index: 39; scrollbar-width: none; }
.questnav a { white-space: nowrap; text-decoration: none; color: var(--muted); padding: 0.35rem 0.7rem; border-radius: 999px; font-size: 0.9rem; }
.questnav a:hover { background: var(--subtle); color: var(--text); }
.questnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (min-width: 1200px) { .side.left { top: 6.1rem; height: calc(100vh - 6.1rem); } }
@media (min-width: 900px) { .side.right { top: 6.1rem; height: calc(100vh - 6.1rem); } }
body.questing .side { display: none; }
body.questing .shell { grid-template-columns: minmax(0, 1fr); }
body.questing .passage, body.questing #studyBtn, body.questing #menuBtn { display: none !important; }
.quest { max-width: 52rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.quest.wide { max-width: 72rem; }
.quest h1 { margin: 0.2rem 0 0; font-size: 1.6rem; }
.quest h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
.quest .card { display: flex; flex-direction: column; gap: 0.5rem; }
.quest .card > * { margin-top: 0; margin-bottom: 0; }
.statusbar { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.8rem; text-decoration: none; color: var(--text); font-size: 0.9rem; display: inline-flex; align-items: center; gap: 0.2rem; }
.hearts { letter-spacing: 0.05em; }
.heart { color: var(--border); }
.heart.on { color: #d6336c; }
.quick { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
a.btn-primary { color: #fff; }
.dark a.btn-primary { color: #0b1220; }
.banner-soft { background: var(--accent-soft); border-radius: 0.6rem; padding: 0.6rem 0.9rem; margin: 0; }
.missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.mission-row { display: flex; justify-content: space-between; gap: 1rem; }
.missions li.done { color: var(--muted); }
.bar { height: 0.45rem; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.8rem; }
.mode-card { display: flex; flex-direction: column; gap: 0.3rem; padding: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.8rem; text-decoration: none; color: var(--text); transition: transform 0.1s, border-color 0.1s; }
.mode-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.mode-card.off { opacity: 0.55; pointer-events: none; }
.mode-icon { font-size: 1.6rem; }
.welcome { max-width: 36rem; margin: 2rem auto; display: flex; flex-direction: column; gap: 1rem; }
.welcome h1 { font-size: 2rem; }
.lead { font-size: 1.1rem; margin: 0; }
.how { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.5rem; margin: 0; }
.game-head { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: baseline; }
.qtext { font-size: 1.15rem !important; }
.verse-q { font-family: var(--serif); font-size: calc(var(--read-size) * 1.02); line-height: 1.6; margin: 0; padding: 0.7rem 1rem; border-left: 3px solid var(--accent); background: var(--subtle); border-radius: 0 0.5rem 0.5rem 0; }
.verse-q.small { font-size: 0.95rem; }
.clues { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.3rem; }
.answers { display: grid; gap: 0.5rem; }
.answer { display: flex; gap: 0.7rem; align-items: center; text-align: left; padding: 0.75rem 0.9rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.6rem; cursor: pointer; font-size: 1rem; min-height: 3rem; }
.answer:hover:not(:disabled) { border-color: var(--accent); }
.answer:disabled { cursor: default; }
.answer[disabled]:not(.right):not(.wrong) { opacity: 0.6; }
.answer-letter { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--subtle); font-weight: 700; font-size: 0.85rem; flex: none; }
.answer.right { border-color: #2f9e44; background: rgba(47, 158, 68, 0.12); opacity: 1; }
.answer.wrong { border-color: #e03131; background: rgba(224, 49, 49, 0.1); opacity: 1; }
.heb { font-family: var(--hebrew-font); font-size: 1.25em; direction: rtl; unicode-bidi: isolate; }
.grk { font-family: var(--greek-font); font-size: 1.1em; }
.big { font-size: 1.35rem; }
.built { min-height: 3rem; padding: 0.6rem; border: 1px dashed var(--border); border-radius: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem; font-family: var(--serif); }
.chunks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip, .chip-btn { font-family: var(--serif); border-radius: 0.5rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border); background: var(--subtle); }
.chip-btn { cursor: pointer; font-size: 1rem; }
.chip-btn:disabled { opacity: 0.3; }
.hints { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.hint-text { background: var(--warn-bg); color: var(--warn); padding: 0.5rem 0.8rem; border-radius: 0.5rem; }
.timer { position: relative; height: 1.4rem; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.timer > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width 0.2s linear; }
.timer > em { position: absolute; right: 0.6rem; top: 0; font-size: 0.8rem; line-height: 1.4rem; font-style: normal; font-weight: 700; }
.feedback { border-radius: 0.6rem; padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.feedback.ok { background: rgba(47, 158, 68, 0.1); }
.feedback.no { background: rgba(224, 49, 49, 0.08); }
.feedback p, .feedback ul { margin: 0; }
.verdict { font-size: 1.05rem; }
.summary { text-align: center; align-items: center; }
.summary .quick { justify-content: center; }
.dialog { border: 1px solid var(--border); border-radius: 0.8rem; background: var(--card); color: var(--text); max-width: 30rem; width: calc(100% - 2rem); display: flex; flex-direction: column; gap: 0.7rem; }
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.code { font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: 0.05em; text-align: center; background: var(--subtle); padding: 0.7rem; border-radius: 0.5rem; user-select: all; }
.form { max-width: 26rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.field input { width: 100%; }
.form-msg { color: var(--error); margin: 0; min-height: 1.2em; }
.tab-link { text-decoration: none; color: var(--text); }
.board { margin: 0; padding-left: 1.5rem; }
.board li { display: flex; justify-content: space-between; gap: 1rem; }
.ranks { margin: 0; padding-left: 1.5rem; }
.ranks .current { font-weight: 700; color: var(--accent); }
.ranks .past { color: var(--muted); }
.stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem; }
.badge { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: 0.6rem; opacity: 0.65; }
.badge.earned { opacity: 1; border-color: #e0a800; background: rgba(224, 168, 0, 0.08); }
.admin-tabs { flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.qrow summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.pill { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--subtle); border: 1px solid var(--border); }
.pill.published { background: rgba(47, 158, 68, 0.15); }
.pill.review { background: var(--warn-bg); color: var(--warn); }
.right-text { color: #2f9e44; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.6rem; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.7rem; display: flex; flex-direction: column; gap: 0.2rem; }
.tile strong { font-size: 1.2rem; }
.table-wrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--border); padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.6rem; }
fieldset.card { margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.check { display: inline-flex; gap: 0.3rem; margin-right: 1rem; align-items: center; }
@media (max-width: 899px) {
  .questnav { top: auto; position: fixed; bottom: 0; left: 0; right: 0; z-index: 41; border-top: 1px solid var(--border); border-bottom: 0; justify-content: space-between; padding: 0.25rem 0.3rem calc(0.25rem + env(safe-area-inset-bottom)); }
  .questnav a { display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; padding: 0.25rem 0.4rem; gap: 0.05rem; }
  .questnav a span { font-size: 1.15rem; }
  body { padding-bottom: 3.6rem; }
  .row2 { grid-template-columns: 1fr; }
}
@media print { .questnav { display: none !important; } }

/* ---------- Adventure ---------- */
:root { --parch: #f6ecd6; --parch-edge: #d9c49a; --ink: #4a3519; --gold: #c99a2e; }
.dark { --parch: #2b2519; --parch-edge: #5a4a2c; --ink: #ecdcb8; --gold: #e0b44c; }
.adventure-card { display: flex; gap: 1rem; align-items: center; padding: 1.1rem 1.2rem; border-radius: 1rem; text-decoration: none; color: var(--ink);
  background: linear-gradient(135deg, var(--parch), color-mix(in srgb, var(--parch) 70%, var(--gold))); border: 1px solid var(--parch-edge); box-shadow: 0 4px 16px rgba(120, 90, 30, 0.15); }
.adventure-card > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.adventure-card strong { font-size: 1.2rem; }
.adv-map { font-size: 2.6rem; }
.adv-head { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.adv-head h1 { margin-right: auto; }
.parchment { background: var(--parch); color: var(--ink); border: 1px solid var(--parch-edge); border-radius: 0.9rem; padding: 1.1rem 1.3rem; box-shadow: inset 0 0 40px rgba(150, 110, 40, 0.15); }
.parchment h2 { margin: 0 0 0.3rem; }
.parchment .muted { color: color-mix(in srgb, var(--ink) 65%, transparent); }
.story p { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; margin: 0 0 0.6rem; }
.story p:last-child { margin: 0; }
.world-tabs { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.2rem; }
.world-tab { display: flex; gap: 0.35rem; align-items: center; white-space: nowrap; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.8rem; font-size: 0.88rem; }
.world-tab.current { border-color: var(--gold); background: var(--parch); color: var(--ink); font-weight: 600; }
.world-tab.soon, .world-tab.locked { opacity: 0.6; }
.trail { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.stop { position: relative; display: flex; padding: 0.4rem 0; }
.stop:not(:last-child)::after { content: ''; position: absolute; left: calc(var(--x) + 1.6rem); top: 3.6rem; height: calc(100% - 3.2rem); border-left: 3px dashed var(--parch-edge); }
.stop.pos0 { --x: 4%; } .stop.pos1 { --x: 30%; } .stop.pos2 { --x: 56%; } .stop.pos3 { --x: 30%; }
.stop-btn { margin-left: var(--x); display: flex; gap: 0.7rem; align-items: center; text-decoration: none; color: var(--ink); max-width: 22rem; }
.stop-dot { flex: none; width: 3.2rem; height: 3.2rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; background: var(--card); border: 3px solid var(--parch-edge); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.stop.open .stop-dot { border-color: var(--gold); animation: pulse 1.8s ease-in-out infinite; }
.stop.done .stop-dot { border-color: #2f9e44; }
.stop.locked { opacity: 0.55; }
.stop.boss .stop-dot { width: 3.8rem; height: 3.8rem; font-size: 1.8rem; border-color: #b02a37; }
.stop-label { display: flex; flex-direction: column; }
.stars { color: var(--gold); letter-spacing: 0.1em; }
.stars.big { font-size: 2.2rem; margin: 0; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 154, 46, 0.5); } 50% { box-shadow: 0 0 0 10px rgba(201, 154, 46, 0); } }
@media (prefers-reduced-motion: reduce) { .stop.open .stop-dot { animation: none; } }
.satchel { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem; }
.artifact { border: 1px solid var(--parch-edge); background: var(--parch); color: var(--ink); border-radius: 0.6rem; padding: 0.6rem; }
.artifact summary { cursor: pointer; display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }
.artifact.empty { display: flex; gap: 0.5rem; align-items: center; background: var(--subtle); border-style: dashed; color: var(--muted); }
.art-icon { font-size: 1.5rem; }
.scene-head h1 { margin: 0.3rem 0 0; }
.scene-head p { margin: 0; }
.scroll { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--gold); border-radius: 0.6rem; padding: 0.9rem 1.1rem; }
.scroll h2 { font-size: 1rem; margin: 0 0 0.4rem; }
.scroll-verse { font-family: var(--serif); font-size: var(--read-size); line-height: 1.65; margin: 0 0 0.4rem; }
.vref { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; text-decoration: none; }
.nw sup { font-family: var(--sans); font-size: 0.6rem; color: var(--accent); margin-right: 1px; }
.puzzle-head { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: baseline; }
.puzzle-status { margin: 0; min-height: 1.3em; font-weight: 600; }
.puzzle-status.no { color: var(--error); }
.puzzle-status.ok { color: #2f9e44; }
.lock { display: flex; flex-direction: column; gap: 0.8rem; align-items: flex-start; }
.lock-slots, .lock-tiles { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.slot { width: 2.6rem; height: 3rem; border: 2px solid var(--parch-edge); border-radius: 0.4rem; background: var(--parch); color: var(--ink); font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.slot:disabled { cursor: default; opacity: 1; }
.slot.fixed { background: color-mix(in srgb, var(--gold) 35%, var(--parch)); }
.tile { width: 2.6rem; height: 2.6rem; border-radius: 0.4rem; border: 1px solid var(--border); background: var(--card); font-size: 1.2rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 0 var(--border); }
.tile:disabled { opacity: 0.2; }
.codes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.code-chip { font-family: ui-monospace, monospace; background: var(--parch); color: var(--ink); border: 1px solid var(--parch-edge); border-radius: 0.4rem; padding: 0.3rem 0.55rem; }
.code-chip.solved { background: rgba(47, 158, 68, 0.12); }
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.order-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.5rem; }
.order-item.fixed { background: var(--parch); color: var(--ink); }
.order-n { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--subtle); font-weight: 700; font-size: 0.85rem; flex: none; }
.order-text { flex: 1; }
.order-btns { display: flex; gap: 0.2rem; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.match-col { display: flex; flex-direction: column; gap: 0.4rem; }
.match-item { text-align: left; padding: 0.55rem 0.6rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; cursor: pointer; display: flex; gap: 0.4rem; align-items: center; min-height: 2.8rem; }
.match-item.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.match-item.paired { background: var(--accent-soft); }
.badge-n { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.grid-wrap { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.grid { display: grid; gap: 2px; width: min(100%, 26rem); user-select: none; touch-action: manipulation; }
.cell { aspect-ratio: 1; border: 1px solid var(--border); background: var(--card); border-radius: 0.3rem; font-weight: 700; font-size: clamp(0.8rem, 3.6vw, 1.05rem); cursor: pointer; padding: 0; }
.cell.found { background: rgba(47, 158, 68, 0.22); }
.cell.secret { background: color-mix(in srgb, var(--gold) 55%, var(--card)); }
.cell.start { outline: 3px solid var(--accent); }
.cell.hinted { box-shadow: inset 0 0 0 2px var(--gold); }
.word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; letter-spacing: 0.05em; }
.word-list .done { text-decoration: line-through; color: var(--muted); }
.secret-word { color: var(--gold); }
.puzzle.complete { text-align: center; align-items: center; background: linear-gradient(180deg, var(--card), var(--parch)); }
.artifact-reveal { display: flex; gap: 0.8rem; align-items: center; text-align: left; background: var(--parch); color: var(--ink); border: 1px solid var(--gold); border-radius: 0.7rem; padding: 0.8rem; }
.treasure-icon { font-size: 3rem; text-align: center; animation: pop 0.5s ease-out; }
.treasure { text-align: center; align-items: center; }
@keyframes pop { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@media (max-width: 899px) {
  .stop.pos0 { --x: 0%; } .stop.pos1 { --x: 14%; } .stop.pos2 { --x: 28%; } .stop.pos3 { --x: 14%; }
  .match { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .match-item { font-size: 0.88rem; }
  .questnav a { padding: 0.25rem 0.25rem; font-size: 0.64rem; }
  .tools #soundBtn { display: inline-block !important; }
}
