* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --story-bg: #F5ECD9;
  --story-paper: #FBF4E2;
  --story-paper-dark: #EEDFC0;
  --story-ink: #2A1F18;
  --story-ink-soft: #7A6650;
  --story-line: #C9B997;
  --story-orange: #D9612C;
  --story-orange-soft: #F2C5A0;
  --story-teal: #5E8A86;
  --story-teal-soft: #B5D1CC;
  --story-red: #B23A30;
  --story-red-soft: #E6B5B0;
  --story-mustard: #D9A23D;
  --story-mustard-soft: #F0D58A;
  --story-shadow: 1.5px 2px 0 var(--story-ink);
  --story-shadow-strong: 2px 3px 0 var(--story-ink);
}

html {
  background: var(--story-bg);
}

body {
  min-height: 100vh;
  color: var(--story-ink);
  font-family: Lora, Georgia, serif;
  background-color: var(--story-bg);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(42,31,24,0.018) 22px 23px),
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(42,31,24,0.018) 26px 27px);
}

button {
  color: inherit;
  font: inherit;
}

button,
a,
.resource-card {
  -webkit-tap-highlight-color: transparent;
}

button:active,
.resource-card:active {
  transform: translate(1px, 1px);
  box-shadow: 0.5px 1px 0 var(--story-ink);
}

.site-header,
main,
.site-footer {
  width: min(100%, 520px);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--story-paper);
  padding: 12px 18px 14px;
  border-bottom: 1.5px solid var(--story-ink);
  box-shadow: var(--story-shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-hoot {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.brand {
  color: var(--story-ink);
  font-family: Caveat, cursive;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.tagline {
  color: var(--story-ink-soft);
  font-size: 12px;
  font-style: italic;
  margin-top: 3px;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.nav-btn,
.mode-btn,
.chip,
.text-btn,
.back-btn,
.resource-action,
.primary-btn,
.secondary-btn,
.play-all-btn,
.mic-button,
.replay-button,
.card-icon,
.reader-pager button,
.reader-action-prompt,
.reader-links a {
  border: 1.5px solid var(--story-ink);
  box-shadow: var(--story-shadow);
  cursor: pointer;
}

.nav-btn,
.mode-btn {
  border-radius: 999px;
  background: var(--story-paper);
  color: var(--story-ink);
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 0;
}

.nav-btn.active,
.mode-btn.active,
.chip.active {
  background: var(--story-ink);
  color: var(--story-paper);
  box-shadow: none;
}

.reader-open .site-header {
  padding: 10px 18px;
}

.reader-open .tagline,
.reader-open .nav-tabs {
  display: none;
}

.reader-open .brand-hoot {
  width: 34px;
  height: 34px;
}

.reader-open .brand {
  font-size: 24px;
}

main {
  min-height: calc(100vh - 116px);
  padding-bottom: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-intro,
.page-heading {
  background: transparent;
  padding: 22px 18px 8px;
}

.home-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.home-hoot {
  width: 78px;
  height: 78px;
  flex: 0 0 auto;
  filter: drop-shadow(1.5px 2px 0 var(--story-ink));
}

.eyebrow,
.section-kicker {
  color: var(--story-orange);
  font-family: Caveat, cursive;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
}

.home-intro h1,
.page-heading h1 {
  color: var(--story-ink);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.05;
  margin-top: 6px;
}

.home-intro p:not(.eyebrow),
.page-heading p,
.resource-card p,
.about-card p,
.coming-detail p {
  color: var(--story-ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.home-intro p:not(.eyebrow) {
  margin-top: 7px;
}

.story-wave {
  display: block;
  width: calc(100% - 36px);
  height: 14px;
  margin: 2px 18px 6px;
}

.story-wave path {
  fill: none;
  stroke: var(--story-ink);
  stroke-width: 1.4;
  opacity: .45;
}

.section-block,
.filter-panel,
.about-card,
.coming-detail,
.empty-state {
  margin: 16px 18px 0;
  background: var(--story-paper);
  border: 1.5px solid var(--story-ink);
  border-radius: 18px;
  box-shadow: var(--story-shadow);
}

.section-block,
.filter-panel,
.about-card,
.coming-detail,
.empty-state {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-kicker {
  color: var(--story-teal);
  font-size: 18px;
  margin-bottom: 2px;
}

.section-title h2,
.about-card h2 {
  color: var(--story-ink);
  font-size: 22px;
  line-height: 1.1;
}

.text-btn {
  background: var(--story-paper);
  color: var(--story-ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-family: Caveat, cursive;
  font-size: 18px;
  white-space: nowrap;
}

.resource-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#library-resource-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 14px 18px 0;
}

.resource-card {
  min-height: 108px;
  display: grid;
  grid-template-columns: 76px 1fr 44px;
  gap: 12px;
  align-items: center;
  background: var(--story-paper);
  border: 1.5px solid var(--story-ink);
  border-radius: 18px;
  box-shadow: var(--story-shadow);
  padding: 12px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.resource-card:hover {
  transform: translate(0, -1px);
  box-shadow: 2px 4px 0 var(--story-ink);
}

.resource-cover {
  width: 76px;
  height: 76px;
  border-radius: 16px;
  border: 1.5px solid var(--story-ink);
  box-shadow: 1px 1.5px 0 var(--story-ink);
  background: var(--story-orange-soft);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--story-ink);
  font-size: 34px;
}

.resource-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.accent-teal .resource-cover { background: var(--story-teal-soft); }
.accent-red .resource-cover { background: var(--story-red-soft); }
.accent-mustard .resource-cover { background: var(--story-mustard-soft); }

.resource-main {
  min-width: 0;
}

.resource-title {
  color: var(--story-ink);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.12;
  margin-top: 4px;
}

.resource-subtitle {
  color: var(--story-orange);
  font-family: Caveat, cursive;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.accent-teal .resource-subtitle { color: var(--story-teal); }
.accent-red .resource-subtitle { color: var(--story-red); }
.accent-mustard .resource-subtitle { color: var(--story-mustard); }

.resource-card p {
  display: -webkit-box;
  margin-top: 6px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.meta-row span {
  color: var(--story-ink-soft);
  font-size: 11px;
  font-style: italic;
}

.resource-action {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--story-orange);
  color: var(--story-paper);
  display: flex;
  align-items: center;
  justify-content: center;
}

.resource-action span {
  transform: translateX(1px);
  font-size: 15px;
  line-height: 1;
}

.accent-teal .resource-action { background: var(--story-teal); }
.accent-red .resource-action { background: var(--story-red); }
.accent-mustard .resource-action {
  background: var(--story-mustard);
  color: var(--story-ink);
}

.resource-card.coming-soon .resource-action,
.resource-action:disabled {
  background: var(--story-line);
  color: var(--story-ink-soft);
}

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-label {
  color: var(--story-ink);
  font-family: Caveat, cursive;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--story-paper);
  color: var(--story-ink);
  padding: 7px 11px;
  border-radius: 999px;
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  color: var(--story-ink-soft);
  text-align: center;
}

.reader-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  padding: 14px 18px 8px;
}

.back-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: var(--story-paper);
  color: var(--story-ink);
  font-family: Georgia, serif;
  font-size: 28px;
  line-height: 1;
  flex: 0 0 auto;
}

.book-title {
  color: var(--story-ink);
  font-family: Caveat, cursive;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.book-meta {
  color: var(--story-ink-soft);
  font-size: 12px;
  font-style: italic;
  margin-top: 3px;
}

.mode-bar {
  display: flex;
  gap: 8px;
  background: transparent;
  padding: 8px 18px;
}

.mode-btn {
  flex: 1;
}

#video-area {
  margin: 12px 18px 0;
  border: 1.5px solid var(--story-ink);
  border-radius: 18px;
  box-shadow: var(--story-shadow);
  overflow: hidden;
  background: var(--story-ink);
}

#video-area video {
  display: block;
  width: 100%;
}

#sentences-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 18px 18px;
}

.reader-page {
  background: var(--story-paper);
  border: 1.5px solid var(--story-ink);
  border-radius: 22px;
  box-shadow: var(--story-shadow-strong);
  overflow: visible;
}

.reader-stage-label {
  color: var(--story-orange);
  font-family: Caveat, cursive;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 12px 12px 0;
}

.reader-image-wrap {
  margin: 10px 12px 0;
  padding: 12px;
  border: 1.5px solid var(--story-ink);
  border-radius: 18px;
  box-shadow: 1px 1.5px 0 var(--story-ink);
  background-color: var(--story-paper-dark);
  background-image: repeating-linear-gradient(45deg, transparent 0 8px, rgba(42,31,24,0.04) 8px 9px);
}

.reader-image-wrap img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--story-paper);
  transition: transform 220ms cubic-bezier(.34,1.56,.64,1);
}

.reader-page-label {
  display: inline-flex;
  margin: 12px 14px 0;
  padding: 5px 10px;
  background: var(--story-paper);
  color: var(--story-ink);
  border: 1.2px solid var(--story-ink);
  border-radius: 999px;
  box-shadow: 1px 1.5px 0 var(--story-ink);
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
}

.reader-action-prompt {
  min-height: 48px;
  margin: 10px 12px 0;
  border-radius: 16px;
  background: var(--story-mustard-soft);
  color: var(--story-ink);
  font-family: Caveat, cursive;
  font-size: 21px;
  font-weight: 700;
}

.reader-page-sentences {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.sentence-card {
  display: block;
  background: var(--story-paper);
  border: 1.5px solid var(--story-ink);
  border-radius: 18px;
  box-shadow: var(--story-shadow);
  padding: 13px;
  user-select: none;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.sentence-card.playing {
  background: var(--story-orange-soft);
}

.sentence-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}

.card-icon {
  width: 62px;
  min-width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 50%;
  background: var(--story-orange);
  color: var(--story-paper);
  font-family: Caveat, cursive;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.sentence-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.sentence-prompt {
  color: var(--story-teal);
  font-family: Caveat, cursive;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.card-en {
  color: var(--story-ink);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.22;
}

.practice-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--story-line);
}

.practice-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mic-button,
.replay-button {
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 16px;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 700;
}

.mic-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--story-teal);
  color: var(--story-paper);
}

.mic-button.recording {
  background: var(--story-red);
}

.mic-button.requesting {
  background: var(--story-mustard);
  color: var(--story-ink);
}

.mic-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(251,244,226,0.2);
  line-height: 1;
}

.replay-button {
  background: var(--story-paper);
  color: var(--story-ink);
}

.practice-actions button:disabled {
  opacity: .45;
  cursor: default;
}

.recording-player {
  width: 100%;
  margin-top: 10px;
}

.practice-feedback,
.practice-notice,
.temporary-notice {
  color: var(--story-ink-soft);
  background: var(--story-paper-dark);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.practice-feedback {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 16px;
  font-weight: 700;
}

.practice-feedback.perfect,
.practice-feedback.well,
.practice-feedback.good {
  color: var(--story-ink);
  background: var(--story-teal-soft);
}

.practice-feedback.retry {
  color: var(--story-ink);
  background: var(--story-red-soft);
}

.practice-notice {
  margin: 0 12px 12px;
  padding: 7px 9px;
}

.temporary-notice {
  padding: 0 8px 4px;
  background: transparent;
}

.reader-pager {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  gap: 12px;
  align-items: center;
}

.reader-pager button {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--story-orange);
  color: var(--story-paper);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.reader-pager button:disabled {
  background: var(--story-paper-dark);
  color: var(--story-ink-soft);
}

.reader-pager span {
  color: var(--story-ink);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.reader-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.reader-dots span {
  width: 9px;
  height: 9px;
  border: 1.2px solid var(--story-ink);
  border-radius: 999px;
  background: var(--story-paper);
  transition: width 180ms ease, background 180ms ease;
}

.reader-dots span.active {
  width: 24px;
  background: var(--story-orange);
}

.reader-swipe-hint {
  color: var(--story-ink-soft);
  font-family: Caveat, cursive;
  font-size: 17px;
  text-align: center;
}

.reader-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.reader-links a {
  display: block;
  padding: 11px 10px;
  border-radius: 16px;
  background: var(--story-paper);
  color: var(--story-ink);
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

#auto-bar {
  display: flex;
  justify-content: center;
  padding: 8px 18px 28px;
}

.play-all-btn,
.primary-btn,
.secondary-btn {
  border-radius: 18px;
  padding: 12px 18px;
  font-weight: 700;
}

.play-all-btn,
.primary-btn {
  background: var(--story-orange);
  color: var(--story-paper);
  box-shadow: var(--story-shadow-strong);
}

.secondary-btn {
  background: var(--story-paper);
  color: var(--story-ink);
}

.coming-label {
  display: inline-block;
  background: var(--story-paper-dark);
  color: var(--story-ink);
  border: 1.2px solid var(--story-ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.coming-detail h2 {
  color: var(--story-ink);
  font-size: 22px;
  margin-top: 12px;
}

.coming-detail p {
  margin-top: 8px;
}

.coming-grid {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.coming-grid span {
  background: var(--story-paper-dark);
  color: var(--story-ink);
  border: 1.2px solid var(--story-ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.contact-card {
  margin-bottom: 24px;
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.contact-item {
  border: 1.5px solid var(--story-ink);
  border-radius: 16px;
  box-shadow: var(--story-shadow);
  padding: 14px;
  background: var(--story-paper);
}

.contact-label {
  color: var(--story-ink-soft);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.contact-item a {
  color: var(--story-ink);
  font-size: 16px;
  font-weight: 700;
  word-break: break-all;
}

.qr-item {
  text-align: center;
}

.qr-item img {
  display: block;
  width: 150px;
  height: 150px;
  object-fit: contain;
  margin: 0 auto 8px;
  border: 1.5px solid var(--story-ink);
  border-radius: 12px;
  box-shadow: var(--story-shadow);
  background: var(--story-paper);
}

.qr-item span,
.site-footer,
.site-footer a {
  color: var(--story-ink-soft);
}

.site-footer {
  padding: 0 16px 26px;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.site-footer a {
  text-decoration: none;
}

@media (max-width: 560px) {
  .site-header,
  main,
  .site-footer {
    width: 100%;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .qr-item {
    text-align: left;
  }

  .qr-item img {
    width: 170px;
    height: 170px;
    margin-left: 0;
  }

  #sentences-container {
    padding: 10px 12px 16px;
    gap: 12px;
  }

  .reader-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .reader-image-wrap {
    padding: 9px;
  }

  .reader-image-wrap img {
    max-height: clamp(170px, 33vh, 270px);
  }

  .sentence-card {
    padding: 12px;
  }

  .card-icon {
    width: 58px;
    min-width: 58px;
    height: 58px;
    font-size: 17px;
  }

  .card-en {
    font-size: clamp(20px, 6vw, 25px);
  }
}

@media (min-width: 860px) {
  .site-header {
    position: fixed;
    left: calc(50% - 620px);
    top: 24px;
    width: 240px;
    min-height: calc(100vh - 48px);
    border: 1.5px solid var(--story-ink);
    border-radius: 22px;
    padding: 18px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-hoot {
    width: 48px;
    height: 48px;
  }

  .nav-tabs {
    display: flex;
    flex-direction: column;
    margin-top: 22px;
  }

  .nav-btn {
    text-align: left;
    padding: 12px 14px;
  }

  main,
  .site-footer {
    width: min(920px, calc(100% - 320px));
    margin-left: max(300px, calc(50% - 340px));
    margin-right: auto;
  }

  .home-intro h1,
  .page-heading h1 {
    font-size: 42px;
  }

  .home-hoot {
    width: 96px;
    height: 96px;
  }

  .resource-list,
  #library-resource-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #home-resource-list {
    grid-template-columns: 1fr;
  }

  .reader-open .site-header {
    padding: 18px;
  }

  .reader-open .tagline {
    display: block;
  }

  .reader-open .nav-tabs {
    display: flex;
  }

  .reader-open .brand {
    font-size: 28px;
  }

  .reader-open .brand-hoot {
    width: 48px;
    height: 48px;
  }

  .reader-image-wrap img {
    max-height: 380px;
  }
}
