:root {
    --ink: #123c33;
    --green: #10513f;
    --green-dark: #0b3f33;
    --green-2: #3d8774;
    --soft: #7ebba8;
    --peach: #e9a474;
    --gold: #ffda8d;
    --cream: #fff1ce;
    --paper: #fffdf9;
    --mist: #f5f8f6;
    --muted: #667873;
    --line: #dce8e3;
    --shadow: 0 24px 60px rgba(18, 60, 51, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "Segoe UI", Arial, sans-serif; line-height: 1.55; }
body.access-required { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
img { display: block; max-width: 100%; }
.shell { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.site-header, .reader-header { position: sticky; top: 0; z-index: 40; background: rgba(255, 241, 206, .96); border-bottom: 1px solid rgba(16, 81, 63, .1); backdrop-filter: blur(12px); }
.topbar { background: var(--green); color: #fff8e8; font-size: .72rem; }
.topbar-inner { min-height: 29px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar-inner span:last-child { font-weight: 800; }
.nav, .reader-nav { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 50%; color: var(--cream); background: var(--green); font: italic 1.72rem Georgia, serif; }
.brand strong { display: block; font-family: Georgia, serif; letter-spacing: .15em; }
.brand small { display: block; margin-top: -3px; color: var(--green-2); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; }
.nav-links, .reader-actions { display: flex; align-items: center; gap: 25px; }
.nav-links a, .reader-actions a { color: var(--green); font-weight: 650; text-transform: lowercase; }
.hero { min-height: 580px; display: grid; grid-template-columns: 1.12fr .88fr; align-items: center; gap: 70px; padding-block: 75px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-weight: 900; font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; }
.hero h1, .section-heading h2, .access-form-wrap h2, .admin-hero h1 { margin: 0; font: 400 clamp(2.8rem, 5vw, 4.65rem)/1.06 Georgia, serif; letter-spacing: -.05em; }
.hero h1 strong, .section-heading strong, .access-form-wrap strong { color: var(--green); font-weight: 800; }
.hero p:not(.eyebrow) { max-width: 650px; color: var(--muted); font-size: 1.08rem; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 28px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 24px; min-height: 48px; padding: 0 24px; border: 0; border-radius: 999px; color: white; background: linear-gradient(100deg, var(--soft), var(--green)); cursor: pointer; font-weight: 850; box-shadow: 0 12px 24px rgba(16, 81, 63, .16); }
.button.ghost { color: var(--green); background: #fff; border: 1px solid #b8cdc5; box-shadow: none; }
.button.full { width: 100%; }
.hero-book { position: relative; justify-self: center; padding: 22px; border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.hero-book::before { content: ""; position: absolute; inset: -24px 38px auto auto; width: 130px; height: 130px; border-radius: 50%; background: var(--gold); z-index: -1; }
.hero-book img { width: min(330px, 100%); border-radius: 18px; box-shadow: 0 18px 40px rgba(0,0,0,.16); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; padding-bottom: 70px; }
.stats article { padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: #fff; text-align: center; }
.stats strong { display: block; color: var(--peach); font: 400 2.7rem/1 Georgia, serif; }
.stats span { color: var(--green); font-weight: 850; }
.catalog-section { padding: 92px 0 105px; background: var(--mist); }
.section-heading { display: grid; grid-template-columns: 1fr 440px; gap: 45px; align-items: end; margin-bottom: 38px; }
.section-heading.compact { grid-template-columns: 1fr 360px; }
.section-heading h2 { color: var(--peach); font-size: clamp(2.4rem, 4vw, 4rem); }
.section-heading > p { color: var(--muted); }
.search-field { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px; border: 1px solid #b4c9c1; border-radius: 999px; background: #fff; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field span { color: var(--green); font-size: 1.4rem; }
.search-field.mini { min-height: 42px; margin: 20px 0; }
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.book-card { overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: 0 13px 34px rgba(18,60,51,.07); transition: transform .2s ease, box-shadow .2s ease; }
.book-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.book-card[hidden], .topic-row[hidden], .reader-topic-list a[hidden] { display: none; }
.book-cover { display: block; height: 330px; padding: 22px; background: linear-gradient(135deg, #fff8e8, #eef6f2); }
.book-cover img { width: 100%; height: 100%; object-fit: contain; }
.book-body { padding: 22px; }
.book-tag { margin: 0 0 10px; color: var(--peach); font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.book-body h3 { margin: 0; font: 800 1.35rem/1.2 Georgia, serif; }
.subtitle { color: var(--green-2); font-weight: 750; }
.book-body p:not(.book-tag,.subtitle) { color: var(--muted); font-size: .92rem; }
.read-link { display: inline-flex; gap: 18px; margin-top: 10px; color: var(--green); font-weight: 900; }
.empty-state { padding: 35px; border-radius: 20px; background: #fff; text-align: center; color: var(--muted); }
.topics-section { padding: 95px 0; }
.topic-list { display: grid; gap: 12px; }
.topic-row { display: grid; grid-template-columns: 220px 1fr 105px; gap: 18px; align-items: center; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 8px 24px rgba(18,60,51,.05); }
.topic-row span, .topic-row em { color: var(--muted); font-size: .82rem; font-style: normal; }
.topic-row strong { font-family: Georgia, serif; color: var(--ink); }
.footer { padding: 40px 0; background: var(--green); color: rgba(255,255,255,.76); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.footer-brand .brand-mark { color: var(--green); background: var(--gold); }
.footer-brand strong, .footer-brand small { color: var(--gold); }
.access-modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 22px; opacity: 1; visibility: visible; transition: .2s ease; }
.access-modal[aria-hidden="true"] { opacity: 0; visibility: hidden; pointer-events: none; }
.access-backdrop { position: absolute; inset: 0; background: rgba(7,41,32,.8); backdrop-filter: blur(9px); }
.access-panel { position: relative; display: grid; grid-template-columns: .82fr 1.18fr; width: min(940px, 100%); max-height: calc(100vh - 44px); overflow: auto; border-radius: 30px; background: #fff; box-shadow: 0 34px 90px rgba(0,0,0,.28); }
.access-art { position: relative; min-height: 570px; display: flex; flex-direction: column; justify-content: flex-end; padding: 38px; overflow: hidden; color: #fff; background: var(--green); }
.access-art::before { content: ""; position: absolute; width: 370px; height: 370px; top: -130px; left: -110px; border-radius: 50%; background: var(--gold); }
.access-art::after { content: ""; position: absolute; width: 210px; height: 210px; right: -70px; bottom: 120px; border-radius: 50%; background: var(--peach); opacity: .45; }
.modal-brand { position: absolute; z-index: 2; top: 36px; left: 42px; color: var(--green); font: 800 1.05rem Georgia, serif; letter-spacing: .15em; }
.mini-books { position: relative; z-index: 2; display: flex; align-items: flex-end; gap: 8px; height: 170px; margin-bottom: 38px; }
.mini-books span { width: 54px; height: 145px; border-radius: 6px 10px 10px 6px; background: var(--cream); border-left: 7px solid var(--gold); transform: rotate(-7deg); }
.mini-books span:nth-child(2) { height: 170px; background: var(--peach); transform: rotate(2deg); }
.mini-books span:nth-child(3) { height: 127px; background: var(--soft); transform: rotate(8deg); }
.access-art h2, .access-art p { position: relative; z-index: 2; }
.access-art h2 { margin: 0; font: 800 2.2rem/1.1 Georgia, serif; }
.access-form-wrap { position: relative; padding: 34px 48px 30px; }
.access-form-wrap h2 { font-size: 2.25rem; }
.modal-close { position: absolute; top: 18px; right: 20px; z-index: 3; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--green); background: var(--cream); cursor: pointer; font-size: 1.55rem; line-height: 1; box-shadow: 0 10px 24px rgba(18, 60, 51, .12); }
.modal-close:hover { color: #fff; background: var(--green); }
.access-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0 18px; padding: 5px; border-radius: 999px; background: var(--mist); }
.access-tabs button { min-height: 40px; border: 0; border-radius: 999px; color: var(--green); background: transparent; cursor: pointer; font-weight: 800; }
.access-tabs button.active { color: #fff; background: var(--green); }
.access-form { display: grid; gap: 12px; }
.access-form.hidden { display: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; color: #35544c; font-size: .82rem; font-weight: 800; }
input { min-height: 44px; padding: 0 14px; border: 1px solid #c8d8d2; border-radius: 11px; outline: 0; color: var(--ink); background: #fbfcfb; }
input:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(61,135,116,.13); }
.form-message { min-height: 20px; margin: 12px 0 0; color: #a53f34; font-size: .82rem; font-weight: 800; }
.form-message.success { color: var(--green-2); }
.reader-page { background: #edf3f0; }
.reader-layout { display: grid; grid-template-columns: 330px 1fr; gap: 28px; padding-block: 28px 70px; }
.reader-sidebar { position: sticky; top: 105px; align-self: start; max-height: calc(100vh - 130px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 24px; background: #fff; }
.reader-sidebar h1 { margin: 0; font: 800 1.4rem/1.18 Georgia, serif; }
.reader-sidebar p:not(.eyebrow) { color: var(--muted); font-size: .88rem; }
.reader-topic-list { display: grid; gap: 8px; }
.reader-topic-list a { display: grid; gap: 5px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; }
.reader-topic-list a.active, .reader-topic-list a:hover { border-color: var(--green); background: #eef8f4; }
.reader-topic-list strong { font-size: .88rem; line-height: 1.25; }
.reader-topic-list span { color: var(--muted); font-size: .74rem; }
.reader-main { min-width: 0; }
.paper-toolbar { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 18px; padding: 22px; border-radius: 24px; background: #fff; border: 1px solid var(--line); }
.paper-toolbar h2 { margin: 0; font: 800 1.55rem/1.18 Georgia, serif; }
.paper-toolbar p { margin: 6px 0 0; color: var(--muted); }
.page-jump { display: grid; gap: 9px; justify-items: end; }
.page-jump span { color: var(--green); font-weight: 900; }
.page-jump form { display: flex; gap: 8px; }
.page-jump input { width: 86px; min-height: 38px; }
.page-jump button { border: 0; border-radius: 999px; color: #fff; background: var(--green); padding: 0 16px; cursor: pointer; }
.page-frame { padding: 20px; border-radius: 26px; background: #dfe9e4; box-shadow: inset 0 0 0 1px rgba(16,81,63,.08); }
.page-frame img { width: min(100%, 900px); margin: auto; border-radius: 8px; background: #fff; box-shadow: 0 18px 40px rgba(0,0,0,.18); }
.reader-pager { display: flex; justify-content: space-between; gap: 15px; margin-top: 22px; }
.admin-login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, rgba(255,218,141,.35), transparent 28rem), var(--green); }
.admin-login { width: min(440px, calc(100% - 32px)); }
.admin-card { display: grid; gap: 16px; padding: 32px; border-radius: 28px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.admin-card h1, .admin-hero h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
.admin-dashboard { padding-block: 55px 80px; }
.admin-hero { display: flex; justify-content: space-between; gap: 25px; align-items: end; margin-bottom: 25px; }
.admin-search { display: flex; gap: 10px; width: min(520px, 100%); }
.admin-search input { flex: 1; }
.admin-stats { grid-template-columns: repeat(3, 1fr); padding-bottom: 30px; }
.history-table-wrap { padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.table-actions { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.table-actions h2 { margin: 0; font: 800 1.6rem Georgia, serif; }
.table-scroll { overflow: auto; }
.history-table { width: 100%; min-width: 1150px; border-collapse: collapse; font-size: .84rem; }
.history-table th, .history-table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.history-table th { position: sticky; top: 0; color: var(--green); background: #f7fbf9; }

@media (max-width: 920px) {
    .hero, .section-heading, .section-heading.compact, .reader-layout { grid-template-columns: 1fr; }
    .book-grid { grid-template-columns: repeat(2, 1fr); }
    .reader-sidebar { position: static; max-height: none; }
    .paper-toolbar, .admin-hero { align-items: stretch; flex-direction: column; }
    .page-jump { justify-items: start; }
}

@media (max-width: 700px) {
    .shell { width: min(100% - 28px, 1120px); }
    .topbar-inner span:first-child { display: none; }
    .topbar-inner { justify-content: center; }
    .nav, .reader-nav { min-height: 68px; }
    .nav-links, .reader-actions { gap: 12px; font-size: .86rem; }
    .hero { padding-block: 45px; text-align: center; }
    .hero-actions { justify-content: center; }
    .stats, .admin-stats, .book-grid { grid-template-columns: 1fr; }
    .topic-row { grid-template-columns: 1fr; gap: 7px; }
    .footer-inner { align-items: flex-start; flex-direction: column; }
    .access-panel { grid-template-columns: 1fr; }
    .access-art { display: none; }
    .access-form-wrap { padding: 30px 24px; }
    .form-row, .access-tabs { grid-template-columns: 1fr; border-radius: 18px; }
    .reader-pager { flex-direction: column; }
}
