/* Мини-приложение рассказов — дизайн «Бархатный вечер» (вариант 1.2, выбран в общей группе 19.11.2026).
   Пять цветов: бордовый, зелёный, серебряный, золотой, чёрный. Приложение всегда тёмное, бархатное;
   читательница выбирает только фон для чтения: бархат, тёмно-зелёный или светлый пергамент. */

:root {
  --bg: #0e0a0b;
  --glow-1: rgba(122, 28, 48, 0.42);
  --glow-2: rgba(46, 140, 104, 0.16);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.075);
  --line: rgba(215, 219, 224, 0.14);
  --line-strong: rgba(215, 219, 224, 0.3);
  --text: #f3eee9;
  --text-2: #c9bfc2;
  --text-3: #93878b;
  --gold: #e3c77a;
  --gold-hi: #f3dc9a;
  --gold-fill: linear-gradient(135deg, #f3dc9a, #c39a45);
  --ink: #15100a;
  --burgundy: #7a1c30;
  --burgundy-lo: #4a0f1c;
  --burgundy-hi: #b0384f;
  --emerald: #2e8c68;
  --emerald-lo: #12382b;
  --emerald-hi: #4fb38c;
  --silver: #d7dbe0;
  --ok: #4fb38c;
  --bad: #ff9c8f;
  --title-fill: linear-gradient(180deg, #f8e7b0, #c39a45);
  --drop-cap: #e3c77a;
  --sheet: #160b10;
  --radius: 18px;
  --display: "Cormorant Garamond", "Times New Roman", serif;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 18px;
  --read-size: 18px;
  /* Сколько места сверху и снизу занято не приложением: часы, вырез экрана и кнопки Telegram */
  --top-inset: calc(max(var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --bottom-inset: calc(max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
}

/* Фон для чтения — действует только в читалке, остальное приложение остаётся бархатным. */
html[data-screen="reader"][data-read="forest"] {
  --bg: #08130f;
  --glow-1: rgba(46, 140, 104, 0.34);
  --glow-2: rgba(227, 199, 122, 0.08);
  --text-2: #b4c2ba;
  --text-3: #7d8f86;
  --sheet: #0c1a14;
}
html[data-screen="reader"][data-read="parchment"] {
  --bg: #f3ead7;
  --glow-1: rgba(195, 154, 69, 0.22);
  --glow-2: rgba(122, 28, 48, 0.06);
  --surface: rgba(255, 252, 244, 0.6);
  --surface-2: rgba(255, 252, 244, 0.9);
  --line: rgba(74, 44, 20, 0.16);
  --line-strong: rgba(74, 44, 20, 0.32);
  --text: #2b2018;
  --text-2: #5d4c3f;
  --text-3: #8b7867;
  --gold: #9a6d24;
  --ok: #1f6a50;
  --bad: #b3412e;
  --title-fill: linear-gradient(180deg, #8e2238, #5e1424);
  --drop-cap: #7a1c30;
  --sheet: #f3ead7;
}

html[data-font="0"] { --read-size: 15.5px; }
html[data-font="1"] { --read-size: 16.75px; }
html[data-font="2"] { --read-size: 18px; }
html[data-font="3"] { --read-size: 19.5px; }
html[data-font="4"] { --read-size: 21.5px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(95% 34% at 50% -6%, var(--glow-1), transparent 72%),
    radial-gradient(70% 40% at 108% 42%, var(--glow-2), transparent 70%),
    radial-gradient(80% 30% at 0% 104%, rgba(122, 28, 48, 0.16), transparent 70%),
    var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(12px + var(--top-inset)) var(--gutter) calc(28px + var(--bottom-inset));
  min-height: 100vh;
}
html[data-tabs="1"] .screen { padding-bottom: calc(108px + var(--bottom-inset)); }

.loading { display: grid; place-items: center; min-height: 70vh; }
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- общие элементы ---------- */

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 27px; line-height: 1.1; }
h3 { font-size: 22px; line-height: 1.15; }
p { margin: 0 0 12px; line-height: 1.55; }
.muted { color: var(--text-2); }
.small { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.center { text-align: center; }
.eyebrow { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 22px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text);
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.primary { background: var(--gold-fill); color: var(--ink); border-color: transparent; font-weight: 800; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28); }
.btn.velvet { background: linear-gradient(160deg, #7a1c30, #4a0f1c); color: var(--gold-hi); border-color: rgba(227, 199, 122, 0.45); box-shadow: 0 10px 24px rgba(74, 15, 28, 0.45); }
.btn.emerald { background: var(--emerald-lo); color: var(--silver); border-color: rgba(215, 219, 224, 0.3); }
.btn.ghost { border-color: var(--line); color: var(--text-2); }
.btn.wide { width: 100%; }
.btn.small { min-height: 40px; padding: 8px 16px; font-size: 13.5px; }
.btn svg { width: 18px; height: 18px; }

.icon-btn {
  width: 42px; height: 42px; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); cursor: pointer; flex: none; font-family: var(--sans); font-size: 14px; font-weight: 700;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.emerald { background: var(--emerald-lo); color: var(--silver); width: 50px; height: 50px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; min-height: 44px; }
.topbar .title { flex: 1; min-width: 0; font-family: var(--display); font-size: 24px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-title { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-3); margin: 26px 2px 10px; }
.empty { color: var(--text-3); text-align: center; padding: 20px 0; font-family: var(--display); font-style: italic; font-size: 19px; }

/* ромбик между золотыми линиями */
.divider { display: flex; align-items: center; gap: 10px; width: 130px; margin: 16px auto 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(227, 199, 122, 0.55); }
.divider i { width: 7px; height: 7px; transform: rotate(45deg); background: var(--emerald); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px rgba(227, 199, 122, 0.6); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--bottom-inset)); transform: translate(-50%, 20px);
  max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px;
  background: #22101a; border: 1px solid rgba(227, 199, 122, 0.3); color: #f3eee9;
  font-family: var(--sans); font-size: 14.5px; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
html[data-tabs="1"] .toast { bottom: calc(96px + var(--bottom-inset)); } /* над нижним меню */

/* ---------- портреты героев в кольцах ---------- */

.avatar { --size: 74px; width: var(--size); height: var(--size); border-radius: 50%; padding: 2px; display: inline-block; vertical-align: middle; flex: none; }
.avatar.md { --size: 56px; }
.avatar.sm { --size: 46px; }
.avatar.xs { --size: 40px; }
.avatar img, .avatar .mono { width: 100%; height: 100%; border-radius: 50%; }
.avatar img { display: block; object-fit: cover; object-position: 42% 24%; }
.avatar .mono { display: grid; place-items: center; }
.avatar .mono { font-family: var(--display); font-weight: 700; font-size: calc(var(--size) * 0.46); line-height: 1; color: var(--gold);
  background: radial-gradient(circle at 40% 30%, #2a2d31, #0d0e10); }
.ring-silver { background: linear-gradient(135deg, #f1f3f5, #8d959c 50%, #e3e6e9); }
.ring-emerald { background: linear-gradient(135deg, #4fb38c, #12382b 55%, #2e8c68); }
.ring-emerald .mono { background: radial-gradient(circle at 40% 30%, #1d5843, #0a1d16); }
.ring-gold { background: linear-gradient(135deg, #f3dc9a, #a8792f 50%, #f3dc9a); }
.ring-gold .mono { background: radial-gradient(circle at 40% 30%, #241c10, #0b0907); color: var(--gold-hi); }
.ring-burgundy .mono, .avatar.me .mono { background: radial-gradient(circle at 35% 30%, #962a40, #4a0f1c); color: var(--gold-hi); }
.ring-burgundy { background: linear-gradient(135deg, #c24a62, #4a0f1c 55%, #9b2c43); }
.ring-dashed { padding: 0; border: 1.5px dashed rgba(227, 199, 122, 0.6); color: var(--gold); display: inline-grid; place-items: center; }
.ring-dashed svg { width: 28px; height: 28px; }

/* ---------- нижнее меню ---------- */

.tabbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(14px + var(--bottom-inset)); z-index: 30;
  max-width: 608px; margin: 0 auto; height: 64px; border-radius: 22px;
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(26, 10, 16, 0.9); border: 1px solid rgba(227, 199, 122, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 14px; border: 0; background: none;
  color: #b3a7ab; font-family: var(--sans); font-size: 11px; font-weight: 600; cursor: pointer; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--gold); }

/* ---------- 18+ ---------- */

.gate { display: flex; flex-direction: column; margin: calc(-12px - var(--top-inset)) calc(-1 * var(--gutter)) 0; min-height: 100vh; }
.gate-art { position: relative; height: 48vh; min-height: 300px; overflow: hidden;
  background: radial-gradient(90% 70% at 50% 30%, rgba(122, 28, 48, 0.55), transparent 70%), #0e0a0b; display: grid; place-items: center; }
.gate-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
.gate-art::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 6, 7, 0.45) 0%, rgba(74, 15, 28, 0.35) 55%, var(--bg) 100%); }
.gate-art .emblem { width: 150px; height: 150px; color: var(--gold); position: relative; z-index: 1; }
.gate-art .emblem svg { width: 100%; height: 100%; }
.gate-body { position: relative; margin-top: -80px; padding: 0 calc(var(--gutter) + 6px) calc(28px + var(--bottom-inset));
  display: grid; gap: 14px; justify-items: center; text-align: center; }
.wordmark { font-family: var(--display); font-style: italic; font-weight: 600; color: var(--gold); line-height: 1; }
.gate .wordmark { font-size: 48px; }
.gate .lead { color: var(--text-2); max-width: 30ch; font-size: 16px; margin: 0; }
.gate .actions { display: grid; gap: 10px; width: min(340px, 100%); margin-top: 6px; }
.gate .actions p { margin: 0 0 4px; }
.gate .notice { font-size: 12.5px; color: var(--text-3); max-width: 36ch; margin: 6px 0 0; }

/* ---------- главная ---------- */

.home-hero { position: relative; margin: calc(-12px - var(--top-inset)) calc(-1 * var(--gutter)) 0;
  padding: calc(18px + var(--top-inset)) calc(var(--gutter) + 4px) 18px; min-height: calc(470px + var(--top-inset));
  display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(90% 60% at 70% 20%, rgba(46, 140, 104, 0.25), transparent 70%), radial-gradient(90% 60% at 20% 70%, rgba(122, 28, 48, 0.5), transparent 70%), #0e0a0b; }
.home-hero .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
.home-hero .shade { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 6, 7, 0.7) 0%, rgba(8, 6, 7, 0.05) 22%, rgba(74, 15, 28, 0.42) 56%, var(--bg) 100%); }
.home-top, .home-cont { position: relative; }
.home-top { display: flex; align-items: center; justify-content: space-between; }
.home-top .wordmark { font-size: 26px; }
.me-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.home-cont { margin-top: auto; padding-top: 40px; }
.home-cont .eyebrow { color: var(--silver); }
.home-cont h1 { font-size: 39px; margin-top: 8px; }
.home-cont .meta { font-size: 13px; color: #d4c8cb; margin-top: 8px; }
.home-cont .lead { font-size: 15px; color: #e0d6d8; margin: 10px 0 0; max-width: 34ch; line-height: 1.5; }
.home-cont .actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }

.home-new { margin-top: 14px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row-head .hint { font-size: 12.5px; color: var(--text-3); }
.hero-row { display: flex; justify-content: space-between; margin: 16px 0 20px; }
.hero-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 76px; padding: 0; border: 0; background: none;
  color: var(--text); cursor: pointer; }
.hero-pick .name { font-family: var(--display); font-size: 17px; font-weight: 700; white-space: nowrap; }
.hero-pick.more .name { color: var(--text-2); }

/* ---------- мои истории ---------- */

.page-head { margin: 8px 2px 18px; }
.page-head h1 { font-size: 36px; }
.page-head .small { margin-top: 6px; }
.story-list { display: grid; gap: 12px; }
.story-card { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; width: 100%; text-align: left; cursor: pointer; padding: 14px; color: var(--text); }
.story-card .title { display: block; font-family: var(--display); font-size: 21px; font-weight: 700; line-height: 1.12; }
.story-card .meta { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.story-card .line { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(215, 219, 224, 0.16); overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald), var(--gold)); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid; }
.badge.s-active, .badge.s-planning, .badge.s-choosing { color: var(--emerald-hi); border-color: rgba(79, 179, 140, 0.45); }
.badge.s-fork { color: var(--gold); border-color: rgba(227, 199, 122, 0.5); }
.badge.s-done { color: var(--silver); border-color: rgba(215, 219, 224, 0.35); }
.badge.s-paused, .badge.s-error { color: #f0a1b0; border-color: rgba(176, 56, 79, 0.65); }

/* ---------- профиль ---------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin: 8px 2px 8px; }
.profile-head h1 { font-size: 34px; }
.read-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.read-swatch { display: grid; gap: 8px; padding: 8px 8px 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 12.5px; font-weight: 600; text-align: center; }
.read-swatch.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.read-swatch .page { height: 66px; border-radius: 11px; display: grid; place-items: center; font-family: var(--display); font-size: 27px; font-weight: 700;
  border: 1px solid rgba(128, 128, 128, 0.28); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 14px 16px; font-size: 15px; }
.size-ctl { display: flex; align-items: center; gap: 10px; }
.size-ctl .sample { font-family: var(--serif); min-width: 2.2ch; text-align: center; color: var(--text); }
.notice-card { margin-top: 20px; }
.notice-card p { margin: 0; }

/* ---------- анкета ---------- */

.progress { height: 3px; border-radius: 3px; background: rgba(215, 219, 224, 0.14); overflow: hidden; margin: 2px 0 20px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald), var(--gold)); transition: width 0.3s ease; }
.step-head { margin-bottom: 18px; }
.step-head .count { font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.step-head h2 { font-size: 30px; line-height: 1.08; }
.step-head .small { margin: 10px 0 0; }
.options { display: grid; gap: 10px; }
.option {
  position: relative; display: block; width: 100%; text-align: left; padding: 15px 46px 15px 16px; cursor: pointer;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option .label { font-size: 16px; font-weight: 700; }
.option .sub { display: block; margin-top: 4px; font-size: 13.5px; color: var(--text-2); line-height: 1.4; }
.option.on { border-color: rgba(227, 199, 122, 0.75); background: linear-gradient(160deg, rgba(122, 28, 48, 0.55), rgba(74, 15, 28, 0.3));
  box-shadow: inset 0 0 0 1px rgba(227, 199, 122, 0.45); }
.option.on::before { content: ""; position: absolute; top: 50%; right: 14px; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; background: var(--gold-fill); }
.option.on::after { content: ""; position: absolute; top: 50%; right: 22px; width: 5px; height: 10px; margin-top: -7px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.option.hero { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.hero-img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; display: block; }
.group-label { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); margin: 22px 2px 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; line-height: 1.3; text-align: left;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
.chip.on { border-color: transparent; background: var(--gold-fill); color: var(--ink); font-weight: 700; }
.chip[disabled] { opacity: 0.4; }
.counter { font-size: 12.5px; color: var(--text-2); margin-top: 10px; }

.field { display: grid; gap: 8px; margin-top: 16px; }
.field label { font-size: 13.5px; color: var(--text-2); }
.input, .textarea {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05); color: var(--text); font-family: var(--sans); font-size: 16px;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--gold); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 22px 0 14px; }
.stepper .value { font-family: var(--display); font-size: 64px; font-weight: 700; color: var(--gold); min-width: 2.2ch; text-align: center; line-height: 1; font-variant-numeric: lining-nums; }
.stepper .icon-btn { width: 54px; height: 54px; font-size: 26px; font-weight: 400; }

.wizard-nav {
  position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 0 calc(8px + var(--bottom-inset));
  margin-top: 22px; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.wizard-nav .btn { flex: 1; white-space: nowrap; }
.wizard-nav .btn.ghost { flex: 0 0 auto; padding: 12px 24px; }
.error-box { border: 1px solid var(--bad); color: var(--bad); border-radius: 14px; padding: 12px 14px; margin-top: 14px;
  font-size: 14px; line-height: 1.45; background: rgba(176, 56, 79, 0.12); }
.error-box ul { margin: 6px 0 0; padding-left: 18px; }

.summary { display: grid; gap: 8px; }
.summary .row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; }
.summary .q { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.summary .a { font-size: 15px; line-height: 1.4; }
.summary .edit { font-size: 13px; font-weight: 700; color: var(--gold); background: none; border: 0; cursor: pointer; padding: 4px; }

/* ---------- чтение ---------- */

.read-progress { height: 3px; border-radius: 3px; background: rgba(215, 219, 224, 0.12); overflow: hidden; margin-bottom: 12px; }
.read-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald), var(--gold)); }
.reader-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.reader-bar .t { flex: 1; min-width: 0; }
.reader-bar .t b { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-bar .t span { font-size: 12px; color: var(--text-2); }
.chapter-head { text-align: center; margin: 26px 0 24px; }
.chapter-head .eyebrow { letter-spacing: 0.3em; }
.chapter-title { font-family: var(--display); font-style: italic; font-weight: 700; font-size: 39px; line-height: 1.04; margin-top: 8px;
  background: var(--title-fill); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0 0.04em; }
.text { font-family: var(--serif); font-size: var(--read-size); line-height: 1.72; hyphens: auto; -webkit-hyphens: auto; color: var(--text); }
.text p { margin: 0 0 0.95em; text-indent: 1.4em; }
.text p.dialog, .text p:first-child { text-indent: 0; }
.text p:first-child:not(.dialog)::first-letter { float: left; font-family: var(--display); font-weight: 700; font-size: 3.7em; line-height: 0.8;
  margin: 0.06em 0.12em 0 0; color: var(--drop-cap); }
.text .scene-break { text-align: center; color: var(--gold); letter-spacing: 0.6em; margin: 1.4em 0; text-indent: 0; }
.caret { display: inline-block; width: 0.5em; height: 1em; margin-left: 2px; vertical-align: -0.12em;
  background: var(--gold); opacity: 0.75; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.writing-note { font-size: 13px; color: var(--text-3); text-align: center; margin: 14px 0; }
.state { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 12vh 8px; }
.state h3 { font-style: italic; font-size: 26px; color: var(--gold); }
.state p { max-width: 32ch; }
.state .spinner { margin-bottom: 6px; }

.after { display: grid; gap: 12px; margin-top: 28px; }
.after > .divider { margin: 0 auto 10px; }
.chapter-actions { display: flex; gap: 10px; }
.chapter-actions .btn { padding: 12px 16px; white-space: nowrap; }
.chapter-actions .btn.primary { flex: 1; }
.wish-panel { display: grid; gap: 10px; }
.wish-panel .small { margin: 0; }
.wish-panel .buttons { display: flex; gap: 10px; justify-content: flex-end; }
.wish-saved { font-size: 13.5px; color: var(--ok); line-height: 1.45; }
.wish-saved button { margin-left: 6px; border: 0; background: none; color: var(--gold); font-weight: 700; cursor: pointer; padding: 0; }
.fork { display: grid; gap: 10px; }
.fork h3 { text-align: center; font-style: italic; font-size: 27px; color: var(--gold); margin-bottom: 6px; }
.the-end { text-align: center; font-family: var(--display); font-style: italic; font-weight: 700; font-size: 38px; color: var(--gold); margin: 4px 0; }
.continue { display: grid; gap: 12px; text-align: center; padding: 22px 18px; color: #f3eee9;
  background: linear-gradient(160deg, rgba(122, 28, 48, 0.92), rgba(58, 12, 22, 0.92)); border-color: rgba(227, 199, 122, 0.45); }
.continue h3 { font-size: 25px; }
.continue p { margin: 0 0 4px; color: #e3d3d7; }
.continue .btn.ghost { color: #e3d3d7; border-color: rgba(243, 238, 233, 0.3); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }

/* ---------- листы снизу ---------- */

.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; animation: fade 0.2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 640px; margin: 0 auto;
  max-height: calc(100% - var(--top-inset) - 24px); overflow-y: auto;
  background: var(--sheet); color: var(--text); border: 1px solid rgba(227, 199, 122, 0.25); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 20px var(--gutter) calc(20px + var(--bottom-inset));
  animation: rise 0.25s ease;
}
.sheet h3 { margin-bottom: 14px; }
.sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.toc { display: grid; gap: 6px; margin-bottom: 14px; }
.toc button { text-align: left; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; font-family: var(--sans); font-size: 14.5px; }
.toc button.current { border-color: var(--gold); color: var(--gold); }
.toc button[disabled] { opacity: 0.45; }
.switch { width: 52px; height: 30px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-3); transition: left 0.2s ease, background 0.2s ease; }
.switch.on { background: var(--emerald); border-color: transparent; }
.switch.on::after { left: 25px; background: var(--gold-hi); }

/* ---------- админка ---------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 14px; }
.stat .num { font-family: var(--display); font-size: 32px; font-weight: 700; line-height: 1; color: var(--gold); font-variant-numeric: lining-nums; }
.stat .lbl { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.admin-list { display: grid; gap: 8px; }
.admin-item { padding: 12px 14px; cursor: pointer; }
.admin-item .top { display: flex; justify-content: space-between; gap: 10px; font-family: var(--display); font-size: 18px; font-weight: 700; }
.admin-item .meta { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }
.admin-item .err { color: var(--bad); }
.cap-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.cap-row .input { max-width: 120px; padding: 9px 12px; font-size: 16px; }
.anketa-lines { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.anketa-lines div { margin-bottom: 4px; }
.flag { color: var(--bad); font-size: 13px; }
.reader .chapter-head h2 { font-size: 27px; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
