:root {
  --paper: oklch(96.5% 0.012 85);
  --paper-2: oklch(93% 0.018 85);
  --card: oklch(98.5% 0.008 85);
  --ink: oklch(23% 0.02 60);
  --ink-2: oklch(40% 0.02 60);
  --muted: oklch(53% 0.02 60);
  --line: oklch(85% 0.02 80);
  --accent: oklch(50% 0.14 32);
  --accent-ink: oklch(98% 0.01 85);
  --shadow: 0 1px 0 oklch(80% 0.02 80), 0 8px 24px -14px oklch(30% 0.03 60 / .35);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Commissioner", -apple-system, "Segoe UI", sans-serif;
  --step--1: clamp(.8rem, .78rem + .1vw, .86rem);
  --step-0: clamp(.95rem, .92rem + .15vw, 1.03rem);
  --step-1: clamp(1.1rem, 1.04rem + .3vw, 1.28rem);
  --step-2: clamp(1.3rem, 1.18rem + .6vw, 1.7rem);
  --step-3: clamp(1.65rem, 1.4rem + 1.2vw, 2.45rem);
  --step-4: clamp(2.05rem, 1.6rem + 2.3vw, 3.6rem);
  --gut: clamp(16px, 3.4vw, 44px);
  --maxw: 1240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: oklch(19% 0.012 60); --paper-2: oklch(23.5% 0.014 60); --card: oklch(21.5% 0.013 60);
    --ink: oklch(91% 0.015 80); --ink-2: oklch(79% 0.015 80); --muted: oklch(66% 0.015 75);
    --line: oklch(34% 0.015 60); --accent: oklch(70% 0.13 40); --accent-ink: oklch(18% 0.02 50);
    --shadow: 0 1px 0 oklch(30% 0.015 60), 0 8px 24px -14px oklch(0% 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: oklch(19% 0.012 60); --paper-2: oklch(23.5% 0.014 60); --card: oklch(21.5% 0.013 60);
  --ink: oklch(91% 0.015 80); --ink-2: oklch(79% 0.015 80); --muted: oklch(66% 0.015 75);
  --line: oklch(34% 0.015 60); --accent: oklch(70% 0.13 40); --accent-ink: oklch(18% 0.02 50);
  --shadow: 0 1px 0 oklch(30% 0.015 60), 0 8px 24px -14px oklch(0% 0 0 / .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--step-0)/1.55 var(--sans); overflow-x: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: var(--step-4); font-weight: 600; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 .8em; }
a { color: inherit; text-decoration-color: color-mix(in oklch, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.eyebrow { font: italic 400 var(--step-0)/1.3 var(--serif); color: var(--muted); margin-bottom: .5em; }
.eyebrow a { text-decoration: none; }
.lead { font-size: var(--step-1); color: var(--ink-2); max-width: 60ch; }
.pill { display: inline-block; margin-left: 8px; padding: 0 6px; border: 1px solid var(--line); border-radius: 3px; font-size: .75em; color: var(--muted); vertical-align: 1px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 18px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-weight: 550; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 50px; padding: 10px 24px; font-size: var(--step-1); }
.btn.ghost, .ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); min-height: 42px; padding: 8px 14px; }
.ghost:hover { border-color: var(--ink); }
.ghost[aria-pressed="true"], .btn.ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.ghost-link { margin-left: 14px; font-size: var(--step--1); }

.demo-bar { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between; padding: 7px var(--gut); background: var(--ink); color: var(--paper); font-size: var(--step--1); }
.demo-bar p { margin: 0; }
.demo-bar nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.demo-bar a { text-decoration: none; opacity: .8; }
.demo-bar a[aria-current] { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px 26px; align-items: center; padding: 10px var(--gut); background: color-mix(in oklch, var(--paper) 94%, transparent); border-bottom: 1px solid var(--line); }
.logo { font: 650 1.45rem/1 var(--serif); text-decoration: none; letter-spacing: -.02em; }
.logo::first-letter { color: var(--accent); }
.search { position: relative; display: flex; max-width: 560px; }
.search input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-right: 0; background: var(--card); }
.search input:focus { outline: none; border-color: var(--ink); }
.search button { height: 40px; padding: 0 14px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
.sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: min(70vh, 520px); overflow: auto; background: var(--card); border: 1px solid var(--ink); z-index: 40; padding: 6px 0; }
.sugg a { display: flex; align-items: center; gap: 10px; padding: 7px 12px; text-decoration: none; }
.sugg a:hover, .sugg a.act { background: var(--paper-2); }
.sugg small { color: var(--muted); }
.sg-k { min-width: 46px; font: italic .8rem/1.2 var(--serif); color: var(--muted); }
.sg-book span:last-child { display: grid; line-height: 1.3; }
.sg-fix { padding: 6px 12px; margin: 0; color: var(--muted); font-size: var(--step--1); }
.sg-all { border-top: 1px solid var(--line); margin-top: 4px; font-weight: 550; }
.main-nav { display: flex; gap: 18px; }
.main-nav a { text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.main-nav a[aria-current] { border-color: var(--accent); }
.theme-t { border: 1px solid var(--line); background: none; padding: 6px 10px; font-size: var(--step--1); }

main { display: block; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut) 72px; outline: none; }
.boot { padding: 18vh 0; text-align: center; color: var(--muted); font-family: var(--serif); font-size: var(--step-2); }
.foot { max-width: var(--maxw); margin: 0 auto; padding: 22px var(--gut) 96px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--step--1); }
.tabbar { display: none; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; max-width: min(92vw, 520px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; background: var(--ink); color: var(--paper); transition: .2s; font-size: var(--step--1); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* обложки */
.cover { --w: 120px; position: relative; display: flex; flex-direction: column; justify-content: space-between; width: var(--w); aspect-ratio: 2 / 3; padding: 10% 9%; overflow: hidden; flex: none;
  background: var(--c); color: oklch(97% 0.01 85); font-family: var(--serif); border-radius: 1px 3px 3px 1px;
  box-shadow: inset 4px 0 0 oklch(0% 0 0 / .18), inset 5px 0 0 oklch(100% 0 0 / .08), 0 1px 2px oklch(0% 0 0 / .2); }
.cover .c-title { font-size: calc(var(--w) * .118); font-weight: 600; line-height: 1.12; hyphens: auto; overflow-wrap: anywhere; }
.cover .c-author { font: 500 calc(var(--w) * .072)/1.2 var(--sans); letter-spacing: .04em; text-transform: uppercase; opacity: .82; }
.cover.s { --w: 30px; padding: 0; align-items: center; justify-content: center; }
.cover.m { --w: 112px; }
.cover.l { --w: 220px; }
.c-ini { font-size: 15px; font-weight: 600; }
.cover.v0 { justify-content: flex-end; gap: 8%; }
.cover.v0::before { content: ""; position: absolute; left: 9%; right: 9%; top: 12%; height: 1px; background: currentColor; opacity: .5; }
.cover.v1 { background: linear-gradient(180deg, var(--c) 62%, color-mix(in oklch, var(--c) 70%, black) 62%); }
.cover.v1 .c-author { order: -1; }
.cover.v2 { text-align: center; align-items: center; justify-content: center; gap: 10%; }
.cover.v2::after { content: ""; position: absolute; inset: 6%; border: 1px solid currentColor; opacity: .45; }
.cover.v3 { background: radial-gradient(circle at calc(30% + var(--k) * 40%) 72%, color-mix(in oklch, var(--c) 55%, white) 0 18%, transparent 18.5%), var(--c); }
.cover.v4 { background: repeating-linear-gradient(135deg, transparent 0 9px, oklch(100% 0 0 / .06) 9px 10px), var(--c); }
.cover.v4 .c-title { font-style: italic; font-weight: 500; }
.cover.v5 { background: linear-gradient(90deg, color-mix(in oklch, var(--c) 75%, black) 0 18%, var(--c) 18%); padding-left: 24%; }
.cover.v6 { justify-content: center; }
.cover.v6 .c-title { text-transform: uppercase; letter-spacing: .03em; font-size: calc(var(--w) * .1); }
.cover.v6 .c-author { position: absolute; bottom: 8%; left: 9%; }

/* герой: полка недели */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px 56px; padding: 44px 0 36px; align-items: end; }
.hero h1 { max-width: 11ch; }
.shelf-wrap { display: grid; gap: 18px; }
.shelf { display: flex; align-items: flex-end; gap: 3px; height: 300px; padding: 0 6px; border-bottom: 10px solid color-mix(in oklch, var(--ink) 72%, var(--paper)); overflow-x: auto; scrollbar-width: none; }
.spine { flex: none; position: relative; width: var(--w); height: var(--h); padding: 12px 0; border: 0; background: var(--c); color: oklch(96% 0.01 85); border-radius: 2px 2px 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; transition: transform .2s, filter .2s;
  box-shadow: inset 3px 0 0 oklch(100% 0 0 / .12), inset -3px 0 0 oklch(0% 0 0 / .18); }
.spine span { writing-mode: vertical-rl; transform: rotate(180deg); font: 560 13px/1.1 var(--serif); max-height: calc(100% - 34px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spine i { font: 600 10px/1 var(--sans); font-style: normal; opacity: .7; letter-spacing: .05em; }
.spine.v1::before, .spine.v3::before { content: ""; position: absolute; left: 0; right: 0; top: 14px; height: 4px; border-top: 1px solid oklch(100% 0 0 / .45); border-bottom: 1px solid oklch(100% 0 0 / .45); }
.spine.v2 { filter: saturate(.75) brightness(1.08); }
.spine[aria-pressed="true"] { transform: translateY(-14px); }
.spine:hover { filter: brightness(1.12); }
.shelf-info { min-height: 170px; padding-left: 16px; border-left: 3px solid var(--accent); }
.shelf-info h2 { margin-bottom: .2em; }
.shelf-info .by { margin-bottom: .6em; color: var(--ink-2); }
.si-genre { font-size: var(--step--1); color: var(--muted); margin: 0 0 .4em; }
.si-act { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

/* ленты */
.rail { padding: 30px 0 10px; border-top: 1px solid var(--line); }
.rail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rail-head a { font-size: var(--step--1); }
.rail-row { display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 20px; overflow-x: auto; padding: 6px 2px 14px; scroll-snap-type: x proximity; }
.mini { display: grid; gap: 3px; text-decoration: none; scroll-snap-align: start; font-size: var(--step--1); }
.mini .cover { --w: 132px; margin-bottom: 6px; transition: transform .15s; }
.mini:hover .cover { transform: translateY(-3px); }
.mini b { font: 560 .95rem/1.2 var(--serif); }
.mini span { color: var(--ink-2); }
.mini small { color: var(--muted); }
.talk { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 0 48px; }
.talk .rail-head { grid-column: 1 / -1; }
.talk ol { margin: 0; padding: 0; list-style: none; counter-reset: t; }
.talk li { counter-increment: t; border-bottom: 1px dotted var(--line); }
.talk li a { display: grid; grid-template-columns: 34px 1fr; padding: 10px 0; text-decoration: none; }
.talk li a::before { content: counter(t); grid-row: span 2; font: 600 var(--step-2)/1 var(--serif); color: var(--accent); }
.talk li b { font-family: var(--serif); font-weight: 560; }
.talk li span { color: var(--muted); font-size: var(--step--1); }
.for-authors { align-self: start; padding: 22px; background: var(--paper-2); border-top: 3px solid var(--ink); }

/* каталог */
.catalog { padding-top: 34px; }
.cat-h { font-size: var(--step-3); }
.cat-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding-right: 8px; scrollbar-width: thin; font-size: var(--step--1); }
.filters section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.filters h3 { font: 650 .9rem/1 var(--sans); color: var(--muted); margin-bottom: 10px; }
.f-head { display: none; }
.genres { list-style: none; margin: 0; padding: 0; }
.genres a { display: flex; align-items: center; gap: 8px; padding: 4px 6px; margin: 0 -6px; text-decoration: none; }
.genres a span { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.genres a i { width: 8px; height: 12px; background: var(--c); border-radius: 1px; }
.genres a[aria-current] { background: var(--ink); color: var(--paper); }
.genres a[aria-current] span { color: inherit; opacity: .7; }
.seg { display: flex; border: 1px solid var(--line); }
.seg a { flex: 1; text-align: center; padding: 6px 4px; text-decoration: none; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current] { background: var(--ink); color: var(--paper); }
.hint { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 3px 8px; border: 1px solid var(--line); background: none; font-size: .8rem; }
.tag span { color: var(--muted); font-size: .72rem; }
.tag.inc { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag.exc { border-color: var(--accent); color: var(--accent); text-decoration: line-through; text-decoration-thickness: 1px; }
.tag.zero { opacity: .45; }
.reset { display: inline-block; margin-top: 12px; color: var(--accent); }
.res-head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.res-line { margin: 0; font-size: var(--step--1); color: var(--ink-2); }
.res-line b { color: var(--ink); font-size: var(--step-0); }
.sort { font-size: var(--step--1); color: var(--muted); }
.sort select { margin-left: 6px; padding: 5px 8px; border: 1px solid var(--line); background: var(--card); }
.f-open { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.chips a { padding: 3px 8px; background: var(--paper-2); text-decoration: none; font-size: var(--step--1); }
.chips a span { color: var(--muted); margin-left: 2px; }
.list { display: grid; }
.card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.card h3 { margin: 0 0 2px; font-size: var(--step-1); }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card .by { margin: 0 0 4px; color: var(--ink-2); }
.card .by a { text-decoration: none; }
.card .meta, .card .stat { margin: 0 0 6px; font-size: var(--step--1); color: var(--muted); }
.card .about { margin: 0 0 6px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 70ch; }
.card .stat span + span::before { content: "·"; margin: 0 8px; }
.tagline { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: var(--step--1); }
.tagline a { color: var(--accent); text-decoration: none; }
.tagline a::before { content: "#"; opacity: .6; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; font-size: var(--step--1); color: var(--muted); }
.pager a { padding: 8px 14px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.empty { padding: 40px 0; }
.empty p:first-child { font: 560 var(--step-2)/1.2 var(--serif); }

/* книга */
.book { padding-top: 34px; }
.book-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 40px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.book-main h1 { font-size: var(--step-4); margin-bottom: .15em; }
.book-main > .by { font-size: var(--step-1); color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; margin: 20px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; }
.book-act { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.shelves { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); }
.shelves button { border: 0; background: none; padding: 7px 14px; font-size: var(--step--1); }
.shelves button + button { border-left: 1px solid var(--line); }
.shelves button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.sub-note { margin-top: 14px; font-size: var(--step--1); color: var(--ink-2); }
.book-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; padding-top: 30px; }
.annot p { max-width: 68ch; font-family: var(--serif); font-size: 1.06rem; line-height: 1.65; }
.annot .next { color: var(--muted); font-style: italic; }
.toc { margin-top: 36px; }
.toc ol { list-style: none; margin: 0 0 14px; padding: 0; columns: 2; column-gap: 32px; }
.toc li { break-inside: avoid; }
.toc a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dotted var(--line); text-decoration: none; font-size: var(--step--1); }
.toc small { color: var(--muted); white-space: nowrap; }
.lock { font-style: normal; color: var(--accent); margin-right: 8px; }
.comments { margin-top: 40px; }
.c-n { font: 500 var(--step-0) var(--sans); color: var(--muted); }
.book-side { display: grid; gap: 22px; align-content: start; }
.author-box, .widget-cta { padding: 20px; background: var(--paper-2); }
.author-box h3 a { text-decoration: none; }
.author-box .btn { width: 100%; margin: 6px 0 10px; }
.author-box .muted { font-size: var(--step--1); margin: 0; }
.widget-cta { background: none; border: 1px solid var(--line); }

/* комментарии */
.cm-form { display: grid; gap: 6px; margin-bottom: 18px; }
.cm-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--card); resize: vertical; }
.cm-form p { display: flex; justify-content: space-between; align-items: center; margin: 0; font-size: var(--step--1); color: var(--muted); }
.cm-form .btn { min-height: 36px; padding: 6px 14px; }
.thread, .thread ol { list-style: none; margin: 0; padding: 0; }
.thread ol { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--line); }
.cm { padding: 12px 0 4px; }
.cm.by-author > .cm-head b { color: var(--accent); }
.cm-head { display: flex; gap: 8px; align-items: baseline; margin: 0 0 3px; font-size: var(--step--1); }
.cm-head .pill { margin-left: 0; border-color: var(--accent); color: var(--accent); }
.cm-head time { color: var(--muted); margin-left: auto; }
.cm-t { margin: 0 0 4px; white-space: pre-line; }
.cm-act { display: flex; gap: 14px; margin: 0; }
.cm-act button, .spoiler { border: 0; background: none; padding: 2px 0; color: var(--muted); font-size: var(--step--1); }
.cm-act button[aria-pressed="true"] { color: var(--accent); }
.spoiler { display: block; padding: 6px 10px; margin-bottom: 4px; background: var(--paper-2); color: var(--ink-2); }
.cm .cm-form { margin: 8px 0 4px; }

/* автор, полка */
.author, .library, .widgets, .write { padding-top: 40px; }
.author h2, .library h2 { margin-top: 40px; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 10px 0; border-bottom: 1px dotted var(--line); }
.feed span { color: var(--muted); font-size: var(--step--1); }

/* читалка */
body.reading .top, body.reading .foot, body.reading .tabbar, body.reading .demo-bar { display: none; }
body.reading main { max-width: none; padding: 0; }
.reader { --r-bg: oklch(97% 0.01 85); --r-ink: oklch(24% 0.02 60); --r-mut: oklch(52% 0.02 60); --r-line: oklch(86% 0.02 80);
  min-height: 100vh; background: var(--r-bg); color: var(--r-ink); }
.reader[data-rtheme="sepia"] { --r-bg: oklch(91% 0.04 80); --r-ink: oklch(30% 0.04 55); --r-mut: oklch(50% 0.04 60); --r-line: oklch(80% 0.04 75); }
.reader[data-rtheme="night"] { --r-bg: oklch(17% 0.01 260); --r-ink: oklch(82% 0.01 85); --r-mut: oklch(60% 0.01 85); --r-line: oklch(30% 0.01 260); }
.r-bar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px var(--gut); background: var(--r-bg); border-bottom: 1px solid var(--r-line); }
.r-back { font-size: 1.3rem; text-decoration: none; padding: 4px 8px; }
.r-where { margin: 0; display: grid; line-height: 1.25; min-width: 0; font-size: var(--step--1); }
.r-where b, .r-where span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-where span { color: var(--r-mut); }
.r-btn { border: 1px solid var(--r-line); background: none; padding: 6px 12px; font-size: var(--step--1); }
.r-btn[aria-expanded="true"] { border-color: var(--r-ink); }
.r-progress { position: sticky; top: 54px; z-index: 19; height: 2px; background: var(--r-line); }
.r-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.r-stage { margin: 0 auto; padding: 40px var(--gut) 60px; }
.r-stage.w-narrow { max-width: calc(34em + 2 * var(--gut)); }
.r-stage.w-mid { max-width: calc(40em + 2 * var(--gut)); }
.r-stage.w-wide { max-width: calc(50em + 2 * var(--gut)); }
.r-flow { font-family: var(--serif); font-size: var(--rs); line-height: var(--rlh); hyphens: auto; }
.r-stage.f-sans .r-flow { font-family: var(--sans); }
.r-stage.w-narrow .r-flow, .r-stage.w-mid .r-flow, .r-stage.w-wide .r-flow { font-size: var(--rs); }
.r-title { font-size: 1.7em; text-align: center; margin: .4em 0 1.6em; font-weight: 560; }
.r-title small { display: block; font: italic 400 .5em/1.4 var(--serif); color: var(--r-mut); margin-bottom: .6em; }
.r-flow p[data-i] { margin: 0; text-indent: 1.5em; text-align: justify; position: relative; }
.r-flow p[data-i="0"] { text-indent: 0; }
.r-note { font: 400 .8rem/1.5 var(--sans); color: var(--r-mut); padding: 8px 12px; border: 1px dashed var(--r-line); margin-bottom: 2em; }
.pc { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; margin-left: 6px; padding: 0 5px; border: 0; border-radius: 9px; background: color-mix(in oklch, var(--accent) 18%, transparent); color: var(--accent); font: 600 11px/1 var(--sans); text-indent: 0; vertical-align: 2px; }
.pc.add { background: none; border: 1px solid var(--r-line); color: var(--r-mut); opacity: 0; }
p[data-i]:hover .pc.add, .pc.add:focus-visible { opacity: 1; }
@media (hover: none) { .pc.add { display: none; } }
p.blur { filter: blur(4px); user-select: none; -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }
.paywall { margin-top: 1.2em; padding: 24px; border: 1px solid var(--r-line); font: 400 var(--step-0)/1.55 var(--sans); text-align: center; }
.pw-h { font: 560 var(--step-2)/1.2 var(--serif); }
.paywall .muted { color: var(--r-mut); font-size: var(--step--1); margin: 12px 0 0; }
.r-end { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 3em; padding-top: 1.4em; border-top: 1px solid var(--r-line); font: 400 var(--step-0)/1.5 var(--sans); }
.r-end p { margin: 0; color: var(--r-mut); }
.reader .btn { background: var(--r-ink); color: var(--r-bg); border-color: var(--r-ink); }
.r-pager { display: none; }
.reader[data-mode="pages"] .r-stage { height: calc(100dvh - 56px - 2px - 46px); overflow: hidden; padding-top: 28px; padding-bottom: 20px; }
.reader[data-mode="pages"] .r-flow { height: 100%; column-fill: auto; transition: transform .25s ease; }
.reader[data-mode="pages"] .r-end { break-inside: avoid; }
.reader[data-mode="pages"] .r-pager { display: flex; justify-content: center; align-items: center; gap: 22px; height: 46px; color: var(--r-mut); font-size: var(--step--1); }
.r-pager button { border: 1px solid var(--r-line); background: none; width: 38px; height: 32px; font-size: 1.1rem; }
.r-panel, .r-toc { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(420px, 100%); overflow: auto; padding: 16px 20px 40px; background: var(--paper); color: var(--ink); border-left: 1px solid var(--line); box-shadow: -10px 0 30px -18px oklch(0% 0 0 / .4); }
.rp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.rp-head button { border: 1px solid var(--line); background: none; padding: 5px 10px; font-size: var(--step--1); }
.r-panel blockquote { margin: 0 0 16px; padding-left: 12px; border-left: 3px solid var(--accent); font: italic 400 .95rem/1.5 var(--serif); color: var(--ink-2); }
.r-toc ol { list-style: none; padding: 0; margin: 0; }
.r-toc a { display: block; padding: 8px 0; border-bottom: 1px dotted var(--line); text-decoration: none; font-size: var(--step--1); }
.r-toc li[aria-current] a { font-weight: 650; color: var(--accent); }
.r-set { position: fixed; top: 56px; right: var(--gut); z-index: 45; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); padding: 16px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: var(--step--1); }
.r-set > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.r-set span { width: 72px; color: var(--muted); }
.r-set button { border: 1px solid var(--line); background: none; padding: 5px 9px; }
.r-set button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.r-set output { min-width: 26px; text-align: center; }
.sw-sepia { background: oklch(91% 0.04 80) !important; color: oklch(30% 0.04 55) !important; }
.sw-night { background: oklch(17% 0.01 260) !important; color: oklch(82% 0.01 85) !important; }
.sw-sepia[aria-pressed="true"], .sw-night[aria-pressed="true"] { outline: 2px solid var(--accent); }
.selmenu { position: fixed; z-index: 60; display: flex; background: var(--ink); }
.selmenu button { border: 0; background: none; color: var(--paper); padding: 8px 12px; font-size: var(--step--1); }
.selmenu button + button { border-left: 1px solid color-mix(in oklch, var(--paper) 25%, transparent); }

/* виджеты */
.w-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; margin-top: 30px; align-items: start; }
.w-form { display: grid; gap: 16px; }
.w-form select { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); background: var(--card); }
.w-form fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.w-form legend { font-size: var(--step--1); color: var(--muted); padding: 0 6px 0 0; }
.w-host { padding: 26px; background: oklch(99% 0.003 250); color: oklch(25% 0.01 250); border: 1px solid var(--line); font-family: Georgia, serif; }
.w-host-h { font: 600 .82rem/1 var(--sans); color: oklch(50% 0.01 250); }
.w-fake { max-width: 52ch; }
.wg { font-family: var(--sans); padding: 16px; border: 1px solid oklch(86% 0.01 80); border-radius: 4px; background: oklch(98% 0.008 85); color: oklch(24% 0.02 60); }
.wg-dark { background: oklch(21% 0.012 60); color: oklch(92% 0.012 80); border-color: oklch(32% 0.012 60); }
.wg-card { display: flex; gap: 14px; }
.wg-card .cover { --w: 84px; }
.wg-card > div { display: grid; gap: 2px; align-content: start; font-size: .85rem; }
.wg-card b { font: 600 1.05rem/1.2 var(--serif); }
.wg-card small { opacity: .65; }
.wg-card p { margin: 4px 0 6px; line-height: 1.4; }
.wg-btn { justify-self: start; display: inline-block; padding: 7px 12px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: .85rem; }
.wg-btn.solo { display: block; text-align: center; }
.wg:has(.solo) { padding: 0; border: 0; background: none; }
.wg-latest ol { margin: 8px 0 12px; padding-left: 18px; font-size: .88rem; }
.wg-latest li { margin-bottom: 4px; }
.wg-latest small { display: block; opacity: .6; }
@media (max-width: 400px) { .wg-card { flex-direction: column; } }
.w-code-l { display: block; margin: 22px 0 6px; font-size: var(--step--1); color: var(--muted); }
.w-code { margin: 0 0 12px; padding: 14px; background: var(--ink); color: var(--paper); font: .85rem/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-all; }

/* кабинет автора */
.drop { margin-top: 26px; padding: 34px; border: 2px dashed var(--line); text-align: center; background: var(--card); }
.drop.over { border-color: var(--accent); background: var(--paper-2); }
.drop p:last-child { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 0; }
.w-result { margin-top: 28px; }
.parsed .ok { font-weight: 600; color: var(--accent); }
.chs { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: var(--step--1); }
.chs th, .chs td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.chs th { color: var(--muted); font-weight: 500; }
.chs td:nth-child(2) { font-variant-numeric: tabular-nums; }
.chs select { padding: 4px 6px; border: 1px solid var(--line); background: var(--card); }
.preview { margin: 22px 0; padding: 26px; background: oklch(97% 0.01 85); color: oklch(24% 0.02 60); font-family: var(--serif); }
.preview p:not(.eyebrow) { text-indent: 1.5em; margin: 0; line-height: 1.7; }
.err { color: var(--accent); font-weight: 600; }

/* телефон и планшет */
@media (max-width: 1000px) {
  .top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .main-nav { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 28px; }
  .hero h1 { max-width: none; }
  .cat-grid { grid-template-columns: 1fr; }
  .filters { position: fixed; inset: 0 0 0 auto; top: 0; z-index: 70; width: min(360px, 100%); max-height: none; padding: 0 18px 30px; background: var(--paper); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform .25s; }
  body.f-open .filters { transform: none; box-shadow: -20px 0 40px -20px oklch(0% 0 0 / .5); }
  .f-head { display: flex; position: sticky; top: 0; z-index: 1; justify-content: space-between; align-items: center; padding: 14px 0; background: var(--paper); border-bottom: 1px solid var(--ink); }
  .f-close { border: 0; background: var(--ink); color: var(--paper); padding: 7px 12px; }
  .f-open { display: inline-block; border: 1px solid var(--ink); background: none; padding: 6px 12px; }
  .book-cols { grid-template-columns: 1fr; }
  .talk { grid-template-columns: 1fr; gap: 20px; }
  .w-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .top { grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; }
  .theme-t { display: none; }
  .search button { padding: 0 10px; }
  .shelf { height: 230px; }
  .spine span { font-size: 11.5px; }
  .card { gap: 14px; }
  .card .cover { --w: 78px; }
  .card .about { display: none; }
  .book-top { grid-template-columns: 1fr; gap: 20px; }
  .book-cover { display: flex; justify-content: center; }
  .cover.l { --w: 170px; }
  .toc ol { columns: 1; }
  .res-head .res-line { flex-basis: 100%; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); background: var(--paper); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; align-items: center; justify-content: center; height: 52px; border: 0; background: none; text-decoration: none; font-size: .8rem; }
  .tabbar [aria-current] { color: var(--accent); font-weight: 650; box-shadow: inset 0 2px 0 var(--accent); }
  .toast { bottom: 70px; }
  .r-btn[data-act="toc"] { display: none; }
  .r-stage { padding-top: 24px; }
  .r-flow p[data-i] { text-align: left; }
  .r-end { flex-wrap: wrap; }
  .ghost-link { display: block; margin: 12px 0 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
@media print { .demo-bar, .top, .tabbar, .foot, .r-bar, .r-progress, .r-pager, .filters { display: none !important; } }

.how { max-width: 1000px; margin: 0 auto; padding: clamp(32px, 6vw, 72px) var(--gut) 80px; }
.how section { margin-bottom: clamp(48px, 7vw, 84px); }
.how h1 { max-width: 20ch; }
.how h2 { margin-bottom: 16px; }
.how p + p { margin-top: 12px; }
.how .piece { font: italic 400 var(--step-0)/1.3 var(--serif); color: var(--accent); margin: 0 0 12px; }
.how .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 20px 32px; }
.box { border-top: 2px solid var(--ink); padding: 14px 0 4px; }
.box.alt { border-top-color: var(--accent); background: var(--paper-2); padding: 14px 18px 16px; }
.box h3 { font-size: var(--step-0); font-weight: 650; margin-bottom: 8px; }
.box p, .box li { color: var(--ink-2); }
.box ul { margin: 8px 0 0; padding-left: 18px; }
.box li + li { margin-top: 6px; }
.scheme { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--ink); margin-top: 12px; }
.node { text-align: left; padding: 14px 14px 16px; background: var(--paper); color: var(--ink); border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; }
.node:nth-child(4n) { border-right: 0; }
.node:nth-child(n+5) { border-bottom: 0; }
.node b { display: block; font: 600 var(--step-0)/1.2 var(--serif); margin-bottom: 4px; }
.node small { color: var(--muted); font-size: 13px; }
.node:hover { background: var(--paper-2); }
.node[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.node[aria-pressed="true"] small { color: var(--paper-2); }
.node-info { margin-top: 14px; padding: 14px 18px; background: var(--paper-2); border-left: 3px solid var(--accent); min-height: 84px; max-width: 70ch; }
.flow { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.flow li { position: relative; padding: 0 0 20px 24px; }
.flow li::before { content: ""; position: absolute; left: -5px; top: 7px; width: 9px; height: 9px; background: var(--accent); }
.flow time { display: block; font: 600 13px/1.3 var(--sans); color: var(--accent); font-variant-numeric: tabular-nums; }
.flow p { max-width: 64ch; margin: 2px 0 0; }
.pages { columns: 2 280px; column-gap: 40px; padding: 0; margin: 0; list-style: none; }
.pages li { break-inside: avoid; padding: 9px 0; border-bottom: 1px solid var(--line); font-weight: 550; }
.pages small { display: block; color: var(--muted); font-weight: 400; }
.table-wrap { overflow-x: auto; }
.stages { width: 100%; border-collapse: collapse; min-width: 620px; }
.stages th, .stages td { text-align: left; padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.stages th { font: 600 13px/1.3 var(--sans); color: var(--muted); border-bottom: 2px solid var(--ink); }
.stages td:first-child { font-weight: 600; min-width: 150px; }
.stages td:nth-child(n+3) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stages tfoot td { font-weight: 700; border-bottom: 0; }
.pay { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--ink); margin-top: 16px; }
.pay > div { padding: 14px; border-right: 1px solid var(--line); }
.pay > div:last-child { border-right: 0; }
.pay b { display: block; font: 650 var(--step-1)/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.pay small { color: var(--muted); font-size: 13px; }
.need { columns: 2 260px; column-gap: 40px; padding-left: 18px; margin: 0; }
.need li { margin-bottom: 6px; }
@media (max-width: 760px) {
  .scheme { grid-template-columns: 1fr 1fr; }
  .node:nth-child(4n) { border-right: 1px solid var(--line); }
  .node:nth-child(2n) { border-right: 0; }
  .node:nth-child(n+5) { border-bottom: 1px solid var(--line); }
  .node:nth-child(n+7) { border-bottom: 0; }
  .pay { grid-template-columns: 1fr 1fr; }
  .pay > div { border-bottom: 1px solid var(--line); }
  .pay > div:nth-child(2n) { border-right: 0; }
  .pay > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
}

.cover { clip-path: polygon(0 0, 100% 0, 100% 100%, 3% 100%, 0 98.5%); }
.cover.s { clip-path: none; }
