:root {
  --bg: #fbf7f0;
  --surface: #fffdf8;
  --card: #ffffff;
  --text: #24313a;
  --muted: #5f6870;
  --accent: #a94f5d;
  --accent-2: #f1b84b;
  --accent-3: #2f7f88;
  --ink: #1f2933;
  --border: rgba(36, 49, 58, 0.14);
  --shadow: 0 16px 36px rgba(36, 49, 58, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbf7f0 0%, #f3f8f8 48%, #fffdf8 100%);
  line-height: 1.6;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 4px;
}

.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  font-size: 1.35rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

nav a {
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

nav a:hover {
  background: rgba(47, 127, 136, 0.10);
  color: var(--ink);
}

.private-link {
  color: #8a3d4b;
  background: rgba(183, 93, 105, 0.10);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 36px;
  align-items: center;
  padding: 56px 0 40px;
}

.eyebrow {
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: uppercase;
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(2.35rem, 6vw, 4.7rem);
  line-height: 1.02;
  margin: 0 0 24px;
}

h2 {
  margin-top: 0;
  line-height: 1.2;
}

.hero-copy > p:not(.eyebrow),
.lead {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 680px;
}

.hero-media {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--surface);
}

.hero-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 13px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.button:hover {
  background: #111827;
}

.button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.button.secondary:hover {
  background: #ffffff;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 32px 0;
}

.card,
.welcome-note,
.warning {
  background: rgba(255, 255, 255, 0.90);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 24px;
}

.feature-card {
  display: block;
  text-decoration: none;
  min-height: 188px;
}

.feature-card:hover {
  border-color: rgba(47, 127, 136, 0.38);
  transform: translateY(-2px);
}

.card p,
.welcome-note p,
.warning p {
  color: var(--muted);
}

.welcome-note {
  border-left: 6px solid var(--accent-2);
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-3);
  font-weight: 800;
  text-underline-offset: 4px;
}

.text-link:hover {
  color: var(--ink);
}

.page {
  padding-top: 44px;
}

.warning {
  border-left: 6px solid var(--accent);
}

.warning .eyebrow {
  color: var(--accent);
}

.timeline {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 16px;
}

.timeline li {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  gap: 18px;
  align-items: center;
}

.timeline strong {
  background: var(--accent-2);
  border-radius: 8px;
  min-width: 44px;
  text-align: center;
  padding: 8px 14px;
}

.gallery-placeholder {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.gallery-placeholder article {
  min-height: 180px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(183, 93, 105, 0.22), rgba(47, 127, 136, 0.22)),
    white;
  border: 1px dashed rgba(47, 42, 53, 0.22);
  padding: 24px;
}

.gallery-placeholder p {
  color: var(--muted);
}

footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px;
  color: var(--muted);
}

.library-page {
  padding-bottom: 64px;
}

.library-page h1 {
  font-size: clamp(2.7rem, 7vw, 5rem);
}

.book-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.book-cover {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f4eee5;
}

.book-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(0.96);
  transition: transform 180ms ease;
}

.book-card:hover .book-cover img {
  transform: scale(1.025);
}

.book-level {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
}

.book-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 22px;
  border-top: 6px solid var(--accent);
}

.book-button {
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
}

.story-library {
  margin: 38px 0 34px;
}

.story-library__heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.story-library__heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.story-count {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(420px, 1.25fr);
  gap: 22px;
  margin: 30px 0;
  padding: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.library-search label,
.level-filter legend {
  display: block;
  margin-bottom: 9px;
  font-weight: 800;
}

.library-search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  font: inherit;
}

.library-search input:focus,
.level-filter__options label:has(input:focus-visible) {
  outline: 3px solid rgba(47, 127, 136, 0.3);
  outline-offset: 2px;
}

.level-filter {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.level-filter__options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.level-filter__options label {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-weight: 750;
  text-align: center;
  cursor: pointer;
}

.level-filter__options label:has(input:checked) {
  color: white;
  background: var(--ink);
  border-color: var(--ink);
}

.level-filter__options input {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.story-card .book-cover {
  aspect-ratio: 4 / 3;
}

.story-card .book-card__body {
  padding: 18px;
  border-top-color: var(--accent-3);
}

.story-card .book-card__body h3 {
  margin: 0 0 18px;
  font-size: 1.16rem;
  line-height: 1.3;
}

.story-card .book-button {
  padding-inline: 14px;
}

.story-empty {
  padding: 42px 0;
  color: var(--muted);
  text-align: center;
}

.load-more {
  margin: 28px auto 0;
}

.reader-body {
  min-height: 100vh;
  background: #f5f1e9;
}

.reader-header {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reader-back {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.reader-back:hover {
  color: var(--ink);
}

.reader {
  width: min(1180px, calc(100% - 32px));
  max-width: none;
  padding: 22px 0 56px;
}

.reader-title {
  margin-bottom: 20px;
}

.reader-title h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.reader-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  min-height: 560px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.reader-picture {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 22px;
  background: #f8f6f1;
}

.reader-picture img {
  display: block;
  width: 100%;
  height: min(66vh, 660px);
  object-fit: contain;
}

.reader-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px);
  border-left: 1px solid var(--border);
}

.reader-page-number {
  margin: 0 0 22px;
  color: var(--accent-3);
  font-weight: 800;
}

.reader-text {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  font-weight: 650;
  line-height: 1.42;
}

.reader-controls {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px 0 10px;
}

.reader-button {
  min-width: 132px;
  min-height: 50px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.reader-button--next {
  color: #ffffff;
  background: var(--ink);
}

.reader-button:hover:not(:disabled) {
  border-color: var(--accent-3);
}

.reader-button--next:hover:not(:disabled) {
  background: #111827;
}

.reader-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.reader-progress {
  height: 8px;
  overflow: hidden;
  background: rgba(36, 49, 58, 0.12);
  border-radius: 4px;
}

.reader-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent-3);
  transition: width 180ms ease;
}

.reader-status {
  min-height: 26px;
  margin: 0;
  text-align: center;
  color: var(--accent);
  font-weight: 800;
}

.book-credits {
  margin-top: 22px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.book-credits summary {
  min-height: 36px;
  font-weight: 800;
  cursor: pointer;
}

.book-credits dl {
  display: grid;
  gap: 9px;
}

.book-credits dl div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
}

.book-credits dt {
  font-weight: 800;
}

.book-credits dd {
  margin: 0;
  color: var(--muted);
}

.book-credits dd a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}

.book-credits p {
  color: var(--muted);
}

.reader-header .brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}

.reader-error {
  padding: 48px 0;
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    width: 100%;
  }

  nav a {
    padding-left: 0;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 32px;
  }

  .cards,
  .gallery-placeholder {
    grid-template-columns: 1fr;
  }

  .story-library__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .library-tools {
    grid-template-columns: 1fr;
  }

  .level-filter__options {
    grid-template-columns: 1fr 1fr;
  }

  .story-grid {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: clamp(2.1rem, 14vw, 3.4rem);
  }

  .book-card {
    display: flex;
  }

  .book-card__body {
    padding: 18px;
    border-top: 6px solid var(--accent-3);
  }

  .reader-stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .reader-picture {
    padding: 14px;
  }

  .reader-picture img {
    height: auto;
    max-height: 52vh;
    aspect-ratio: 1 / 1;
  }

  .reader-copy {
    min-height: 210px;
    padding: 24px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .reader-text {
    font-size: clamp(1.25rem, 6vw, 1.7rem);
  }

  .reader-controls {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .reader-progress {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .reader-button {
    min-width: 0;
  }

  .book-credits dl div {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.reader-stage--text-only {
  grid-template-columns: 1fr;
  min-height: 360px;
}

.reader-stage--text-only .reader-copy {
  border-left: 0;
}

@media (max-width: 440px) {
  .story-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
