:root {
  --bg: #f0f0f0; --surface: #ffffff; --text: #484848; --heading: #3a3a3a; --muted: #767676; --line: #dfdfdf;
  --accent: #f7931e; --accent-dark: #e07d0a; --accent-soft: #fdebd3; --hover: #b8620a; --on-accent: #3a3a3a;
  --cream: #f6f6f6; --warn: #c2410c; --reader-bg: #484848; --link: #b8620a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e; --surface: #2a2a2a; --text: #e2e2e2; --heading: #f2f2f2; --muted: #a8a8a8; --line: #3d3d3d;
    --accent: #f7931e; --accent-dark: #ffa94d; --accent-soft: #4a3018; --hover: #ffc078; --on-accent: #2a2a2a;
    --cream: #333333; --warn: #fb923c; --reader-bg: #262626; --link: #ffa94d;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--hover); text-decoration: underline; }
header { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 18px; color: var(--heading); white-space: nowrap; }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; color: var(--heading); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; font-size: 14px; }
.nav a { color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--heading); background: var(--accent-soft); text-decoration: none; }
main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; flex: 1; }
footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; }
footer .bar { justify-content: space-between; }
footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
h1 { color: var(--heading); font-size: 22px; line-height: 1.25; margin: 4px 0 8px; }
h2 { color: var(--heading); font-size: 17px; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; max-width: 760px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 20px; }
.grade { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--heading); display: flex; flex-direction: column; }
.grade b { font-size: 20px; }
.grade small { color: var(--muted); }
.grade:hover { border-color: var(--accent); text-decoration: none; color: var(--heading); }
.chip { display: inline-block; border: 1px solid var(--line); background: var(--cream); color: var(--heading); border-radius: 99px; padding: 5px 13px; cursor: pointer; font: inherit; font-size: 14px; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--heading); text-decoration: none; }
.chip[aria-pressed="true"], .chip[aria-current="page"] { background: linear-gradient(var(--accent), var(--accent-dark)); border-color: var(--accent-dark); color: var(--on-accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.filters input { flex: 1 1 240px; min-width: 0; }
.count { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); display: flex; gap: 12px; align-items: flex-start; }
.card:hover { border-color: var(--accent); color: var(--text); text-decoration: none; box-shadow: 0 2px 8px rgba(60,60,60,.14); }
.card .cv { flex: none; width: 64px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; background: var(--cream); border: 1px solid var(--line); display: block; }
.cv.ph, .bcv.ph { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; font-size: 22px; }
.card .cb { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card .t { font-weight: 600; color: var(--heading); }
.card:hover .t { color: var(--hover); }
.card .a { color: var(--muted); font-size: 13px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; background: var(--accent-soft); color: var(--heading); border-radius: 4px; padding: 1px 6px; }
.mine { margin-bottom: 18px; }
.subj[hidden], .card[hidden] { display: none; }
.book { display: grid; grid-template-columns: 1fr; gap: 12px; }
.book-head { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.book-head::after { content: ""; display: block; clear: both; }
.bcv { float: right; width: 150px; aspect-ratio: 3 / 4; object-fit: cover; margin: 0 0 8px 14px; border-radius: 6px; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(60,60,60,.18); background: var(--cream); }
.bcv.ph { font-size: 44px; }
@media (max-width: 520px) { .bcv { width: 96px; } .bcv.ph { font-size: 30px; } }
.book-head dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 14px; }
.book-head dt { color: var(--muted); }
.book-head dd { margin: 0; }
.extras { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; font-size: 14px; }
.parts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.reader { background: var(--reader-bg); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-height: 60vh; }
.reader.fs { position: fixed; inset: 0; z-index: 20; border-radius: 0; }
.reader iframe { flex: 1; border: 0; width: 100%; min-height: 78vh; background: #fff; }
.reader.fs iframe { min-height: 0; }
.rbar { display: flex; gap: 10px; align-items: center; padding: 8px; background: rgba(60,60,60,.55); color: #eeeeee; flex-wrap: wrap; }
.rbar a { color: #ffc078; }
.rbar a:hover { color: #fdd975; }
.rbar .dl { background: var(--accent); color: #2a2a2a; font-weight: 600; border-radius: 6px; padding: 6px 12px; }
.rbar .dl:hover { background: #ffa94d; color: #2a2a2a; text-decoration: none; }
.rbar button { font: inherit; background: rgba(255,255,255,.14); color: #ffffff; border: 0; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.rbar .sp { flex: 1; }
.status { color: #dddddd; padding: 40px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.note { font-size: 13px; color: var(--muted); }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 20px 16px; max-width: 820px; }
.prose p, .prose li { max-width: 72ch; }
.results:empty { display: none; }
.results { margin-bottom: 18px; }
.side { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 14px; }
.side h2 { font-size: 15px; margin: 0 0 6px; }
.placeholder { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; color: var(--muted); font-size: 13px; }
.ad { position: relative; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12px; text-align: center;
  background: repeating-linear-gradient(45deg, transparent 0 10px, var(--cream) 10px 20px); }
.ad::before { content: "Реклама"; position: absolute; top: 4px; left: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.side .ad-rect { width: 300px; max-width: 100%; height: 250px; margin: 14px auto 0; }
@media (min-width: 960px) {
  .book { grid-template-columns: 1fr 300px; }
  .book-head { grid-column: 1 / -1; }
  .book > .reader { grid-column: 1; grid-row: 2; }
  .book > .side { grid-column: 2; grid-row: 2; align-self: start; }
}
@media (max-width: 959px) { .side:empty { display: none; } }
@media (min-width: 960px) { .side:empty { min-height: 300px; } }
