/* ============================================================
   ЧудоСказ — PWA-читалка (T-09)
   Три темы, свайп-страницы, подсветка речи, нижний плеер.
   Никаких внешних шрифтов и CDN — читалка обязана работать офлайн.
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Классы вроде .player{display:flex} перебивают браузерное [hidden]{display:none}.
   Без этой строки плеер виден у сказок без озвучки, а кнопка установки — всегда. */
[hidden] { display: none !important; }

:root {
    --brand:      #7C3AED;
    --brand-2:    #EC4899;
    --gold:       #F59E0B;

    --bg:         #141131;
    --bg-2:       #1E1B4B;
    --fg:         #F3F0FF;
    --fg-soft:    #C4B5FD;
    --muted:      #A78BFA;

    --card:       rgba(255,255,255,.055);
    --card-line:  rgba(255,255,255,.12);
    --sheet:      #1B1740;
    --shadow:     0 24px 60px rgba(0,0,0,.45);

    --hl:         rgba(245,158,11,.22);
    --hl-fg:      #FFE9B8;

    --font:       Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --fs:         1.06rem;
    --lh:         1.85;

    --bar-h:      54px;
    --player-h:   66px;
    --radius:     20px;
}

[data-theme="day"] {
    --bg: #FFFBF5; --bg-2: #FFF6E9; --fg: #241F45; --fg-soft: #5B5480; --muted: #7C6FB0;
    --card: rgba(124,58,237,.05); --card-line: rgba(76,29,149,.14);
    --sheet: #FFFFFF; --shadow: 0 24px 60px rgba(76,29,149,.16);
    --hl: rgba(245,158,11,.3); --hl-fg: #4A2C00;
}

[data-theme="sepia"] {
    --bg: #F3E7D3; --bg-2: #EBDBC1; --fg: #3B2C1A; --fg-soft: #6B563C; --muted: #8A7250;
    --card: rgba(59,44,26,.05); --card-line: rgba(59,44,26,.16);
    --sheet: #FBF2E4; --shadow: 0 24px 60px rgba(59,44,26,.2);
    --hl: rgba(180,120,20,.26); --hl-fg: #3B2C1A;
}

/* Контраст — для слабовидящих («Особая сказка», таблица особенностей, В-28):
   белые буквы на чёрном, жёлтые акценты, без полупрозрачных подложек */
[data-theme="contrast"] {
    --bg: #000000; --bg-2: #000000; --fg: #FFFFFF; --fg-soft: #FFE14D; --muted: #FFE14D;
    --card: #111111; --card-line: #FFE14D;
    --sheet: #111111; --shadow: none;
    --hl: #FFE14D; --hl-fg: #000000;
}
[data-theme="contrast"] .body { font-weight: 500; }

/* Главное слово страницы крупно — «глобальное чтение» (ОС-09).
   Слово не переносится никогда («УМЫВАЕ/ТСЯ» — так читать нельзя, ОС-16):
   длинное уменьшается под ширину своего блока. --kw-len — число букв (ставит шаблон).
   Первый font-size — запас для браузеров без единиц cqi (от ширины экрана). */
.key-word-box { container-type: inline-size; }
.key-word {
    font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: min(calc(var(--fs) * 2.3), calc((100vw - 88px) / (var(--kw-len, 8) * 0.8)));
    font-size: min(calc(var(--fs) * 2.3), calc(100cqi / (var(--kw-len, 8) * 0.8)));
    font-weight: 800; letter-spacing: .06em;
    line-height: 1.1; text-align: center; color: var(--fg);
    margin: .15em 0 .45em; white-space: nowrap; overflow: hidden;
}

[data-font="sans"] { --font: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Звёздное небо — только в ночной теме, чистый CSS ради батареи */
/* overflow:hidden обязателен — слои ниже растянуты за края и иначе
   растягивают документ по горизонтали, ломая ширину страниц */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; opacity: 0; transition: opacity .6s; }
[data-theme="night"] .sky { opacity: 1; }
.sky::before, .sky::after {
    content: ''; position: absolute; inset: -50%;
    background-image:
        radial-gradient(1.4px 1.4px at 20% 30%, rgba(214,200,255,.85), transparent),
        radial-gradient(1.2px 1.2px at 70% 15%, rgba(255,235,190,.7), transparent),
        radial-gradient(1.6px 1.6px at 45% 70%, rgba(214,200,255,.7), transparent),
        radial-gradient(1.1px 1.1px at 85% 60%, rgba(236,72,153,.55), transparent),
        radial-gradient(1.3px 1.3px at 12% 82%, rgba(214,200,255,.6), transparent),
        radial-gradient(1px 1px at 60% 45%, rgba(255,255,255,.5), transparent);
    background-size: 260px 260px, 340px 340px, 300px 300px, 420px 420px, 380px 380px, 240px 240px;
    animation: twinkle 7s ease-in-out infinite alternate;
}
.sky::after { animation-delay: -3.5s; opacity: .55; transform: scale(1.3); }
@keyframes twinkle { from { opacity: .35; } to { opacity: .9; } }

/* ============================================================
   Каркас
   ============================================================ */
.reader {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    z-index: 1;
}

/* ── Верхняя панель ───────────────────────────────────────── */
.bar {
    height: var(--bar-h);
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 6px;
    padding: 0 6px 0 4px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--bar-h) + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--card-line);
    transition: transform .35s ease, opacity .35s ease;
    position: relative; z-index: 30;
}
.bar.is-hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }

.bar-title {
    flex: 1; min-width: 0;
    font-size: .95rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-sub { display: block; font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--muted); font-weight: 400; }

.icon-btn {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 14px;
    background: transparent; color: var(--fg);
    font-size: 1.15rem; cursor: pointer;
    transition: background .18s, transform .18s;
}
.icon-btn svg { width: 22px; height: 22px; display: block; }
.icon-btn:hover { background: var(--card); }
.icon-btn:active { transform: scale(.92); }
.icon-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 30%, transparent); }
.icon-btn:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* Полоса прогресса чтения */
.readbar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.readbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .35s ease; }

/* ── Страницы ─────────────────────────────────────────────── */
.pages {
    flex: 1 1 auto; min-height: 0;
    display: flex;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}
.pages::-webkit-scrollbar { display: none; }

.page {
    flex: 0 0 100%; width: 100%; height: 100%;
    scroll-snap-align: center; scroll-snap-stop: always;
    overflow-y: auto; overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 18px 18px 26px;
    /* 14.10.2026: центрирование — полями .page-inner (margin:auto), а не justify-content:center. Тот срезал верх
       длинной страницы так, что до картинки было не долистать, — казалось, что текст лёг на картинку. */
    display: flex; flex-direction: column; justify-content: flex-start;
}
.page::-webkit-scrollbar { width: 6px; }
.page::-webkit-scrollbar-thumb { background: var(--card-line); border-radius: 3px; }

.page-inner {
    width: 100%; max-width: 1180px; margin: auto;
    display: flex; flex-direction: column; align-items: center; gap: 18px;
}

/* Иллюстрация */
.illo {
    width: 100%; max-width: 460px;
    /* Пропорции самого кадра (ставит шаблон: --ark = ширина/высота), без обрезки краёв (14.10.2026) */
    aspect-ratio: var(--ark, 1);
    border-radius: var(--radius);
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-2), color-mix(in srgb, var(--brand) 35%, var(--bg-2)));
    box-shadow: var(--shadow);
    flex: 0 0 auto;
    position: relative;
}
.illo img { width: 100%; height: 100%; object-fit: cover; display: block; will-change: transform; }
.illo.is-empty::after {
    content: '✨'; position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center; font-size: 3rem; opacity: .5;
}

/* Текст */
.text {
    width: 100%; max-width: 42rem;
    background: var(--card);
    border: 1px solid var(--card-line);
    border-radius: var(--radius);
    padding: 22px 24px;
}
.badge {
    display: block;
    font-family: system-ui, sans-serif; font-size: .8125rem; font-weight: 700;
    letter-spacing: .18em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 12px;
}
.body { font-size: var(--fs); line-height: var(--lh); }
.body p + p { margin-top: .9em; }
.body .dialog, .body em { color: var(--gold); font-style: normal; }

/* Подсветка читаемого предложения */
.s { transition: background-color .25s ease, color .25s ease; border-radius: 4px; }
.s.is-live {
    background: var(--hl); color: var(--hl-fg);
    box-shadow: 0 0 0 .16em var(--hl);
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* ── Развилки интерактива (T-116) ─────────────────────────── */

/* Барьер листания. Страницы за невыбранной развилкой убираем из потока:
   .pages — флекс-строка, .page держит flex:0 0 100%, поэтому со скрытым
   хвостом укорачивается scrollWidth и листать вперёд физически некуда.
   Нативный снап, инерция и свайп назад при этом не тронуты — бороться
   со scroll-snap из JS бесполезно, свайп идёт мимо всей навигации. */
.page.is-locked { display: none; }

.choice {
    margin-top: 18px; padding-top: 16px;
    border-top: 1px dashed var(--card-line);
}
.choice-q {
    font-family: system-ui, sans-serif; font-size: .95rem; font-weight: 700;
    color: var(--fg); margin-bottom: 12px; text-align: center;
}
.choice-opts { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .choice-opts { grid-template-columns: 1fr 1fr; } }

.choice-opt {
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 12px 14px;
    background: var(--card); border: 1px solid var(--card-line);
    border-radius: 14px; color: var(--fg);
    font-family: inherit; font-size: calc(var(--fs) * .92); line-height: 1.45;
    text-align: left; cursor: pointer;
    transition: border-color .2s ease, transform .12s ease, opacity .2s ease;
}
.choice-opt:hover  { border-color: var(--brand-2); }
.choice-opt:active { transform: scale(.985); }

.choice-key {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand); color: #fff;
    font-family: system-ui, sans-serif; font-weight: 700; font-size: .85rem;
}
.choice-opt.is-chosen { border-color: var(--brand-2); }
.choice-opt.is-chosen .choice-key { background: var(--brand-2); }
.choice-opt.is-dimmed { opacity: .45; }

.choice-note {
    margin-top: 10px; text-align: center;
    font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--muted);
}
.choice-redo {
    display: block; margin: 8px auto 0;
    background: none; border: none; cursor: pointer;
    font-family: system-ui, sans-serif; font-size: .8125rem;
    color: var(--muted); text-decoration: underline;
}

/* Развилку не заметили — карточка подмигивает */
.choice.is-calling { animation: choice-call .5s ease 2; }
@keyframes choice-call {
    0%, 100% { transform: none; }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) { .choice.is-calling { animation: none; } }

/* Первая фраза продолжения — её выбрал читатель, поэтому выделена.
   Озвучки у неё нет: её читает взрослый, дальше подхватывает диктор */
.bridge {
    font-style: normal; color: var(--gold);
    margin-bottom: .9em; font-size: var(--fs); line-height: var(--lh);
}

.toc-item.is-locked { opacity: .4; pointer-events: none; }
.nav-arrow:disabled { opacity: .3; cursor: default; }

/* ── Обложка и финал ──────────────────────────────────────── */
.cover, .finale { text-align: center; }
.cover .page-inner, .finale .page-inner { gap: 14px; }

.cover-art {
    width: min(300px, 62vw); aspect-ratio: 1/1;
    border-radius: 50%; overflow: hidden;
    border: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
    box-shadow: 0 0 50px color-mix(in srgb, var(--brand) 40%, transparent), var(--shadow);
    background: var(--bg-2);
    animation: float 5s ease-in-out infinite;
}
.cover-art img { width: 100%; height: 100%; object-fit: cover; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.title {
    font-size: clamp(1.8rem, 6.5vw, 3.1rem); line-height: 1.12; font-weight: 700;
    background: linear-gradient(135deg, var(--gold), var(--brand-2), var(--muted));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.moral-lbl { display: block; font-family: system-ui, sans-serif; font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.subtitle { color: var(--fg-soft); font-style: normal; font-size: clamp(.95rem, 3.6vw, 1.15rem); }
.dedication { color: var(--fg-soft); font-style: normal; line-height: 1.7; max-width: 30rem; }
.the-end {
    font-size: clamp(1.7rem, 5.5vw, 2.6rem); font-weight: 700; letter-spacing: .35em;
    background: linear-gradient(135deg, var(--gold), var(--brand-2));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.moral {
    font-family: system-ui, sans-serif; font-size: .92rem; line-height: 1.75;
    color: var(--muted); max-width: 30rem;
}

/* Кнопки */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 12px 22px;
    border: 1px solid var(--card-line); border-radius: 999px;
    background: var(--card); color: var(--fg);
    font-family: system-ui, sans-serif; font-size: .92rem; font-weight: 600;
    text-decoration: none; cursor: pointer;
    transition: transform .18s, background .18s, box-shadow .18s;
}
.btn:hover { background: color-mix(in srgb, var(--brand) 18%, var(--card)); }
.btn:active { transform: scale(.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent; color: #fff;
    box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 45%, transparent);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.btn-lg { min-height: 54px; padding: 15px 30px; font-size: 1rem; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }

/* Кольцо прогресса скачивания */
.ring {
    width: 20px; height: 20px; border-radius: 50%;
    background: conic-gradient(var(--gold) calc(var(--p, 0) * 1%), rgba(255,255,255,.18) 0);
    position: relative; flex: 0 0 auto;
}
.ring::after {
    content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--sheet);
}

/* Стрелки листания (десктоп) */
.nav-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 52px; height: 52px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    border: 1px solid var(--card-line); color: var(--fg);
    backdrop-filter: blur(8px); cursor: pointer; z-index: 20;
    font-size: 1.3rem; transition: background .2s, transform .2s;
}
.nav-arrow:hover { background: color-mix(in srgb, var(--brand) 35%, var(--bg)); }
.nav-arrow[hidden] { display: none !important; }
.nav-prev { left: 14px; } .nav-next { right: 14px; }
@media (hover: hover) and (min-width: 820px) { .nav-arrow { display: flex; } }

.stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }

/* ── Нижний плеер ─────────────────────────────────────────── */
.player {
    flex: 0 0 auto;
    min-height: var(--player-h);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 10px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--card-line);
    position: relative; z-index: 30;
    transition: transform .35s ease, opacity .35s ease;
}
.player.is-hidden { transform: translateY(100%); opacity: 0; pointer-events: none; }

.play-btn {
    width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
    border: 0; cursor: pointer; color: #fff; font-size: 1.1rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 45%, transparent);
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .18s;
}
.play-btn:active { transform: scale(.93); }
.play-btn svg { width: 24px; height: 24px; display: block; }

.track { flex: 1 1 auto; min-width: 0; }
.track-name {
    font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px;
}
.seek {
    height: 16px; display: flex; align-items: center; cursor: pointer; touch-action: none;
}
.seek-line { width: 100%; height: 4px; border-radius: 2px; background: var(--card-line); position: relative; }
.seek-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 2px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.seek-dot { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); opacity: 0; transition: opacity .2s; }
.seek:hover .seek-dot, .seek.is-active .seek-dot { opacity: 1; }
.time { font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.chip {
    flex: 0 0 auto; min-height: 44px; min-width: 44px; padding: 6px 12px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; border: 1px solid var(--card-line);
    background: transparent; color: var(--muted); cursor: pointer;
    font-family: system-ui, sans-serif; font-size: .8125rem; font-weight: 600;
}
.chip.is-on { background: color-mix(in srgb, var(--brand) 26%, transparent); color: var(--fg); border-color: transparent; }
.chip-hide-sm { display: none; }
@media (min-width: 560px) { .chip-hide-sm { display: inline-flex; align-items: center; } }

/* ── Шторки (настройки, содержание) ───────────────────────── */
.backdrop {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(6,4,24,.55); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .28s;
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    max-height: 82vh; overflow-y: auto;
    background: var(--sheet); color: var(--fg);
    border-radius: 24px 24px 0 0;
    border-top: 1px solid var(--card-line);
    box-shadow: var(--shadow);
    padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
    transform: translateY(101%); transition: transform .32s cubic-bezier(.22,.85,.3,1);
}
.sheet.is-open { transform: translateY(0); }
@media (min-width: 720px) {
    .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 101%); border-radius: 24px 24px 0 0; }
    .sheet.is-open { transform: translate(-50%, 0); }
}
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--card-line); margin: 4px auto 14px; }
.sheet h2 { font-size: 1.05rem; margin-bottom: 14px; }
.row { padding: 12px 0; border-bottom: 1px solid var(--card-line); }
.row:last-child { border-bottom: 0; }
.row-label { font-family: system-ui, sans-serif; font-size: .82rem; color: var(--muted); margin-bottom: 9px; display: block; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg .chip { min-height: 44px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch-row .row-label { margin: 0; color: var(--fg); font-size: .95rem; }
.switch-hint { display: block; font-size: .8125rem; color: var(--muted); margin-top: 3px; }
.switch {
    flex: 0 0 auto; width: 52px; height: 30px; border-radius: 999px;
    border: 1px solid var(--card-line); background: var(--card); cursor: pointer; position: relative;
    transition: background .22s;
}
.switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
    border-radius: 50%; background: var(--muted); transition: transform .22s, background .22s;
}
.switch[aria-checked="true"] { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: #fff; }

/* Содержание */
.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 12px; }
.toc-item {
    border: 1px solid var(--card-line); background: var(--card);
    border-radius: 14px; overflow: hidden; cursor: pointer; text-align: left;
    color: var(--fg); font-family: system-ui, sans-serif; padding: 0;
    transition: transform .18s, border-color .18s;
}
.toc-item:hover { transform: translateY(-2px); border-color: var(--brand); }
.toc-item.is-current { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2) inset; }
.toc-thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: var(--bg-2); }
.toc-cap { display: block; padding: 8px 10px; font-size: .8125rem; line-height: 1.35; }
.toc-num { display: block; font-size: .8125rem; color: var(--muted); margin-bottom: 2px; }

/* ── Тост ─────────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--player-h) + 22px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px); z-index: 90;
    background: var(--sheet); color: var(--fg);
    border: 1px solid var(--card-line); border-radius: 14px;
    padding: 11px 18px; font-family: system-ui, sans-serif; font-size: .84rem;
    box-shadow: var(--shadow); opacity: 0; pointer-events: none;
    transition: opacity .25s, transform .25s; max-width: min(92vw, 460px); text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ── Индикатор офлайна ────────────────────────────────────── */
.offline-flag {
    position: fixed; top: calc(var(--bar-h) + env(safe-area-inset-top) + 8px); left: 50%;
    transform: translateX(-50%); z-index: 40;
    background: var(--gold); color: #241900; border-radius: 999px;
    padding: 5px 14px; font-family: system-ui, sans-serif; font-size: .8125rem; font-weight: 700;
    box-shadow: var(--shadow);
}
.offline-flag[hidden] { display: none; }

/* ── Мелочи ───────────────────────────────────────────────── */
.hint { font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--muted); line-height: 1.6; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Планшет/десктоп: картинка и текст рядом */
@media (min-width: 900px) {
    .page-inner { flex-direction: row; align-items: center; gap: 34px; }
    .page-inner > .illo { flex: 0 1 46%; max-width: 520px; }
    .page-inner > .text { flex: 1 1 54%; max-height: 82vh; overflow-y: auto; }
    .cover .page-inner, .finale .page-inner { flex-direction: column; }
    :root { --fs: 1.12rem; }
}

/*
 | Телефон вертикально (14.10.2026, «премиальная выдача»): картинка — главное, за что платят, поэтому она всегда
 | целиком сверху, а длинный текст прокручивается в своём блоке ниже. Страница целиком не прокручивается, плеер —
 | отдельной полосой под страницами и текст не закрывает. Обложка и финал прокручиваются как раньше.
 */
@media (max-width: 899px) and (orientation: portrait) {
    .page:not(.cover):not(.finale) { overflow: hidden; padding: 12px 14px 10px; }
    .page:not(.cover):not(.finale) > .page-inner { height: 100%; margin: 0 auto; gap: 12px; }
    .page:not(.cover):not(.finale) .illo {
        width: min(100%, calc(46vh * var(--ark, 1))); width: min(100%, calc(46dvh * var(--ark, 1)));
        max-width: 100%;
    }
    .page:not(.cover):not(.finale) .text {
        flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain;
        padding: 16px 18px;
    }
}

/*
 | Подсказка «текст продолжается» (ревизор R-06, 14.10.2026): текст прокручивается в своей рамке, и без подсказки мама,
 | читая вслух, доходила до края и листала дальше — конец страницы терялся. Пока ниже есть текст — край рамки затухает,
 | а внизу кнопка «ещё ↓» (листает текст, а не страницу). Класс has-more ставит reader.js по прокрутке.
 */
.text.has-more {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 56px), transparent);
            mask-image: linear-gradient(to bottom, #000 calc(100% - 56px), transparent);
}
.more-hint { display: none; }
.text.has-more + .more-hint {
    display: inline-flex; align-items: center; gap: 6px;
    position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 5;
    min-height: 44px; padding: 7px 18px; border-radius: 999px; border: 1px solid var(--card-line);
    background: var(--sheet); color: var(--fg); box-shadow: var(--shadow);
    font: 600 .85rem/1 system-ui, sans-serif; cursor: pointer;
}
.page { position: relative; }

/* Телефон горизонтально: картинка слева целиком по высоте, текст справа со своей прокруткой — по реальному месту, а не 78vh */
@media (orientation: landscape) and (max-height: 560px) {
    .page:not(.cover):not(.finale) { overflow: hidden; padding: 10px 16px; }
    .page:not(.cover):not(.finale) > .page-inner { flex-direction: row; height: 100%; margin: 0 auto; gap: 16px; align-items: stretch; }
    .page:not(.cover):not(.finale) .illo { flex: 0 0 auto; height: 100%; width: auto; max-width: 52%; align-self: center; max-height: 100%; }
    .page:not(.cover):not(.finale) .text { flex: 1 1 auto; max-height: none; min-height: 0; overflow-y: auto; padding: 14px 18px; }
    .cover-art { width: min(190px, 34vw); }
    /* 15.10.2026 (тайный покупатель): лёжа на обложке были видны только круг и половина названия — кнопки «Слушать» и
       «Читать» уезжали вниз без подсказки. Теперь картинка слева, название и кнопки справа, всё в одном экране. */
    .cover .page-inner { display: grid; grid-template-columns: auto 1fr; column-gap: 22px; row-gap: 6px; align-items: center; text-align: left; margin: auto; }
    .cover .cover-art { grid-row: 1 / span 4; width: min(150px, 26vw); }
    .cover .title { font-size: clamp(1.2rem, 3.6vw, 1.6rem); margin: 0; }
    .cover .actions { justify-content: flex-start; margin-top: 4px; }
    .finale .cover-art { width: min(110px, 20vw); }
    /* Лёжа подсказку «листайте» на обложке закрывал плеер, если название в две строки — кнопки «Слушать/Читать» и так ведут в книгу */
    .cover #cover-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .pages { scroll-behavior: auto; }
}

/* Страница-заглушка «нет сети» */
.plain {
    position: static; min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: 16px; padding: 32px 22px;
}

        /* ── Именная грамота (Премиум) ─────────────────────────── */
        .award       { border: 2px double #B08D2F; border-radius: 10px; padding: 18px 20px;
                       margin: 22px auto 4px; max-width: 420px; background: #FFFDF7; color: #44403C; }
        .award-stars { color: #D4AF37; letter-spacing: 6px; font-size: 14px; }
        .award-ttl   { font-size: 20px; font-weight: 700; color: #7C2D12; letter-spacing: 5px; margin-top: 8px; }
        .award-sub   { font-size: 12px; color: #A16207; letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }
        .award-name  { font-size: 24px; font-weight: 700; color: #1E1B4B; margin-top: 12px; }
        .award-for   { font-size: 15px; font-style: normal; line-height: 1.6; margin-top: 10px; }
        .award-date  { font-size: 13px; color: #78716C; margin-top: 12px; }   /* было #A8A29E — 2,5 (замер клиентской 26.10.2026) */

/* ── Финал: всё, что входит в тариф (14.10.2026, «премиальная выдача») ──────────
   Три группы — «Читать и слушать», «Скачать», «Творить вместе». На телефоне — аккуратный список строк,
   на компьютере — сетка в две колонки. Чего нет в тарифе, здесь нет вовсе (App\Support\Deliverables). */
.kit { width: 100%; max-width: 46rem; margin: 18px auto 0; text-align: left; display: flex; flex-direction: column; gap: 18px; }
.kit-ttl {
    font-family: system-ui, sans-serif; font-size: .8125rem; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--muted); margin: 0 4px 8px;
}
.kit-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .kit-grid { grid-template-columns: 1fr 1fr; } }
.kit-item, .kit-upsell {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px;
    padding: 11px 14px; border-radius: 16px; text-align: left; text-decoration: none; cursor: pointer;
    background: var(--card); border: 1px solid var(--card-line); color: var(--fg);
    font: inherit; transition: border-color .2s ease, transform .2s ease;
}
.kit-item:hover, .kit-item:focus-visible { border-color: color-mix(in srgb, var(--brand) 60%, var(--card-line)); transform: translateY(-1px); }
.kit-ico { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; background: color-mix(in srgb, var(--brand) 18%, transparent); }
.kit-txt { display: flex; flex-direction: column; min-width: 0; font-family: system-ui, sans-serif; }
.kit-txt b { font-size: .95rem; font-weight: 700; line-height: 1.3; }
.kit-txt small { font-size: .8125rem; line-height: 1.4; color: var(--fg-soft); margin-top: 2px; }
.kit-item.is-wait { border-style: dashed; }
.kit-item.is-wait .kit-txt small { color: var(--gold); }
.kit-upsell { border-style: dashed; border-color: color-mix(in srgb, var(--gold) 55%, var(--card-line)); }
.kit-upsell .kit-ico { background: color-mix(in srgb, var(--gold) 20%, transparent); }
.kit-help { text-align: center; margin-top: 4px; }
.kit-note { font-family: system-ui, sans-serif; font-size: .8125rem; color: var(--fg-soft); margin-top: 8px; line-height: 1.5; }
.kit-more { text-align: center; font-family: system-ui, sans-serif; font-size: .85rem; margin: 2px 0 10px; }
.kit-more a { color: var(--muted); }
#btn-share { align-self: center; }
[data-theme="contrast"] .kit-ico { background: transparent; border: 1px solid var(--card-line); }

/* Шторка «Здесь ошибка» */
.edit-kinds { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.edit-kind { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px;
    border: 1px solid var(--card-line); background: var(--card); cursor: pointer; font-family: system-ui, sans-serif; }
.edit-kind input { margin-top: 4px; accent-color: var(--brand); }
.edit-kind b { display: block; font-size: .9rem; }
.edit-kind small { display: block; font-size: .8125rem; color: var(--fg-soft); margin-top: 2px; }
.edit-field { display: block; margin-bottom: 12px; font-family: system-ui, sans-serif; font-size: .85rem; color: var(--fg-soft); }
.edit-field span { display: block; margin-bottom: 6px; }
.edit-field input, .edit-field textarea {
    width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--card-line);
    background: var(--bg); color: var(--fg); font: 1rem/1.5 system-ui, sans-serif;
}
.edit-msg { min-height: 1.4em; font-family: system-ui, sans-serif; font-size: .88rem; margin: 0 0 10px; }
.edit-msg.is-ok { color: #34D399; }
.edit-msg.is-err { color: #FCA5A5; }
[data-theme="day"] .edit-msg.is-ok, [data-theme="sepia"] .edit-msg.is-ok { color: #047857; }
[data-theme="day"] .edit-msg.is-err, [data-theme="sepia"] .edit-msg.is-err { color: #B91C1C; }

/* «(если знаете)» в окне правки — не мельче 12 px (15.10.2026) */
.edit-field small { font-size: .8125rem; }

/* ── Открыто по QR-коду (16.10.2026, TaleShare): большая «Слушать» поверх обложки ── */
.qr-start { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(20, 17, 49, .72); backdrop-filter: blur(3px); }
.qr-start-card { width: 100%; max-width: 380px; background: #fff; color: #1E1B4B; border-radius: 24px;
    padding: 26px 22px 20px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.qr-start-kicker { font-size: .82rem; font-weight: 800; color: #7C3AED; letter-spacing: .02em; margin-bottom: 6px; }
.qr-start-ttl { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.35rem; line-height: 1.25; margin-bottom: 20px; }
.qr-listen { display: block; width: 100%; border: 0; border-radius: 999px; padding: 18px 20px; font-size: 1.35rem; font-weight: 900;
    color: #fff; background: linear-gradient(135deg, #7C3AED, #EC4899); box-shadow: 0 10px 26px rgba(124, 58, 237, .4); cursor: pointer; }
.qr-listen span { margin-right: 6px; }
.qr-read { display: block; width: 100%; margin-top: 10px; border: 0; background: none; color: #6B7280; font-size: 1rem;
    font-weight: 700; padding: 10px; cursor: pointer; }
.kit-more .qr-create { display: inline-block; padding: 12px 22px; border-radius: 999px; text-decoration: none; font-weight: 800; }

/* Дизайн, 26.10.2026 (премиальный вид после оплаты): значки материалов — иконки (SVG) вместо эмодзи, цвет — от темы */
/* читалка не грузит wt-ui.css — базовый стиль линейной иконки (как .wt-i там) */
.wt-i { display: inline-block; flex: 0 0 auto; vertical-align: -.22em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.kit-ico .wt-i { color: var(--fg); }
#btn-listen .wt-i, .qr-listen .wt-i, [data-open-edit] .wt-i, .qr-create .wt-i, .qr-start-kicker .wt-i { vertical-align: -.2em; }
/* переключатель 52×30 — зона нажатия 44 px по высоте, вид тот же */
.switch::before { content: ''; position: absolute; inset: -7px -4px; }
#btn-listen, .qr-listen { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
