:root {
  color-scheme: dark;
  --ink: #161411;
  --paper: #f4eddf;
  --muted: #aaa092;
  --rule: rgba(244, 237, 223, 0.17);
  --accent: #f2c54f;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #343029 0, transparent 38rem), var(--ink);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; }
button { cursor: pointer; }

.catalog-shell {
  width: min(100%, 1200px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.catalog-status { color: var(--muted); font-size: 0.85rem; }
.catalog-intro { max-width: 42rem; padding: clamp(3rem, 10vw, 7rem) 0 2rem; }
.catalog-intro h1 { margin: 0.25rem 0 0.75rem; font-size: clamp(2.4rem, 8vw, 5.5rem); letter-spacing: -0.06em; }
.catalog-intro > p:last-child { color: var(--muted); font-size: 1.1rem; line-height: 1.5; }

.comic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1.25rem; }
.comic-card { overflow: hidden; border: 1px solid var(--rule); border-radius: 0.65rem; background: rgba(244, 237, 223, 0.04); }
.comic-cover { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; border-bottom: 1px solid var(--rule); }
.comic-card-body { padding: 1.25rem; }
.comic-card h2 { margin: 0.2rem 0 0.6rem; letter-spacing: 0.04em; }
.comic-card-body > p:not(.eyebrow) { color: var(--muted); margin: 0 0 1.25rem; }
.comic-card .start-button { display: inline-block; text-decoration: none; }

.reader-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.reader-header, .reader-footer {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.reader-header { border-bottom: 1px solid var(--rule); }

.wordmark {
  color: var(--paper);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.chapter-meta, #page-count { color: var(--muted); font-size: 0.84rem; }
.chapter-meta { display: flex; gap: 0.45rem; }
.header-actions { display: flex; gap: 0.45rem; margin-left: auto; }

.icon-button, .text-button, .start-button, .page-jump select {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--paper);
  border-radius: 0.35rem;
  padding: 0.45rem 0.7rem;
}

.icon-button:hover, .text-button:hover, .page-jump select:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reader-stage {
  position: relative;
  width: min(100%, 1400px);
  min-height: 0;
  margin: 0 auto;
  padding: 1.1rem clamp(0.5rem, 5vw, 5rem);
  display: grid;
  place-items: center;
}

.page-frame {
  max-width: 100%;
  max-height: calc(100vh - 11rem);
  margin: 0;
  position: relative;
  filter: drop-shadow(0 1rem 2rem rgba(0, 0, 0, 0.55));
}

#comic-page {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 11rem);
  width: auto;
  height: auto;
  border: 1px solid rgba(244, 237, 223, 0.32);
  user-select: none;
}

#page-caption, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.page-nav {
  position: absolute;
  z-index: 1;
  top: 50%;
  width: 3.25rem;
  height: 5rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: rgba(244, 237, 223, 0.75);
  font-size: 2.1rem;
}

.page-nav:hover, .page-nav:focus-visible { color: var(--accent); }
.previous { left: 0.2rem; }
.next { right: 0.2rem; }

.reader-footer { justify-content: center; border-top: 1px solid var(--rule); }
.page-jump select { min-width: 6rem; }

.start-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #211b0f;
  font-weight: 800;
}

dialog {
  max-width: 34rem;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  padding: 2rem;
  background: #211e1a;
  color: var(--paper);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.65);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.68); }
dialog h1 { margin: 0.15rem 0 0.7rem; letter-spacing: 0.05em; }
dialog p { line-height: 1.55; }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reader-shell.focus .reader-header, .reader-shell.focus .reader-footer {
  opacity: 0;
  pointer-events: none;
}

.reader-shell.focus { grid-template-rows: 0 minmax(0, 1fr) 0; }
.reader-shell.focus .page-frame, .reader-shell.focus #comic-page { max-height: calc(100vh - 1rem); }

@media (max-width: 650px) {
  .chapter-meta { display: none; }
  .icon-button { font-size: 0.8rem; padding: 0.4rem 0.5rem; }
  .page-nav { width: 2.5rem; height: 4rem; font-size: 1.7rem; }
  .reader-footer { gap: 0.45rem; }
}
