:root {
  --k: 1;
  --bg: #fbf9f4;
  --paper: #fffdf8;
  --ink: #2a2622;
  --muted: #7d7469;
  --line: #e6dfd2;
  --accent: #8a3b2b;
  --accent-soft: #f3e4dc;
  --mark: #fbe7a6;
  --sel: #e9efe0;
  --shadow: 0 10px 30px rgba(40, 30, 20, .16);
  --fs: 19px;
  --text-font: "Literata", "PT Serif", "Noto Serif", Georgia, "Times New Roman", serif;
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f1ebe2; --paper: #f6f1e9; --ink: #3a3129; --muted: #827565; --line: #e1d8ca;
  --accent: #8a3b2b; --accent-soft: #ead8c2; --mark: #f1d98c; --sel: #e4e1c8;
}
:root[data-theme="dark"] {
  --bg: #17181a; --paper: #1d1f22; --ink: #e2ddd3; --muted: #948d82; --line: #33363a;
  --accent: #e0957f; --accent-soft: #3a2a25; --mark: #5a4a1c; --sel: #2c3527;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-font="sans"] { --text-font: var(--ui-font); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--ui-font); font-size: 15px;
}
button, select, input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: var(--bg); }

/* Верхня панель */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; background: none; border-radius: 10px; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--accent-soft); }
.place {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  border: 0; background: none; padding: 6px 8px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden;
}
.place:hover { background: var(--accent-soft); }
.place #placeBook { overflow: hidden; text-overflow: ellipsis; }
.place .chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
#selTr {
  border: 1px solid var(--line); background: var(--paper); border-radius: 10px;
  padding: 7px 8px; max-width: 150px; cursor: pointer;
}

/* Текст */
main {
  max-width: 720px; margin: 0 auto; padding: 28px 22px 120px;
}
.chapter-title {
  font-family: var(--text-font); font-weight: 600; text-align: center;
  font-size: calc(var(--fs) * 1.45); margin: 8px 0 2px; letter-spacing: .01em;
}
.chapter-title .cn { color: var(--accent); margin-left: .35em; }
.text {
  font-family: var(--text-font); font-size: var(--fs); line-height: 1.7;
  hyphens: auto; -webkit-hyphens: auto; text-align: left;
}
.v { border-radius: 4px; cursor: pointer; transition: background .15s; padding: 1px 0; }
@media (hover: hover) { .v:hover { background: color-mix(in srgb, var(--sel) 60%, transparent); } }
.v.sel { background: var(--sel); box-shadow: inset 0 -2px 0 var(--accent); }
.v.flash { background: var(--mark); }
.v.marked .vn { color: #fff; background: var(--accent); border-radius: 4px; padding: 0 3px; }
.vn {
  font-family: var(--ui-font); font-size: .58em; font-weight: 700; color: var(--accent);
  vertical-align: .55em; margin: 0 .2em 0 .1em; user-select: none;
}



.fn {
  font-family: var(--ui-font); font-size: .6em; color: var(--accent); cursor: pointer;
  vertical-align: .6em; padding: 0 1px; border-radius: 3px;
}
.fn:hover { background: var(--accent-soft); }
.text.nonotes .fn { display: none; }
.text i { font-style: italic; color: color-mix(in srgb, var(--ink) 75%, var(--muted)); }
.empty { color: var(--muted); text-align: center; font-family: var(--ui-font); font-size: 15px; }

.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
.nav-btn {
  flex: 1; border: 1px solid var(--line); background: var(--paper); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; color: var(--ink); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn[disabled] { visibility: hidden; }
#btnNext { text-align: right; }

/* Паралельні місця */
.text-wrap { position: relative; }
.xcol { display: none; }
body.xmargin main { max-width: 1000px; }
body.xmargin .text-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 34px; }
body.xmargin .xcol { display: block; position: relative; border-left: 1px solid var(--line); }
.xcol .xg {
  position: absolute; left: 14px; right: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted);
  font-family: var(--ui-font);
}
.xcol .xg b, .xr-inline b { color: var(--accent); font-weight: 700; margin-right: 3px; }
.xr { color: var(--ink); cursor: pointer; text-decoration: none; border-radius: 3px; white-space: nowrap; }
.xr:hover { color: var(--accent); background: var(--accent-soft); }
.xg.hot { background: var(--accent-soft); border-radius: 6px; box-shadow: 0 0 0 4px var(--accent-soft); }
.xr-inline {
  display: block; font-family: var(--ui-font); font-size: 12.5px; line-height: 1.5; color: var(--muted);
  margin: 1px 0 8px; padding-left: .2em; text-indent: 0;
}
.text.lines .xr-inline { margin: -2px 0 8px 0; }
.text.lines .v .xr-inline { padding-left: 0; }

.xlist { list-style: none; margin: 0; padding: 0; }
.xlist li { padding: 10px 8px; border-top: 1px solid var(--line); cursor: pointer; }
.xlist li:hover { background: var(--accent-soft); }
.xlist li.hot { background: var(--accent-soft); }
.xlist .ref { display: block; font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.xlist .tx { font-family: var(--text-font); font-size: calc(var(--fs) * .85); line-height: 1.55; }
.xlist .tx sup { color: var(--muted); font-size: .65em; font-family: var(--ui-font); margin-right: 2px; }
.modal-card .hint { margin: 0 0 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.back-chip {
  position: fixed; left: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 24;
  border: 1px solid var(--line); background: var(--paper); color: var(--accent); box-shadow: var(--shadow);
  border-radius: 999px; padding: 9px 14px; font-weight: 600; cursor: pointer;
  transform: translateY(180%); transition: transform .22s ease;
}
.back-chip.show { transform: none; }

/* Панелі */
.drawer {
  position: fixed; top: 0; bottom: 0; z-index: 40; width: min(380px, 92vw);
  background: var(--paper); box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding: 10px 14px 0;
  padding-top: max(10px, env(safe-area-inset-top));
  transition: transform .25s ease; visibility: hidden;
}
.drawer.wide { width: min(560px, 100vw); }
.drawer.left { left: 0; transform: translateX(-105%); }
.drawer.right { right: 0; transform: translateX(105%); }
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.drawer-title { font-size: 19px; margin: 6px 4px 12px; font-family: var(--text-font); }
.drawer-title.inline { margin: 0 4px; }
.drawer-body { flex: 1; overflow-y: auto; margin: 0 -14px; padding: 0 14px 24px; overscroll-behavior: contain; }
.scrim {
  position: fixed; inset: 0; z-index: 30; background: rgba(20, 15, 10, .35);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 8px 12px; border-radius: 999px; cursor: pointer;
  color: var(--muted); white-space: nowrap; font-weight: 600;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.field:focus { border-color: var(--accent); }
.field.small { width: auto; padding: 8px 10px; }

.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 8px 4px; font-weight: 600; }

.book-list { list-style: none; margin: 0; padding: 0; }
.book-list li button {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  border: 0; background: none; text-align: left; padding: 10px 10px; border-radius: 10px;
  cursor: pointer; font-size: 16px;
}
.book-list li button:hover { background: var(--accent-soft); }
.book-list li button.cur { color: var(--accent); font-weight: 700; }
.book-list .cnt { color: var(--muted); font-size: 12px; }
.book-list .group { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.chapter-grid button {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  cursor: pointer; font-size: 16px; font-variant-numeric: tabular-nums;
}
.chapter-grid button:hover { border-color: var(--accent); color: var(--accent); }
.chapter-grid button.cur { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Пошук */
.search-form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.search-opts { display: flex; gap: 8px; }
.search-opts select { flex: 1 1 0; min-width: 0; }
.btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #1b1413; }
.search-info { color: var(--muted); font-size: 13px; padding: 10px 2px; min-height: 20px; }
.results { list-style: none; margin: 0; padding: 0; }
.results li {
  padding: 10px 10px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid var(--line);
  font-family: var(--text-font); font-size: 16px; line-height: 1.5;
}
.results li:hover { background: var(--accent-soft); }
.results .ref { display: block; font-family: var(--ui-font); font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.results mark, .text mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.results .more { text-align: center; border: 0; padding: 14px; }
.results .group-head {
  cursor: default; border: 0; padding: 14px 10px 4px; font-family: var(--ui-font);
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.results .group-head:hover { background: none; }

/* Закладки */
.marks { list-style: none; margin: 0; padding: 0; }
.marks li { display: flex; gap: 6px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.marks .mk { flex: 1; border: 0; background: none; text-align: left; padding: 10px 8px; cursor: pointer; border-radius: 10px; }
.marks .mk:hover { background: var(--accent-soft); }
.marks .ref { display: block; font-weight: 700; color: var(--accent); font-size: 13px; }
.marks .tx { font-family: var(--text-font); font-size: 15px; line-height: 1.45; }
.marks .when { color: var(--muted); font-size: 12px; }

/* Налаштування */
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.settings .row.check { justify-content: flex-start; cursor: pointer; }
.settings .row.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper span { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Модальне вікно */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 15, 10, .4); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-card {
  position: relative; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow);
  max-width: 620px; width: 100%; max-height: 82vh; overflow-y: auto; padding: 22px 22px 18px;
}
.modal-card .close { position: absolute; top: 8px; right: 8px; }
.modal-card h3 { margin: 0 34px 14px 0; font-family: var(--text-font); }
.cmp-item { padding: 10px 0; border-top: 1px solid var(--line); }
.cmp-item .tr { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.cmp-item .tx { font-family: var(--text-font); font-size: calc(var(--fs) * .92); line-height: 1.6; }
.note { font-family: var(--text-font); font-size: 16px; line-height: 1.6; }
.note a { color: var(--accent); }

.toast {
  position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .2s; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  main { padding: 18px 16px 120px; }
  #selTr { max-width: 128px; padding: 6px; }
  .icon-btn { width: 36px; height: 36px; }
  .topbar { gap: 0; }
}
@media print {
  .topbar, .chapter-nav, .drawer, .pop, .study, .scrim { display: none !important; }
}

/* Спливаюче вікно вірша */
.pop {
  position: absolute; z-index: 26; width: min(360px, calc(100vw - 16px));
  display: flex; flex-direction: column;
  background: var(--pop-bg); border: 1px solid var(--pop-line); border-radius: 14px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px) scale(.98); transform-origin: var(--ax) 100%;
  transition: opacity .16s ease, transform .16s ease;
}
.pop.below { transform: translateY(-6px) scale(.98); transform-origin: var(--ax) 0; }
.pop.show { opacity: 1; transform: none; }
.pop::after {
  content: ""; position: absolute; left: var(--ax); bottom: -7px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--pop-bg); border: solid var(--pop-line); border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.pop.below::after { bottom: auto; top: -7px; border-width: 1px 0 0 1px; }
.pop-head { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); flex: none; }
.pop-head .icon-btn { width: 42px; height: 40px; }
.pop-ref { margin-right: auto; padding-left: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
#popCopy .i-done { display: none; color: var(--accent); }
#popCopy.done .i-copy { display: none; }
#popCopy.done .i-done { display: block; }
.star.on svg { fill: #e0a526; stroke: #c98a12; }
.pop-body { overflow-y: auto; overscroll-behavior: contain; padding: 8px; min-height: 0; }
.pop-body:empty { display: none; }
.pop-lbl { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 8px 4px; }
.pop-empty { color: var(--muted); font-size: 14px; margin: 8px; }
.pop-list { list-style: none; margin: 0; padding: 0; }
.pop-list button {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 7px 8px; border-radius: 9px; line-height: 1.4;
}
.pop-list button:active { background: var(--accent-soft); }
@media (hover: hover) { .pop-list button:hover { background: var(--accent-soft); } }
.pop-list b { color: var(--accent); font-size: 13.5px; margin-right: 6px; }
.pop-list .snip {
  color: var(--ink); font-family: var(--text-font); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pop-list .snip:empty { display: none; }

/* Дослідження: копія вірша піднімається, під нею пов'язані */
#reader, .topbar { transition: opacity .3s ease; }
body.study-on #reader, body.study-on .topbar, body.study-on .back-chip { opacity: .7; pointer-events: none; }
.study { position: fixed; inset: 0; z-index: 36; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.study { background: transparent; transition: background-color .3s ease; }
body.study-on .study { background: rgba(25, 12, 8, .42); }
.s-card {
  position: absolute; display: flex; flex-direction: column; overflow: visible; overscroll-behavior: contain;
  border: 1px solid transparent; border-radius: 16px; padding: 12px 0 8px;
  transition: border-color .35s ease, background-color .35s ease, box-shadow .35s ease;
}
.study.moved .s-card {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); background: var(--paper);
  box-shadow: 0 8px 28px rgba(60, 30, 20, .12); transition-delay: .3s;
}
.study.listed .s-card { overflow-y: auto; }
.s-clip, .s-ref, .s-listwrap { flex: none; }
.s-clip { position: relative; overflow: hidden; transition: transform .42s cubic-bezier(.2, .75, .25, 1); will-change: transform; }
.s-ref {
  align-self: flex-start; font-size: 13px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 8px; padding: 2px 9px; margin-bottom: 2px; opacity: 0; transition: opacity .25s ease;
}
:root[data-theme="dark"] .s-ref, :root[data-theme="dark"] .s-list .ref { color: #1b1413; }
.study.moved .s-ref { opacity: 1; transition-delay: .2s; }
.s-listwrap { margin-top: 8px; }
.s-agent {
  display: flex; align-items: center; gap: 8px; padding: 10px 8px 8px; border-top: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600; color: var(--muted); opacity: 0; transition: opacity .2s ease;
}
.study.listed .s-agent { opacity: 1; }
.orb { width: 26px; height: 26px; flex: none; overflow: visible; margin: 0 2px; }
.orb * { fill: none; stroke-linecap: round; transform-box: view-box; transform-origin: 50% 50%; }
.orb .ring { stroke: var(--accent); stroke-width: 1.6; opacity: 0; transition: opacity .4s ease; }
.orb .arc { stroke: var(--accent); stroke-width: 2.4; transition: opacity .4s ease; }
.orb .a1 { stroke-dasharray: 26 49.4; animation: orb-spin 1.1s linear infinite; }
.orb .a2 { stroke-dasharray: 15 32.1; opacity: .55; animation: orb-spin 1.6s linear infinite reverse; }
.orb .core { fill: var(--accent); stroke: none; animation: orb-pulse 1.1s ease-in-out infinite alternate; }
@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-pulse { from { transform: scale(.6); opacity: .5; } to { transform: scale(1.15); opacity: 1; } }
.s-agent.done .orb .arc { opacity: 0; animation-play-state: paused; }
.s-agent.done .orb .ring { opacity: .9; }
.s-agent.done .orb .core { animation: orb-pulse 2.6s ease-in-out infinite alternate; }
.s-agent.done { color: var(--accent); }
.s-agent { padding-left: 2px; }
.s-agent .dots i { font-style: normal; animation: dot 1.2s infinite; opacity: 0; }
.s-agent .dots i:nth-child(2) { animation-delay: .2s; }
.s-agent .dots i:nth-child(3) { animation-delay: .4s; }
.s-agent.done .dots { display: none; }
@keyframes dot { 0%, 20% { opacity: 0; } 40%, 100% { opacity: 1; } }
.s-list { list-style: none; margin: 0; padding: 0; }
.s-list li { padding: 10px 8px; border-radius: 10px; cursor: pointer; opacity: 0; transform: translateY(14px); }
.s-list li:not(.show) { display: none; }
.s-list li.show { animation: s-in .38s cubic-bezier(.2, .75, .25, 1) forwards; }
@keyframes s-in { to { opacity: 1; transform: none; } }
.s-list li + li { border-top: 1px solid var(--line); }
.s-list li:active, .s-list li.hot { background: var(--accent-soft); }
@media (hover: hover) { .s-list li:hover { background: var(--accent-soft); } }
.s-list .ref { display: table; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 7px; padding: 1px 8px; margin-bottom: 5px; }
.s-list .tx { font-family: var(--text-font); font-size: calc(var(--fs) * .88); line-height: 1.6; }
.s-list .tx sup { color: var(--muted); font-size: .65em; font-family: var(--ui-font); margin-right: 2px; }
.explore {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
}
:root[data-theme="dark"] .explore { color: #1b1413; }
.explore svg { width: 18px; height: 18px; }
.explore .cnt { font-size: 12px; background: rgba(255,255,255,.22); border-radius: 999px; padding: 1px 7px; }
@media (prefers-reduced-motion: reduce) {
  .pop, .s-clip, .s-ref, .s-lbl, #reader, .topbar, .ctx-layer, .ctx-card, .ctx-frame { transition: none !important; }
  .s-list li.show { animation: none; opacity: 1; transform: none; }
  .orb .arc, .orb .core, .s-agent .dots i { animation: none; opacity: 1; }
}
.pop[hidden] { display: none; }
.study[hidden] { display: none; }

/* Кольорові позначки */
:root { --hl-green: #d3ecc4; --hl-yellow: #fbec9f; --hl-blue: #cfe3f7; }
:root[data-theme="sepia"] { --hl-green: #cfe0b0; --hl-yellow: #f2dc85; --hl-blue: #c7d9e6; }
:root[data-theme="dark"] { --hl-green: #2e4a2a; --hl-yellow: #55491c; --hl-blue: #22405c; }
.v.hl-green { background: var(--hl-green); }
.v.hl-yellow { background: var(--hl-yellow); }
.v.hl-blue { background: var(--hl-blue); }
.pop-colors { display: flex; justify-content: center; gap: 18px; padding: 2px 8px 10px; flex: none; }
.pop-colors button {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid color-mix(in srgb, var(--ink) 15%, transparent);
  transition: transform .12s ease;
}
.pop-colors button:active { transform: scale(.9); }
.pop-colors button.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }
.pop-colors [data-color="green"] { background: #8fcf6f; }
.pop-colors [data-color="yellow"] { background: #f5d33f; }
.pop-colors [data-color="blue"] { background: #6fa8e6; }
.s-listwrap { transition: opacity .18s ease; }
.study:not(.listed) .s-listwrap { opacity: 0; }

/* Друге вікно: пов'язаний вірш у контексті розділу */
.ctx-layer { position: fixed; inset: 0; z-index: 38; background: rgba(25, 12, 8, 0); transition: background-color .22s ease; }
.ctx-layer.show { background: rgba(25, 12, 8, .45); }
.ctx-layer[hidden] { display: none; }
.ctx-card {
  position: absolute; overflow-y: auto; overscroll-behavior: contain; background: var(--paper);
  border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  box-shadow: 0 14px 40px rgba(30, 12, 6, .3);
  opacity: 0; pointer-events: none; transition: opacity .16s ease;
}
.ctx-layer.card-in .ctx-card { opacity: 1; pointer-events: auto; }
.ctx-frame {
  position: absolute; border: 2px solid var(--accent); border-radius: 14px; background: var(--paper);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), 0 14px 40px rgba(30, 12, 6, .3);
  transition: left .32s cubic-bezier(.2, .75, .25, 1), top .32s cubic-bezier(.2, .75, .25, 1), width .32s cubic-bezier(.2, .75, .25, 1), height .32s cubic-bezier(.2, .75, .25, 1), opacity .13s ease;
}
.s-list li.opening { background: var(--accent-soft); }
.ctx-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 8px; background: var(--paper); border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0;
}
.ctx-back {
  display: flex; align-items: center; gap: 2px; border: 0; cursor: pointer; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #fff; border-radius: 9px; padding: 6px 12px 6px 6px;
}
.ctx-back svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .ctx-back { color: #1b1413; }
.ctx-title { flex: 1; font-weight: 700; font-family: var(--text-font); font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-open { border: 1px solid var(--line); background: var(--bg); color: var(--accent); border-radius: 9px; padding: 6px 10px; font-weight: 600; font-size: 13px; cursor: pointer; }
.ctx-text { padding: 12px 14px 18px; font-size: calc(var(--fs) * .95); }
.ctx-text .v { cursor: default; }
@media (hover: hover) { .ctx-text .v:hover { background: none; } }
.ctx-text .v.ctx-hit { background: var(--mark); border-radius: 4px; }

/* Власна смуга прокрутки у вікнах */
.s-card, .ctx-card { scrollbar-width: none; }
.s-card::-webkit-scrollbar, .ctx-card::-webkit-scrollbar { display: none; }
.fat-scroll {
  position: absolute; z-index: 3; width: 40px; display: flex; justify-content: center;
  touch-action: none; cursor: grab; opacity: 0; pointer-events: none;
  transition: opacity .35s ease, height .35s cubic-bezier(.2, .75, .25, 1);
}
.fat-scroll.on { opacity: 1; pointer-events: auto; }
.fat-scroll i {
  display: block; width: 14px; height: 100%; border-radius: 99px; background: var(--accent); opacity: .45;
  transition: width .12s ease, opacity .12s ease;
}
.fat-scroll.drag i, .fat-scroll:active i { width: 18px; opacity: .7; }
@media (hover: hover) { .fat-scroll:hover i { width: 18px; opacity: .7; } }
.s-list li { padding-right: 34px; }
.ctx-text { padding-right: 38px; }

/* Копія вірша у вікні «Дослідити» */
.s-clip .v.s-target { background: color-mix(in srgb, var(--mark) 75%, transparent); border-radius: 4px; }
.s-clip .v.s-dim { opacity: .32; background: none; }

/* «Знайдено N віршів» — біла плашка з вишневим текстом і рухомим відблиском */
.s-pill {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 12px; overflow: hidden;
  background: #fff; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 16%, transparent);
}
:root[data-theme="dark"] .s-pill { background: var(--paper); }
.s-agent.done .s-pill { box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 26%, transparent); }
/* слова пошуку праворуч: зона розширюється під час пошуку і згортається після */
.s-words {
  display: inline-block; overflow: hidden; white-space: nowrap; width: 0; opacity: 0; margin-left: -8px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  transition: width .4s cubic-bezier(.2, .75, .25, 1), opacity .3s ease, margin .4s ease, padding .4s ease;
}
.s-agent.scanning .s-words { width: min(132px, 30vw); opacity: 1; margin-left: 2px; padding-left: 10px; }
#sWord { display: inline-block; font-family: var(--text-font); font-style: italic; font-weight: 400; color: var(--ink); }
#sWord.w-in { animation: w-in .17s ease-out; }
@keyframes w-in { from { opacity: 0; transform: translateY(7px); filter: blur(1.5px); } to { opacity: 1; transform: none; filter: none; } }
.s-agent.done .orb .ring, .s-agent.done .orb .core { stroke: currentColor; }
.s-agent.done .orb .core { fill: currentColor; }
.s-agent.done .num { font-size: 1.35em; line-height: 1; margin: 0 1px; }
.s-agent.found-in .s-pill { animation: pill-in .5s cubic-bezier(.2, .8, .25, 1); }
.s-agent.found-in .s-pill::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 25%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 75%);
  transform: translateX(-120%); animation: pill-sheen 1.1s .35s ease-in-out 1;
}
@keyframes pill-in {
  from { clip-path: inset(0 100% 0 0 round 12px); transform: scale(.92); }
  to { clip-path: inset(0 0 0 0 round 12px); transform: none; }
}
@keyframes pill-sheen { to { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .s-agent.found-in .s-pill, .s-agent.found-in .s-pill::after { animation: none; } }

/* Палітра кольорів у спливаючому вікні */
:root { --dot-green: #8fcf6f; --dot-yellow: #f5d33f; --dot-blue: #6fa8e6; }
#popPalette { position: relative; }
.palette svg .d1 { fill: var(--dot-green); stroke: none; }
.palette svg .d2 { fill: var(--dot-yellow); stroke: none; }
.palette svg .d3 { fill: var(--dot-blue); stroke: none; }
.palette .cur-dot {
  position: absolute; right: 7px; bottom: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--cur, transparent); box-shadow: 0 0 0 2px var(--paper); display: none;
}
.palette.has .cur-dot { display: block; }
.pop.pal-open #popPalette { background: var(--accent-soft); }
.pop .pop-colors { display: none; }
.pop.pal-open .pop-colors {
  display: flex; justify-content: flex-end; padding: 10px 14px; gap: 16px; border-bottom: 1px solid var(--line);
  animation: colors-in .2s ease;
}
@keyframes colors-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pop.pal-open .pop-colors button { animation: dot-in .22s cubic-bezier(.2, .8, .3, 1.3) backwards; }
.pop.pal-open .pop-colors button:nth-child(2) { animation-delay: .04s; }
.pop.pal-open .pop-colors button:nth-child(3) { animation-delay: .08s; }
@keyframes dot-in { from { transform: scale(.4); opacity: 0; } }

/* Примітка перекладачів у спливаючому вікні */
.pop-note { font-family: var(--text-font); font-size: 14px; line-height: 1.5; color: var(--muted); padding: 8px 4px 2px; }
.pop-note::before { content: attr(data-label); display: block; font-family: var(--ui-font); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.pop-note em { color: var(--ink); }

/* Спливаюче вікно — легкий жовтий відтінок */
/* легкий відтінок кольору теми */
:root { --pop-bg: #ffffff; --pop-line: color-mix(in srgb, var(--accent) 22%, var(--line)); }
:root[data-theme="dark"] { --pop-bg: #26282c; }
.pop .pop-head, .pop.pal-open .pop-colors { border-color: var(--pop-line); }
.palette .cur-dot { box-shadow: 0 0 0 2px var(--pop-bg); }

/* Кольорова палітра */
#popPalette svg path { fill: #f2d7a4; stroke: #9a6a36; stroke-width: 1.4; }
:root[data-theme="dark"] #popPalette svg path { fill: #8a6a3e; stroke: #e5c48f; }
#popPalette svg circle { stroke: none; }
#popPalette svg .d1 { fill: #4caf50; }
#popPalette svg .d2 { fill: #f4c20d; }
#popPalette svg .d3 { fill: #3b82f6; }
#popPalette svg .d4 { fill: #d64545; }

/* Кольори теми */
:root[data-accent="blue"]   { --accent: #2f5d9e; --accent-soft: #e1eaf6; }
:root[data-accent="green"]  { --accent: #3d7a4a; --accent-soft: #e1efe3; }
:root[data-accent="purple"] { --accent: #6b4196; --accent-soft: #ece3f5; }
:root[data-accent="gold"]   { --accent: #9a6a1c; --accent-soft: #f5ead3; }
:root[data-accent="teal"]   { --accent: #1f7a7a; --accent-soft: #ddf0ef; }
:root[data-theme="dark"][data-accent="blue"]   { --accent: #8fb4ec; --accent-soft: #22303f; }
:root[data-theme="dark"][data-accent="green"]  { --accent: #8fcf9c; --accent-soft: #22352a; }
:root[data-theme="dark"][data-accent="purple"] { --accent: #c3a3ea; --accent-soft: #312640; }
:root[data-theme="dark"][data-accent="gold"]   { --accent: #e3b866; --accent-soft: #3a3020; }
:root[data-theme="dark"][data-accent="teal"]   { --accent: #7fd1cf; --accent-soft: #1f3534; }
.accents { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.accents button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.accents button.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.accents [data-accent="cherry"] { background: #8a3b2b; }
.accents [data-accent="blue"] { background: #2f5d9e; }
.accents [data-accent="green"] { background: #3d7a4a; }
.accents [data-accent="purple"] { background: #6b4196; }
.accents [data-accent="gold"] { background: #9a6a1c; }
.accents [data-accent="teal"] { background: #1f7a7a; }

/* Світіння: спливаюче вікно вірша і кнопка «Дослідити» */
.pop {
  box-shadow: 0 12px 40px rgba(40, 25, 15, .26), 0 0 38px color-mix(in srgb, var(--accent) 42%, transparent);
}
.explore {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent),
              0 4px 18px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Досліджені вірші — легке жовте світіння навколо букв */
:root { --explored-glow: rgba(255, 190, 30, .3); }
:root[data-theme="sepia"] { --explored-glow: rgba(240, 175, 30, .35); }
:root[data-theme="dark"] { --explored-glow: rgba(255, 205, 70, .22); }
.v.explored { text-shadow: 0 0 7px var(--explored-glow); }
.v.explored .vn { text-shadow: none; }
.s-clip .v.explored { text-shadow: none; }

/* Безкінечна стрічка розділів */
html { overflow-anchor: none; }
.ctx-card { overflow-anchor: none; }
.stream .chap { padding-bottom: 34px; }
.stream .chap + .chap .chapter-title { padding-top: 22px; border-top: 1px solid var(--line); }
.stream .chapter-title { margin: 6px 0 18px; }
main { padding-bottom: 60px; }
.ctx-chap-title {
  margin: 14px 14px 0; font-family: var(--text-font); font-size: 15px; font-weight: 700; color: var(--accent);
}
.ctx-chap + .ctx-chap { border-top: 1px solid var(--line); margin-top: 6px; }

/* Дрібні позначки біля тексту масштабуються разом з текстом (--k = розмір шрифту / 19) */
.xcol .xg, .xr-inline { font-size: calc(12.5px * var(--k)); }
.pop { width: min(calc(360px * var(--kp)), calc(100vw - 16px)); }
.pop-ref { font-size: calc(13px * var(--kp)); }
.pop-head .icon-btn { width: calc(42px * var(--kp)); height: calc(40px * var(--kp)); }
.pop-head .icon-btn svg { width: calc(22px * var(--kp)); height: calc(22px * var(--kp)); }
.palette .cur-dot { width: calc(9px * var(--kp)); height: calc(9px * var(--kp)); }
.explore { font-size: calc(15px * var(--kp)); padding: calc(10px * var(--kp)) calc(12px * var(--kp)); }
.explore svg { width: calc(18px * var(--kp)); height: calc(18px * var(--kp)); }
.pop-note { font-size: calc(14px * var(--kp)); }
.pop-note::before { font-size: calc(11px * var(--kp)); }
.pop-empty { font-size: calc(14px * var(--kp)); }
.pop .pop-colors button { width: calc(34px * var(--kp)); height: calc(34px * var(--kp)); }
.s-ref { font-size: calc(13px * var(--k)); }
.s-list .ref { font-size: calc(12.5px * var(--k)); }
.s-agent { font-size: calc(13.5px * var(--k)); }
.s-agent.scanning .s-words { width: min(calc(132px * var(--k)), 34vw); }
.ctx-back { font-size: calc(14px * var(--k)); }
.ctx-back svg { width: calc(18px * var(--k)); height: calc(18px * var(--k)); }
.ctx-title { font-size: calc(16px * var(--k)); }
.ctx-open { font-size: calc(13px * var(--k)); }
.ctx-chap-title { font-size: calc(15px * var(--k)); }

.pop { --kp: min(var(--k), 1.3); }
@media (min-width: 700px) { .pop { --kp: var(--k); } }
.pop-ref { white-space: nowrap; }

/* Вікно розділу: заголовки як у звичайному читанні, «Назад» унизу зліва */
.ctx-stream .ctx-chap { padding: 6px 0 18px; }
.ctx-stream .ctx-chap + .ctx-chap { border-top: 0; margin-top: 0; }
.ctx-stream .ctx-chap + .ctx-chap .chapter-title { padding-top: 20px; border-top: 1px solid var(--line); margin-left: 14px; margin-right: 14px; }
.ctx-stream .chapter-title { margin: 12px 14px 10px; font-size: calc(var(--fs) * 1.3); }
.ctx-head { justify-content: space-between; }
.ctx-title { text-align: left; padding-left: 6px; }
.ctx-foot { position: sticky; bottom: 0; z-index: 2; height: 0; overflow: visible; }
.ctx-foot .ctx-back {
  position: absolute; left: 12px; bottom: 12px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 0 3px var(--paper);
  padding: calc(9px * var(--k)) calc(16px * var(--k)) calc(9px * var(--k)) calc(10px * var(--k));
}
.ctx-text { padding-bottom: 8px; }
.ctx-stream { padding-bottom: 64px; }

/* Панель книг: вкладки по краях, списки їздять вбік */
.bk-tabs { flex: 1; justify-content: space-between; }
.bk-tabs .tab { padding: 8px 14px; }
.books-body { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
.bk-track {
  flex: 1; min-height: 0; display: flex; width: calc(var(--n, 2) * 100%);
  transition: transform .34s cubic-bezier(.2, .75, .25, 1); will-change: transform;
}
.bk-track[hidden], .books-body .book-list[hidden] { display: none; }
.bk-panel { flex: 1 1 0; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 24px; }
.books-body > .book-list { overflow-y: auto; padding: 0 14px 24px; }
.bk-panel .group {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent);
  padding: 16px 10px 4px;
}
.bk-panel .book-list li.sep { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.bk-panel { touch-action: pan-y; }
.bk-panel .book-list { padding-top: 8px; }
.bk-panel .book-list li.sep.sec { margin-top: 12px; padding-top: 12px; border-top-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

/* Пошук книги: лупа посередині, поле виїжджає зверху */
.bk-head { position: relative; overflow: hidden; margin: 0 -14px; padding: 0 14px; }
.bk-tabs { align-items: center; }
.bk-lens { width: 40px; height: 40px; color: var(--muted); }
.bk-lens:hover { color: var(--accent); }
.bk-search {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 14px;
  background: var(--paper); transform: translateY(-110%); transition: transform .28s cubic-bezier(.2, .75, .25, 1);
}
.bk-search.open { transform: none; }
.bk-search > svg { flex: none; color: var(--accent); }
.bk-search .field { flex: 1; margin: 0; padding: 8px 10px; }
#drawerBooks .books-body { margin-top: 6px; }
.bk-tabs.three .tab { padding: 8px 9px; }
.bk-tabs.three .bk-lens { width: 34px; }
.bk-tabs { scrollbar-width: none; gap: 0; }
.bk-tabs::-webkit-scrollbar { display: none; }
.bk-tabs .tab { padding: 8px 11px; }

/* Вужчі списки під своїми вкладками; неактивний — майже прозорий */
.bk-track { width: max-content; }
.bk-panel { flex: none; transition: opacity .3s ease; }
.bk-panel.inactive { opacity: .14; }
.bk-panel.inactive * { pointer-events: none; }
/* без смуги прокрутки в меню книг і розділів */
.bk-panel, .books-body > .book-list, #drawerBooks .drawer-body, #drawerChapters .drawer-body { scrollbar-width: none; }
.bk-panel::-webkit-scrollbar, .books-body > .book-list::-webkit-scrollbar,
#drawerBooks .drawer-body::-webkit-scrollbar, #drawerChapters .drawer-body::-webkit-scrollbar { display: none; }

/* компактні списки книг */
#drawerBooks .books-body { margin: 6px -14px 0; padding: 0; }
.bk-panel { padding: 0 6px 20px; }
.bk-panel .book-list { padding-top: 2px; }
.bk-panel .book-list li button { padding: 7px 8px; font-size: 15.5px; }
.bk-panel .book-list li button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-panel .book-list li.sep { margin-top: 3px; padding-top: 3px; }
.bk-panel .book-list li.sep.sec { margin-top: 7px; padding-top: 7px; }

/* Сітка розділів у тому самому меню */
#drawerBooks .books-body { position: relative; }
.bk-panel.gone { opacity: 0; pointer-events: none; }
.bk-panel .book-list li button.picked { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .bk-panel .book-list li button.picked { color: #1b1413; }
.bk-chapters {
  position: absolute; top: 0; bottom: 0; right: 0; z-index: 2; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; padding: 0 10px 0 6px;
  transform: translateX(105%); transition: transform .34s cubic-bezier(.2, .75, .25, 1);
  scrollbar-width: none;
}
.bk-chapters::-webkit-scrollbar { display: none; }
.bk-chapters.open { transform: none; }
.bk-ch-inner { margin: auto 0; padding: 20px 0; } /* по центру висоти */
.bk-ch-title { font-family: var(--text-font); font-weight: 700; font-size: 16px; color: var(--accent); margin: 0 2px 10px; }
.bk-chapters .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.bk-chapters .chapter-grid button { font-size: 15px; border-radius: 9px; }
/* порожнє місце над і під списком книг — щоб дотягнутися пальцем */
.bk-panel::before, .bk-panel::after { content: ""; display: block; height: 42%; }
/* м'яке прозоре жовте тло під досліджуваним віршем і під віршем у вікні розділу */
.s-clip .v.s-target, .ctx-text .v.ctx-hit {
  background: color-mix(in srgb, var(--mark) 38%, transparent);
  box-shadow: 0 0 8px 3px color-mix(in srgb, var(--mark) 30%, transparent);
  border-radius: 6px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* меню плавно ховається; текст плавно змінюється */
.drawer { transition: transform .28s ease, visibility 0s linear .28s; }
.drawer.open { transition: transform .28s ease, visibility 0s; }
#text { transition: opacity .2s ease; }
#text.fading { opacity: 0; }

/* Налаштування: шрифт (A + лупи), тема (4 кнопки) */
.font-ctl { display: flex; align-items: center; gap: 10px; }
.face-btn {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer;
  font-family: var(--ui-font); font-size: 26px; font-weight: 600; color: var(--ink); line-height: 1;
}
.face-btn.serif { font-family: "Literata", "PT Serif", "Noto Serif", Georgia, serif; font-weight: 500; }
.face-btn:active { transform: scale(.94); }
.zoom-stack { display: flex; flex-direction: column; gap: 4px; }
.zoom-stack .icon-btn { width: 40px; height: 34px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--bg); }
.seg button { border: 0; background: none; padding: 8px 10px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .seg button.on { color: #1b1413; }
.settings .row.stack { flex-direction: column; align-items: stretch; gap: 8px; }
.settings .row.stack select { width: 100%; }

/* Кнопки шрифту — посередині рядка */
.settings .font-row .font-ctl { flex: 1; justify-content: center; }

/* Меню й налаштування масштабуються разом з текстом (до 1,5 раза) */
.drawer { --kd: min(var(--k), 1.5); font-size: calc(15px * var(--kd)); width: min(calc(380px * var(--kd)), 96vw); }
.drawer.wide { width: min(calc(560px * var(--kd)), 100vw); }
.drawer .drawer-title { font-size: calc(19px * var(--kd)); }
.drawer .icon-btn { width: calc(40px * var(--kd)); height: calc(40px * var(--kd)); }
.drawer .icon-btn svg { width: calc(22px * var(--kd)); height: calc(22px * var(--kd)); }
.drawer .tab { font-size: calc(15px * var(--kd)); }
.bk-panel .book-list li button { font-size: calc(15.5px * var(--kd)); padding: calc(7px * var(--kd)) 8px; }
.books-body > .book-list li button { font-size: calc(16px * var(--kd)); }
.bk-ch-title { font-size: calc(16px * var(--kd)); }
.bk-chapters .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(calc(40px * var(--kd)), 1fr)); }
.bk-chapters .chapter-grid button, #chapterGrid button { font-size: calc(15px * var(--kd)); }
.seg button { font-size: calc(14px * var(--kd)); padding: calc(8px * var(--kd)) calc(10px * var(--kd)); }
.face-btn { width: calc(48px * var(--kd)); height: calc(48px * var(--kd)); font-size: calc(26px * var(--kd)); }
.zoom-stack .icon-btn { width: calc(40px * var(--kd)); height: calc(34px * var(--kd)); }
.settings .row.check input { width: calc(18px * var(--kd)); height: calc(18px * var(--kd)); }
.results li { font-size: calc(16px * var(--kd)); }
.results .ref, .marks .ref { font-size: calc(13px * var(--kd)); }
.search-info, .hint { font-size: calc(13px * var(--kd)); }
.marks .tx { font-size: calc(15px * var(--kd)); }
.marks .when { font-size: calc(12px * var(--kd)); }
.settings .row.stack .seg { display: flex; }
.settings .row.stack .seg button { flex: 1; }
.drawer .tab { font-size: calc(15px * min(var(--kd), 1.15)); }
.drawer .bk-tabs .tab { padding: 8px calc(11px * min(var(--kd), 1.1)); }
.bk-chapters .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(calc(36px * var(--kd)), 1fr)); }
.bk-chapters .chapter-grid button { aspect-ratio: auto; height: calc(40px * var(--kd)); }

/* квадрати з номерами розділів — вишневі з білими цифрами */
.chapter-grid button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chapter-grid button:hover { filter: brightness(1.12); color: #fff; }
.chapter-grid button.cur { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
:root[data-theme="dark"] .chapter-grid button { color: #1b1413; }
/* лупа пошуку — посередині шапки */
.topbar { position: sticky; }
#btnSearch { position: absolute; left: 50%; transform: translateX(-50%); }
.topbar .place { max-width: calc(50% - 70px); }
.bk-panel.inactive { overflow-y: hidden; touch-action: none; }

/* Список перекладів у налаштуваннях */
.tr-list { list-style: none; margin: 4px 0 0; padding: 0; }
.tr-list li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.tr-list li.cur .tr-name b { color: var(--accent); }
.tr-name { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 8px 2px; cursor: pointer; color: var(--ink); }
.tr-name:disabled { cursor: default; opacity: .75; }
.tr-name b { display: block; font-size: 1em; }
.tr-name small { display: block; color: var(--muted); font-size: .8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-act { border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 6px 10px; cursor: pointer; font-size: .9em; }
.tr-act.add { background: var(--accent); border-color: var(--accent); color: #fff; }
.tr-act.del { color: var(--muted); }
.tr-cur { color: var(--accent); font-weight: 700; padding: 0 10px; }

/* Текст пов'язаного вірша «летить» разом з рамкою на своє місце в розділі */
.ctx-fly {
  position: absolute; z-index: 1; pointer-events: none; transform-origin: 0 0;
  font-family: var(--text-font); line-height: 1.7; color: var(--ink);
  transition: transform .34s cubic-bezier(.2, .75, .25, 1), width .34s cubic-bezier(.2, .75, .25, 1),
              text-indent .34s cubic-bezier(.2, .75, .25, 1), opacity .18s ease;
}
.ctx-fly[hidden] { display: none; }
.ctx-fly sup { color: var(--muted); font-size: .65em; font-family: var(--ui-font); margin-right: 2px; }
.ctx-fly .fly-hit {
  background: color-mix(in srgb, var(--mark) 38%, transparent); border-radius: 6px;
  box-shadow: 0 0 8px 3px color-mix(in srgb, var(--mark) 30%, transparent);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.ctx-card { z-index: 2; }

.tr-add-btn { margin-top: 6px; align-self: flex-start; color: var(--accent); font-weight: 600; }
.tr-add-box[hidden] { display: none; }
.tr-list .tr-name:is(span) { cursor: default; }
.tr-empty { color: var(--muted); padding: 10px 2px; font-size: .9em; }
.modal-card .tr-lang { display: flex; margin-bottom: 6px; }
.modal-card .tr-lang button { flex: 1; }

/* «Додати переклад» — розгортається під кнопкою */
.tr-add-btn { display: inline-flex; align-items: center; gap: 6px; }
.tr-add-btn .chev { transition: transform .25s ease; font-size: .9em; }
.tr-add-btn.open .chev { transform: rotate(180deg); }
.tr-drop { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease, opacity .25s ease; opacity: 0; }
.tr-drop.open { grid-template-rows: 1fr; opacity: 1; }
.tr-drop-in { overflow: hidden; min-height: 0; }
.tr-drop .tr-lang { display: flex; margin: 10px 0 4px; }
.tr-drop .tr-lang button { flex: 1; }

/* Кожен вірш з нового рядка: окремий абзац, відступ першого рядка, дрібний сірий номер */
.text.lines .v { display: block; text-indent: 1.1em; margin-bottom: .75em; }
.text.lines .vn { color: var(--muted); font-weight: 400; font-family: var(--text-font); font-size: .6em; margin-right: .35em; vertical-align: .55em; }
.text.lines .v.marked .vn { color: #fff; }

/* Мова й переклади в налаштуваннях */
.tr-box { border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px 12px; margin: 4px 0 14px; background: var(--bg); }
.tr-box .tr-list li:last-child { border-bottom: 0; }
.tr-box .tr-add-btn { margin-top: 8px; width: 100%; justify-content: center; }
.tr-act.del { font-size: .85em; padding: 6px 10px; }
/* поточний розділ у сітці: біле тло, вишневий текст, товща рамка і блакитне світіння */
.chapter-grid button.cur {
  background: #fff; color: var(--accent); font-weight: 700;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(120, 180, 255, .35), 0 0 14px 4px rgba(110, 170, 255, .45);
}
:root[data-theme="dark"] .chapter-grid button.cur { background: var(--paper); color: var(--accent); }
/* шрифт, вибраний кнопкою «A», — і для всіх текстів у налаштуваннях */
#drawerSettings, #drawerSettings .drawer-title { font-family: var(--text-font); }
#drawerSettings .face-btn { font-family: var(--ui-font); }
#drawerSettings .face-btn.serif { font-family: "Literata", "PT Serif", "Noto Serif", Georgia, serif; }
/* книга, яку зараз читаєте: вишневий текст і вишнева рамка; після натискання — заповнена */
.bk-panel .book-list li button.cur, .books-body > .book-list li button.cur {
  color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 10px;
}
.bk-panel .book-list li button.cur.picked { box-shadow: none; color: #fff; }
:root[data-theme="dark"] .bk-panel .book-list li button.cur.picked { color: #1b1413; }

/* Інші переклади цього вірша — у спливаючому вікні */
.pop-other { padding: 10px 4px 2px; }
.pop-other-lbl { font-size: calc(11px * var(--kp)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.pop-other ul { list-style: none; margin: 0; padding: 0; }
.pop-other li { padding: 7px 6px; border-top: 1px solid var(--pop-line); cursor: pointer; border-radius: 8px; }
.pop-other li:active { background: var(--accent-soft); }
@media (hover: hover) { .pop-other li:hover { background: var(--accent-soft); } }
.pop-other b { display: block; color: var(--accent); font-size: calc(12.5px * var(--kp)); margin-bottom: 1px; }
.pop-other .tx { font-family: var(--text-font); font-size: calc(14.5px * var(--kp)); line-height: 1.5; color: var(--ink); }

/* Кнопка перекладу в шапці — поруч з лупою */
.tr-pill {
  position: absolute; left: calc(50% + 24px); max-width: 92px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--paper); color: var(--accent);
  font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
#btnSearch { left: calc(50% - 26px); }
.topbar .place { max-width: calc(50% - 96px); }
.pick-list .tr-name b { font-size: 1.05em; }
.dual-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.dual-toggle input { display: none; }
.dual-toggle i { width: 46px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.dual-toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.dual-toggle input:checked + i { background: var(--accent); }
.dual-toggle input:checked + i::after { transform: translateX(20px); }

/* Подвійний режим: екран навпіл */
.dual { position: fixed; left: 0; right: 0; bottom: 0; top: var(--topbar-h, 53px); z-index: 15; display: flex; flex-direction: column; background: var(--bg); }
.dual[hidden] { display: none; }
body.dual-on #reader { visibility: hidden; }
.dpane { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.dpane + .dpane { border-top: 3px solid color-mix(in srgb, var(--accent) 45%, var(--line)); }
.dp-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--paper); flex: none; }
.dp-sel { max-width: 46%; padding: 6px 8px; }
.dp-title { flex: 1; font-family: var(--text-font); font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-close { width: 34px; height: 34px; }
.dp-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; }
.dp-stream { max-width: 720px; margin: 0 auto; padding: 4px 18px 40px; }
.dp-stream .chapter-title { font-size: calc(var(--fs) * 1.15); margin: 14px 0 8px; }
.dp-stream .pchap + .pchap .chapter-title { padding-top: 14px; border-top: 1px solid var(--line); }
#btnSearch { left: 50%; }
.tr-pill { left: calc(50% + 24px); max-width: calc(50% - 112px); }
.topbar .place { max-width: calc(50% - 60px); }

/* Без трикрапок: задовгий текст переноситься на наступний рядок, рядки однієї назви — щільно */
.bk-panel .book-list li button span, .books-body > .book-list li button span,
.tr-name small, .tr-name b, .dp-title, .tr-pill, .topbar .place #placeBook, .ctx-title, .pop-ref, .bk-ch-title {
  white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
}
.bk-panel .book-list li button, .books-body > .book-list li button { line-height: 1.15; align-items: center; }
.tr-name b { line-height: 1.2; }
.tr-name small { line-height: 1.2; margin-top: 2px; }
.dp-title, .ctx-title, .bk-ch-title { line-height: 1.15; }
.topbar .place { white-space: normal; line-height: 1.1; text-align: left; }
.tr-pill { line-height: 1.1; text-align: center; }

/* Вибір перекладу в подвійному режимі — випадний список з білим тлом і стрілочкою */
.dp-sel {
  -webkit-appearance: none; appearance: none; background-color: #fff; color: var(--ink); font-weight: 600;
  border: 1.5px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 10px;
  padding: 7px 34px 7px 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3b2b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
:root[data-theme="dark"] .dp-sel { background-color: var(--paper); }
/* кнопка перекладу в шапці — як випадний список (біле тло, рамка, стрілочка ▾) */
.tr-pill {
  border-radius: 10px; background-color: #fff; color: var(--ink); font-weight: 600; font-size: 13px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  padding: 5px 26px 5px 10px; text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3b2b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
:root[data-theme="dark"] .tr-pill { background-color: var(--paper); }

/* Розкривний список перекладів під кнопкою в шапці */
.tr-drop-menu {
  position: fixed; z-index: 45; max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--pop-bg); border: 1px solid var(--pop-line); border-radius: 14px; padding: 6px 12px 12px;
  box-shadow: 0 12px 36px rgba(40, 25, 15, .22);
  opacity: 0; transform: translateY(-8px) scaleY(.96); transform-origin: top center;
  transition: opacity .18s ease, transform .2s cubic-bezier(.2, .75, .25, 1);
}
.tr-drop-menu.open { opacity: 1; transform: none; }
.tr-drop-menu[hidden] { display: none; }
.tr-pill.open { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3b2b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E"); }
.tr-drop-menu .dual-toggle { margin-top: 8px; }

/* Подвійний режим: вибір перекладу — по центру шапки половини */
.dp-head { display: grid; grid-template-columns: 1fr auto 1fr; }
.dp-head .dp-sel { max-width: none; justify-self: center; }
.dp-head .dp-title { justify-self: start; font-size: 13px; }
.dp-head .dp-close { justify-self: end; }
.tr-pill { overflow-wrap: normal; word-break: normal; }
.tr-pill.dual { font-size: 11.5px; line-height: 1.05; padding: 3px 22px 3px 8px; background-position: right 5px center; }
.tr-pill { top: 50%; transform: translateY(-50%); }
.tr-pill.dual { min-height: 32px; }

/* Шапка масштабується разом з текстом (до 1,35 раза, щоб усе вміщалося) */
.topbar { }
.topbar .place { font-size: calc(16px * var(--kh)); }
.topbar .place .chev { width: calc(18px * var(--kh)); height: calc(18px * var(--kh)); }
.topbar .icon-btn { width: calc(40px * var(--kh)); height: calc(40px * var(--kh)); }
.topbar .icon-btn svg { width: calc(22px * var(--kh)); height: calc(22px * var(--kh)); }
.topbar .tr-pill { font-size: calc(13px * var(--kh)); left: calc(50% + 24px * var(--kh)); }
.topbar .tr-pill.dual { font-size: calc(11.5px * var(--kh)); }
.dp-head { }
.dp-head .dp-title { font-size: calc(13px * var(--kh)); }
.dp-head .dp-sel { font-size: calc(14px * var(--kh)); }
.tr-drop-menu { font-size: calc(15px * min(var(--k), 1.35)); }

/* Шапка: три групи — зліва меню й назва, посередині лупа й переклад, справа зірочка й налаштування */
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px; }
.tb-left, .tb-mid, .tb-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.topbar #btnSearch, .topbar .tr-pill { position: static; transform: none; left: auto; top: auto; }
.topbar .place { max-width: none; min-width: 0; flex: 1 1 auto; }
.topbar .tr-pill { max-width: calc(110px * var(--kh)); }
.topbar { display: flex; }
.tb-left { flex: 1 1 auto; }
.tb-mid, .tb-right { flex: none; }
.topbar .place, .topbar .place #placeBook { overflow-wrap: normal; word-break: normal; white-space: nowrap; }
.topbar .place.tight .chev { display: none; }
.topbar .place.tight { padding-left: 4px; padding-right: 4px; }
.topbar .place.hidden-name { visibility: hidden; }

:root { --kh: 1; }
.topbar .place, .topbar .place #placeBook { overflow: visible; }
.topbar .place.tight .chev, .topbar .place.hidden-name { display: revert; visibility: visible; }

/* Браузер не масштабує сторінку (ні щипком, ні подвійним дотиком) — лише прокрутка;
   щипок двома пальцями обробляє застосунок і змінює розмір тексту */
html, body { touch-action: pan-x pan-y; }
/* кнопка перекладу — ширина за текстом, стрілочка завжди праворуч від тексту, не на ньому */
.topbar .tr-pill { max-width: none; white-space: nowrap; overflow: visible; padding-right: calc(24px * var(--kh)); background-position: right calc(7px * var(--kh)) center; background-size: calc(14px * var(--kh)); }
.topbar .tr-pill.dual { white-space: normal; }
/* рамка з перекладами в налаштуваннях — на білому тлі */
.tr-box { background: #fff; }
.tr-box .tr-add-btn, .tr-box .tr-act.del { background: #fff; }
:root[data-theme="dark"] .tr-box, :root[data-theme="dark"] .tr-box .tr-add-btn, :root[data-theme="dark"] .tr-box .tr-act.del { background: var(--paper); }

/* міні-пояснення під параметром у налаштуваннях */
.opt-hint { display: block; font-size: .8em; line-height: 1.35; color: var(--muted); margin-top: 2px; }

/* «Інші переклади» з'являються по одному; своя смуга прокрутки */
.pop-other li.po-hide { display: none; }
.pop-other li.po-show { animation: s-in .38s cubic-bezier(.2, .75, .25, 1) both; }
@media (prefers-reduced-motion: reduce) { .pop-other li.po-show { animation: none; } }
#popBody { scrollbar-width: none; }
#popBody::-webkit-scrollbar { display: none; }
.pop .pop-other li { padding-right: 30px; }
/* лінії між пунктами закінчуються до смуги прокрутки */
.pop .pop-other li { margin-right: 26px; padding-right: 6px; }
.s-list li { margin-right: 34px; padding-right: 8px; }

/* вимір повної висоти спливаючого вікна (разом з перекладами, що ще не з'явились) */
.pop.measure .pop-other li.po-hide { display: block; visibility: hidden; }

/* Кнопка-список у налаштуваннях і розкритий список з поясненнями */
.opt-select {
  width: 100%; text-align: left; border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 10px;
  padding: 9px 36px 9px 12px; background-color: #fff; color: var(--ink); font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3b2b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.opt-select.open { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3b2b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .opt-select { background-color: var(--paper); }
.opt-menu { z-index: 46; padding: 4px 8px; }
.opt-list { list-style: none; margin: 0; padding: 0; }
.opt-list li { display: flex; align-items: flex-start; gap: 8px; border-bottom: 1px solid var(--pop-line); }
.opt-list li:last-child { border-bottom: 0; }
.opt-list button { flex: 1; text-align: left; border: 0; background: none; padding: 10px 4px; cursor: pointer; color: var(--ink); }
.opt-list b { display: block; font-size: 1em; margin-bottom: 3px; }
.opt-list li.cur b { color: var(--accent); }
.opt-list small { display: block; font-size: .85em; line-height: 1.4; color: var(--muted); }
.opt-list .tr-cur { padding: 10px 6px 0; }

/* поточний переклад у налаштуваннях — вибраний: вишневе тло, білий текст */
#trInstalled li.cur { background: var(--accent); border-radius: 10px; border-bottom-color: transparent; margin: 4px -6px; padding: 0 6px; }
#trInstalled li.cur .tr-name b, #trInstalled li.cur .tr-name small, #trInstalled li.cur .tr-cur { color: #fff; }
#trInstalled li.cur .tr-name small { opacity: .85; }
:root[data-theme="dark"] #trInstalled li.cur .tr-name b, :root[data-theme="dark"] #trInstalled li.cur .tr-name small, :root[data-theme="dark"] #trInstalled li.cur .tr-cur { color: #1b1413; }

/* Плавна поява пунктів: місце під пункт плавно розсувається, текст проявляється з прозорого */
.pop-other li, .s-list li {
  display: grid !important; grid-template-rows: 0fr; opacity: 0; transform: none; animation: none !important;
  padding: 0 !important; border-top: 0 !important;
  transition: grid-template-rows .42s cubic-bezier(.2, .75, .25, 1), opacity .5s ease .08s;
}
.pop-other li.po-show, .s-list li.show { grid-template-rows: 1fr; opacity: 1; }
.li-in { overflow: hidden; min-height: 0; }
.pop-other .li-pad { padding: 7px 6px; border-top: 1px solid var(--pop-line); }
.s-list .li-pad { padding: 9px 8px; }
.s-list li + li .li-pad { border-top: 1px solid var(--line); }
/* вимір повної висоти вікна вірша (наперед, разом з пунктами, що ще з'являтимуться) */
.pop.measure .pop-other li.po-hide { grid-template-rows: 1fr; transition: none; }
@media (prefers-reduced-motion: reduce) { .pop-other li, .s-list li { transition: none; } }
/* приховані пункти не анімуються (вимір висоти їх не зрушує); анімується лише поява */
.pop-other li.po-hide, .s-list li:not(.show) { transition: none; }
/* браузер не підкручує сторінку сам, коли щось змінює розмір (вікно вірша росте вгору — текст стоїть) */
body, #reader, #text, .pop, .pop * { overflow-anchor: none; }

/* плавне зникнення спливаючого вікна вірша і подвійного режиму */
.pop { transition: opacity .22s ease, transform .22s ease; }
.dual { opacity: 0; transition: opacity .25s ease; }
.dual.in { opacity: 1; }

/* ---------- Заставка ---------- */
#intro {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center;
  transition: opacity .4s ease; overflow: hidden;
}
#intro.gone { opacity: 0; pointer-events: none; }
.ib-stage { perspective: 1300px; }
.ib-book {
  --pw: min(41vw, 170px);
  position: relative; width: calc(var(--pw) * 2); height: calc(var(--pw) * 1.42);
  transform: translateX(calc(var(--pw) / -2)) scale(.92); opacity: 0;
  animation: ib-in .45s ease-out forwards;
  transition: transform .75s cubic-bezier(.55, .05, .35, 1);
  transform-style: preserve-3d;
}
@keyframes ib-in { to { opacity: 1; transform: translateX(calc(var(--pw) / -2)) scale(1); } }
#intro.open .ib-book { animation: none; opacity: 1; transform: translateX(0) scale(1); }
#intro.zoom .ib-book {
  transition: transform .75s cubic-bezier(.6, 0, .3, 1);
  transform: scale(var(--zoom)) translateX(calc(var(--pw) / -2));
}
.ib-page {
  position: absolute; top: 0; width: 50%; height: 100%; background: var(--paper); overflow: hidden;
  box-shadow: 0 10px 30px rgba(40, 25, 15, .25);
}
.ib-left { left: 0; border-radius: 6px 0 0 6px; background: linear-gradient(90deg, var(--paper) 85%, color-mix(in srgb, var(--ink) 10%, var(--paper))); }
.ib-right { right: 0; border-radius: 0 6px 6px 0; background: linear-gradient(270deg, var(--paper) 85%, color-mix(in srgb, var(--ink) 10%, var(--paper))); }
.ib-txt {
  padding: 10% 9%; font-family: var(--text-font); font-size: calc(var(--pw) / 21); line-height: 1.55; color: var(--ink);
  text-align: justify; hyphens: auto;
}
.ib-txt b { display: block; text-align: center; font-size: 1.35em; margin-bottom: .5em; }
.ib-txt sup { color: var(--accent); font-size: .6em; }
.ib-left .ib-txt { opacity: .55; }
.ib-cover {
  position: absolute; top: 0; right: 0; width: 50%; height: 100%; transform-origin: left center;
  transform-style: preserve-3d; transition: transform .85s cubic-bezier(.45, .05, .3, 1);
}
#intro.open .ib-cover { transform: rotateY(-180deg); }
.ib-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 0 7px 7px 0; }
.ib-front {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #fff) 0%, var(--accent) 45%, color-mix(in srgb, var(--accent) 70%, #000) 100%);
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--accent) 70%, #000), inset 0 0 0 8px #d9b45a, 0 14px 34px rgba(40, 20, 10, .35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10%;
}
.ib-cross { color: #e4c36a; font-size: calc(var(--pw) / 4.5); line-height: 1; }
.ib-title { color: #ecd189; font-family: var(--text-font); font-weight: 700; font-size: calc(var(--pw) / 5.2); letter-spacing: .04em; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.ib-back { transform: rotateY(180deg); background: var(--paper); border-radius: 7px 0 0 7px; box-shadow: inset -8px 0 14px rgba(0,0,0,.08); }
@media (prefers-reduced-motion: reduce) { #intro { display: none; } }
.ib-back { overflow: hidden; background: linear-gradient(90deg, var(--paper) 85%, color-mix(in srgb, var(--ink) 10%, var(--paper))); box-shadow: 0 10px 30px rgba(40, 25, 15, .25); }
.ib-back .ib-txt { opacity: .55; }
