:root {
    --accent: #9b3f32;
    --serif: Georgia, 'Times New Roman', serif;
    --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --reading-size: 20px;
    --reading-line: 1.85;
    --page-bg: #eee9df;
    --surface: #fffdf8;
    --text: #292622;
    --muted: #756e65;
    --border: rgba(54, 44, 35, .14);
    --shadow: 0 24px 70px rgba(55, 43, 30, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page-bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }

.theme-sepia { --page-bg: #e8dcc3; --surface: #f6eddc; --text: #372d23; --muted: #796b59; --border: rgba(68, 51, 34, .17); }
.theme-minimal { --page-bg: #f4f5f7; --surface: #fff; --text: #202227; --muted: #6e737c; --border: rgba(30, 35, 45, .12); }
.theme-night { --page-bg: #121416; --surface: #1b1e21; --text: #e6e1d7; --muted: #aaa59b; --border: rgba(255, 255, 255, .1); --shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.font-modern .chapter-content, .font-modern .chapter-title h1, .font-modern .hero-copy h1, .font-modern .chapter-list strong { font-family: var(--sans); }
.font-classic .chapter-content, .font-classic .chapter-title h1, .font-classic .hero-copy h1, .font-classic .chapter-list strong { font-family: 'Times New Roman', Times, serif; }

.site-header { width: min(1180px, calc(100% - 48px)); height: 82px; margin: auto; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.wordmark { display: flex; align-items: center; gap: 12px; min-width: 0; }
.wordmark > span { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50% 50% 48% 52%; font: 700 12px var(--sans); letter-spacing: -.03em; }
.wordmark b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-size: 16px; }
.site-header nav { display: flex; gap: 28px; color: var(--muted); font-size: 13px; font-weight: 650; }
.site-header nav a:hover { color: var(--accent); }

.book-hero { width: min(1120px, calc(100% - 48px)); min-height: 650px; margin: 0 auto; padding: 72px 0 88px; display: grid; grid-template-columns: 340px 1fr; align-items: center; gap: clamp(60px, 10vw, 130px); }
.cover-wrap { position: relative; }
.cover-wrap::before { content: ''; position: absolute; z-index: -1; inset: 8% -12% -6% 12%; border-radius: 50%; background: color-mix(in srgb, var(--accent) 10%, transparent); filter: blur(2px); }
.book-cover, .cover-placeholder { display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 4px 12px 12px 4px; box-shadow: -10px 18px 45px rgba(37, 27, 18, .25), inset 8px 0 0 rgba(255, 255, 255, .08); object-fit: cover; }
.cover-placeholder { padding: 42px 30px; color: #f4ede5; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 83%, #18140f), #281d19); display: flex; flex-direction: column; text-align: center; justify-content: center; border: 1px solid rgba(255, 255, 255, .15); }
.cover-placeholder::before, .cover-placeholder::after { content: ''; display: block; width: 46px; height: 1px; margin: 0 auto 28px; background: rgba(255, 255, 255, .5); }
.cover-placeholder::after { margin: 28px auto 0; }
.cover-placeholder h2 { margin: 18px 0; font: 700 clamp(27px, 3vw, 39px)/1.15 var(--serif); }
.cover-placeholder p { margin: 0; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .18em; }
.cover-ornament { font-size: 15px; opacity: .8; }
.kicker { margin: 0 0 14px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .19em; text-transform: uppercase; }
.hero-copy h1 { max-width: 700px; margin: 0; font: 700 clamp(45px, 6.2vw, 80px)/.99 var(--serif); letter-spacing: -.045em; text-wrap: balance; }
.hero-copy .subtitle { max-width: 650px; margin: 20px 0 0; color: var(--muted); font: italic 21px/1.5 var(--serif); }
.author { margin: 26px 0 0; color: var(--muted); font-size: 13px; }
.author strong { color: var(--text); }
.description { max-width: 610px; margin: 28px 0 0; color: var(--muted); font: 17px/1.75 var(--serif); }
.hero-actions { display: flex; align-items: center; gap: 12px; margin-top: 36px; }
.read-button, .ghost-button { min-height: 52px; padding: 0 22px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; gap: 28px; font-size: 13px; font-weight: 750; }
.read-button { color: #fff; background: var(--accent); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 25%, transparent); }
.read-button:hover { transform: translateY(-2px); }
.ghost-button { border: 1px solid var(--border); }
.latest-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.latest-note a { color: var(--accent); font-weight: 750; }

.chapter-section { width: min(960px, calc(100% - 48px)); margin: 0 auto 110px; padding: 65px 0 0; border-top: 1px solid var(--border); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-heading h2 { margin: 0; font: 700 clamp(30px, 4vw, 43px)/1.1 var(--serif); }
.section-heading > span { color: var(--muted); font-size: 12px; }
.chapter-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.chapter-list li { border-bottom: 1px solid var(--border); }
.chapter-list a { min-height: 118px; display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 28px; padding: 20px 10px; transition: padding .2s ease, color .2s ease; }
.chapter-list a:hover { padding-left: 20px; color: var(--accent); }
.chapter-index { color: var(--muted); font: 12px var(--sans); }
.chapter-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.chapter-info small { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.chapter-info strong { color: var(--text); font: 700 24px/1.25 var(--serif); }
.chapter-info em { color: var(--muted); font: italic 14px var(--serif); }
.chapter-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.chapter-meta b { display: inline-grid; width: 30px; height: 30px; margin-left: 14px; place-items: center; border: 1px solid var(--border); border-radius: 50%; color: var(--accent); }
.empty-reader { padding: 80px 20px; text-align: center; border: 1px solid var(--border); }
.empty-reader > span { color: var(--accent); }
.empty-reader h3 { margin: 15px 0 8px; font: 700 27px var(--serif); }
.empty-reader p { color: var(--muted); }
.site-footer { width: min(1120px, calc(100% - 48px)); margin: auto; padding: 30px 0 50px; display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

.reading-progress { position: fixed; z-index: 100; inset: 0 0 auto; height: 3px; background: transparent; }
.reading-progress span { display: block; width: 0; height: 100%; background: var(--accent); }
.reader-header { position: fixed; z-index: 50; inset: 3px 0 auto; height: 68px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--page-bg) 89%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px); }
.back-home { display: flex; align-items: center; gap: 14px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.back-home span { color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reader-actions { display: flex; gap: 8px; }
.icon-button { width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.type-button { font: 700 13px var(--serif); }
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.reader-main { min-height: 100vh; padding: 142px 24px 90px; }
.chapter-article { width: min(760px, 100%); margin: auto; }
.chapter-title { margin-bottom: 66px; text-align: center; }
.chapter-title > p { margin: 0 0 18px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .24em; text-transform: uppercase; }
.chapter-title h1 { margin: 0; font: 700 clamp(40px, 7vw, 66px)/1.08 var(--serif); letter-spacing: -.035em; text-wrap: balance; }
.chapter-title h2 { margin: 18px 0 0; color: var(--muted); font: italic 19px/1.5 var(--serif); }
.chapter-rule { margin: 36px auto 20px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--accent); font-size: 9px; }
.chapter-rule::before, .chapter-rule::after { content: ''; width: 48px; height: 1px; background: var(--border); }
.chapter-facts { display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.chapter-content { font-family: var(--serif); font-size: var(--reading-size); line-height: var(--reading-line); letter-spacing: .002em; overflow-wrap: break-word; }
.chapter-content > p { margin: 0 0 1.42em; }
.chapter-content > p:first-of-type::first-letter { float: left; margin: .08em .1em 0 0; color: var(--accent); font-size: 4.15em; font-weight: 700; line-height: .72; }
.chapter-content h2, .chapter-content h3 { margin: 2.2em 0 .8em; line-height: 1.2; text-align: center; }
.chapter-content h2 { font-size: 1.65em; }
.chapter-content h3 { font-size: 1.3em; }
.chapter-content blockquote { margin: 2.2em 5%; padding: .3em 0 .3em 1.4em; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.book-list { margin: 1.5em 0; padding-left: 1.5em; }
.scene-break { margin: 2.8em 0; color: var(--accent); text-align: center; font-size: .65em; letter-spacing: .7em; }
.chapter-figure { margin: 2.5em -7%; }
.chapter-figure img { display: block; width: 100%; max-height: 80vh; object-fit: contain; border-radius: 3px; box-shadow: var(--shadow); }
.chapter-figure figcaption { max-width: 80%; margin: 13px auto 0; color: var(--muted); text-align: center; font: italic 13px/1.5 var(--serif); }
.chapter-end { padding: 54px 0 30px; text-align: center; color: var(--muted); }
.chapter-end span { color: var(--accent); font-size: 10px; }
.chapter-end p { margin: 9px 0 0; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .18em; }
.chapter-navigation { width: min(900px, 100%); margin: 40px auto 0; padding: 34px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 30px; border-top: 1px solid var(--border); }
.chapter-navigation a { display: flex; flex-direction: column; gap: 7px; }
.chapter-navigation .next { text-align: right; align-items: flex-end; }
.chapter-navigation small { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.chapter-navigation strong { max-width: 300px; font: 700 18px var(--serif); }
.not-found { width: min(600px, 100%); margin: 100px auto; text-align: center; }
.not-found > span { color: var(--accent); font: 800 14px var(--sans); }
.not-found h1 { font: 700 48px var(--serif); }
.not-found p { color: var(--muted); }
.not-found a { display: inline-block; margin-top: 20px; padding: 14px 20px; color: #fff; background: var(--accent); }

.reader-drawer { position: fixed; z-index: 80; inset: 0 auto 0 0; width: min(420px, 90vw); padding: 30px; background: var(--surface); box-shadow: 20px 0 60px rgba(0, 0, 0, .18); transform: translateX(-104%); transition: transform .25s ease; overflow-y: auto; }
.reader-drawer.open { transform: translateX(0); }
.drawer-head { margin-bottom: 25px; padding-bottom: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.drawer-head div { display: flex; flex-direction: column; gap: 5px; }
.drawer-head small { color: var(--accent); font-size: 9px; text-transform: uppercase; letter-spacing: .15em; }
.drawer-head strong { font: 700 28px var(--serif); }
.drawer-head button { border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.reader-drawer nav { display: flex; flex-direction: column; }
.reader-drawer nav a { padding: 14px 4px; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.reader-drawer nav a span { color: var(--muted); font-size: 10px; }
.reader-drawer nav a b { font: 600 16px var(--serif); }
.reader-drawer nav a.active { color: var(--accent); }
.drawer-overlay { position: fixed; z-index: 70; inset: 0; background: rgba(15, 13, 10, .42); backdrop-filter: blur(2px); }
.settings-popover { position: fixed; z-index: 90; top: 78px; right: 28px; width: min(330px, calc(100% - 30px)); padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-8px); transition: .2s ease; }
.settings-popover.open { opacity: 1; visibility: visible; transform: translateY(0); }
.setting-row { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border: 0; }
.setting-row > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.setting-row button { min-width: 36px; height: 32px; border: 1px solid var(--border); background: transparent; cursor: pointer; }
.theme-picks { display: flex; gap: 6px; }
.theme-picks button { min-width: 28px; width: 28px; height: 28px; border-radius: 50%; }
.theme-picks .paper { background: #fffdf8; }.theme-picks .sepia { background: #e8dcc3; }.theme-picks .minimal { background: #f4f5f7; }.theme-picks .night { background: #1b1e21; }
.theme-picks button.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.toast { position: fixed; z-index: 110; left: 50%; bottom: 25px; padding: 11px 17px; border-radius: 30px; color: #fff; background: #26221f; font-size: 12px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
    .site-header { width: calc(100% - 30px); height: 68px; }
    .site-header nav { gap: 14px; }.site-header nav a:first-child { display: none; }
    .book-hero { width: calc(100% - 32px); min-height: auto; padding: 45px 0 68px; grid-template-columns: 1fr; gap: 48px; }
    .cover-wrap { width: min(270px, 78vw); margin: auto; }
    .hero-copy { text-align: center; }
    .hero-copy h1 { font-size: clamp(40px, 13vw, 60px); }
    .description { font-size: 16px; }.hero-actions { justify-content: center; flex-wrap: wrap; }.latest-note { text-align: center; }
    .chapter-section { width: calc(100% - 32px); margin-bottom: 70px; padding-top: 50px; }
    .chapter-list a { min-height: 105px; grid-template-columns: 32px 1fr auto; gap: 10px; padding-inline: 2px; }
    .chapter-info strong { font-size: 20px; }.chapter-meta { font-size: 0; }.chapter-meta b { margin: 0; font-size: 12px; }
    .site-footer { width: calc(100% - 32px); flex-direction: column; text-align: center; }
    .reader-header { height: 60px; padding: 0 14px; }.back-home span { max-width: 145px; }.reader-actions { gap: 5px; }.icon-button { width: 35px; height: 35px; }
    .reader-main { padding: 115px 19px 60px; }.chapter-title { margin-bottom: 46px; }.chapter-title h1 { font-size: clamp(37px, 12vw, 53px); }
    .chapter-content { font-size: var(--reading-size); }.chapter-figure { margin-inline: -10px; }.chapter-figure figcaption { max-width: 95%; }
    .chapter-navigation { gap: 14px; }.chapter-navigation strong { font-size: 15px; }.reader-drawer { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto; transition: none; }
}
