/* «Орфография» — сайт-читалка. Темы: бумага / сепия / ночь. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root { color-scheme: light; }
html[data-theme="paper"] {
  --bg:#f6f1e6; --ink:#2b2620; --muted:#7d715e; --accent:#8a2b20; --accent-ink:#f6f1e6;
  --line:#ddd2bc; --card:#fffdf6; --bar:#efe7d5; --shadow:0 1px 3px rgba(90,70,40,.12);
}
html[data-theme="sepia"] {
  --bg:#e7d7b4; --ink:#42351f; --muted:#7a684a; --accent:#7c3f16; --accent-ink:#f3e7c9;
  --line:#cdbb93; --card:#efe2c1; --bar:#ddcca4; --shadow:0 1px 3px rgba(80,55,20,.18);
}
html[data-theme="night"] {
  --bg:#141519; --ink:#c8cdd4; --muted:#8a919c; --accent:#d09a4e; --accent-ink:#16181d;
  --line:#2a2f38; --card:#1b1e24; --bar:#191c22; --shadow:0 1px 3px rgba(0,0,0,.5);
  color-scheme: dark;
}
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Georgia, "PT Serif", "Times New Roman", serif;
  line-height: 1.72; font-size: clamp(1rem, .92rem + .35vw, 1.145rem);
  transition: background .25s ease, color .25s ease;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 700; }

/* ---- прогресс чтения ---- */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 60; transition: width .1s linear; }

/* ---- верхняя панель ---- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--bar); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 74rem; margin: 0 auto; padding: .55rem clamp(.9rem, 3vw, 1.6rem);
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; justify-content: space-between; }
.brand { color: var(--ink); font-weight: 700; font-size: 1.06rem; letter-spacing: .02em; display: flex; flex-direction: column; line-height: 1.25; }
.brand em { font-style: normal; font-weight: 400; font-size: .72rem; color: var(--muted); letter-spacing: .04em; }
.topnav { display: flex; align-items: center; gap: clamp(.5rem, 1.6vw, 1.1rem); flex-wrap: wrap; font-size: .84rem; }
.topnav > a { color: var(--muted); }
.topnav > a:hover { color: var(--accent); text-decoration: none; }
.themes { display: flex; gap: .25rem; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .18rem; }
.themes button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .76rem; padding: .22rem .62rem; border-radius: 999px; cursor: pointer; }
.themes button:hover { color: var(--ink); }
html[data-theme="paper"] .themes button[data-set-theme="paper"],
html[data-theme="sepia"] .themes button[data-set-theme="sepia"],
html[data-theme="night"] .themes button[data-set-theme="night"] { background: var(--accent); color: var(--accent-ink); }
.star { border: 0; background: transparent; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .1rem .2rem; }
.star:hover { color: var(--accent); }
.star.on { color: var(--accent); }
.star.on::before { content: "★"; }

/* ---- герой титульной страницы ---- */
.hero { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--bar), var(--bg)); }
.hero-in { max-width: 74rem; margin: 0 auto; padding: clamp(2rem, 6vw, 4.2rem) clamp(.9rem, 3vw, 1.6rem);
  display: flex; gap: clamp(1.4rem, 4vw, 3.4rem); align-items: center; }
.hero-text { flex: 1 1 22rem; min-width: 0; }
.hero-kicker { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: var(--muted); margin-bottom: .8rem; }
.hero h1 { font-size: clamp(2.6rem, 9vw, 4.6rem); line-height: 1.04; letter-spacing: .01em; margin-bottom: .6rem; }
.hero-sub { color: var(--muted); font-size: .98rem; margin-bottom: 1.3rem; }
.hero-quote { border-left: 3px solid var(--accent); padding: .35rem 0 .35rem 1rem; font-style: italic;
  font-size: 1.05rem; margin-bottom: 1.1rem; }
.hero-quote cite { display: block; font-style: normal; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.hero-desc { max-width: 38rem; margin-bottom: 1.1rem; }
.hero-stats { color: var(--muted); font-size: .88rem; margin-bottom: 1.4rem; }
.hero-stats b { color: var(--accent); font-size: 1.1rem; }
.hero-cta { display: flex; gap: .7rem; flex-wrap: wrap; }
.hero-cover { flex: 0 1 15rem; max-width: 15rem; }
.hero-cover img { max-width: 100%; height: auto; border-radius: .35rem; box-shadow: 0 10px 30px rgba(50,35,10,.28); display: block; }

/* ---- кнопки ---- */
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  padding: .55rem 1.15rem; border-radius: .3rem; font-size: .92rem; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }

/* ---- общий контейнер ---- */
.wrap { max-width: 74rem; margin: 0 auto; padding: 0 clamp(.9rem, 3vw, 1.6rem) 2.4rem; }
.wrap section { margin-top: 2.6rem; }
.wrap h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); margin-bottom: 1rem; }
.toc-title { padding-top: 1.2rem; }

/* ---- закладки ---- */
.bm-list { list-style: none; display: grid; gap: .5rem; }
.bm-list li { display: flex; align-items: center; gap: .6rem; background: var(--card); border: 1px solid var(--line);
  border-radius: .3rem; padding: .5rem .8rem; }
.bm-list a { flex: 1; min-width: 0; }
.bm-list .del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; }
.bm-list .del:hover { color: var(--accent); }

/* ---- оглавление ---- */
.toc-front { display: grid; gap: .55rem; margin-bottom: 1.6rem; }
.toc-item { display: flex; flex-direction: column; gap: .15rem; background: var(--card); border: 1px solid var(--line);
  border-radius: .35rem; padding: .7rem 1rem; box-shadow: var(--shadow); }
.toc-item b { color: var(--ink); }
.toc-item span { color: var(--muted); font-size: .86rem; }
.toc-item:hover { text-decoration: none; border-color: var(--accent); }
.act-card { background: var(--card); border: 1px solid var(--line); border-radius: .5rem; padding: clamp(1rem, 3vw, 1.6rem);
  margin-bottom: 1.6rem; box-shadow: var(--shadow); }
.act-head { display: flex; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .5rem; }
.act-kicker { text-transform: uppercase; letter-spacing: .16em; font-size: .7rem; color: var(--muted); }
.act-head h3 { font-size: clamp(1.25rem, 3.4vw, 1.7rem); }
.act-place { color: var(--muted); font-size: .84rem; }
.act-quote { font-style: italic; font-size: .92rem; color: var(--muted); max-width: 20rem; text-align: right; }
.act-quote cite { display: block; font-style: normal; font-size: .74rem; margin-top: .3rem; }
.act-desc { color: var(--ink); font-size: .94rem; max-width: 44rem; margin-bottom: 1.1rem; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .45rem; }
.ch-link { display: flex; gap: .6rem; align-items: baseline; border: 1px solid var(--line); border-radius: .3rem;
  padding: .45rem .65rem; font-size: .82rem; color: var(--muted); background: var(--bg); min-width: 0; }
.ch-link .n { color: var(--accent); font-weight: 700; flex: 0 0 auto; }
.ch-link .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-link:hover { text-decoration: none; border-color: var(--accent); color: var(--ink); }
.about-block p { max-width: 44rem; margin-bottom: .8rem; color: var(--ink); }

/* ---- страницы чтения ---- */
.reader { max-width: 41rem; margin: 0 auto; padding: 1.6rem clamp(.9rem, 3vw, 1.4rem) 2rem; }
.reader.wide { max-width: 56rem; }
.ch-head { margin: 1.2rem 0 1.8rem; }
.crumbs { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-bottom: .9rem; }
.crumbs .crumb-place { margin-left: .8rem; }
.ch-num { font-size: clamp(1.9rem, 6vw, 2.7rem); line-height: 1.15; font-weight: 700; }
.ch-num span { display: block; font-size: .58em; font-weight: 400; color: var(--muted); }
.ch-num .ch-no { display: inline; font-size: inherit; color: var(--accent); font-weight: 700; }
.act-title span { display: block; }
.act-note { color: var(--muted); font-size: .88rem; margin-top: .5rem; }
.text p { margin-bottom: 1.05rem; text-align: justify; hyphens: auto; overflow-wrap: break-word; }
.text p:first-of-type::first-letter { font-size: 2.1em; float: left; line-height: 1; padding: .1em .12em 0 0; color: var(--accent); font-weight: 700; }
.text .fin { margin-top: 1.6rem; text-align: center; font-style: italic; color: var(--muted); }
.finale { margin-top: 1.8rem; text-align: center; font-style: italic; color: var(--muted); }
.finale p { text-align: center; }
.sign { margin-top: 1.6rem; color: var(--muted); font-style: italic; text-align: right; }
.text .sign { text-align: right; }
.sign::before { content: none; }

/* эпиграфы */
.epigraphs { margin: 0 0 1.8rem; display: grid; gap: 1.1rem; }
.epigraphs p { font-style: italic; }
.epi p { margin-bottom: .15rem; }
.epi.epi-text p { max-width: 34rem; }
.epi.epi-verse p { text-align: center; white-space: pre-line; }
.epi-cap { text-align: center; font-size: .82rem; color: var(--muted); font-style: normal !important; }
.epi-attr { text-align: right; font-size: .85rem; color: var(--muted); margin-top: .3rem !important; }
.epi-attr::before { content: "— "; }

/* листинг персонажей */
.cast { display: grid; gap: 1.6rem; }
.cast-group h2 { font-size: 1.2rem; border-bottom: 1px solid var(--line); padding-bottom: .4rem; margin-bottom: .8rem; }
.cast-list { list-style: none; display: grid; gap: .55rem; }
.cast-list li { font-size: .94rem; }
.cast-list b { color: var(--accent); }

/* ---- пагинация ---- */
.pager { display: flex; align-items: stretch; gap: .6rem; margin-top: 2.2rem; flex-wrap: wrap; }
.pager a { display: flex; flex-direction: column; justify-content: center; gap: .15rem; min-width: 0; }
.pager a span { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.pager .prev, .pager .next { flex: 1 1 12rem; border: 1px solid var(--line); border-radius: .35rem; padding: .6rem .9rem;
  color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
.pager .prev:hover, .pager .next:hover { text-decoration: none; border-color: var(--accent); }
.pager .prev { text-align: left; }
.pager .next { text-align: right; }
.pager .btn { align-self: center; white-space: nowrap; }
.pager a.ghost-only { border-style: dashed; background: transparent; }

/* ---- подвал ---- */
.sitefoot { border-top: 1px solid var(--line); background: var(--bar); margin-top: 2rem; }
.foot-in { max-width: 74rem; margin: 0 auto; padding: 1.6rem clamp(.9rem, 3vw, 1.6rem); font-size: .82rem; color: var(--muted); }
.foot-title { font-weight: 700; color: var(--ink); margin-bottom: .4rem; font-size: .92rem; }
.foot-in p { margin-bottom: .3rem; max-width: 46rem; }
.foot-nav { margin-top: .6rem; }
.foot-note { font-size: .74rem; }

/* ---- адаптив ---- */
@media (max-width: 760px) {
  .hero-in { flex-direction: column-reverse; text-align: center; align-items: center; }
  .hero-cover { max-width: 11rem; }
  .hero-quote { border-left: 0; padding: 0; text-align: center; }
  .hero-quote cite { margin-top: .35rem; }
  .hero-desc, .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-cta { justify-content: center; }
  .act-head { flex-direction: column; }
  .act-quote { text-align: left; max-width: none; }
  .text p { text-align: left; hyphens: none; }
  .text p:first-of-type::first-letter { font-size: 1.9em; }
  .pager .btn { order: 3; flex-basis: 100%; text-align: center; }
}
@media (max-width: 420px) {
  .ch-grid { grid-template-columns: 1fr; }
  .topbar-in { padding: .5rem .7rem; }
  .themes button { padding: .22rem .45rem; }
}
