:root {
    --ink: #1d1b19;
    --muted: #6f6a63;
    --paper: #f7f4ee;
    --card: #fffdf9;
    --rule: #e2ddd3;
    --accent: #0b6e4f;
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --radius: 10px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
a { color: var(--accent); }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-family: Georgia, serif; font-weight: 600; font-size: 24px; margin: 0 0 16px; }
code { font-size: 13px; background: #efebe3; padding: 2px 6px; border-radius: 4px; }

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }
.main { padding: 40px 0 72px; min-height: 70vh; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.inline { display: inline; }

.site-header { border-bottom: 1px solid var(--rule); background: var(--card); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 18px; }
.brand-mark { width: 14px; height: 22px; background: var(--accent); border-radius: 2px 4px 4px 2px; box-shadow: 5px 0 0 -1px #c9a227; }
.nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }

.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; padding: 20px 0; flex-wrap: wrap; }

.button { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink) !important; font: inherit; font-weight: 600; padding: 10px 18px; cursor: pointer; text-decoration: none; }
.button:hover { filter: brightness(1.08); }
.button-small { padding: 6px 12px; font-size: 14px; }
.button-ghost { background: transparent; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--rule); }
.button-danger { background: var(--danger); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link-danger { color: var(--danger); }

.flash { background: #e3f1ea; border: 1px solid #b9dcc9; border-radius: var(--radius); padding: 12px 16px; margin: 0 0 24px; }
.error { color: var(--danger); font-size: 14px; font-style: normal; margin: 6px 0 0; display: block; }
.empty { color: var(--muted); padding: 24px 0; }

.intro { margin-bottom: 28px; max-width: 720px; }
.lead { font-size: 18px; color: var(--muted); margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
input, select, textarea { font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }

.filters { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr auto; gap: 14px; align-items: end; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 18px; margin-bottom: 32px; }
.years { display: flex; gap: 8px; }
.filter-actions { display: flex; align-items: center; gap: 14px; }

.book-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.book-card { display: flex; height: 100%; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.book-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgb(29 27 25 / 0.08); }
.book-spine { width: 12px; flex: none; background: hsl(var(--hue) 45% 38%); }
.book-body { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; }
.book-title { font-family: Georgia, serif; font-size: 18px; font-weight: 600; line-height: 1.25; }
.book-author { color: var(--muted); }
.book-meta { margin-top: auto; padding-top: 8px; font-size: 13px; color: var(--muted); }

.pager { display: flex; justify-content: center; gap: 12px; margin-top: 32px; }

.breadcrumb { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.book-detail { display: grid; grid-template-columns: 220px 1fr; gap: 40px; align-items: start; }
.cover { aspect-ratio: 2 / 3; border-radius: 4px 10px 10px 4px; background: linear-gradient(135deg, hsl(var(--hue) 45% 34%), hsl(var(--hue) 40% 22%)); color: #fff; padding: 22px 18px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: inset 8px 0 0 rgb(0 0 0 / 0.18), 0 14px 30px rgb(29 27 25 / 0.18); }
.cover-title { font-family: Georgia, serif; font-size: 22px; line-height: 1.2; }
.cover-author { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; opacity: .85; }
.byline { font-size: 18px; margin: 0 0 18px; }
.summary { max-width: 680px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin: 24px 0; }
.facts div { border-top: 1px solid var(--rule); padding-top: 8px; }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.files { margin-top: 48px; }
.file-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; font-size: 15px; }
.file-table th, .file-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.file-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.file-table tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #ece7dd; margin-right: 4px; }
.badge-primary { background: var(--accent); color: #fff; }
.upload { display: grid; grid-template-columns: 2fr 1fr auto; gap: 14px; align-items: end; margin-top: 20px; }

.book-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; max-width: 820px; margin-top: 24px; }
.field-wide { grid-column: 1 / -1; }
.filters .field-wide { grid-column: auto; }

.login { max-width: 420px; }
.login form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.checkbox { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.checkbox input { width: auto; }

@media (max-width: 860px) {
    .filters { grid-template-columns: 1fr 1fr; }
    .filters .field-wide { grid-column: 1 / -1; }
    .book-detail { grid-template-columns: 1fr; }
    .cover { max-width: 200px; }
    .upload, .book-form { grid-template-columns: 1fr; }
    .file-table { display: block; overflow-x: auto; }
}
