/* ---------- темы читателя ---------- */
:root,
[data-theme='night'] {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #192134;
  --text: #e8e3d6;
  --muted: #929aae;
  --accent: #e8a33d;
  --accent-ink: #1a1206;
  --border: #252e43;
  --bubble: #182033;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
[data-theme='paper'] {
  --bg: #f3ecdc;
  --surface: #fbf6ea;
  --surface-2: #efe6d1;
  --text: #2b2519;
  --muted: #6d6350;
  --accent: #a85f14;
  --accent-ink: #fff8ec;
  --border: #dccfb2;
  --bubble: #fffaf0;
  --shadow: 0 8px 24px rgba(80, 60, 20, 0.12);
  color-scheme: light;
}
[data-theme='day'] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #121826;
  --muted: #586173;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --border: #e1e5ec;
  --bubble: #ffffff;
  --shadow: 0 8px 24px rgba(18, 24, 38, 0.08);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
}
img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
[hidden] {
  display: none !important;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
}
.muted {
  color: var(--muted);
}
.noscript {
  padding: 2rem;
  text-align: center;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}
.skip-link:focus {
  top: 1rem;
}

/* ---------- шапка ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.01em;
  flex: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 800;
}
.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.controls::-webkit-scrollbar {
  display: none;
}
.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  flex: none;
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn[aria-checked='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.icon-btn:hover,
.seg-btn:hover {
  color: var(--text);
}
.icon-btn[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--accent);
}
.icon-btn.ghost {
  background: transparent;
}
.sound-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}
.sound-btn {
  padding: 0.4rem 0.55rem;
}
.sound-pop {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.vol {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.vol span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.vol input {
  width: 84px;
  accent-color: var(--accent);
}
.vol input:disabled {
  opacity: 0.4;
}
.mini-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.mini-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: min(78vh, 680px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
}
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
.hero-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.1) 0%, rgba(8, 10, 16, 0.45) 45%, rgba(8, 10, 16, 0.92) 100%);
}
.hero-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1rem 3.5rem;
  color: #f4efe2;
}
.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #f2b75a;
}
.hero h1 {
  margin: 0;
  font-family: 'PT Serif', Georgia, serif;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  max-width: 14ch;
  text-wrap: balance;
}
.tagline {
  max-width: 56ch;
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: #d9d3c4;
  margin: 1rem 0 1.6rem;
  text-wrap: pretty;
}
.cta {
  display: inline-flex;
  background: #e8a33d;
  color: #1a1206;
  font-weight: 700;
  text-decoration: none;
  padding: 0.75rem 1.3rem;
  border-radius: 999px;
}
.cta:hover {
  background: #f2b75a;
}

/* ---------- лор ---------- */
.lore,
.story {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3.5rem 1rem;
}
.lore {
  border-bottom: 1px solid var(--border);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.section-head h2,
.story-head h2 {
  font-family: 'PT Serif', Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
.sub {
  margin: 2.2rem 0 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.hero-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--c);
  border-radius: 14px;
  padding: 1rem;
  transition: box-shadow 0.2s;
}
.hero-card.open {
  box-shadow: var(--shadow);
}
.hero-toggle {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.hero-card .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--c);
  flex: none;
}
.hero-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.hero-name {
  font-weight: 800;
  font-size: 1.05rem;
}
.hero-role {
  font-size: 0.82rem;
  color: var(--muted);
}
.chev {
  color: var(--muted);
  transition: transform 0.2s;
}
.hero-card.open .chev {
  transform: rotate(180deg);
}
.hero-short {
  margin: 0.85rem 0 0;
  font-size: 0.93rem;
}
.hero-full p {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.93rem;
  color: var(--muted);
}
.chapters {
  display: grid;
  gap: 0.6rem;
  max-width: 820px;
}
.chapter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.chapter summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 700;
}
.chapter summary::-webkit-details-marker {
  display: none;
}
.chapter summary .icon {
  color: var(--muted);
  transition: transform 0.2s;
}
.chapter[open] summary .icon {
  transform: rotate(180deg);
}
.chapter-body {
  padding: 0 1.1rem 1rem;
  font-family: 'PT Serif', Georgia, serif;
  font-size: 1.02rem;
}
.chapter-body p {
  margin: 0 0 0.8rem;
}

/* ---------- история ---------- */
.story-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin-bottom: 2rem;
  padding-bottom: 0.25rem;
}
.story-tabs a {
  flex: none;
  text-decoration: none;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 600;
}
.story-tabs a[aria-current='page'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.story-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
.toc {
  display: none;
}
@media (min-width: 960px) {
  .story-layout {
    grid-template-columns: 220px minmax(0, 720px);
    justify-content: center;
    gap: 3rem;
  }
  .toc {
    display: block;
  }
  .toc nav {
    position: sticky;
    top: 5.5rem;
  }
}
.toc-title {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.toc li a,
.toc li span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0 0.35rem 0.9rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
}
.toc li a:hover {
  color: var(--text);
}
.toc li a[aria-current='true'] {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 700;
}
.toc li.locked span {
  opacity: 0.55;
}
.toc .icon {
  width: 14px;
  height: 14px;
}
.story-head {
  margin-bottom: 2.5rem;
}
.story-head time {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.summary {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0.8rem 0 0;
  text-wrap: pretty;
}

.para {
  padding: 1.5rem 0 1rem;
  border-top: 1px solid var(--border);
}
.para-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.para-num {
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}
.para-num:hover {
  text-decoration: underline;
}
.para-head h3 {
  margin: 0;
  font-family: 'PT Serif', Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.2;
  flex: 1;
  min-width: 12ch;
}
.mode-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}
.para-image,
.media-image {
  margin: 0 0 1.4rem;
}
.para-image img,
.media-image img {
  width: 100%;
  border-radius: 12px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
}
figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.5rem;
}
.media-audio {
  margin: 0 0 1.4rem;
}
.media-audio audio {
  width: 100%;
}

/* классика */
.prose,
.classic-line {
  font-family: 'PT Serif', Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.75;
  margin: 0 0 1.05rem;
  text-wrap: pretty;
}
.mode-classic .prose + .prose {
  text-indent: 1.5em;
}
.classic-line .speaker {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.92em;
  color: var(--c, var(--accent));
}

/* чат */
.mode-chat .blocks {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.narration {
  margin: 0.4rem 0;
  font-family: 'PT Serif', Georgia, serif;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  font-size: 1rem;
  padding: 0 1rem;
}
.msg {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
  max-width: 88%;
}
.msg.me {
  flex-direction: row-reverse;
  margin-left: auto;
}
.msg .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 2px solid var(--c, var(--border));
}
.msg .avatar.npc {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 800;
  color: var(--muted);
}
.bubble {
  background: var(--bubble);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow);
}
.msg.me .bubble {
  border-radius: 16px 16px 4px 16px;
  background: color-mix(in srgb, var(--accent) 16%, var(--bubble));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.msg-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--c, var(--accent));
  margin-bottom: 0.15rem;
}
.bubble p {
  margin: 0;
  font-size: 0.98rem;
}
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.lock-note {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
}

/* ---------- футер и тост ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-size: 0.85rem;
}
.site-footer p {
  margin: 0.2rem 0;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- мобильная шапка ---------- */
@media (max-width: 720px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .controls {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  .btn-label {
    display: none;
  }
  .icon-btn {
    padding: 0.4rem 0.55rem;
  }
  .vol input {
    width: 64px;
  }
  .msg {
    max-width: 96%;
  }
}
