:root {
  color-scheme: light;
  --paper: #fffaf2;
  --ink: #241f1b;
  --muted: #72675d;
  --line: #ddd2c4;
  --button: #ffffff;
  --button-hover: #f4eadb;
  --button-read: #d8cdbf;
  --accent: #b84632;
  --modal-bg: rgba(14, 12, 10, 0.88);
  --shadow: 0 14px 38px rgba(30, 24, 18, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
}

.site-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 40px 18px 64px;
}

.site-header {
  text-align: center;
  margin-bottom: 34px;
}

.series-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1.1;
}

.episode-section h2 {
  margin: 0 0 18px;
  text-align: center;
  font-size: 1rem;
  color: var(--muted);
}

.episode-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.episode-button {
  width: min(100%, 420px);
  min-height: 50px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.episode-button:hover,
.episode-button:focus-visible {
  background: var(--button-hover);
  border-color: #c7ad98;
  transform: translateY(-1px);
}

.episode-button.read {
  background: var(--button-read);
  color: #5d534a;
  box-shadow: none;
}

.load-message {
  margin: 20px 0 0;
  text-align: center;
  color: var(--muted);
}

.load-message:empty {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--modal-bg);
}

.hidden {
  display: none;
}

.modal-header,
.modal-nav {
  z-index: 2;
  background: rgba(255, 250, 242, 0.96);
  border-color: rgba(36, 31, 27, 0.14);
  backdrop-filter: blur(10px);
}

.modal-header {
  position: relative;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 64px;
  border-bottom: 1px solid;
}

.modal-header h2 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.icon-button,
.nav-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.close-button {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 40px;
  height: 40px;
  font-size: 1.7rem;
  line-height: 1;
}

.comic-scroller {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 0;
}

.comic-pages {
  width: min(100%, 600px);
  margin: 0 auto;
}

.comic-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 14px;
  background: #fff;
}

.comic-page:last-child {
  margin-bottom: 0;
}

.modal-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
  border-top: 1px solid;
}

.nav-button {
  min-height: 46px;
  font-weight: 700;
}

.nav-button:disabled {
  opacity: 0.38;
  cursor: default;
}

@media (max-width: 560px) {
  .site-shell {
    padding-top: 28px;
  }

  .modal-header {
    min-height: 52px;
    padding-inline: 56px;
  }

  .comic-scroller {
    padding-block: 8px;
  }

  .comic-page {
    margin-bottom: 8px;
  }
}
