/* Читалка: три темы (день, сепия, ночь), два шрифта, размер и ширина колонки. */
:root { --read-size: 19px; --read-width: 720px; --read-font: Literata, Georgia, serif; }
html[data-font="sans"] { --read-font: Manrope, "Segoe UI", sans-serif; }
html[data-width="narrow"] { --read-width: 600px; }
html[data-width="wide"] { --read-width: 880px; }
html, html[data-reader="day"] { --bg: #FFFFFF; --text: #1C1B20; --muted: #64636E; --surface: #F4F4F6; --surface-2: #F4F4F6; --line: #E6E5EA; --line-2: #E6E5EA; --control: #DAD9E0; }
html[data-reader="sepia"] { --bg: #F3EBDD; --text: #3B3024; --muted: #76664F; --surface: #EADFCB; --surface-2: #EADFCB; --line: #D9C9AE; --line-2: #D9C9AE; --control: #D9C9AE; --accent-soft: #EBD2C8; color-scheme: light; }
html[data-reader="night"] { --bg: #15141A; --text: #DAD8DF; --muted: #9896A2; --surface: #1F1E25; --surface-2: #1F1E25; --line: #2E2D35; --line-2: #2E2D35; --control: #3A3942; --accent-ink: #F07A92; --accent-soft: #3A1620; color-scheme: dark; }

.reader-body { background: var(--bg); }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.reader-bar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); transition: transform .2s; }
.reader-bar.is-hidden { transform: translateY(-100%); }
.reader-bar-in { max-width: 1100px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 14px; }
.reader-bar .icon-btn { background: var(--bg); border-color: var(--line); color: var(--text); text-decoration: none; }
.reader-bar .icon-btn.is-off { opacity: .35; }
.reader-book { font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.reader-nav { display: flex; gap: 8px; align-items: center; }
.ch-select { height: 44px; max-width: 280px; border: 1px solid var(--line); border-radius: 12px; padding: 0 30px 0 12px; background-color: var(--bg); color: var(--text); font-weight: 600; }
.reader-settings { max-width: 1100px; margin: 0 auto; padding: 4px 24px 16px; display: flex; flex-wrap: wrap; gap: 12px 28px; }
.set-row { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.set-row > span { color: var(--muted); min-width: 60px; }
.seg { display: flex; align-items: center; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: none; padding: 8px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg output { min-width: 28px; text-align: center; font-weight: 700; }

.reader { max-width: var(--read-width); margin: 0 auto; padding: 32px 24px 80px; }
.reader .crumbs { margin-bottom: 18px; }
.chapter-title { font-family: var(--read-font); font-weight: 600; font-size: calc(var(--read-size) * 1.5); display: flex; flex-direction: column; gap: 6px; }
.chapter-title small { font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.chapter-meta { color: var(--muted); font-size: 14px; margin: 10px 0 28px; }
.chapter-text { font-family: var(--read-font); font-size: var(--read-size); line-height: 1.75; overflow-wrap: break-word; }
.chapter-text p { margin: 0 0 1em; }
.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.pager-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: 16px; background: var(--surface); text-decoration: none; color: var(--text); min-width: 0; }
.pager-card small { color: var(--muted); font-weight: 600; }
.pager-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-card.next { text-align: right; background: var(--accent); color: #fff; }
.pager-card.next small { color: rgba(255,255,255,.8); }
.pager-card.next:hover { color: #fff; filter: brightness(1.06); }
.chapter-foot { margin-top: 28px; font-size: 14px; color: var(--muted); text-align: center; }

/* Шапка: назад к книге и названия видны только на телефоне */
.reader-back, .reader-ch, .reader-dock { display: none; }
.reader-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Телефон: шапка «назад + книга + глава», управление внизу */
@media (max-width: 720px) {
  .reader-bar-in { padding: 8px 12px; gap: 6px; min-height: 52px; }
  .reader-bar .logo, .reader-bar .reader-nav, .reader-bar [data-settings-toggle] { display: none; }
  .reader-bar.is-hidden { transform: none; }
  .reader-back { display: grid; place-items: center; width: 36px; height: 36px; margin-left: -6px; color: var(--text); flex: none; }
  .reader-book { font-size: 11px; font-weight: 600; color: var(--muted); }
  .reader-ch { display: block; font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .read-progress { top: 52px; z-index: 31; background: var(--line); }
  .reader { padding: 20px 16px 150px; }
  .chapter-pager { grid-template-columns: 1fr; }
  .reader .crumbs, .chapter-meta { display: none; }
  .chapter-title { margin-bottom: 18px; }

  .reader-dock { display: flex; flex-direction: column; gap: 10px; position: fixed; z-index: 35; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 12px 14px; border-radius: 20px; background: var(--text); color: var(--bg); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
  .dock-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; white-space: nowrap; }
  .dock-progress span { opacity: .75; }
  .dock-bar { flex: 1; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--bg) 25%, transparent); overflow: hidden; }
  .dock-bar span { display: block; height: 100%; width: 0; background: var(--accent); opacity: 1; }
  .dock-btns { display: flex; justify-content: space-between; align-items: center; }
  .dock-btns a, .dock-btns span, .dock-btns button { width: 52px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--bg); text-decoration: none; border: 0; background: none; font: inherit; font-weight: 800; cursor: pointer; }
  .dock-btns .is-off { opacity: .35; }
  .dock-btns .dock-aa, .dock-btns .dock-aa[aria-expanded="true"] { width: 64px; background: var(--bg); color: var(--text); }
  .reader-settings { position: fixed; z-index: 36; left: 10px; right: 10px; bottom: calc(132px + env(safe-area-inset-bottom)); padding: 14px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); flex-direction: column; gap: 10px; }
  .reader-settings:not([hidden]) { display: flex; }
}
