:root {
  --paper: #f4f0e7;
  --paper-deep: #e9e2d3;
  --ink: #202622;
  --muted: #67706a;
  --forest: #24473c;
  --forest-dark: #19362d;
  --cream: #fffdf8;
  --card: #fff;
  --line: #d8d0c0;
  --gold: #bc8c42;
  --warning: #8a4d13;
  --warning-bg: #fff2d8;
  --error: #8a2f2a;
  --current: #246347;
  --current-bg: #e8f5ed;
  --on-accent: #fff;
  --reader-background: #d8d8d5;
  --reader-header: #f4f0e7;
  --reader-bar: #e9e2d3;
  --reader-text: #202622;
  --reader-muted: #67706a;
  --reader-border: #c8c0b2;
  --reader-select: #fffdf8;
  --reader-action: #24473c;
  --reader-action-text: #fff;
  --shadow: 0 18px 50px rgb(37 43 40 / 9%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

html[data-theme="dark"] {
  --paper: #111513;
  --paper-deep: #18201c;
  --ink: #eeeae0;
  --muted: #a4aea8;
  --forest: #8cb8a7;
  --forest-dark: #6b9e8a;
  --cream: #171c19;
  --card: #1d2420;
  --line: #343c37;
  --gold: #d4a75d;
  --warning: #efb978;
  --warning-bg: #3a2917;
  --error: #ee918b;
  --current: #9bcab5;
  --current-bg: #1c352a;
  --on-accent: #101713;
  --reader-background: #303634;
  --reader-header: #252b28;
  --reader-bar: #3b4340;
  --reader-text: #f4f7f5;
  --reader-muted: #afbbb5;
  --reader-border: #505956;
  --reader-select: #2f3734;
  --reader-action: #f2e8d3;
  --reader-action-text: #17211d;
  --shadow: 0 18px 50px rgb(0 0 0 / 24%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
button, input, select { font: inherit; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 0.9rem;
  color: white;
  background: var(--forest-dark);
  border-radius: 0.35rem;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header {
  max-width: 1200px;
  margin: auto;
  padding: 1.55rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.8rem; font-weight: 600; text-decoration: none; letter-spacing: -0.02em; }
.brand img { box-shadow: 0 5px 16px rgb(36 71 60 / 17%); }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.about-link { color: var(--muted); font-size: 0.93rem; text-underline-offset: 0.25rem; }
.theme-picker { display: flex; gap: 0.15rem; padding: 0.2rem; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--paper) 86%, transparent); }
.theme-button { min-height: 2rem; padding: 0.4rem 0.6rem; color: var(--muted); background: transparent; border: 0; border-radius: 999px; cursor: pointer; font-size: 0.67rem; letter-spacing: 0.05em; text-transform: uppercase; }
.theme-button.active { color: var(--paper); background: var(--ink); }
.theme-button:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

.intro {
  max-width: 1136px;
  margin: 0 auto;
  padding: 1.5rem 2rem 2.25rem;
}
.intro p { max-width: 610px; margin: 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.65; }
.section-heading h2, .about h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.045em;
}

.library { padding: 3.25rem max(2rem, calc((100vw - 1136px) / 2)) 4.5rem; background: var(--cream); border-block: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.4rem; }
.section-heading h2, .about h2 { margin: 0; font-size: clamp(2.3rem, 5vw, 3.4rem); line-height: 1; }
.search { width: min(100%, 330px); display: flex; align-items: center; gap: 0.65rem; padding: 0.78rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.search:focus-within { outline: 2px solid var(--forest); outline-offset: 2px; }
.search svg { width: 1.1rem; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search input::placeholder { color: var(--muted); }

.site-status { min-height: 2.5rem; margin-bottom: 2rem; padding: 0.7rem 0.9rem; display: flex; align-items: center; gap: 0.45rem; border-radius: 0.45rem; font-size: 0.87rem; }
.site-status.current { color: var(--current); background: var(--current-bg); }
.site-status.warning { color: var(--warning); background: var(--warning-bg); }
.status-dot { width: 0.48rem; height: 0.48rem; border-radius: 50%; background: #398261; }

.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.book-card {
  min-height: 390px;
  padding: 1.65rem;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--card);
  box-shadow: 0 1px 0 rgb(32 38 34 / 2%);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.book-card:hover { transform: translateY(-3px); border-color: var(--muted); box-shadow: var(--shadow); }
.book-topline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.book-author { margin: 0; color: var(--forest); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.freshness-chip { padding: 0.3rem 0.55rem; border-radius: 99px; font-size: 0.7rem; font-weight: 600; }
.freshness-chip.current { color: var(--current); background: var(--current-bg); }
.freshness-chip.unknown, .freshness-chip.processing, .freshness-chip.delayed { color: var(--warning); background: var(--warning-bg); }
.book-card h3 { margin: 2.1rem 0 0.8rem; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; line-height: 1.08; letter-spacing: -0.035em; }
.book-description { margin: 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; line-height: 1.6; }
.book-meta { margin: auto 0 1.5rem; padding-top: 2rem; display: flex; gap: 2.5rem; }
.book-meta div { display: grid; gap: 0.2rem; }
.book-meta dt { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.book-meta dd { margin: 0; font-size: 0.85rem; font-weight: 600; }
.book-actions { display: flex; align-items: center; gap: 1.1rem; }
.read-button { flex: 1; padding: 0.75rem 0.95rem; display: flex; justify-content: space-between; color: var(--on-accent); background: var(--forest); border-radius: 0.35rem; font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.read-button:hover { background: var(--forest-dark); }
.details-link { color: var(--muted); font-size: 0.76rem; text-underline-offset: 0.22rem; }
.loading, .load-error { grid-column: 1 / -1; padding: 4rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.load-error { color: var(--error); }
.empty-state { padding: 4rem; text-align: center; color: var(--muted); }

.about { max-width: 1136px; margin: auto; padding: 8rem 2rem; }
.about h2 { max-width: 800px; }
.about-grid { margin: 3rem 0 0 33%; display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 1.1rem; line-height: 1.7; }
.about-grid p { margin: 0; }
footer { padding: 2rem max(2rem, calc((100vw - 1136px) / 2)); display: flex; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.8rem; }

.reader-page { height: 100vh; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); overflow: hidden; background: var(--reader-background); }
.reader-header { min-height: 74px; padding: 0.7rem 1.1rem; display: grid; grid-template-columns: minmax(110px, 1fr) minmax(0, 2fr) minmax(420px, 1fr); align-items: center; gap: 1rem; color: var(--reader-text); background: var(--reader-header); border-bottom: 1px solid var(--reader-border); }
.reader-home { display: inline-flex; width: fit-content; align-items: center; gap: 0.35rem; color: var(--reader-muted); text-decoration: none; font-size: 0.86rem; }
.reader-home svg { width: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.reader-identity { min-width: 0; text-align: center; }
.reader-identity p { margin: 0 0 0.18rem; color: var(--reader-muted); font-size: 0.69rem; letter-spacing: 0.08em; text-transform: uppercase; }
.reader-identity h1 { margin: 0; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.reader-actions { display: flex; justify-content: end; gap: 0.6rem; }
.reader-theme-picker { border-color: var(--reader-border); background: transparent; }
.action-link { padding: 0.56rem 0.75rem; color: var(--reader-action-text); background: var(--reader-action); border: 1px solid var(--reader-action); border-radius: 0.3rem; font-size: 0.75rem; font-weight: 600; text-decoration: none; }
.action-link.secondary { color: var(--reader-muted); background: transparent; border-color: var(--reader-border); }
.freshness-banner { min-height: 40px; padding: 0.55rem 1.1rem; display: flex; justify-content: center; align-items: center; gap: 0.45rem; font-size: 0.76rem; }
.freshness-banner.current { color: #194f37; background: #dff1e6; }
.freshness-banner.unknown, .freshness-banner.delayed, .freshness-banner.processing { color: #6e3b0d; background: var(--warning-bg); }
.document-bar { min-height: 50px; padding: 0.45rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--reader-text); background: var(--reader-bar); border-bottom: 1px solid var(--reader-border); font-size: 0.75rem; }
.document-bar label { display: flex; align-items: center; gap: 0.55rem; }
.document-bar label span { color: var(--reader-muted); }
.document-bar select { max-width: 230px; padding: 0.38rem 1.8rem 0.38rem 0.55rem; color: var(--reader-text); background: var(--reader-select); border: 1px solid var(--reader-border); border-radius: 0.25rem; }
.release-summary { display: flex; align-items: center; gap: 0.45rem; color: var(--reader-muted); }
.release-summary a { text-underline-offset: 0.2rem; }
.viewer-shell { min-height: 0; position: relative; }
#pdf-frame { width: 100%; height: 100%; display: block; border: 0; background: var(--reader-background); }
.reader-error { position: absolute; inset: 0; padding: 4rem 2rem; text-align: center; color: var(--reader-text); background: var(--reader-background); }

@media (max-width: 850px) {
  .book-grid { grid-template-columns: 1fr 1fr; }
  .about-grid { margin-left: 15%; }
  .reader-header { grid-template-columns: auto 1fr auto; }
  .reader-home span, .action-link.secondary { display: none; }
  .reader-actions { min-width: 0; }
}

@media (max-width: 620px) {
  .site-header { padding: 1rem 1.1rem; }
  .brand span { font-size: 0.88rem; }
  .intro { padding: 1rem 1.15rem 1.5rem; }
  .intro p { font-size: 1rem; }
  .library { padding: 2.5rem 1.1rem 3.5rem; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { min-height: 355px; }
  .about { padding: 5rem 1.15rem; }
  .about-grid { margin-left: 0; grid-template-columns: 1fr; gap: 1.2rem; }
  footer { padding: 1.5rem 1.1rem; flex-direction: column; }
  .reader-header { min-height: 62px; padding: 0.55rem 0.7rem; gap: 0.45rem; }
  .reader-identity h1 { font-size: 0.88rem; }
  .reader-identity p { font-size: 0.58rem; }
  .reader-actions .action-link { display: none; }
  .reader-theme-picker .theme-button { min-height: 1.8rem; padding: 0.35rem 0.42rem; font-size: 0.55rem; }
  .freshness-banner { padding: 0.45rem 0.7rem; align-items: start; flex-direction: column; gap: 0.1rem; }
  .document-bar { padding: 0.45rem 0.7rem; }
  .document-bar label span, .release-summary a:not(#release-link), .release-summary span { display: none; }
  .document-bar select { max-width: 180px; }
}

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