/* ТАЙНИТЕ — online reader. Themes: light / dark / contrast (+ auto). Text size via --scale. */
@import url("fonts.css");

:root {
  --scale: 1;
  --bg: #f5efe3; --bg2: #ece4d3; --paper: #fbf7ee; --ink: #2a241d; --ink2: #5e5446; --muted: #8a7d6a;
  --accent: #9a7330; --accent2: #c49a4a; --rule: #d9ccb3; --shadow: 0 18px 50px -20px rgba(60, 40, 10, .35);
  --plate: #191512; --plate-dim: .55; --sel: #e9d6a8;
  --serif: "Literata", "PT Serif", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", "Cormorant", "Times New Roman", serif;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text: var(--serif); --text-weight: 380;
  --measure: 36rem;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0f13; --bg2: #16171d; --paper: #121318; --ink: #e6dfd2; --ink2: #b9b0a0; --muted: #8b8476;
  --accent: #d4b06a; --accent2: #e8c98a; --rule: #2c2b30; --shadow: 0 18px 60px -20px rgba(0, 0, 0, .8);
  --plate: #07080a; --plate-dim: .45; --sel: #4a3d22; --text-weight: 340;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e0f13; --bg2: #16171d; --paper: #121318; --ink: #e6dfd2; --ink2: #b9b0a0; --muted: #8b8476;
    --accent: #d4b06a; --accent2: #e8c98a; --rule: #2c2b30; --shadow: 0 18px 60px -20px rgba(0, 0, 0, .8);
    --plate: #07080a; --plate-dim: .45; --sel: #4a3d22; --text-weight: 340;
    color-scheme: dark;
  }
}
:root[data-theme="contrast"] {
  --bg: #000; --bg2: #000; --paper: #000; --ink: #fff; --ink2: #fff; --muted: #f2f2f2;
  --accent: #ffe14d; --accent2: #ffe14d; --rule: #fff; --shadow: none;
  --plate: #000; --plate-dim: .25; --sel: #ffe14d; --text-weight: 460;
  color-scheme: dark;
}
:root[data-font="sans"] { --text: var(--ui); --text-weight: 400; }
:root[data-theme="contrast"][data-font="sans"] { --text-weight: 500; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; overflow-x: clip; background: var(--bg); color: var(--ink);
  font-family: var(--text); font-weight: var(--text-weight); font-optical-sizing: auto;
  font-size: calc(clamp(1.05rem, .96rem + .45vw, 1.28rem) * var(--scale)); line-height: 1.72;
  transition: background-color .4s, color .4s;
}
::selection { background: var(--sel); color: var(--ink); }
:root[data-theme="contrast"] ::selection { color: #000; }
a { color: var(--accent); text-underline-offset: .18em; }
:root[data-theme="contrast"] a { text-decoration-thickness: 2px; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: .5rem; z-index: 100; background: var(--accent); color: var(--bg); padding: .5rem 1rem; border-radius: 6px; font-family: var(--ui); }
.skip:focus { left: .5rem; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .15s linear; }
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: 3.4rem; padding: 0 max(.75rem, env(safe-area-inset-left));
  display: flex; align-items: center; gap: .5rem; font-family: var(--ui); font-size: .95rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
  transition: transform .35s ease, background-color .4s;
}
:root[data-theme="contrast"] .bar { background: #000; border-bottom-color: #fff; }
.bar.hide { transform: translateY(-100%); }
.brand { font-family: var(--display); font-weight: 600; letter-spacing: .28em; font-size: 1.15rem; color: var(--ink); text-decoration: none; padding: .3rem .2rem; white-space: nowrap; }
.bar-title { flex: 1; min-width: 0; text-align: center; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--display); font-size: 1.05rem; letter-spacing: .08em; opacity: 0; transition: opacity .3s; }
.bar.scrolled .bar-title { opacity: 1; }
.bar .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-width: 2.6rem; height: 2.6rem; padding: 0 .7rem;
  background: transparent; border: 1px solid transparent; border-radius: 999px; cursor: pointer; color: var(--ink); font-family: var(--ui); font-size: .92rem;
}
.icon-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.icon-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
:root[data-theme="contrast"] .icon-btn { border-color: #fff; }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.aa { font-family: var(--display); font-size: 1.3rem; font-weight: 600; line-height: 1; }
@media (max-width: 520px) { .icon-btn .lbl { display: none; } }

/* ---------- panels ---------- */
.panel {
  position: fixed; z-index: 70; top: 3.9rem; right: max(.75rem, env(safe-area-inset-right)); width: min(22rem, calc(100vw - 1.5rem));
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 18px; box-shadow: var(--shadow);
  padding: 1.1rem 1.1rem 1.2rem; font-family: var(--ui); font-size: .95rem; line-height: 1.4;
  opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none; transition: opacity .2s, transform .2s; visibility: hidden;
}
.panel.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; }
.panel h2 { font-family: var(--display); font-weight: 600; font-size: 1.35rem; margin: 0 0 .8rem; letter-spacing: .04em; }
.row { margin: .9rem 0 0; }
.row > .label { display: block; color: var(--muted); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .45rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .3rem; background: var(--bg2); padding: .25rem; border-radius: 12px; }
:root[data-theme="contrast"] .seg { border: 1px solid #fff; }
.seg button { border: 0; background: transparent; padding: .55rem .3rem; border-radius: 9px; cursor: pointer; font-size: .88rem; color: var(--ink2); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 24%, var(--paper)); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); font-weight: 600; }
:root[data-theme="contrast"] .seg button[aria-pressed="true"] { background: #ffe14d; color: #000; }
.size { display: flex; align-items: center; gap: .5rem; }
.size button { width: 2.8rem; height: 2.8rem; border-radius: 12px; border: 1px solid var(--rule); background: var(--bg2); cursor: pointer; font-family: var(--display); font-weight: 600; }
.size button.small { font-size: 1rem; } .size button.big { font-size: 1.5rem; }
.size output { flex: 1; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink2); }
.size input[type=range] { flex: 1; accent-color: var(--accent); }
.theme-swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; border: 1px solid var(--rule); }
.sw-light { background: #f5efe3; } .sw-dark { background: #0e0f13; } .sw-contrast { background: linear-gradient(135deg, #000 50%, #ffe14d 50%); } .sw-auto { background: linear-gradient(135deg, #f5efe3 50%, #0e0f13 50%); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 2.8rem; height: 1.6rem; border-radius: 999px; background: var(--rule); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(1.2rem); }
:root[data-theme="contrast"] .switch input:checked::after { background: #000; }
.hint { color: var(--muted); font-size: .8rem; margin: .35rem 0 0; }

/* table of contents drawer */
.scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 70; inset: 0 auto 0 0; width: min(24rem, 88vw); background: var(--paper); border-right: 1px solid var(--rule);
  transform: translateX(-102%); transition: transform .3s ease, visibility .3s; visibility: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: 1.2rem 1rem calc(2rem + env(safe-area-inset-bottom)); font-family: var(--ui);
}
.drawer.open { transform: none; visibility: visible; }
.drawer h2 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; margin: .2rem .4rem 1rem; letter-spacing: .06em; display: flex; justify-content: space-between; align-items: center; }
.drawer ol { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.drawer li a { display: grid; grid-template-columns: 2.2rem 1fr; align-items: center; gap: .3rem; padding: .55rem .5rem; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: .95rem; line-height: 1.3; }
.drawer li a:hover { background: var(--bg2); }
.drawer li a .n { font-family: var(--display); color: var(--accent); font-size: 1.1rem; font-weight: 600; }
.drawer li a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.drawer li a .t { font-family: var(--display); font-size: 1.12rem; letter-spacing: .05em; font-weight: 500; }

/* ---------- picture plates ---------- */
.plate {
  position: relative; margin: 0; overflow: hidden; background: var(--plate); isolation: isolate;
  width: 100%; height: clamp(16rem, calc(100vw / (var(--ratio))), 86vh);
}
.plate.hero { margin-top: 3.4rem; height: clamp(16rem, calc(100vw / (var(--ratio))), calc(100vh - 3.4rem)); }
.plate .bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(1.15); opacity: var(--plate-dim); z-index: -1; transform: scale(1.1); }
.plate .bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, .55) 100%); }
.plate .pic { position: absolute; inset: 0; }
.plate .pic > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.plate .pic img { cursor: zoom-in; }
.plate video { opacity: 0; transition: opacity 1.6s ease; pointer-events: none; }
.plate video.on { opacity: 1; }
.plate .tools { position: absolute; right: .8rem; bottom: .8rem; display: flex; gap: .4rem; z-index: 2; }
.plate .tools button { background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; height: 2.4rem; min-width: 2.4rem; padding: 0 .7rem; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-family: var(--ui); font-size: .8rem; display: inline-flex; align-items: center; gap: .35rem; }
.plate .tools button svg { width: 1.05rem; height: 1.05rem; }
.plate .tools button:hover { background: rgba(0, 0, 0, .65); }
.plate.no-live .live-btn { display: none; }
.plate-empty { display: grid; place-items: center; margin-top: 3.4rem; height: min(46vh, 22rem); background:
    radial-gradient(ellipse at 30% 20%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    radial-gradient(ellipse at 75% 85%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 55%), var(--plate); }
.plate-empty .glyph { font-family: var(--display); font-size: clamp(6rem, 22vw, 13rem); line-height: 1; color: color-mix(in srgb, var(--accent2) 80%, #fff); opacity: .85; text-shadow: 0 0 60px color-mix(in srgb, var(--accent) 60%, transparent); }
figcaption.sr { }

/* ---------- chapter ---------- */
main { display: block; }
.chapter-head { text-align: center; padding: clamp(2.2rem, 6vw, 4rem) 1.25rem 1rem; max-width: 46rem; margin: 0 auto; }
.kicker { font-family: var(--ui); font-size: .78rem; letter-spacing: .32em; text-transform: uppercase; color: var(--accent); margin: 0 0 .8rem; }
.chapter-head h1 { font-family: var(--display); font-weight: 500; font-size: calc(clamp(2.2rem, 1.4rem + 4vw, 4.2rem) * (0.6 + 0.4 * var(--scale))); line-height: 1.08; letter-spacing: .08em; margin: 0; text-wrap: balance; }
.ornament { color: var(--accent); font-size: 1.3rem; letter-spacing: 1.2em; margin: 1.2rem 0 0; padding-left: 1.2em; user-select: none; }
.meta { font-family: var(--ui); font-size: .85rem; color: var(--muted); margin: .8rem 0 0; }
.text { max-width: var(--measure); margin: 0 auto; padding: 1rem 1.35rem 1rem; hyphens: manual; overflow-wrap: break-word; }
.text p { margin: 0 0 .1em; text-indent: 1.6em; text-align: left; }
.text p.first { text-indent: 0; }
.text p.first::first-letter { font-family: var(--display); float: left; font-size: 4.15em; line-height: .82; padding: .07em .12em 0 0; color: var(--accent); font-weight: 600; }
.text p + p { margin-top: .55em; }
.text p.quote { text-indent: 0; font-style: italic; margin: 1.4em 0 1.4em; padding: .2em 0 .2em 1.2em; border-left: 2px solid var(--accent); color: var(--ink2); }
.text p.short { text-indent: 0; text-align: center; font-style: italic; margin: 1.2em 0; }
.text h2 { font-family: var(--display); font-weight: 600; text-align: center; letter-spacing: .16em; font-size: 1.5em; margin: 2em 0 1em; }
.end-orn { text-align: center; color: var(--accent); font-size: 1.6rem; margin: 2.2rem 0 2.6rem; user-select: none; }
.plate.second { margin-top: 0; }

.chapter-nav { max-width: 60rem; margin: 0 auto; padding: 2.5rem 1.25rem 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; font-family: var(--ui); }
.chapter-nav a { display: flex; flex-direction: column; gap: .3rem; padding: 1.1rem 1.2rem; border: 1px solid var(--rule); border-radius: 16px; text-decoration: none; color: var(--ink); background: var(--paper); transition: transform .2s, border-color .2s; min-height: 5.5rem; }
.chapter-nav a:hover { transform: translateY(-2px); border-color: var(--accent); }
.chapter-nav .dir { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.chapter-nav .t { font-family: var(--display); font-size: 1.3rem; letter-spacing: .05em; line-height: 1.15; }
.chapter-nav .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .chapter-nav { grid-template-columns: 1fr; } .chapter-nav .next { grid-column: 1; } }

.player-slot:empty { display: none; }
footer { text-align: center; font-family: var(--ui); font-size: .8rem; color: var(--muted); padding: 2.5rem 1rem calc(2.5rem + env(safe-area-inset-bottom)); }
footer .brand-s { font-family: var(--display); letter-spacing: .3em; font-size: 1rem; color: var(--ink2); display: block; margin-bottom: .4rem; }

.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 150%); z-index: 80; background: var(--ink); color: var(--bg); font-family: var(--ui); font-size: .88rem; padding: .7rem .9rem .7rem 1.1rem; border-radius: 999px; display: flex; gap: .8rem; align-items: center; box-shadow: var(--shadow); transition: transform .35s ease; max-width: calc(100vw - 2rem); }
.toast.show { transform: translate(-50%, 0); }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 999px; padding: .3rem .8rem; cursor: pointer; font-size: .82rem; white-space: nowrap; }

/* ---------- lightbox ---------- */
dialog.lightbox { padding: 0; border: 0; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100dvh; background: #050507; color: #fff; margin: 0; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .8); }
.lb-stage { width: 100%; height: 100%; overflow: auto; display: grid; place-items: center; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; }
.lb-stage img { max-width: 100vw; max-height: 100dvh; object-fit: contain; cursor: zoom-in; }
.lb-stage.zoom { place-items: start; }
.lb-stage.zoom img { max-width: none; max-height: none; width: auto; height: auto; cursor: zoom-out; }
.lb-close { position: fixed; top: max(.8rem, env(safe-area-inset-top)); right: .8rem; z-index: 2; width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .35); background: rgba(0, 0, 0, .5); color: #fff; font-size: 1.4rem; cursor: pointer; }
.lb-hint { position: fixed; bottom: calc(.8rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-family: var(--ui); font-size: .8rem; opacity: .7; pointer-events: none; }

/* ---------- cover / index ---------- */
.cover { position: relative; min-height: 100svh; display: grid; place-items: center; overflow: hidden; background: #07080a; color: #f3ecdd; isolation: isolate; }
.cover .plate { position: absolute; inset: 0; height: 100%; z-index: -1; }
.cover .plate .tools { display: none; }
@media (max-aspect-ratio: 1/1) { .cover .plate .pic > * { object-fit: cover; } }
.cover .plate .pic img { cursor: default; }
.cover .plate .pic { opacity: .9; }
.cover::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at center, rgba(0, 0, 0, .15), rgba(0, 0, 0, .7) 75%), linear-gradient(180deg, rgba(0, 0, 0, .35), transparent 30%, transparent 60%, rgba(0, 0, 0, .75)); }
.cover-inner { text-align: center; padding: 6rem 1.25rem 4rem; max-width: 50rem; }
.cover h1 { font-family: var(--display); font-weight: 500; font-size: clamp(2.6rem, 1rem + 8vw, 7rem); letter-spacing: .22em; margin: 0 -.22em 0 0; line-height: 1; text-shadow: 0 4px 40px rgba(0, 0, 0, .6); }
.cover .sub { font-family: var(--display); font-style: italic; font-size: clamp(1.2rem, 1rem + 1vw, 1.7rem); margin: 1.2rem 0 0; opacity: .9; letter-spacing: .06em; }
.cover .actions { margin-top: 2.6rem; display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; font-family: var(--ui); }
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .85rem 1.5rem; border-radius: 999px; text-decoration: none; font-size: .95rem; letter-spacing: .04em; border: 1px solid rgba(255, 255, 255, .45); color: #fff; background: rgba(0, 0, 0, .25); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .2s, transform .2s; }
.btn:hover { background: rgba(0, 0, 0, .45); transform: translateY(-1px); }
.btn.primary { background: #d4b06a; color: #1a140a; border-color: #d4b06a; font-weight: 600; }
.btn.primary:hover { background: #e8c98a; }
.btn[hidden] { display: none; }
.scroll-cue { position: absolute; bottom: calc(1.2rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); color: #fff; opacity: .7; font-family: var(--ui); font-size: .75rem; letter-spacing: .25em; text-transform: uppercase; text-decoration: none; }
.cover .bar-cover { position: absolute; top: 0; right: 0; padding: .6rem max(.75rem, env(safe-area-inset-right)); z-index: 3; }
.cover .bar-cover .icon-btn { color: #fff; }

.contents { max-width: 72rem; margin: 0 auto; padding: clamp(3rem, 7vw, 5rem) 1.25rem 2rem; }
.contents > h2 { font-family: var(--display); font-weight: 500; font-size: clamp(2rem, 1.5rem + 2vw, 3rem); text-align: center; letter-spacing: .14em; margin: 0 0 .4rem; }
.contents > .ornament { text-align: center; margin: 0 0 2.4rem; }
.intro { max-width: var(--measure); margin: 0 auto 3rem; text-align: center; color: var(--ink2); font-style: italic; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); gap: 1.4rem; }
.card a { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; transition: transform .25s, box-shadow .25s, border-color .25s; }
.card a:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 60%, var(--rule)); }
.card .thumb { aspect-ratio: 4 / 3; background: var(--plate); position: relative; overflow: hidden; display: grid; place-items: center; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.card a:hover .thumb img { transform: scale(1.04); }
.card .thumb .glyph { font-family: var(--display); font-size: 5.5rem; color: color-mix(in srgb, var(--accent2) 85%, #fff); opacity: .85; }
.card .thumb.empty { background: radial-gradient(ellipse at 30% 20%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 60%), radial-gradient(ellipse at 80% 90%, color-mix(in srgb, var(--accent2) 20%, transparent), transparent 55%), var(--plate); }
.card .body { padding: 1rem 1.15rem 1.2rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.card .n { font-family: var(--ui); font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.card .t { font-family: var(--display); font-weight: 600; font-size: 1.45rem; line-height: 1.1; letter-spacing: .05em; }
.card .ex { font-size: .9rem; color: var(--ink2); line-height: 1.5; margin: .2rem 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .m { margin-top: auto; padding-top: .5rem; font-family: var(--ui); font-size: .78rem; color: var(--muted); }
.card.done .m::after { content: " · прочетено"; color: var(--accent); }

@media print {
  .bar, .progress, .panel, .drawer, .scrim, .plate .tools, .chapter-nav, .toast, .player-slot { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .plate { height: auto; background: none; } .plate .bg { display: none; } .plate video { display: none; }
}

/* ======================================================================
   Chapter = pictures as the background (like the video): picture 1 behind page 1,
   crossfade to picture 2 at the page turn; the text sits on a translucent sheet.
   ====================================================================== */
body.chapter { background: var(--plate); }
.stage { position: fixed; inset: 0; z-index: 0; background: var(--plate); overflow: hidden; }
.stage .plate { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; transition: opacity 1.8s ease; }
.stage .plate.active { opacity: 1; }
.stage .plate .tools { display: none; }
.stage .plate .pic img { cursor: default; }
.stage .plate .pic { inset: 3.4rem 0 0 0; }
.stage .plate-empty { display: grid; place-items: center; }
.stage .plate-empty .glyph { transform: translateY(-18vh); }
.reading { position: relative; z-index: 1; }
.opening { height: clamp(14rem, 46vh, 34rem); }
.closing { height: 72vh; }
.stage.no-art ~ .reading .closing { height: 18vh; }
.sheet {
  position: relative; max-width: calc(var(--measure) + 6rem); margin: 0 auto; padding: .5rem clamp(.4rem, 2.5vw, 2.6rem) 1rem;
  background: color-mix(in srgb, var(--paper) 90%, transparent); border-radius: 24px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid color-mix(in srgb, var(--rule) 60%, transparent);
  transition: opacity .5s ease, transform .5s ease;
}
:root[data-theme="contrast"] .sheet { background: #000; border: 2px solid #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
.sheet .chapter-head { padding-top: clamp(1.8rem, 5vw, 3.2rem); }
.sheet-foot { padding-bottom: 0; margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sheet-foot .chapter-nav { padding-top: 1.6rem; }
.sheet-foot footer { padding-bottom: calc(1.8rem + env(safe-area-inset-bottom)); }
.reading .text { padding-left: clamp(.85rem, 3vw, 1.35rem); padding-right: clamp(.85rem, 3vw, 1.35rem); }
@media (max-width: 700px) {
  .sheet { margin: 0 .5rem; border-radius: 20px; }
  .sheet-foot { margin-bottom: 0; }
}
/* portrait screens: the picture sits whole at the top (under the bar); the sheet starts right below it */
@media (max-aspect-ratio: 1/1) {
  .stage .plate .pic { inset: 3.4rem 0 auto 0; height: calc(100vw / (var(--ratio))); max-height: calc(100% - 3.4rem); }
  .opening { height: clamp(10rem, calc(100vw / (var(--ratio1)) - 1.5rem), 60vh); }
  .stage .plate .bg { opacity: calc(var(--plate-dim) * .8); }
}
/* "show me the picture": the sheet fades away, the whole picture is shown centred */
.pic-tools { position: fixed; z-index: 45; right: max(.8rem, env(safe-area-inset-right)); bottom: calc(.9rem + env(safe-area-inset-bottom)); display: flex; gap: .45rem; }
.pic-tools button { display: inline-flex; align-items: center; gap: .4rem; height: 2.7rem; min-width: 2.7rem; padding: 0 .9rem; border-radius: 999px; cursor: pointer; font-family: var(--ui); font-size: .85rem;
  color: #fff; background: rgba(10, 10, 14, .55); border: 1px solid rgba(255, 255, 255, .3); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .6); }
.pic-tools .stage-zoom { padding: 0; justify-content: center; }
.pic-tools button svg { width: 1.15rem; height: 1.15rem; }
.pic-tools button[aria-pressed="true"] { background: #d4b06a; color: #1a140a; border-color: #d4b06a; }
:root[data-theme="contrast"] .pic-tools button { background: #000; border: 2px solid #fff; }
body.peek .reading { pointer-events: none; }
body.peek .sheet { opacity: 0; transform: translateY(2rem); }
body.peek .stage .plate .pic { inset: 3.4rem 0 0 0; height: auto; max-height: none; }
body.peek .stage .plate .pic img { cursor: zoom-in; }
body.peek .bar { transform: none; }
.stage .plate .pic { transition: inset .6s ease, height .6s ease; }
@media print { .stage, .pic-tools, .opening, .closing { display: none !important; } .sheet { background: none; box-shadow: none; border: 0; backdrop-filter: none; } }
