:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: #16171b;
  --panel-alt: #1e2026;
  --text: #f7f4ea;
  --muted: #b8b2a5;
  --accent: #d7a03f;
  --accent-strong: #efbb61;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(215, 160, 63, 0.16), transparent 28%),
    linear-gradient(180deg, #101114 0%, #09090b 100%);
  color: var(--text);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: 10px 10px 16px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, 460px);
}

.top-bar {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.top-bar h1 {
  margin: 0;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.top-bar-spacer {
  min-height: 1px;
}

.nav-button,
.primary-button,
.secondary-button,
.mode-card {
  border-radius: 20px;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.nav-button:hover,
.primary-button:hover,
.secondary-button:hover,
.mode-card:hover {
  transform: translateY(-1px);
}

.nav-button {
  padding: 10px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.panel {
  background: rgba(21, 22, 27, 0.92);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.mode-selection {
  padding: 18px;
}

.hero-card {
  overflow: hidden;
  border-radius: 24px;
  background: #000;
  aspect-ratio: 3 / 4;
}

.hero-card img,
.story-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.intro {
  padding: 22px 8px 8px;
  text-align: center;
}

.intro h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.intro p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.mode-actions {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  text-align: left;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(215, 160, 63, 0.14);
  font-size: 1.5rem;
}

.mode-copy {
  display: grid;
  gap: 4px;
}

.mode-copy strong {
  font-size: 1.1rem;
}

.mode-copy span {
  color: var(--muted);
  line-height: 1.35;
}

.story-stage {
  position: relative;
  background: #000;
  aspect-ratio: 3 / 4;
}

.caption-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
  line-height: 1.4;
  font-size: 1.05rem;
}

.controls {
  padding: 10px 12px 12px;
  background: linear-gradient(180deg, rgba(16, 17, 20, 0.96), rgba(26, 28, 33, 0.98));
}

.controls-layout {
  display: grid;
  gap: 10px;
}

.button-row {
  display: grid;
  gap: 8px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-nav {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 14px 16px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #1b1305;
}

.secondary-button {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.page-indicator {
  min-width: 92px;
  text-align: center;
  color: var(--text);
  font-weight: 700;
}

.listening-caption {
  padding: 16px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.6);
  text-align: center;
  line-height: 1.4;
  min-height: 74px;
}

.slider-group {
  display: grid;
  gap: 8px;
}

#timeline-slider {
  width: 100%;
  accent-color: var(--accent-strong);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.error-box {
  margin: 16px 16px 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(189, 59, 59, 0.18);
  border: 1px solid rgba(189, 59, 59, 0.28);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

@media (max-width: 480px) {
  body {
    padding: 6px 8px 12px;
  }

  .top-bar {
    grid-template-columns: 68px 1fr 68px;
  }

  .top-bar h1 {
    font-size: 1rem;
  }

  .page-nav,
  .two-up {
    grid-template-columns: 1fr;
  }

  .page-indicator {
    min-width: 0;
  }
}
