/* ============================================
   TaleBuddy — Landing Page Styles
   Theme: Warm night sky, magical bedtime
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Night sky palette */
  --bg-deep: #0b0a1a;
  --bg-mid: #12103a;
  --bg-card: #1a1744;
  --bg-card-hover: #211e52;
  --bg-surface: rgba(255, 255, 255, 0.04);
  --bg-surface-hover: rgba(255, 255, 255, 0.08);

  /* Accent colors */
  --gold: #f5c542;
  --gold-dim: #c9a235;
  --gold-glow: rgba(245, 197, 66, 0.15);
  --lavender: #b8a9e8;
  --coral: #ff7b7b;
  --mint: #7bdfb0;

  /* Text */
  --text-primary: #f0ecff;
  --text-secondary: #9d95c0;
  --text-muted: #6b6390;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Spacing */
  --container-max: 1120px;
  --section-padding: 100px 0;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Fonts */
  --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-story: 'Crimson Pro', Georgia, serif;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button, input, select {
  font: inherit;
  color: inherit;
}

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Stars Background --- */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: repeat;
}

.stars-small {
  background-image:
    radial-gradient(1px 1px at 50px 80px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 150px 200px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 300px 50px, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 450px 320px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 600px 150px, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 100px 400px, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 700px 250px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 250px 350px, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 500px 420px, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 800px 100px, rgba(255,255,255,0.5), transparent);
  background-size: 850px 500px;
  animation: drift 120s linear infinite;
}

.stars-medium {
  background-image:
    radial-gradient(1.5px 1.5px at 120px 160px, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 380px 90px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 550px 300px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 200px 420px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 720px 200px, rgba(255,255,255,0.4), transparent);
  background-size: 800px 500px;
  animation: drift 180s linear infinite reverse;
}

.stars-large {
  background-image:
    radial-gradient(2px 2px at 250px 120px, rgba(245,197,66,0.6), transparent),
    radial-gradient(2px 2px at 650px 350px, rgba(184,169,232,0.5), transparent),
    radial-gradient(2.5px 2.5px at 450px 200px, rgba(255,255,255,0.7), transparent);
  background-size: 900px 500px;
  animation: twinkle 4s ease-in-out infinite alternate, drift 200s linear infinite;
}

@keyframes drift {
  from { transform: translateY(0); }
  to   { transform: translateY(-500px); }
}

@keyframes twinkle {
  0%   { opacity: 0.4; }
  100% { opacity: 1; }
}

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 0;
  background: rgba(11, 10, 26, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 300ms var(--ease-out);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
}

.logo-icon {
  font-size: 24px;
}

.nav {
  display: flex;
  gap: 32px;
}

.nav a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  transition: color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .nav a:hover {
    color: var(--text-primary);
  }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), opacity 200ms var(--ease-out), background 200ms var(--ease-out);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 8px 18px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--gold);
  color: #1a1200;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    opacity: 0.9;
  }
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border-hover);
  color: var(--text-primary);
}

@media (hover: hover) and (pointer: fine) {
  .btn-outline:hover {
    border-color: var(--gold);
    color: var(--gold);
  }
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loading[hidden] {
  display: none;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  padding: 140px 0 80px;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--gold-glow);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(245, 197, 66, 0.25);
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.hero-title {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.text-gradient {
  background: linear-gradient(135deg, var(--gold) 0%, var(--lavender) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 520px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Hero Visual — Storybook */
.hero-visual {
  display: flex;
  justify-content: center;
}

.story-book {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(145deg, #1e1b4b 0%, #1a1744 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-hover);
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(245, 197, 66, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.4);
}

.book-page {
  padding: 32px;
}

.book-illustration {
  position: relative;
  height: 180px;
  background: linear-gradient(180deg, #1a1040 0%, #2d1f6b 50%, #1a3a2a 100%);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow: hidden;
}

.moon {
  position: absolute;
  top: 20px;
  right: 40px;
  width: 50px;
  height: 50px;
  background: radial-gradient(circle at 35% 35%, #ffeebb 0%, #f5c542 100%);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(245, 197, 66, 0.4);
  animation: float 6s ease-in-out infinite;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 20px;
}

.cloud-1 {
  top: 40px;
  left: 20px;
  width: 80px;
  height: 24px;
  animation: drift-cloud 20s linear infinite;
}

.cloud-2 {
  top: 70px;
  left: 180px;
  width: 60px;
  height: 18px;
  animation: drift-cloud 25s linear infinite reverse;
}

@keyframes drift-cloud {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(30px); }
  100% { transform: translateX(0); }
}

.house {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 40px;
  background: #2a2050;
  border-radius: 4px 4px 0 0;
}

.house::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -8px;
  width: 0;
  height: 0;
  border-left: 33px solid transparent;
  border-right: 33px solid transparent;
  border-bottom: 24px solid #352a65;
}

.house::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 20px;
  background: rgba(245, 197, 66, 0.3);
  border-radius: 2px 2px 0 0;
}

.tree {
  position: absolute;
  bottom: 10px;
  width: 6px;
  height: 30px;
  background: #2a2050;
}

.tree::before {
  content: '';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 22px solid #1a4a30;
}

.tree-1 { left: 30px; }
.tree-2 { right: 40px; height: 24px; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.book-text {
  font-family: var(--font-story);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.book-line {
  margin-bottom: 8px;
}

.book-line strong {
  color: var(--gold);
}

.book-line.line-1 {
  animation: fade-in-line 1s 0.5s both;
}
.book-line.line-2 {
  animation: fade-in-line 1s 1.5s both;
}

@keyframes fade-in-line {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Sections Common --- */
.section-title {
  text-align: center;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 17px;
  margin-bottom: 56px;
}

/* --- How It Works --- */
.how-it-works {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.step {
  position: relative;
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 300ms var(--ease-out), border-color 300ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .step:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
  }
}

.step-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  background: var(--gold-glow);
  color: var(--gold);
  border-radius: 50%;
}

.step-number {
  display: inline-block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  font-size: 13px;
  font-weight: 800;
  color: var(--bg-deep);
  background: var(--gold);
  border-radius: 50%;
  margin-bottom: 16px;
}

.step-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.step-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Demo Section --- */
.demo-section {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.demo-wrapper {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.demo-form-panel {
  padding: 32px;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 200ms var(--ease-out);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--gold);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239d95c0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Theme grid */
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-btn {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms var(--ease-out), color 200ms var(--ease-out);
}

.theme-btn:active {
  transform: scale(0.97);
}

.theme-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-glow);
}

@media (hover: hover) and (pointer: fine) {
  .theme-btn:hover:not(.active) {
    border-color: var(--border-hover);
    color: var(--text-primary);
  }
}

/* Lesson pills */
.lesson-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms var(--ease-out), color 200ms var(--ease-out);
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn.active {
  border-color: var(--lavender);
  color: var(--lavender);
  background: rgba(184, 169, 232, 0.1);
}

@media (hover: hover) and (pointer: fine) {
  .pill-btn:hover:not(.active) {
    border-color: var(--border-hover);
    color: var(--text-primary);
  }
}

/* Story output panel */
.demo-story-panel {
  padding: 32px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.placeholder-hint {
  font-size: 13px;
  margin-top: 8px;
}

.story-output {
  width: 100%;
  font-family: var(--font-story);
}

.story-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.story-title {
  font-family: var(--font-body);
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
}

.story-age-badge {
  padding: 3px 10px;
  background: var(--gold-glow);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-body);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(245, 197, 66, 0.2);
}

.story-body {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.story-body p {
  margin-bottom: 16px;
}

.story-body strong {
  color: var(--gold);
}

.story-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.story-end {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

/* Post-story rating — captures PM feedback signal via Amplitude. */
.story-rating {
  margin: 8px auto 20px;
  padding: 14px 18px;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.story-rating-prompt,
.story-rating-thanks {
  margin: 0;
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.4;
}
.story-rating-prompt { color: var(--text-secondary); }
.story-rating-thanks { color: var(--gold); }
.story-rating-buttons {
  display: flex;
  gap: 14px;
}
.story-rating-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-deep, var(--bg, transparent));
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 160ms var(--ease-out), border-color 200ms var(--ease-out), background 200ms var(--ease-out);
}
.story-rating-btn:active { transform: scale(0.94); }
.story-rating-btn.is-selected {
  border-color: var(--gold);
  background: var(--gold-glow);
}
@media (hover: hover) and (pointer: fine) {
  .story-rating-btn:hover:not(.is-selected) {
    border-color: var(--border-hover, var(--gold));
    transform: translateY(-1px);
  }
}

.story-cta {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Anon-conversion card — shown after the first anon story streams in.
   This is the highest-leverage signup CTA in the entire funnel:
   the user just experienced the value, the story is on screen,
   they have an emotional pull to keep it. Make it big. */
.anon-convert-card {
  margin: 8px auto 0;
  max-width: 460px;
  padding: 22px 22px 20px;
  background: linear-gradient(180deg, var(--gold-glow) 0%, rgba(245, 197, 66, 0.05) 100%);
  border: 1px solid rgba(245, 197, 66, 0.4);
  border-radius: var(--radius-md);
  text-align: center;
}
.anon-convert-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 800;
  color: var(--gold);
  margin: 0 0 6px;
  letter-spacing: 0.3px;
}
.anon-convert-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  margin: 0 0 16px;
}
.anon-convert-body strong { color: var(--gold); }
.anon-convert-card .btn-lg { width: 100%; max-width: 320px; }
.anon-convert-footnote {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Features --- */
.features {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature-card {
  padding: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 300ms var(--ease-out), border-color 300ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
  }
}

.feature-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-glow);
  color: var(--gold);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Pricing --- */
.pricing {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  align-items: start;
}

.pricing-card {
  position: relative;
  padding: 36px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: transform 300ms var(--ease-out);
}

.pricing-featured {
  border-color: var(--gold);
  background: var(--gold-glow);
  transform: scale(1.03);
}

@media (hover: hover) and (pointer: fine) {
  .pricing-card:hover {
    transform: translateY(-4px);
  }
  .pricing-featured:hover {
    transform: scale(1.03) translateY(-4px);
  }
}

.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: var(--gold);
  color: #1a1200;
  font-size: 12px;
  font-weight: 800;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.pricing-tier {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pricing-price {
  margin-bottom: 28px;
}

.price-amount {
  font-size: 48px;
  font-weight: 800;
  color: var(--text-primary);
}

.price-period {
  font-size: 15px;
  color: var(--text-muted);
}

.pricing-features {
  list-style: none;
  margin-bottom: 28px;
  text-align: left;
}

.pricing-features li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.pricing-features li::before {
  content: '\2713';
  margin-right: 10px;
  color: var(--mint);
  font-weight: 800;
}

.pricing-features li:last-child {
  border-bottom: none;
}

.pricing-features li.pricing-feature-soon {
  color: var(--text-muted);
}
.pricing-features li.pricing-feature-soon::before {
  content: '\2713';
  color: var(--text-muted);
  opacity: 0.6;
}
.pricing-features li.pricing-feature-soon span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-left: 6px;
  opacity: 0.85;
}

/* Tier tagline — one short line under the tier name */
.pricing-tagline {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin: -4px 0 16px;
  letter-spacing: 0.2px;
}

/* Highlighted lead bullet (e.g. "Unlimited bedtime stories") */
.pricing-features li.pricing-feature-headline {
  color: var(--text-primary);
  font-weight: 700;
}

/* NEW badge on freshly-shipped features — drives novelty perception */
.pricing-features li.pricing-feature-new {
  color: var(--text-primary);
  position: relative;
  font-weight: 600;
}
.pricing-features li.pricing-feature-new::after {
  content: 'NEW';
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1200;
  vertical-align: 2px;
  line-height: 1;
}

/* Cancel-anytime reassurance under the CTA */
.pricing-cancel-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 10px 0 0;
  letter-spacing: 0.2px;
}

/* --- Waitlist --- */
.waitlist {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.waitlist-card {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  padding: 56px 40px;
  background: linear-gradient(135deg, rgba(245, 197, 66, 0.06) 0%, rgba(184, 169, 232, 0.06) 100%);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
}

.waitlist-title {
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 800;
  margin-bottom: 12px;
}

.waitlist-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 32px;
}

.waitlist-form .form-row {
  display: flex;
  gap: 10px;
}

.waitlist-form input[type="email"] {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 200ms var(--ease-out);
}

.waitlist-form input[type="email"]::placeholder {
  color: var(--text-muted);
}

.waitlist-form input[type="email"]:focus {
  border-color: var(--gold);
}

.waitlist-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.waitlist-success {
  padding: 20px;
}

.success-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: var(--mint);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}

.waitlist-success h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.waitlist-success p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* --- FAQ --- */
.faq {
  position: relative;
  z-index: 1;
  padding: var(--section-padding);
}

.faq-list {
  max-width: 700px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-question {
  padding: 20px 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  transition: color 200ms var(--ease-out);
}

.faq-question::after {
  content: '+';
  font-size: 22px;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 200ms var(--ease-out);
}

.faq-item[open] .faq-question::after {
  content: '\2212';
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-answer {
  padding: 0 0 20px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 48px 0 32px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 48px;
}

.footer-brand {
  flex: 1;
  min-width: 200px;
}

.footer-brand .logo-text {
  font-weight: 800;
  font-size: 18px;
}

.footer-tagline {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 64px;
}

.footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .footer-col a:hover {
    color: var(--text-primary);
  }
}

.footer-bottom {
  width: 100%;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.footer-bottom p {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Reveal Animation --- */
[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-subtitle {
    max-width: 100%;
  }

  .hero-actions {
    justify-content: center;
  }

  /* On tablet still show the storybook BELOW the headline so the CTA stays
     close to the top of the page. On phone we hide it entirely (see <600px). */
  .hero-visual {
    order: 1;
    margin-top: 32px;
  }

  .story-book {
    max-width: 320px;
  }

  .steps {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
  }

  .demo-wrapper {
    grid-template-columns: 1fr;
  }

  .demo-form-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

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

  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 380px;
    margin: 0 auto;
  }

  .pricing-featured {
    transform: none;
  }

  @media (hover: hover) and (pointer: fine) {
    .pricing-featured:hover {
      transform: translateY(-4px);
    }
  }

  .nav {
    display: none;
  }
}

@media (max-width: 600px) {
  :root {
    --section-padding: 64px 0;
  }

  .hero {
    padding: 96px 0 40px;
  }

  /* On phone, drop the storybook visual entirely. It pushes the primary CTA
     below the fold on common phone heights (~700px), tanking conversion. */
  .hero-visual {
    display: none;
  }

  .hero-title {
    font-size: 30px;
    line-height: 1.18;
  }

  .hero-subtitle {
    font-size: 16px;
    line-height: 1.55;
    margin-bottom: 24px;
  }

  .hero-actions .btn-lg {
    width: 100%;
  }

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

  .footer-links {
    gap: 32px;
  }

  .waitlist-form .form-row {
    flex-direction: column;
  }

  .waitlist-card {
    padding: 36px 24px;
  }
}

/* --- Auth: header actions, user menu, modal --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-trigger-wrap {
  position: relative;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.user-trigger:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

.user-trigger[aria-expanded="true"] {
  background: var(--bg-surface-hover);
  border-color: var(--gold);
}

.user-trigger-chevron {
  color: var(--text-muted);
  transition: transform 200ms var(--ease-out);
  flex-shrink: 0;
}

.user-trigger[aria-expanded="true"] .user-trigger-chevron {
  transform: rotate(180deg);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: var(--bg-deep);
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-email {
  color: var(--text-secondary);
  font-size: 0.85rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .user-email { display: none; }
  .user-trigger-chevron { display: none; }
  .user-trigger { padding: 4px; }
}

/* --- User dropdown --- */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  z-index: 100;
}

.user-dropdown[hidden] { display: none; }

.user-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-dropdown-header {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.user-dropdown-email {
  margin: 0 0 2px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
}

.user-dropdown-plan {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 140ms var(--ease-out);
}

.user-dropdown-item[hidden] { display: none; }

.user-dropdown-item:hover {
  background: var(--bg-surface);
}

.user-dropdown-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Auth state visibility — toggled by JS */
body.auth-signed-in .auth-signed-out { display: none !important; }
body:not(.auth-signed-in) .auth-signed-in { display: none !important; }

/* Paid users don't need to see the pricing section or the bottom sign-up CTA */
body.tier-pro .pricing,
body.tier-family .pricing,
body.tier-pro .signup-cta,
body.tier-family .signup-cta {
  display: none !important;
}

/* Tier-paid-only elements: hide unless the body has a paid tier class. JS toggles
   the [hidden] attribute too as a defensive belt-and-braces. */
body:not(.tier-pro):not(.tier-family) .tier-paid-only {
  display: none !important;
}

/* --- Profile selector (signed-in with ≥1 saved profile) --- */
.profile-selector {
  margin: 0 0 22px;
}

.profile-selector[hidden] { display: none; }

.profile-selector-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.profile-selector-wrap {
  position: relative;
}

.profile-selector-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.profile-selector-trigger:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

.profile-selector-trigger[aria-expanded="true"] {
  background: var(--bg-surface-hover);
  border-color: var(--gold);
}

.profile-selector-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender) 0%, var(--gold-dim) 100%);
  color: var(--bg-deep);
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.profile-selector-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}

.profile-selector-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.profile-selector-age {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-selector-chevron {
  color: var(--text-muted);
  transition: transform 200ms var(--ease-out);
  flex-shrink: 0;
}

.profile-selector-trigger[aria-expanded="true"] .profile-selector-chevron {
  transform: rotate(180deg);
}

.profile-selector-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  z-index: 50;
}

.profile-selector-dropdown[hidden] { display: none; }

.profile-selector-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: background 140ms var(--ease-out);
}

.profile-row + .profile-row {
  margin-top: 2px;
}

.profile-row.is-active {
  background: rgba(245, 197, 66, 0.1);
}

.profile-row-select {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.profile-row-select:hover {
  background: var(--bg-surface);
}

.profile-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender) 0%, var(--gold-dim) 100%);
  color: var(--bg-deep);
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.profile-row-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.profile-row-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-row-age {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.profile-row-check {
  margin-left: auto;
  color: var(--gold);
  flex-shrink: 0;
}

.profile-row-action {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 140ms var(--ease-out), background 140ms var(--ease-out);
}

.profile-row-action:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.profile-row-action.is-danger:hover {
  color: var(--coral);
  background: rgba(255, 123, 123, 0.1);
}

.profile-add-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.profile-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}

.profile-add-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.profile-add-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-add-form[hidden] { display: none; }

.profile-add-form input[type="text"],
.profile-add-form select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 10px;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.profile-add-form input[type="text"]:focus,
.profile-add-form select:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--bg-surface-hover);
}

.profile-add-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.profile-tier-hint {
  margin: 0;
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.profile-tier-hint a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
}

/* When a signed-in user has at least one saved profile, hide the raw
   name input + age select — the profile selector replaces them. */
body.has-profiles .form-group-childname,
body.has-profiles .form-group-childage {
  display: none;
}

/* --- Story length pills --- */
.length-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.length-btn {
  padding: 9px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.length-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.length-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg-deep);
}

/* --- Library chain visualization --- */
.library-row-chain {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 2px 8px;
  background: rgba(245, 197, 66, 0.12);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.recent-card-chain {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 2px 8px;
  background: rgba(245, 197, 66, 0.12);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Chain breadcrumb links in the library detail view */
.library-chain-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
  margin-bottom: 14px;
  width: 100%;
  text-align: left;
}

.library-chain-link-after {
  margin-top: 20px;
  margin-bottom: 0;
}

.library-chain-link:hover {
  background: var(--bg-surface-hover);
  border-color: var(--gold);
  color: var(--text-primary);
}

.library-chain-link-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.library-chain-link-title {
  font-family: var(--font-story);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.library-chain-link-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.library-chain-link svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* "Continue this adventure" button in library detail (Pro/Family only) */
.library-continue-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  margin: 20px 0 0;
  background: var(--gold);
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-deep);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), filter 160ms var(--ease-out);
}

.library-continue-btn:hover {
  filter: brightness(1.05);
}

.library-continue-btn:active {
  transform: scale(0.98);
}

.library-continue-btn[hidden] { display: none; }

/* Generate button focus pulse — used after Continue this adventure */
@keyframes generate-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 197, 66, 0.6); }
  70%  { box-shadow: 0 0 0 14px rgba(245, 197, 66, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 197, 66, 0); }
}

#generateBtn.is-pulsing {
  animation: generate-pulse 1400ms var(--ease-out) 2;
}

/* --- Continuity toggle (Pro / Family) --- */
.continue-toggle {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  margin: 16px 0 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 200ms var(--ease-out), background 200ms var(--ease-out);
}

.continue-toggle[hidden] { display: none; }

.continue-toggle:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.continue-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.continue-toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 22px;
  margin-top: 2px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: background 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.continue-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 200ms var(--ease-out), background 200ms var(--ease-out);
}

.continue-toggle input:checked ~ .continue-toggle-track {
  background: var(--gold);
  border-color: var(--gold);
}

.continue-toggle input:checked ~ .continue-toggle-track::after {
  transform: translateX(14px);
  background: var(--bg-deep);
}

.continue-toggle input:focus-visible ~ .continue-toggle-track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.continue-toggle-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.continue-toggle-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.continue-toggle-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Fix: HTML hidden attribute should hide buttons too. .btn{display:inline-flex} was
   overriding the browser default for [hidden]. */
.btn[hidden] {
  display: none !important;
}

/* Compact footer (signed-in users) */
.footer-compact {
  padding: 32px 0 40px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-compact-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.footer-compact .logo-sm .logo-icon {
  font-size: 1.2rem;
}

.footer-compact .logo-sm .logo-text {
  font-size: 1rem;
}

.footer-compact-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-compact-meta a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-compact-meta a:hover {
  color: var(--gold);
}

/* Modal */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-modal[hidden] { display: none; }

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 10, 26, 0.7);
  backdrop-filter: blur(6px);
  animation: auth-fade-in 200ms var(--ease-out);
}

.auth-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: auth-rise 280ms var(--ease-out);
}

@keyframes auth-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.auth-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.auth-modal-content h3 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.auth-modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 24px;
}

.auth-form input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  margin-bottom: 12px;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.auth-form input[type="email"]:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--bg-surface-hover);
}

.auth-error {
  color: var(--coral);
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.auth-success-state {
  text-align: center;
}

.auth-success-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.auth-success-state h3 {
  text-align: center;
  margin-bottom: 8px;
}

.auth-success-state p {
  color: var(--text-secondary);
  margin: 0 0 24px;
}

/* Rate limit notice */
.rate-limit-notice {
  background: var(--gold-glow);
  border: 1px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-top: 16px;
  color: var(--text-primary);
}

.rate-limit-notice p {
  margin: 0 0 14px;
  line-height: 1.5;
}

.rate-limit-notice p:last-child { margin-bottom: 0; }

.rate-limit-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* --- Recent stories row (signed-in app shell) --- */
.recent-stories {
  margin: 32px 0 40px;
}

.recent-stories[hidden] {
  display: none !important;
}

.recent-stories-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.recent-stories-head h3 {
  font-family: var(--font-story);
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-primary);
}

.recent-stories-all {
  font-size: 0.85rem;
  white-space: nowrap;
}

.recent-stories-grid {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.recent-card {
  flex: 0 0 78%;
  scroll-snap-align: start;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  font-family: var(--font-body);
  color: inherit;
  transition: background 200ms var(--ease-out), border-color 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.recent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.recent-card:active {
  transform: scale(0.99);
  transition-duration: 100ms;
}

.recent-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.recent-card-title {
  font-family: var(--font-story);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.recent-card-fav {
  color: var(--gold);
  font-size: 0.9rem;
}

.recent-card-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.recent-card-preview {
  font-family: var(--font-story);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 720px) {
  .recent-stories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
    padding: 4px 0;
  }

  .recent-card {
    flex: initial;
  }
}

/* Save success block — gives Generate Another its space */
.save-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--mint);
}

.save-success p {
  margin: 0;
  font-weight: 600;
}

/* --- Pro waitlist (inline below pricing) --- */
.pro-waitlist {
  max-width: 520px;
  margin: 40px auto 0;
  text-align: center;
}

.pro-waitlist-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 14px;
}

.pro-waitlist-form {
  display: flex;
  gap: 8px;
}

.pro-waitlist-form input[type="email"] {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.pro-waitlist-form input[type="email"]:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--bg-surface-hover);
}

.pro-waitlist-msg {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.pro-waitlist-msg.success { color: var(--mint); }
.pro-waitlist-msg.error { color: var(--coral); }

@media (max-width: 540px) {
  .pro-waitlist-form { flex-direction: column; }
}

/* --- Save to Library button states --- */
.story-footer-anon p.story-cta { margin-bottom: 12px; }

/* --- Sign-up CTA section (replaced waitlist) --- */
.signup-cta {
  padding: var(--section-padding);
}

.signup-cta-card {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 36px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-mid) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.signup-cta-title {
  font-family: var(--font-story);
  font-size: 2rem;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.signup-cta-subtitle {
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-size: 1.05rem;
}

.signup-cta-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Tier badge in user menu --- */
.user-tier-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: var(--bg-deep);
  text-transform: uppercase;
  line-height: 1;
}

.user-tier-badge[hidden] {
  display: none;
}

.user-tier-badge[data-tier="family"] {
  background: linear-gradient(135deg, var(--gold) 0%, #d4943a 100%);
}

/* --- Floating Sign-in CTA (signed-out, after first story) --- */
.floating-signin {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out);
}

.floating-signin[hidden] { display: none; }

.floating-signin.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.floating-signin-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.floating-signin-cta svg {
  flex-shrink: 0;
}

.floating-signin-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.floating-signin-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

@media (max-width: 720px) {
  .floating-signin {
    bottom: 16px;
    left: 16px;
    right: 16px;
    padding: 8px 8px 8px 12px;
  }

  .floating-signin-cta {
    flex: 1;
    justify-content: center;
  }
}

/* --- Subscription success toast --- */
.sub-success-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 24px);
  opacity: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 22px 18px 20px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  border: 1px solid rgba(245, 197, 66, 0.45);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(245, 197, 66, 0.08) inset;
  color: var(--text-primary);
  width: calc(100vw - 32px);
  max-width: 440px;
  transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out);
}

.sub-success-toast[hidden] { display: none; }

.sub-success-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sub-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--gold);
  color: var(--bg-deep);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(245, 197, 66, 0.15);
}

.sub-success-toast > div {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.sub-success-toast strong {
  display: block;
  font-size: 1.02rem;
  line-height: 1.3;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.sub-success-toast p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}

.sub-success-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  padding: 0;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.sub-success-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* --- Feature card: Coming soon variant --- */
.feature-card-coming {
  position: relative;
}

.feature-card-coming .feature-icon,
.feature-card-coming h3,
.feature-card-coming p {
  opacity: 0.7;
}

.feature-coming-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid rgba(245, 197, 66, 0.35);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* --- Library: header trigger (text + icon) --- */
.library-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.library-trigger:hover {
  color: var(--gold);
  background: var(--bg-surface);
  border-color: rgba(245, 197, 66, 0.5);
}

.library-trigger:active {
  transform: scale(0.96);
  transition-duration: 100ms;
}

@media (max-width: 720px) {
  .library-trigger {
    padding: 8px 10px;
    border-radius: 50%;
    border: none;
    background: var(--bg-surface);
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  .library-trigger-text {
    display: none;
  }
}

/* --- Library: drawer (mobile bottom-sheet by default) --- */
:root {
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

.library-drawer {
  position: fixed;
  inset: 0;
  z-index: 1100;
  pointer-events: none;
}

.library-drawer[hidden] {
  display: none;
}

.library-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 10, 26, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 280ms var(--ease-drawer);
  pointer-events: auto;
}

.library-drawer.is-open .library-drawer-backdrop {
  opacity: 1;
}

.library-drawer-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 92vh;
  max-height: 92vh;
  background: var(--bg-card);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 280ms var(--ease-drawer);
  pointer-events: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.library-drawer.is-open .library-drawer-panel {
  transform: translateY(0);
}

@media (min-width: 720px) {
  .library-drawer-panel {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: 440px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 320ms var(--ease-drawer);
  }

  .library-drawer.is-open .library-drawer-panel {
    transform: translateX(0);
  }
}

.library-drawer-grabber {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.4;
  margin: 10px auto 0;
  flex-shrink: 0;
}

@media (min-width: 720px) {
  .library-drawer-grabber {
    display: none;
  }
}

/* Two-pane push navigation inside the panel */
.library-drawer-view {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  transition: transform 240ms var(--ease-out);
  background: var(--bg-card);
  /* Offset for the grabber on mobile */
  padding-top: 14px;
}

@media (min-width: 720px) {
  .library-drawer-view {
    padding-top: 0;
  }
}

.library-drawer-list {
  transform: translateX(0);
}

.library-drawer-detail {
  transform: translateX(100%);
}

.library-drawer-panel.is-detail .library-drawer-list {
  transform: translateX(-100%);
}

.library-drawer-panel.is-detail .library-drawer-detail {
  transform: translateX(0);
}

.library-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 12px;
  flex-shrink: 0;
}

.library-drawer-title {
  font-family: var(--font-story);
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.library-drawer-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.library-drawer-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.library-drawer-icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.library-drawer-icon-btn:active {
  transform: scale(0.94);
  transition-duration: 100ms;
}

.library-drawer-icon-btn.is-active {
  color: var(--gold);
}

.library-drawer-detail-actions {
  display: flex;
  gap: 4px;
}

/* List */
.library-drawer-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.library-drawer-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.library-drawer-empty h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.library-drawer-empty p {
  margin: 0 0 20px;
  font-size: 0.95rem;
}

.library-drawer-empty .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.library-drawer-empty-dismiss {
  display: inline-block;
  margin: 0;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: var(--text-muted, var(--text-secondary));
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 160ms var(--ease-out);
}
.library-drawer-empty-dismiss:hover {
  color: var(--text-primary);
}

.library-drawer-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.library-row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px 14px;
  font-family: var(--font-body);
  color: inherit;
  cursor: pointer;
  transition: background 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.library-row:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}

.library-row:active {
  transform: scale(0.995);
  transition: transform 100ms var(--ease-out);
}

.library-row + .library-row {
  margin-top: 4px;
}

.library-row.is-highlight {
  background: rgba(245, 197, 66, 0.12);
  border-color: rgba(245, 197, 66, 0.5);
  animation: library-row-pulse 2500ms var(--ease-in-out);
}

@keyframes library-row-pulse {
  0%   { background: rgba(245, 197, 66, 0.22); border-color: rgba(245, 197, 66, 0.7); }
  40%  { background: rgba(245, 197, 66, 0.12); border-color: rgba(245, 197, 66, 0.45); }
  70%  { background: rgba(245, 197, 66, 0.18); border-color: rgba(245, 197, 66, 0.55); }
  100% { background: transparent; border-color: transparent; }
}

.library-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.library-row-head-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.library-row-title {
  font-family: var(--font-story);
  font-size: 1.05rem;
  color: var(--text-primary);
  font-weight: 600;
}

.library-row-fav {
  color: var(--gold);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.library-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.library-row-dot {
  opacity: 0.6;
}

.library-row-preview {
  font-family: var(--font-story);
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Detail */
.library-drawer-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 32px;
  -webkit-overflow-scrolling: touch;
}

.library-drawer-detail-title {
  font-family: var(--font-story);
  font-size: 1.6rem;
  color: var(--gold);
  margin: 0 0 6px;
}

.library-drawer-detail-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 22px;
}

.library-drawer-detail-body {
  font-family: var(--font-story);
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.library-drawer-detail-body p {
  margin: 0 0 14px;
}

/* Undo toast */
.library-undo-toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px 12px 20px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
  pointer-events: auto;
  z-index: 5;
}

.library-undo-toast[hidden] {
  display: none;
}

.library-undo-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.library-undo-text {
  color: var(--text-secondary);
}

.library-undo-btn {
  background: transparent;
  border: none;
  color: var(--gold);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.library-undo-btn:hover {
  background: var(--bg-surface);
}


/* Press feedback for the icon button on touch */
@media (hover: hover) and (pointer: fine) {
  .library-row:hover {
    background: var(--bg-surface);
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* Free-tier upgrade banner.
   Lives inside a narrow form column, so we use flex-wrap (not a viewport
   media query) — the button drops to its own row whenever the available
   width can't fit text + button on one line. */
.free-tier-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 16px;
  margin: 0 0 20px;
  background: linear-gradient(135deg, rgba(255, 200, 87, 0.12), rgba(255, 138, 76, 0.10));
  border: 1px solid rgba(255, 200, 87, 0.35);
  border-radius: var(--radius-md, 12px);
}
.free-tier-banner[hidden] { display: none; }
.free-tier-banner-text {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.free-tier-banner-text strong {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.free-tier-banner-text span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}
.free-tier-banner .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Custom theme / lesson entry buttons (Pro+ feature) */
.theme-btn.theme-btn-custom,
.pill-btn.pill-btn-custom {
  border-style: dashed;
  color: var(--gold);
  background: transparent;
}
.theme-btn.theme-btn-custom.active,
.pill-btn.pill-btn-custom.active {
  border-style: solid;
  border-color: var(--gold);
  background: var(--gold-glow);
  color: var(--gold);
}

/* Inline input row that appears below the theme grid / lesson pills
   when the user picks the custom entry. */
.custom-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}
.custom-input-row[hidden] { display: none; }
.custom-input-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 160ms var(--ease-out);
}
.custom-input-row input:focus {
  outline: none;
  border-color: var(--gold);
}
.custom-input-row .btn {
  flex-shrink: 0;
}
.custom-input-cancel {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 38px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.custom-input-cancel:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Locked control state (free tier).
   Aspirational, not defensive — full color, small PRO badge inline.
   Clicking opens the upgrade flow. The locks should feel like a teaser of
   what's already there waiting, not a disabled state. */
.theme-btn.is-locked,
.pill-btn.is-locked,
.length-btn.is-locked {
  cursor: pointer;
}
.theme-btn.is-locked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  min-width: 0;
}
.pill-btn.is-locked,
.length-btn.is-locked {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.theme-btn.is-locked::after,
.pill-btn.is-locked::after,
.length-btn.is-locked::after {
  content: "PRO";
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--gold);
  opacity: 0.5;
  line-height: 1;
  flex-shrink: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .theme-btn.is-locked:hover::after,
  .pill-btn.is-locked:hover::after,
  .length-btn.is-locked:hover::after {
    opacity: 1;
  }
}
@media (hover: hover) and (pointer: fine) {
  .theme-btn.is-locked:hover,
  .pill-btn.is-locked:hover,
  .length-btn.is-locked:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
    transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out);
  }
}

.rate-limit-footnote {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  opacity: 0.85;
}

/* --- Story pages (SEO landing pages at /stories/*) --- */
body.story-page {
  background: var(--bg-deep);
  min-height: 100vh;
}
.story-page-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 10, 26, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.story-page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.story-page-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.story-page-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 160ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .story-page-nav a:hover { color: var(--text-primary); }
}
.story-page-nav .btn { white-space: nowrap; }

.story-page-article {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 32px;
}
.story-page-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.story-page-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.story-page-breadcrumb a:hover { color: var(--text-primary); }
.story-page-title {
  font-family: var(--font-body);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 16px;
  color: var(--text-primary);
}
.story-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 32px;
  font-size: 13px;
  color: var(--text-muted);
  align-items: center;
}
.story-page-meta span {
  display: inline-flex;
  align-items: center;
}
.story-page-meta span + span::before {
  content: "·";
  margin-right: 14px;
  opacity: 0.6;
}
.story-page-content {
  font-family: var(--font-story);
  font-size: 19px;
  line-height: 1.75;
  color: var(--text-primary);
}
.story-page-content p {
  margin: 0 0 18px;
}
.story-page-end {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 2.5px;
  text-align: center;
  margin: 32px 0 0;
}

.story-page-cta-card {
  max-width: 720px;
  margin: 32px auto;
  padding: 28px 24px 24px;
  background: linear-gradient(180deg, var(--gold-glow) 0%, rgba(245, 197, 66, 0.04) 100%);
  border: 1px solid rgba(245, 197, 66, 0.4);
  border-radius: var(--radius-md);
  text-align: center;
}
.story-page-cta-card h2 {
  font-size: 22px;
  color: var(--gold);
  margin: 0 0 10px;
}
.story-page-cta-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 18px;
  line-height: 1.55;
}
.story-page-cta-footnote {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  margin: 12px 0 0 !important;
}

.story-page-related {
  max-width: 720px;
  margin: 32px auto 64px;
  padding: 0 24px;
}
.story-page-related h2 {
  font-size: 20px;
  margin: 0 0 16px;
  color: var(--text-primary);
}
.story-page-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.story-page-related-grid a {
  display: block;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  transition: border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
  font-size: 14px;
  line-height: 1.4;
}
.story-page-related-grid a strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.story-page-related-grid a span {
  font-size: 12px;
  color: var(--text-muted);
}
@media (hover: hover) and (pointer: fine) {
  .story-page-related-grid a:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
  }
}

/* Stories index / library landing */
.stories-index-hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 64px 24px 24px;
  text-align: center;
}
.stories-index-hero h1 {
  font-size: clamp(32px, 4.5vw, 48px);
  line-height: 1.15;
  margin: 0 0 16px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.stories-index-hero p {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 24px;
}
.stories-index-grid {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.stories-index-card {
  display: block;
  padding: 22px 22px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.stories-index-card h2 {
  font-size: 18px;
  line-height: 1.3;
  margin: 0 0 8px;
}
.stories-index-card-excerpt {
  font-family: var(--font-story);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 14px;
}
.stories-index-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.stories-index-card-meta span + span::before {
  content: "·";
  margin-right: 12px;
  opacity: 0.6;
}
@media (hover: hover) and (pointer: fine) {
  .stories-index-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
  }
}

/* Embedded Stripe Checkout modal */
.checkout-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.checkout-modal[hidden] { display: none; }

.checkout-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 10, 26, 0.78);
  backdrop-filter: blur(6px);
  animation: auth-fade-in 200ms var(--ease-out);
}

.checkout-modal-content {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 48px 20px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: auth-rise 280ms var(--ease-out);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.checkout-modal-title {
  position: absolute;
  top: 16px;
  left: 24px;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.checkout-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #6b6b6b;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.checkout-modal-close:hover {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.06);
}

.checkout-container {
  flex: 1;
  min-height: 640px;
  overflow-y: auto;
}

body.checkout-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .checkout-modal {
    padding: 0;
    align-items: stretch;
  }
  .checkout-modal-content {
    max-width: none;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    padding-top: 52px;
  }
}
