/* ==========================================================================
   OneFable (วันเล่านิทาน) — Pastel Cloth-Book Minimal Stylesheet (v1.1)
   จัดระยะแท็บหัวแอป 760px, ภาพประกอบสีพาสเทลประจำเรื่อง & 7 เสียงบรรยากาศ
   ========================================================================== */

:root {
  /* โทนสีกระดาษถนอมสายตา (Warm Cream Cloth Paper) */
  --bg-app: #F7F3EB;
  --bg-paper: #FDFBF7;
  --bg-card: #FFFFFF;
  --bg-subtle: #F3EDE2;
  --border-soft: #E6DDD0;
  --border-strong: #D5C7B4;

  /* สีตัวอักษรคมชัด สบายตา */
  --ink-primary: #2B2825;
  --ink-secondary: #686058;
  --ink-muted: #93897E;
  --ink-en: #2D3A4B;
  --ink-zh: #262422;
  --ink-pinyin: #B85C4F;
  --ink-th: #453F3A;

  /* สีไฮไลต์พาสเทลอบอุ่น */
  --accent-coral: #E07A68;
  --accent-coral-soft: #FCE8E4;
  --accent-sage: #5A9378;
  --accent-sage-soft: #E1F2EA;
  --accent-gold: #D49B35;
  --accent-gold-soft: #FDF3DC;
  --accent-lavender: #7C6BB0;
  --accent-lavender-soft: #ECE8F8;

  /* สีไฮไลต์ตอนจิ้มคำและคาราโอเกะ */
  --word-hover-bg: #F5EFE4;
  --word-active-bg: #FFE3B8;
  --word-active-border: #E5A94E;
  --sentence-reading-bg: rgba(255, 232, 189, 0.42);

  /* มิติแสงเงาและรัศมีมุม */
  --shadow-sm: 0 2px 8px rgba(66, 52, 38, 0.06);
  --shadow-md: 0 8px 24px rgba(66, 52, 38, 0.09);
  --shadow-popup: 0 14px 36px rgba(40, 32, 24, 0.20);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* ฟอนต์ระบบ 3 ภาษา */
  --font-ui: 'Sarabun', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-en: 'Nunito', 'Sarabun', -apple-system, sans-serif;
  --font-zh: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-th: 'Sarabun', 'Noto Sans Thai', Tahoma, sans-serif;

  /* ระยะปลอดภัยมือถือ */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* โหมดกลางคืนถนอมสายตา (#151824) */
[data-theme="dark"] {
  --bg-app: #10131D;
  --bg-paper: #151824;
  --bg-card: #1D2132;
  --bg-subtle: #252A3F;
  --border-soft: #2E344D;
  --border-strong: #3E4666;

  --ink-primary: #F2EFE9;
  --ink-secondary: #B5BDD6;
  --ink-muted: #7F88A6;
  --ink-en: #E8ECF8;
  --ink-zh: #F6F3EC;
  --ink-pinyin: #F4A394;
  --ink-th: #CBD2E6;

  --accent-coral: #F08C7B;
  --accent-coral-soft: #382529;
  --accent-sage: #73B898;
  --accent-sage-soft: #1F352E;
  --accent-gold: #ECC060;
  --accent-gold-soft: #352D1E;
  --accent-lavender: #A594DC;
  --accent-lavender-soft: #292540;

  --word-hover-bg: #252B42;
  --word-active-bg: #463822;
  --word-active-border: #E6B455;
  --sentence-reading-bg: rgba(236, 192, 96, 0.14);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.42);
  --shadow-popup: 0 16px 40px rgba(0, 0, 0, 0.65);
}

/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  background-color: var(--bg-app);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* ==================== BEDTIME ACTIVE TOP STRIP ==================== */
.bedtime-active-bar {
  position: sticky;
  top: 0;
  z-index: 95;
  width: 100%;
  background: linear-gradient(90deg, #2D2A4A, #3E355F);
  color: #F6F2FF;
  font-size: 0.86rem;
}

.bedtime-bar-inner {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(6px + var(--safe-top)) 14px 6px;
}

.bedtime-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#bedtime-bar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bedtime-pulse-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #F9D67A;
  box-shadow: 0 0 8px #F9D67A;
  animation: softPulse 2s infinite ease-in-out;
}

@keyframes softPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.bedtime-bar-btn {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ==================== STICKY HEADER (ALIGNED TO 760PX CONTENT COLUMN) ==================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  width: 100%;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
}

.brand-logo-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  text-align: left;
}

.brand-book-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent-coral-soft);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  border: 1px solid rgba(224, 122, 104, 0.28);
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-family: var(--font-en);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.74rem;
  color: var(--ink-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease;
}

.lang-pill-btn:active {
  transform: scale(0.96);
}

.pill-caret {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.pro-pill-btn {
  padding: 7px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-gold-soft);
  border: 1px solid rgba(212, 155, 53, 0.42);
  color: var(--ink-primary);
  font-size: 0.8rem;
  font-weight: 700;
}

.pro-pill-btn.is-unlocked {
  background: var(--accent-sage-soft);
  border-color: rgba(90, 147, 120, 0.45);
  color: var(--accent-sage);
}

/* ==================== MAIN CONTAINER & VIEWS ==================== */
.app-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px calc(92px + var(--safe-bottom));
}

.app-main.reader-mode-active {
  padding-top: 10px;
  padding-bottom: calc(96px + var(--safe-bottom));
}

.app-view {
  display: none;
  animation: fadeViewIn 0.22s ease;
}

.app-view.active {
  display: block;
}

@keyframes fadeViewIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== CONTINUE READING CARD & STATS ==================== */
.continue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  margin-bottom: 14px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.continue-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-coral);
  margin-bottom: 2px;
}

.continue-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.continue-meta {
  margin: 2px 0 0;
  font-size: 0.83rem;
  color: var(--ink-secondary);
}

.continue-action-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.shelf-stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  text-align: left;
}

.stat-chip-clickable:active {
  transform: scale(0.97);
}

.stat-emoji {
  font-size: 1.3rem;
}

.stat-chip strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.2;
}

.stat-chip small {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.section-heading-row {
  margin-bottom: 14px;
}

.shelf-main-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
}

.shelf-sub-desc {
  margin: 3px 0 0;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

/* ==================== 9 PASTEL CLOTH-BOUND BOOKS ==================== */
.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 14px;
}

@media (min-width: 580px) {
  .bookshelf-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 16px;
  }
}

.theme-peach    { --cover-bg: #FADCD9; --cover-spine: #E5B2AC; --cover-ribbon: #E06D62; --cover-ink: #4A2B28; }
.theme-mint     { --cover-bg: #D7EFE4; --cover-spine: #9ECBB8; --cover-ribbon: #4C9A7A; --cover-ink: #224235; }
.theme-lavender { --cover-bg: #E6DFF7; --cover-spine: #B9ADDF; --cover-ribbon: #7A66B8; --cover-ink: #32294D; }
.theme-sky      { --cover-bg: #D9ECF9; --cover-spine: #A2C7E2; --cover-ribbon: #4C88B5; --cover-ink: #223B4F; }
.theme-butter   { --cover-bg: #FBF0C9; --cover-spine: #E2CB84; --cover-ribbon: #C98E2B; --cover-ink: #473918; }
.theme-apricot  { --cover-bg: #FCE2CE; --cover-spine: #E6B792; --cover-ribbon: #D97642; --cover-ink: #4A2E1B; }
.theme-sage     { --cover-bg: #E2ECD8; --cover-spine: #B3C8A0; --cover-ribbon: #688B4E; --cover-ink: #2C3D22; }
.theme-lilac    { --cover-bg: #F6DEF0; --cover-spine: #D8ADCE; --cover-ribbon: #B55D9F; --cover-ink: #47253F; }
.theme-caramel  { --cover-bg: #EFE2D2; --cover-spine: #CCB396; --cover-ribbon: #9C6B43; --cover-ink: #3F2E1E; }

[data-theme="dark"] .book-cloth-card {
  filter: brightness(0.92) saturate(0.92);
}

.book-cloth-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 222px;
  padding: 16px 14px 14px 24px;
  border-radius: 8px 18px 18px 8px;
  background-color: var(--cover-bg);
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.22) 0px, rgba(255, 255, 255, 0.22) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.02) 0px, rgba(0, 0, 0, 0.02) 1px, transparent 1px, transparent 4px);
  color: var(--cover-ink);
  text-align: left;
  box-shadow:
    inset -3px 0 0 rgba(255, 255, 255, 0.45),
    4px 5px 0 #EFE8DC,
    5px 6px 0 rgba(0, 0, 0, 0.10),
    0 10px 20px rgba(55, 42, 28, 0.12);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  overflow: hidden;
}

[data-theme="dark"] .book-cloth-card {
  box-shadow:
    inset -2px 0 0 rgba(255, 255, 255, 0.25),
    4px 5px 0 #2B3044,
    0 10px 22px rgba(0, 0, 0, 0.45);
}

.book-cloth-card:active {
  transform: translateY(3px) scale(0.985);
}

.book-cloth-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 14px;
  background: var(--cover-spine);
  border-right: 1.5px dashed rgba(255, 255, 255, 0.65);
}

.book-ribbon {
  position: absolute;
  top: 0;
  right: 14px;
  width: 16px;
  height: 28px;
  background: var(--cover-ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  opacity: 0.92;
}

.book-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-right: 18px;
}

.book-vol-pill {
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0.82;
}

.book-tier-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.78);
  color: #2E6F53;
}

.book-tier-badge.pro-locked {
  background: rgba(45, 36, 28, 0.76);
  color: #FFE59E;
}

.book-tier-badge.pro-owned {
  background: rgba(255, 255, 255, 0.85);
  color: #8A6218;
}

.book-center-emblem {
  margin: 10px auto 8px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.book-title-wrap {
  background: rgba(255, 255, 255, 0.62);
  border-radius: 12px;
  padding: 8px 10px;
  backdrop-filter: blur(2px);
}

.book-cover-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.28;
  color: var(--cover-ink);
}

.book-cover-sub {
  margin: 2px 0 0;
  font-size: 0.74rem;
  opacity: 0.84;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-footer-stars {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ==================== VIEW 2: BOOK TABLE OF CONTENTS ==================== */
.subview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.btn-back-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.access-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
}

.access-pill.free {
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
}

.access-pill.pro {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.toc-book-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 18px 20px 26px;
  border-radius: 12px 22px 22px 12px;
  background-color: var(--cover-bg);
  color: var(--cover-ink);
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.toc-book-banner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: var(--cover-spine);
  border-right: 1.5px dashed rgba(255, 255, 255, 0.7);
}

.toc-banner-ribbon {
  position: absolute;
  top: 0;
  right: 20px;
  width: 18px;
  height: 32px;
  background: var(--cover-ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}

.toc-banner-icon {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  display: grid;
  place-items: center;
  font-size: 2.25rem;
}

.toc-vol-label {
  font-size: 0.78rem;
  font-weight: 800;
  opacity: 0.85;
}

.toc-book-title {
  margin: 2px 0;
  font-size: 1.24rem;
  font-weight: 800;
  line-height: 1.25;
}

.toc-book-sub {
  margin: 0 0 8px;
  font-size: 0.84rem;
  opacity: 0.88;
}

.toc-stars-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
}

.toc-story-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-story-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  background: var(--bg-paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.toc-story-card:active {
  transform: scale(0.985);
}

.toc-story-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.toc-story-emoji {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  font-size: 1.55rem;
}

.toc-story-texts {
  min-width: 0;
}

.toc-story-num {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-coral);
}

.toc-story-main-title {
  margin: 1px 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.toc-story-sub-title {
  margin: 0;
  font-size: 0.83rem;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-story-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.toc-story-stars {
  font-size: 0.82rem;
  letter-spacing: 1px;
}

.toc-open-chip {
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-coral-soft);
  color: var(--accent-coral);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ==================== VIEW 3: INTERACTIVE STORY READER ==================== */
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.reader-toolbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-chip-btn {
  padding: 7px 11px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.reader-chip-btn.is-active {
  background: var(--accent-coral-soft);
  border-color: var(--accent-coral);
  color: var(--accent-coral);
}

.bedtime-chip {
  background: var(--accent-lavender-soft);
  border-color: rgba(124, 107, 176, 0.35);
}

.reader-story-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 2px;
}

.reader-story-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-coral);
  margin-right: 6px;
}

.reader-story-title {
  display: inline;
  margin: 0;
  font-size: 1.16rem;
  font-weight: 800;
}

.reader-page-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.reader-progress-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--border-soft);
  overflow: hidden;
  margin-bottom: 12px;
}

.reader-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-coral), var(--accent-gold));
  transition: width 0.25s ease;
}

.reader-paper {
  position: relative;
  min-height: 56dvh;
  padding: 22px 18px 24px;
  background-color: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: background-color 0.2s ease;
}

@media (min-width: 560px) {
  .reader-paper {
    padding: 28px 30px 28px;
  }
}

.reader-paper[data-fontsize="md"] {
  --size-en: 1.18rem;
  --size-zh: 1.36rem;
  --size-th: 1.16rem;
}

.reader-paper[data-fontsize="lg"] {
  --size-en: 1.36rem;
  --size-zh: 1.60rem;
  --size-th: 1.34rem;
}

.reader-paper[data-fontsize="xl"] {
  --size-en: 1.62rem;
  --size-zh: 1.90rem;
  --size-th: 1.58rem;
}

.reader-tap-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-gold-soft);
  border: 1px dashed rgba(212, 155, 53, 0.5);
  font-size: 0.84rem;
  color: var(--ink-primary);
}

.hint-close-btn {
  padding: 2px 6px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.reader-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.story-lang-block {
  position: relative;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.story-lang-block.block-en {
  background: rgba(120, 155, 190, 0.05);
}

.story-lang-block.block-zh {
  background: rgba(224, 122, 104, 0.05);
}

.story-lang-block.block-th {
  background: rgba(140, 130, 115, 0.05);
}

.story-lang-block.is-reading-sentence {
  background-color: var(--sentence-reading-bg);
  border-color: var(--word-active-border);
}

.lang-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.lang-mini-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.block-speak-mini-btn {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* ==================== COMPACT PASTEL STORY ILLUSTRATION BOX ==================== */
.story-illustration-box {
  margin: 20px auto 4px;
  max-width: 400px;
  padding: 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.story-illustration-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 220px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--bg-subtle);
}

[data-theme="dark"] .story-illustration-img {
  filter: brightness(0.90) saturate(0.94);
}

.story-illustration-fallback {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 200px;
  border-radius: 14px;
  background-color: var(--cover-bg, #FADCD9);
  background-image:
    radial-gradient(circle at 22% 28%, rgba(255, 255, 255, 0.65) 0%, transparent 45%),
    radial-gradient(circle at 80% 75%, rgba(255, 255, 255, 0.50) 0%, transparent 48%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  border: 1.5px dashed rgba(255, 255, 255, 0.85);
  overflow: hidden;
}

[data-theme="dark"] .story-illustration-fallback {
  filter: brightness(0.86) saturate(0.88);
}

.fallback-scene-badge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  place-items: center;
  font-size: 2.35rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.fallback-scene-caption {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--cover-ink, #4A2B28);
  background: rgba(255, 255, 255, 0.66);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
}

/* ==================== TAP-TO-SPEAK INTERACTIVE WORDS & <RUBY> PINYIN ==================== */
.story-paragraph-en {
  font-family: var(--font-en);
  font-size: var(--size-en);
  line-height: 1.75;
  color: var(--ink-en);
  font-weight: 600;
}

.story-paragraph-zh {
  font-family: var(--font-zh);
  font-size: var(--size-zh);
  line-height: 2.38;
  color: var(--ink-zh);
  font-weight: 500;
}

.reader-paper.hide-pinyin .story-paragraph-zh {
  line-height: 1.85;
}

.reader-paper.hide-pinyin ruby rt {
  visibility: hidden;
  font-size: 0;
  line-height: 0;
}

.story-paragraph-th {
  font-family: var(--font-th);
  font-size: var(--size-th);
  line-height: 1.82;
  color: var(--ink-th);
  font-weight: 500;
}

.tap-word {
  display: inline-block;
  padding: 1px 3px;
  margin: 0 1px;
  border-radius: 8px;
  border-bottom: 1.5px dotted rgba(150, 138, 124, 0.35);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.tap-word.th-word {
  padding: 1px 1.5px;
  margin: 0;
}

.tap-word:hover {
  background-color: var(--word-hover-bg);
}

.tap-word:active,
.tap-word.is-active-word {
  transform: translateY(2px) scale(0.97);
  background-color: var(--word-active-bg);
  border-bottom-color: var(--word-active-border);
  box-shadow: 0 0 0 2px var(--word-active-border);
}

.tap-word.is-karaoke-word {
  background-color: var(--word-active-bg);
  border-bottom: 2px solid var(--accent-coral);
}

.tap-word.is-saved-vocab {
  border-bottom: 2px solid var(--accent-gold);
}

.punct-token {
  display: inline;
}

ruby {
  ruby-align: center;
}

ruby rt {
  font-family: var(--font-en);
  font-size: 0.54em;
  font-weight: 700;
  color: var(--ink-pinyin);
  letter-spacing: 0.01em;
  padding: 0 2px;
  user-select: none;
}

.th-spoiler-box {
  border-radius: 14px;
  background: var(--bg-subtle);
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
}

.btn-reveal-th {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-secondary);
  padding: 4px 2px;
}

.th-spoiler-content {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

/* ==================== GOLDEN MORAL CARD ==================== */
.moral-gold-card {
  margin-top: 18px;
  padding: 18px 16px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--accent-gold-soft), var(--bg-paper));
  border: 2px solid rgba(212, 155, 53, 0.55);
  box-shadow: var(--shadow-sm);
}

.moral-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.moral-badge {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--accent-gold);
}

.moral-speak-btn {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid rgba(212, 155, 53, 0.45);
  font-size: 0.8rem;
  font-weight: 700;
}

.moral-body-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.moral-line-en {
  font-family: var(--font-en);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink-en);
}

.moral-line-zh {
  font-family: var(--font-zh);
  font-size: 1.24rem;
  line-height: 2.2;
  color: var(--ink-zh);
}

.moral-line-th {
  font-family: var(--font-th);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.moral-quiz-cta {
  margin-top: 16px;
}

.btn-gold-quiz {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #E2A23B, #D08626);
  color: #FFFFFF;
  font-size: 0.98rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(208, 134, 38, 0.28);
}

.btn-gold-quiz:active {
  transform: scale(0.98);
}

/* ==================== READER ONE-HANDED BOTTOM DOCK ==================== */
.reader-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 85;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background: var(--bg-paper);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -4px 18px rgba(45, 36, 28, 0.08);
}

.dock-page-btn {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  font-size: 0.92rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.dock-page-btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.dock-next-primary {
  background: var(--accent-coral-soft);
  border-color: rgba(224, 122, 104, 0.4);
  color: var(--ink-primary);
}

.dock-center-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.dock-play-btn {
  min-height: 46px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--accent-coral);
  color: #FFFFFF;
  font-size: 0.94rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(224, 122, 104, 0.35);
}

.dock-play-btn.is-playing {
  background: #C95B4A;
}

.dock-submode-btn {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-secondary);
  padding: 2px 8px;
}

/* ==================== FLOATING WORD POP-UP CARD ==================== */
.word-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(20, 18, 15, 0.14);
}

.word-popup {
  position: fixed;
  z-index: 130;
  width: min(340px, calc(100vw - 24px));
  padding: 14px 14px 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-popup);
  animation: popIn 0.15s cubic-bezier(0.2, 0.85, 0.35, 1.05);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.word-popup-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.popup-lang-tag {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.popup-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  font-size: 0.88rem;
}

.popup-tri-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.popup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 12px;
  background: var(--bg-paper);
  border: 1px solid var(--border-soft);
}

.popup-row.is-tapped-lang {
  border-color: var(--accent-coral);
  background: var(--accent-coral-soft);
}

.popup-audio-pill {
  flex-shrink: 0;
  padding: 6px 9px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.popup-audio-pill:active {
  transform: scale(0.94);
}

.popup-word-detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.popup-main-word {
  font-size: 1.06rem;
  line-height: 1.25;
}

.popup-main-word.zh-font {
  font-family: var(--font-zh);
  font-size: 1.2rem;
}

.popup-sub-phonetic {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.pinyin-color {
  color: var(--ink-pinyin);
  font-weight: 700;
}

.popup-bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}

.popup-action-btn {
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 0.83rem;
  font-weight: 700;
  text-align: center;
}

.popup-action-btn.slow-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

.popup-action-btn.star-btn {
  background: var(--accent-gold-soft);
  border: 1px solid rgba(212, 155, 53, 0.45);
}

.popup-action-btn.star-btn.is-saved {
  background: var(--accent-sage-soft);
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}

/* ==================== VIEW 4: VOCABULARY BAG ==================== */
.vocab-toolbar {
  margin-bottom: 14px;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
}

.vocab-search-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 0.95rem;
}

.vocab-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--ink-primary);
  color: var(--bg-paper);
  border-color: var(--ink-primary);
}

.filter-chip.accent-chip {
  background: var(--accent-coral-soft);
  color: var(--accent-coral);
  border-color: rgba(224, 122, 104, 0.35);
}

.empty-state-card {
  padding: 32px 20px;
  text-align: center;
  background: var(--bg-paper);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-emoji {
  font-size: 2.4rem;
  margin-bottom: 6px;
}

.empty-state-card h3 {
  margin: 0 0 6px;
}

.empty-state-card p {
  margin: 0 auto 16px;
  max-width: 380px;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.vocab-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vocab-card {
  padding: 14px 16px;
  background: var(--bg-paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.vocab-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

@media (max-width: 440px) {
  .vocab-card-grid {
    grid-template-columns: 1fr;
  }
}

.vocab-lang-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}

.vocab-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 0.8rem;
}

.vocab-jump-btn {
  color: var(--accent-coral);
  font-weight: 700;
}

.vocab-remove-btn {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

/* ==================== VIEW 5: SETTINGS, TTS SLIDERS & PRO ==================== */
.settings-card {
  padding: 18px 16px;
  margin-bottom: 14px;
  background: var(--bg-paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.settings-card h2 {
  margin: 0 0 4px;
  font-size: 1.06rem;
}

.settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.settings-helper-text {
  margin: 4px 0 14px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.pro-highlight-card {
  background: linear-gradient(145deg, var(--accent-gold-soft), var(--bg-paper));
  border-color: rgba(212, 155, 53, 0.5);
}

.pro-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.pro-crown-icon {
  font-size: 1.9rem;
}

.pro-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-audio-box {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}

.lang-audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.btn-test-voice {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  font-size: 0.78rem;
  font-weight: 700;
}

.dual-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slider-group {
  margin-bottom: 8px;
}

.slider-group.compact {
  margin-bottom: 0;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-coral);
  height: 6px;
}

.soft-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 12px 0;
}

.backup-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-zone-row {
  margin-top: 14px;
  text-align: center;
}

.text-link-btn {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-coral);
}

.text-danger-btn {
  font-size: 0.82rem;
  color: #C75246;
  text-decoration: underline;
}

.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.about-pkg {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.reviewer-subtle-btn {
  font-size: 0.75rem;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.about-links {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.about-link {
  color: var(--accent-coral);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}

/* ==================== BOTTOM NAVIGATION BAR ==================== */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 8px calc(8px + var(--safe-bottom));
  background: var(--bg-paper);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -4px 16px rgba(45, 36, 28, 0.06);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 14px;
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.nav-tab.active {
  color: var(--accent-coral);
  background: var(--accent-coral-soft);
}

.nav-icon-wrap {
  position: relative;
  display: inline-flex;
}

.nav-icon {
  font-size: 1.24rem;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-coral);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* ==================== MODALS (ONBOARDING, BEDTIME, QUIZ, PAYWALL) ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(22, 19, 16, 0.52);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

/* ให้ Paywall และ Reviewer PIN แสดงซ้อนทับบน Modal กล่อมนอนได้ทันทีเมื่อกดเสียง PRO */
#modal-paywall {
  z-index: 170;
}

#modal-reviewer-pin {
  z-index: 180;
}

@media (min-width: 560px) {
  .modal-overlay {
    align-items: center;
    padding: 18px;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 510px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 18px calc(22px + var(--safe-bottom));
  background: var(--bg-paper);
  border-radius: 26px 26px 0 0;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-popup);
  animation: sheetSlideUp 0.22s ease;
}

@media (min-width: 560px) {
  .modal-sheet {
    border-radius: 26px;
    padding: 22px 24px;
  }
}

@keyframes sheetSlideUp {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-cloth-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-coral-soft);
  color: var(--accent-coral);
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.modal-header-bar h2,
.modal-header-bar h3 {
  margin: 0;
  font-size: 1.16rem;
}

.modal-title {
  margin: 0 0 4px;
  font-size: 1.24rem;
  line-height: 1.3;
}

.modal-subtitle {
  margin: 0 0 14px;
  font-size: 0.86rem;
  color: var(--ink-secondary);
}

.lang-mode-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 18px;
}

.lang-mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  text-align: left;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.lang-mode-card.selected {
  border-color: var(--accent-coral);
  background: var(--accent-coral-soft);
}

.lang-mode-flag {
  font-size: 1.65rem;
  flex-shrink: 0;
}

.lang-mode-text {
  flex: 1;
}

.lang-mode-text strong {
  display: block;
  font-size: 0.96rem;
}

.lang-mode-text small {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.lang-mode-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-coral);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  opacity: 0;
}

.lang-mode-card.selected .lang-mode-check {
  opacity: 1;
}

/* ==================== UPGRADED BEDTIME MODAL (LANGUAGE CHOICE & 7 SOUNDS) ==================== */
.bedtime-option-box {
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.switch-row strong {
  display: block;
  font-size: 0.94rem;
}

.switch-row small {
  display: block;
  font-size: 0.77rem;
  color: var(--ink-secondary);
}

.pastel-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-lavender);
  flex-shrink: 0;
}

.bedtime-sub-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}

.bedtime-sub-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.bedtime-lang-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (max-width: 400px) {
  .bedtime-lang-pills {
    grid-template-columns: 1fr;
  }
}

.bedtime-lang-pill {
  padding: 8px 6px;
  border-radius: 10px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.14s ease;
}

.bedtime-lang-pill.active {
  background: var(--accent-coral-soft);
  border-color: var(--accent-coral);
  color: var(--accent-coral);
}

/* แผงเลือกเสียงบรรยากาศทั้ง 7 เสียง (ฟรี 2 / PRO 5) */
.ambient-sound-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 12px;
}

@media (min-width: 440px) {
  .ambient-sound-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.sound-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 12px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.1s ease;
}

.sound-chip:active {
  transform: scale(0.97);
}

.sound-chip.active {
  background: var(--accent-lavender-soft);
  border-color: var(--accent-lavender);
  color: var(--accent-lavender);
}

.sound-chip.is-locked {
  opacity: 0.86;
}

.sound-chip-left {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.sound-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sound-tier-tag {
  flex-shrink: 0;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
}

.sound-tier-tag.free {
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
}

.sound-tier-tag.pro {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.sleep-label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.sleep-pills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.sleep-pill {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.14s ease;
}

.sleep-pill.full-span {
  grid-column: 1 / -1;
}

.sleep-pill.active {
  background: var(--accent-lavender-soft);
  border-color: var(--accent-lavender);
  color: var(--accent-lavender);
}

/* ปุ่มเล่าจบเรื่องนี้แล้วเปิดต่อเรื่องถัดไป */
.next-story-pill {
  width: 100%;
  margin-top: 8px;
}

.next-story-pill.active {
  background: var(--accent-sage-soft);
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}

.bedtime-status-note {
  margin: 8px 0 14px;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  text-align: center;
}

/* มินิเกมควิซท้ายเรื่อง */
.quiz-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.quiz-step-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
}

.quiz-score-live {
  font-weight: 800;
  color: var(--accent-gold);
}

.quiz-question-box {
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 12px;
}

.quiz-opt-btn {
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  font-size: 0.96rem;
  font-weight: 600;
  text-align: left;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.quiz-opt-btn.correct {
  background: var(--accent-sage-soft);
  border-color: var(--accent-sage);
}

.quiz-opt-btn.wrong {
  background: var(--accent-coral-soft);
  border-color: var(--accent-coral);
}

.quiz-feedback {
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 0.88rem;
  font-weight: 600;
}

.quiz-result-box {
  text-align: center;
  padding: 14px 8px 4px;
}

.quiz-stars-display {
  font-size: 2.6rem;
  letter-spacing: 6px;
  margin-bottom: 8px;
}

/* Paywall & Buttons */
.pro-pill-tag {
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
  font-size: 0.8rem;
  font-weight: 800;
}

.pro-feature-list {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.price-highlight-box {
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--accent-gold-soft);
  border: 1.5px solid rgba(212, 155, 53, 0.5);
  text-align: center;
}

.price-label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.price-amount {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
}

.price-sku {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.paywall-action-zone {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.paywall-web-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.pin-input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  font-size: 1.08rem;
  text-align: center;
  letter-spacing: 3px;
}

.btn-primary-full {
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: var(--accent-coral);
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(224, 122, 104, 0.3);
}

.btn-primary-soft {
  min-height: 46px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  background: var(--accent-coral);
  color: #FFFFFF;
  font-size: 0.94rem;
  font-weight: 700;
}

.btn-gold-pro {
  min-height: 50px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #E2A23B, #C87E1E);
  color: #FFFFFF;
  font-size: 0.96rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(200, 126, 30, 0.28);
}

.btn-outline-soft {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.full-width {
  width: 100%;
}

.modal-dual-btns {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

/* Loading & Toast */
.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--ink-secondary);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent-coral);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(420px, calc(100vw - 28px));
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: #2B2825;
  color: #FDFBF7;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  text-align: center;
}

[data-theme="dark"] .app-toast {
  background: #F2EFE9;
  color: #151824;
}