/* Читалка ronic.kz — три темы: ночь, сепия, день */
:root {
  --fs: 19px; --lh: 1.75;
  --bg: #0b0f18; --text: #e4e1d8; --muted: #9aa3b5; --line: rgba(255,255,255,.12); --accent: #7cc0ff; --panel: #121826; --btn: rgba(255,255,255,.05);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="sepia"] { --bg: #f3ead8; --text: #3b2f22; --muted: #7a6a55; --line: rgba(59,47,34,.18); --accent: #8a4b12; --panel: #ece1cb; --btn: rgba(59,47,34,.06); }
:root[data-theme="day"] { --bg: #fbfbf8; --text: #1d1f24; --muted: #5d6470; --line: rgba(0,0,0,.12); --accent: #1f5fae; --panel: #f0f1ee; --btn: rgba(0,0,0,.04); }
* { box-sizing: border-box; }
html { color-scheme: dark; }
:root[data-theme="sepia"], :root[data-theme="day"] { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); -webkit-text-size-adjust: 100%; transition: background .2s, color .2s; }
a { color: var(--accent); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 20; background: var(--panel); padding: 8px 14px; border-radius: 999px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.rtitle { flex: 1; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.rbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--btn); color: var(--text); font: 500 15px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.rbtn:hover { border-color: var(--accent); }
.rbtn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.rbtn:disabled { opacity: .4; cursor: default; }
.rbtn-main { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.rprogress { position: sticky; top: 61px; z-index: 9; height: 3px; background: var(--line); }
.rprogress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.rpanel { position: fixed; z-index: 11; top: 70px; right: 16px; width: min(420px, calc(100% - 32px)); max-height: calc(100vh - 90px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.rpanel[hidden] { display: none; }
.rpanel h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; }
.rpanel ol { margin: 0; padding-left: 22px; line-height: 1.4; }
.rpanel li { margin: 2px 0; }
.rpanel li a { display: block; padding: 8px 4px; color: var(--text); text-decoration: none; border-radius: 8px; }
.rpanel li a:hover, .rpanel li a[aria-current] { color: var(--accent); }
.rpanel li a[aria-current] { font-weight: 600; }
.rrow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.rrow > span { width: 80px; color: var(--muted); font-size: 14px; }
.rrow output { min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }
.rrow .rbtn { min-height: 40px; padding: 0 14px; font-size: 14px; }

.rmain { max-width: 720px; margin: 0 auto; padding: 32px 22px 80px; outline: none; }
.rtext { font-family: var(--serif); font-size: var(--fs); line-height: var(--lh); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
:root[data-font="sans"] .rtext { font-family: var(--sans); }
.rtext h1 { font-family: var(--serif); font-size: 1.5em; line-height: 1.25; font-weight: 600; margin: .5em 0 1.4em; text-align: center; }
.rtext h3 { font-size: 1.1em; margin: 1.6em 0 .8em; text-align: center; font-weight: 600; }
.rtext p { margin: 0; text-indent: 1.5em; text-align: justify; }
.rtext h1 + p, .rtext h3 + p, .rtext .gap + p, .rtext blockquote p { text-indent: 0; }
.rtext p.gap { height: 1em; }
.rtext p.verse { text-indent: 0; text-align: left; padding-left: 2em; }
.rtext p.author { text-align: right; font-style: italic; text-indent: 0; }
.rtext blockquote { margin: 1em 0 1.4em 2em; font-size: .92em; font-style: italic; color: var(--muted); }
.rtext .wm { margin-top: 3em; text-indent: 0; text-align: center; font: 12px var(--sans); color: var(--muted); opacity: .7; }
.rnav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rmuted { color: var(--muted); font-size: 14px; }
.rmsg { margin: 24px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.rlock { text-align: center; padding: 48px 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.rlock h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 12px; }
.rlock p { max-width: 460px; margin: 0 auto 22px; line-height: 1.6; }
.rlib h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; margin: 0 0 8px; }
.rshelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px; margin-top: 24px; }
.rbook { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; }
.rbook img { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.rbook:hover b { color: var(--accent); }
@media (max-width: 560px) {
  .rlabel { display: none; }
  .rbar { padding: 8px 10px; gap: 6px; }
  .rbar .rbtn { padding: 0 12px; }
  .rmain { padding: 24px 18px 64px; }
  .rprogress { top: 61px; }
  .rnav .rbtn { flex: 1; }
  .rnav #r-pos { order: -1; width: 100%; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
