:root {
  --paper: #f6f2e9;
  --paper-deep: #ece5d8;
  --surface: #fffdf9;
  --ink: #19211f;
  --muted: #6b716d;
  --line: #dcd7cc;
  --forest: #1d5b49;
  --forest-dark: #123f34;
  --amber: #c27935;
  --rose: #a94f4f;
  --shadow: 0 18px 46px rgba(35, 31, 24, 0.1);
  --radius: 4px;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

body.reader-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid rgba(194, 121, 53, 0.48);
  outline-offset: 3px;
}

.shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.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; }
.skip-link { position: fixed; z-index: 100; top: -50px; left: 20px; padding: 10px 16px; background: var(--forest); color: white; }
.skip-link:focus { top: 12px; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(246, 242, 233, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  z-index: 10;
  top: 0;
}

.header-inner, .footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--forest);
  color: #fff;
  font-family: var(--serif);
  font-size: 22px;
}
.brand-name { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.05em; }
.brand-tagline { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase; }
.header-nav { display: flex; align-items: center; gap: 28px; }
.nav-link { color: var(--muted); font-size: 13px; font-weight: 600; }
.nav-link:hover, .nav-link.active { color: var(--forest); }

.icon-button, .rail-button, .back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); }
.icon-button:hover { color: var(--forest); border-color: var(--forest); }
[data-icon] { display: inline-flex; width: 17px; height: 17px; }
[data-icon] svg { width: 100%; height: 100%; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 80px;
  align-items: end;
  padding-top: clamp(64px, 10vw, 124px);
  padding-bottom: clamp(70px, 10vw, 120px);
}
.eyebrow { margin: 0 0 14px; color: var(--forest); font-size: 11px; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; }
.eyebrow-dot { display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--amber); }
h1, h2 { margin: 0; font-family: var(--serif); font-weight: 400; letter-spacing: -0.04em; }
h1 { max-width: 760px; font-size: clamp(58px, 8vw, 108px); line-height: 0.91; }
h1 em, h2 em { color: var(--forest); font-style: italic; }
.hero-lede { max-width: 440px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.6; }
.hero-note { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 10px; }
.note-line { width: 1px; height: 66px; background: var(--amber); }
.hero-note p { margin: -5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; text-transform: uppercase; letter-spacing: 0.11em; }

.date-panel { padding: 24px 0 42px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-heading-row, .library-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
h2 { font-size: clamp(32px, 4vw, 49px); line-height: 1; }
.date-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--forest);
  background: var(--surface);
}
.date-picker input { border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; cursor: pointer; }
.date-rail-wrap { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 12px; align-items: center; margin-top: 34px; }
.rail-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--forest); }
.rail-button:hover { border-color: var(--forest); background: var(--surface); }
.date-rail { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 8px; }
.date-item { border: 1px solid transparent; border-radius: var(--radius); padding: 12px 8px; color: var(--muted); background: transparent; text-align: center; cursor: pointer; }
.date-item:hover { background: rgba(255, 253, 249, 0.7); }
.date-item[aria-selected="true"] { border-color: var(--forest); color: var(--forest); background: var(--surface); box-shadow: 0 5px 16px rgba(29, 91, 73, 0.08); }
.date-day { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.date-number { display: block; margin-top: 2px; font-family: var(--serif); font-size: 25px; line-height: 1; }
.date-month { display: block; margin-top: 5px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }

.library-section { padding-top: 75px; padding-bottom: 110px; }
.library-title-row { display: flex; align-items: center; gap: 12px; }
.count-badge { display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 7px; border-radius: 99px; color: var(--forest); background: rgba(29, 91, 73, 0.1); font-size: 12px; font-weight: 700; }
.toolbar-meta { padding-bottom: 4px; }
.live-indicator { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #6b9e78; box-shadow: 0 0 0 4px rgba(107, 158, 120, 0.14); }
.filters { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 35px 0 28px; }
.filter-scroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 99px; padding: 9px 15px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.filter-chip:hover, .filter-chip[aria-selected="true"] { border-color: var(--forest); color: var(--surface); background: var(--forest); }
.search-box { display: flex; flex: 0 0 190px; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.edition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.edition-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease; }
.edition-card:hover { border-color: rgba(29, 91, 73, 0.4); box-shadow: var(--shadow); transform: translateY(-4px); }
.card-cover { position: relative; display: flex; min-height: 250px; flex-direction: column; justify-content: space-between; padding: 20px; overflow: hidden; color: #fff; background: var(--forest); }
.card-cover::before { position: absolute; width: 180px; height: 180px; border: 1px solid rgba(255,255,255,0.2); border-radius: 50%; content: ""; right: -60px; top: -60px; }
.card-cover::after { position: absolute; width: 120px; height: 120px; border: 1px solid rgba(255,255,255,0.16); border-radius: 50%; content: ""; right: -15px; top: -25px; }
.edition-card:nth-child(3n + 2) .card-cover { background: #354d47; }
.edition-card:nth-child(3n) .card-cover { background: #8c5637; }
.edition-card.special .card-cover { background: #5a526a; }
.cover-top, .cover-bottom, .cover-title { position: relative; z-index: 1; }
.cover-top { display: flex; align-items: center; justify-content: space-between; font-size: 10px; letter-spacing: 0.11em; text-transform: uppercase; }
.cover-type { opacity: 0.72; }
.cover-seal { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(255,255,255,0.55); border-radius: 50%; font-family: var(--serif); font-size: 16px; }
.cover-title { max-width: 230px; margin: auto 0; font-family: Georgia, serif; font-size: clamp(31px, 3vw, 45px); letter-spacing: -0.07em; line-height: 0.92; }
.cover-bottom { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.cover-edition { font-size: 11px; opacity: 0.8; }
.cover-date { font-family: var(--serif); font-size: 22px; line-height: 1; }
.card-info { padding: 18px 18px 16px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.card-publisher { color: var(--forest); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.card-name { margin: 7px 0 16px; font-size: 21px; font-weight: 600; letter-spacing: -0.04em; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; border: 1px solid transparent; border-radius: var(--radius); padding: 8px 13px; cursor: pointer; font-size: 12px; font-weight: 700; }
.button-primary { color: #fff; background: var(--forest); }
.button-primary:hover { background: var(--forest-dark); }
.button-secondary { color: var(--forest); border-color: var(--line); background: transparent; }
.button-secondary:hover { border-color: var(--forest); background: rgba(29, 91, 73, 0.05); }
.card-actions .button-primary { flex: 1; }
.status-banner { margin: 0 0 20px; border-left: 3px solid var(--amber); padding: 14px 16px; color: #78552d; background: rgba(194, 121, 53, 0.1); font-size: 13px; }
.empty-state { grid-column: 1 / -1; padding: 65px 20px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); font-family: var(--serif); font-size: 32px; font-weight: 400; }
.empty-state p { max-width: 400px; margin: 0 auto; }

.about-section { padding: 0 0 110px; }
.about-rule { height: 1px; background: var(--line); }
.about-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 40px; padding-top: 58px; }
.about-grid h2 { font-size: clamp(37px, 5vw, 65px); }
.about-copy { max-width: 510px; margin: 25px 0 0; color: var(--muted); font-size: 16px; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.footer-inner { min-height: 75px; }

.reader-overlay { position: fixed; inset: 0; z-index: 40; }
.reader-backdrop { position: absolute; inset: 0; background: rgba(15, 25, 22, 0.74); }
.reader-panel { position: relative; display: flex; width: min(1300px, calc(100% - 28px)); height: calc(100% - 28px); margin: 14px auto; flex-direction: column; overflow: hidden; border-radius: 6px; background: #ececec; box-shadow: 0 30px 90px rgba(0,0,0,0.3); }
.reader-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.reader-heading { display: flex; align-items: center; gap: 24px; min-width: 0; }
.back-button { gap: 8px; color: var(--forest); font-size: 12px; font-weight: 700; white-space: nowrap; }
.reader-kicker { margin: 0; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.reader-header h2 { margin-top: 2px; overflow: hidden; font-family: var(--serif); font-size: 26px; text-overflow: ellipsis; white-space: nowrap; }
.reader-actions { display: flex; align-items: center; gap: 10px; }
.reader-close { flex: 0 0 auto; }
.reader-body { position: relative; flex: 1; background: #353a38; }
#pdf-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.reader-empty { position: absolute; z-index: 1; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: #d8ddd9; background: #353a38; }
.reader-empty p { margin: 0; font-size: 13px; }
.loader { width: 26px; height: 26px; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: none; max-width: 320px; padding: 12px 15px; border-radius: 4px; color: #fff; background: var(--forest-dark); box-shadow: var(--shadow); font-size: 13px; }
.toast.visible { display: block; }

body.dark {
  --paper: #15201d;
  --paper-deep: #1b2925;
  --surface: #1d2a27;
  --ink: #f3efe6;
  --muted: #aeb8b1;
  --line: #34433e;
  --forest: #80c3a3;
  --forest-dark: #59977b;
  --amber: #dfa368;
}
body.dark .site-header { background: rgba(21, 32, 29, 0.9); }
body.dark .filter-chip[aria-selected="true"], body.dark .button-primary { color: #15201d; background: var(--forest); }
body.dark .card-cover { background: #254d40; }
body.dark .edition-card:nth-child(3n + 2) .card-cover { background: #3f5b52; }
body.dark .edition-card:nth-child(3n) .card-cover { background: #815943; }
body.dark .edition-card.special .card-cover { background: #625b70; }
body.dark .status-banner { color: #e5bf90; }

@media (max-width: 900px) {
  .edition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { gap: 35px; }
  .date-rail { grid-template-columns: repeat(5, minmax(75px, 1fr)); }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 32px, 560px); }
  .header-inner { min-height: 68px; }
  .brand-tagline, .header-nav .nav-link { display: none; }
  .hero { display: block; padding-top: 65px; padding-bottom: 68px; }
  h1 { font-size: clamp(55px, 17vw, 86px); }
  .hero-lede { font-size: 15px; }
  .hero-note { margin-top: 38px; }
  .section-heading-row, .library-toolbar { align-items: flex-start; flex-direction: column; }
  .date-picker { align-self: stretch; justify-content: center; }
  .date-rail-wrap { grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 5px; }
  .rail-button { width: 32px; height: 32px; }
  .date-rail { grid-template-columns: repeat(5, minmax(74px, 1fr)); gap: 4px; overflow: hidden; }
  .date-item { padding: 10px 3px; }
  .date-item:nth-child(1), .date-item:nth-child(5) { opacity: 0.45; }
  .date-number { font-size: 22px; }
  .filters { align-items: stretch; flex-direction: column; gap: 15px; }
  .search-box { flex-basis: auto; }
  .edition-grid { grid-template-columns: 1fr; }
  .card-cover { min-height: 230px; }
  .about-grid { display: block; }
  .about-grid > .eyebrow { margin-bottom: 30px; }
  .footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; gap: 5px; }
  .reader-panel { width: 100%; height: 100%; margin: 0; border-radius: 0; }
  .reader-header { align-items: flex-start; padding: 12px; }
  .reader-heading { align-items: flex-start; flex-direction: column-reverse; gap: 10px; }
  .reader-actions .button span:last-child { display: none; }
  .reader-actions .button { width: 38px; padding: 0; }
  .reader-close { width: 38px; }
}

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