/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --theme-colour: #c89b4a;
  --theme-pale: #f5e8c0;
  --theme-mid: rgba(200,155,74,0.18);
  --cream: #fdf8f0;
  --parchment: #f7f0e0;
  --warm-white: #fffdf7;
  --ink: #2c2018;
  --ink-soft: #5a4a35;
  --ink-muted: #9a8870;
  --gold: #c89b4a;
  --gold-light: #e8c97a;
  --gold-pale: #f5e8c0;
  --rose: #d4708a;
  --rose-pale: #fceef3;
  --sage: #7aad8c;
  --sage-pale: #eef5f0;
  --lavender: #a07ab8;
  --lavender-pale: #f3eefc;
  --sky: #7aade0;
  --sky-pale: #eef4fc;
  --shadow: rgba(44, 32, 24, 0.08);
  --shadow-md: rgba(44, 32, 24, 0.14);
  --radius: 20px;
  --radius-sm: 10px;
}

html { scroll-behavior: smooth; }

p {
  font-family: 'Nunito', sans-serif;
}

body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* === ATMOSPHERIC BACKGROUND === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(200, 155, 74, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, rgba(160, 122, 184, 0.07) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 85%, rgba(122, 173, 140, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(212, 112, 138, 0.05) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* === STARS === */
/* === ATMOSPHERIC LAYER — fixed, pointer-events:none, GPU-composited === */
.stars, .fireflies, .aurora, .sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* === AURORA BACKGROUND === */
.aurora {
  z-index: 0;
}
.aurora-orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  animation: aurora-drift var(--a-dur, 18s) ease-in-out infinite alternate;
  animation-delay: var(--a-delay, 0s);
  opacity: 0;
  animation-fill-mode: both;
}
@keyframes aurora-drift {
  0%   { opacity: var(--a-op, 0.06); transform: translate(0, 0) scale(1); }
  50%  { opacity: var(--a-op, 0.06); transform: translate(var(--ax, 40px), var(--ay, -30px)) scale(1.08); }
  100% { opacity: var(--a-op, 0.06); transform: translate(var(--ax2, -20px), var(--ay2, 20px)) scale(0.96); }
}

/* === MAGICAL TREES — SVG silhouettes fixed to bottom corners === */
.magic-trees {
  position: fixed;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.18;
}
.magic-trees-left  { left: 0; }
.magic-trees-right { right: 0; transform: scaleX(-1); }

/* === STARS === */
.stars { z-index: 1; }
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  will-change: transform, opacity;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}
.star.gold { background: var(--gold); }
.star.large {
  box-shadow: 0 0 6px 2px rgba(255,255,255,0.3);
}
@keyframes twinkle {
  0%, 100% { opacity: var(--max-opacity, 0.5); transform: scale(0.7); }
  50% { opacity: var(--max-opacity, 0.5); transform: scale(1); }
}

/* === FIREFLIES === */
.fireflies { z-index: 2; }
.firefly {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--theme-colour);
  border-radius: 50%;
  will-change: transform, opacity;
  animation: fly var(--fly-dur, 8s) ease-in-out infinite;
  animation-delay: var(--fly-delay, 0s);
  opacity: 0;
  box-shadow: 0 0 10px 4px var(--theme-mid);
  transition: background 0.6s ease, box-shadow 0.6s ease;
}
@keyframes fly {
  0%   { opacity: 0.6; transform: translate(0, 0); }
  50%  { opacity: 0.4; transform: translate(var(--tx, 60px), var(--ty, -80px)); }
  100% { opacity: 0; transform: translate(var(--tx2, 120px), var(--ty2, -160px)); }
}

/* === SPARKLES === */
.sparkles { z-index: 2; }
.sparkle {
  position: absolute;
  will-change: transform, opacity;
  animation: sparkle-pop var(--sp-dur, 4s) ease-in-out infinite;
  animation-delay: var(--sp-delay, 0s);
  opacity: 0;
  font-size: var(--sp-size, 14px);
  line-height: 1;
  user-select: none;
}
@keyframes sparkle-pop {
  0%   { opacity: var(--sp-op, 0.5); transform: scale(0.8) rotate(0deg); }
  50%  { opacity: var(--sp-op, 0.5); transform: scale(1) rotate(20deg); }
  100% { opacity: 0; transform: scale(0.2) rotate(30deg); }
}

/* === FLOATING ELEMENTS (lanterns, moons, leaves) === */
.floater {
  position: absolute;
  will-change: transform, opacity;
  animation: float-up var(--fl-dur, 20s) ease-in-out infinite;
  animation-delay: var(--fl-delay, 0s);
  opacity: 0;
  font-size: var(--fl-size, 18px);
  line-height: 1;
  user-select: none;
  filter: var(--fl-filter, none);
}
@keyframes float-up {
  0%   { opacity: var(--fl-op, 0.4); transform: translate(0, 0) rotate(0deg); }
  50%  { opacity: var(--fl-op, 0.4); transform: translate(var(--flx, 20px), var(--fly, -120px)) rotate(var(--flr, 8deg)); }
  100% { opacity: 0; transform: translate(var(--flx2, -10px), var(--fly2, -260px)) rotate(var(--flr2, -5deg)); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .aurora-orb, .star, .firefly, .sparkle, .floater { animation: none !important; opacity: 0 !important; }
}

/* === LAYOUT WRAPPER === */
.site-header, .landing { position: relative; z-index: 1; }

/* === HEADER === */
.site-header {
  text-align: center;
  padding: 3rem 2rem 1.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 20px;
  color: var(--gold);
  animation: spin-slow 12s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.tagline {
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-style: italic;
  font-family: 'Lora', serif;
  letter-spacing: 0.05em;
}

/* === LANDING === */
.landing {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 2rem 2rem;
}

.hero-text {
  text-align: center;
  margin-bottom: 3.5rem;
}

.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 1rem;
}
.hero-title em { color: var(--gold); font-style: italic; }

.hero-sub {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
  font-family: 'Lora', serif;
}

/* === CHOICE GRID === */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

/* === CHOICE CARD === */
.choice-card {
  position: relative;
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 2.5rem 2rem 2rem;
  border: 1.5px solid rgba(200, 155, 74, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  text-decoration: none;
  color: inherit;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  box-shadow: 0 4px 24px var(--shadow);
  cursor: pointer;
}

.choice-card:not(.card-disabled):hover {
  transform: translateY(-6px) rotate(-0.3deg);
  box-shadow: 0 16px 48px var(--shadow-md);
  border-color: rgba(200, 155, 74, 0.4);
}

.card-disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: grayscale(20%);
}

/* Decorative swirls inside cards */
.card-deco {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.card-deco-1 {
  width: 120px; height: 120px;
  top: -40px; right: -30px;
  background: radial-gradient(circle, rgba(200,155,74,0.08) 0%, transparent 70%);
}
.card-deco-2 {
  width: 80px; height: 80px;
  bottom: 20px; left: -20px;
  background: radial-gradient(circle, rgba(160,122,184,0.08) 0%, transparent 70%);
}
.card-deco-3 {
  width: 100px; height: 100px;
  top: -30px; right: -20px;
  background: radial-gradient(circle, rgba(122,173,140,0.08) 0%, transparent 70%);
}
.card-deco-4 {
  width: 110px; height: 110px;
  top: -35px; right: -25px;
  background: radial-gradient(circle, rgba(160,122,184,0.08) 0%, transparent 70%);
}

.card-icon-wrap {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 28px;
}
.card-book .card-icon-wrap { background: var(--gold-pale); }
.card-teddy .card-icon-wrap { background: var(--sage-pale); }
.card-poster .card-icon-wrap { background: var(--lavender-pale); }

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-soft);
  font-family: 'Lora', serif;
  margin-bottom: 1.75rem;
  flex: 1;
}

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--cream);
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.2s, transform 0.2s;
}
.card-book:hover .card-cta { background: var(--gold); }
.card-poster:hover .card-cta { background: var(--gold); }
.disabled-cta {
  background: var(--parchment);
  color: var(--ink-muted);
}

/* Coming Soon badge */
.coming-soon-badge {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: var(--sage-pale);
  color: #4d8a62;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 50px;
  border: 1px solid rgba(122,173,140,0.3);
}

/* === FOOTER NOTE === */
.footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-family: 'Lora', serif;
  font-style: italic;
}

/* ============================================================
   BOOK CREATION PAGE
   ============================================================ */

.create-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.2s;
}
.page-back:hover { color: var(--gold); }
.page-back svg { transition: transform 0.2s; }
.page-back:hover svg { transform: translateX(-3px); }

.page-intro { text-align: center; margin-bottom: 3rem; }
.page-intro h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--ink);
  margin-bottom: 0.75rem;
}
.page-intro p {
  font-family: 'Lora', serif;
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.7;
  max-width: 500px;
  margin: 0 auto;
}

/* === PROGRESS BAR === */
.progress-bar-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 2.5rem;
  align-items: center;
  justify-content: center;
}
.progress-step {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--parchment);
  max-width: 90px;
  transition: background 0.4s ease;
}
.progress-step.active { background: var(--theme-colour); transition: background 0.5s ease; }
.progress-step.done { background: var(--theme-colour); opacity: 0.45; transition: background 0.5s ease; }

.progress-label {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-bottom: 2rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* === FORM SECTIONS === */
.form-section {
  display: none;
  animation: fadeSlideIn 0.45s ease forwards;
}
.form-section.active { display: block; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1.5px solid var(--theme-mid);
  transition: border-color 0.5s ease;
}

.section-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.icon-rose { background: var(--rose-pale); }
.icon-sky { background: var(--sky-pale); }
.icon-lavender { background: var(--lavender-pale); }
.icon-sage { background: var(--sage-pale); }
.icon-gold { background: var(--gold-pale); }

.section-header-text h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.section-header-text p {
  font-size: 0.83rem;
  color: var(--ink-muted);
  font-family: 'Lora', serif;
  font-style: italic;
}

/* === FORM GRID === */
.form-grid {
  display: grid;
  gap: 1.5rem;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 600px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* === FORM FIELDS === */
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span-2 { grid-column: span 2; }
.form-field.span-3 { grid-column: span 3; }

@media (max-width: 600px) {
  .form-field.span-2, .form-field.span-3 { grid-column: span 1; }
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
label .hint {
  font-weight: 400;
  text-transform: none;
  color: var(--ink-muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  font-family: 'Lora', serif;
  font-style: italic;
  margin-left: 4px;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--warm-white);
  border: 1.5px solid rgba(200, 155, 74, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--theme-colour);
  box-shadow: 0 0 0 3px var(--theme-mid);
  transition: border-color 0.3s, box-shadow 0.3s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a8870' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* === PILL SELECTORS === */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill-group input[type="checkbox"],
.pill-group input[type="radio"] { display: none; }

.pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid rgba(200, 155, 74, 0.2);
  background: var(--warm-white);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.pill:hover { border-color: var(--gold); color: var(--ink); }
input[type="checkbox"]:checked + .pill,
input[type="radio"]:checked + .pill {
  background: var(--theme-colour);
  border-color: var(--theme-colour);
  color: var(--warm-white);
  transition: background 0.4s ease, border-color 0.4s ease;
}

/* === RANGE SLIDER === */
.range-wrap { display: flex; flex-direction: column; gap: 8px; }
.range-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--parchment);
  outline: none;
  -webkit-appearance: none;
  border: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 2px solid var(--warm-white);
  box-shadow: 0 1px 6px rgba(200,155,74,0.4);
}
input[type="range"]:focus { box-shadow: none; border: none; }
.range-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  min-width: 28px;
  text-align: right;
}
.range-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--ink-muted); font-style: italic; }

/* === CHARACTER CARDS === */
.character-cards { display: grid; gap: 1rem; }
.character-card {
  background: var(--parchment);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  border: 1.5px solid rgba(200,155,74,0.12);
  position: relative;
}
.character-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.character-card-title { font-size: 0.82rem; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.btn-remove-char {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--ink-muted); line-height: 1;
  transition: color 0.2s;
}
.btn-remove-char:hover { color: var(--rose); }
.character-card .form-grid-2 { gap: 0.75rem; }
.btn-add-character {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px;
  border: 1.5px dashed rgba(200,155,74,0.35);
  border-radius: var(--radius-sm);
  background: transparent; cursor: pointer;
  color: var(--ink-muted); font-size: 0.85rem; font-weight: 600;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
}
.btn-add-character:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-pale); }

/* === NAVIGATION BUTTONS === */
.form-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1.5px solid rgba(200, 155, 74, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.22s ease;
  letter-spacing: 0.02em;
}
.btn-prev {
  background: var(--parchment);
  color: var(--ink-soft);
}
.btn-prev:hover { background: var(--gold-pale); }
.btn-next {
  background: var(--ink);
  color: var(--cream);
}
.btn-next:hover { background: var(--theme-colour); transform: translateX(2px); }
.btn-generate {
  background: var(--theme-colour);
  color: var(--ink);
  box-shadow: 0 4px 16px var(--theme-mid);
  transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.2s;
}
.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--theme-mid);
}
.btn-generate:active { transform: scale(0.98); }

/* === LOADING STATE === */
.story-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  gap: 1.5rem;
}
.story-loading.visible { display: flex; }

.loading-stars {
  display: flex; gap: 12px;
}
.loading-star {
  width: 10px; height: 10px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce-star 1.2s ease-in-out infinite;
}
.loading-star:nth-child(2) { animation-delay: 0.2s; background: var(--rose); }
.loading-star:nth-child(3) { animation-delay: 0.4s; background: var(--lavender); }
.loading-star:nth-child(4) { animation-delay: 0.6s; background: var(--sage); }
@keyframes bounce-star {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-12px); opacity: 1; }
}
.loading-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--ink);
  font-style: italic;
}
.loading-sub { font-size: 0.85rem; color: var(--ink-muted); }

/* === STORY OUTPUT === */
.story-output {
  display: none;
}
.story-output.visible { display: block; }

.story-book {
  --book-tint: rgba(253, 248, 240, 0);
  --book-spine: linear-gradient(180deg, var(--gold) 0%, var(--rose) 50%, var(--lavender) 100%);
  background: var(--warm-white);
  background-image: radial-gradient(ellipse at 60% 0%, var(--book-tint) 0%, transparent 70%);
  border-radius: var(--radius);
  border: 1.5px solid rgba(200, 155, 74, 0.18);
  padding: 3rem 3.5rem;
  box-shadow: 0 4px 32px var(--shadow);
  position: relative;
  overflow: hidden;
  transition: background-image 0.6s ease, border-color 0.6s ease;
}
.story-book::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--book-spine);
  border-radius: var(--radius) 0 0 var(--radius);
  transition: background 0.6s ease;
}

.story-book-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  font-style: italic;
}
.story-book-subtitle {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(200,155,74,0.15);
}

.story-text {
  font-family: 'Lora', serif;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.story-text p { margin-bottom: 1.25em; }

.story-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.btn-restart {
  background: var(--parchment);
  color: var(--ink-soft);
}
.btn-restart:hover { background: var(--gold-pale); }
.btn-new-story {
  background: var(--ink);
  color: var(--cream);
}
.btn-new-story:hover { background: var(--gold); }

/* === WORD COUNT GUIDE === */
.word-count-guide {
  display: flex;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 4px;
  font-style: italic;
}

/* === DIVIDER === */
.section-divider {
  height: 1px;
  background: rgba(200,155,74,0.1);
  margin: 1.5rem 0;
}

/* === TOOLTIP === */
.field-tip {
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-family: 'Lora', serif;
  font-style: italic;
  margin-top: 2px;
}

/* === ILLUSTRATIONS === */
.story-illustration {
  margin: 2rem 0;
  text-align: center;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.story-illustration-img {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: var(--radius);
  border: 1.5px solid rgba(200, 155, 74, 0.15);
  box-shadow: 0 4px 24px var(--shadow);
  display: block;
  margin: 0 auto;
  object-fit: cover;
  animation: fadeInIllustration 0.6s ease forwards;
}

@keyframes fadeInIllustration {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Placeholder shimmer while illustration loads */
.story-illustration-placeholder {
  width: 100%;
  max-width: 560px;
  height: 280px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--parchment) 25%, var(--gold-pale) 50%, var(--parchment) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 600px) {
  .story-book { padding: 2rem 1.5rem; }
  .form-nav { flex-direction: column-reverse; gap: 12px; }
  .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   COVER MODAL
   ============================================================ */
.cover-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 32, 24, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  animation: fadeInOverlay 0.3s ease forwards;
}
.cover-modal-overlay.visible { display: flex; }

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cover-modal {
  background: var(--warm-white);
  border-radius: var(--radius);
  border: 1.5px solid rgba(200,155,74,0.2);
  box-shadow: 0 24px 64px rgba(44,32,24,0.25);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  animation: slideUpModal 0.35s ease forwards;
}

@keyframes slideUpModal {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cover-modal-header {
  padding: 2rem 2rem 1.25rem;
  border-bottom: 1px solid rgba(200,155,74,0.12);
}
.cover-modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-style: italic;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.cover-modal-sub {
  font-size: 0.87rem;
  color: var(--ink-soft);
  font-family: 'Lora', serif;
  line-height: 1.6;
}

.cover-modal-body {
  padding: 1.5rem 2rem;
}

.cover-modal-footer {
  padding: 1.25rem 2rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid rgba(200,155,74,0.1);
}

.btn-skip-cover {
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.85rem;
  padding: 8px 16px;
  border: 1px solid rgba(200,155,74,0.2);
}
.btn-skip-cover:hover { background: var(--parchment); color: var(--ink-soft); }

.btn-make-cover {
  background: var(--theme-colour);
  color: var(--warm-white);
  box-shadow: 0 4px 16px var(--theme-mid);
  transition: background 0.4s, transform 0.2s, box-shadow 0.4s;
}
.btn-make-cover:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--theme-mid); }

/* ============================================================
   COVER PAGE
   ============================================================ */
.story-cover {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2.5rem;
  border: 1.5px solid var(--theme-mid);
  box-shadow: 0 8px 40px var(--shadow-md);
  background: var(--ink);
  position: relative;
  animation: fadeInIllustration 0.7s ease forwards;
}

.story-cover-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
}

.story-cover-shimmer {
  width: 100%;
  padding-top: 150%;
  background: linear-gradient(135deg, #2c2018 0%, #4a3828 50%, #2c2018 100%);
  background-size: 200% 200%;
  animation: coverShimmer 2s ease-in-out infinite;
}
@keyframes coverShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.story-cover-img {
  display: block;
  width: 100%;
  height: auto;
  animation: fadeInIllustration 0.8s ease forwards;
}

.story-cover-text { display: none; }
.story-cover-title { display: none; }
.story-cover-author { display: none; }

/* === DEV: PDF DOWNLOAD BUTTON === */
.btn-download-pdf {
  background: #2c2018;
  color: var(--cream);
  border: 1.5px dashed rgba(200,155,74,0.4);
  font-size: 0.82rem;
  padding: 9px 18px;
  gap: 7px;
  position: relative;
}
.btn-download-pdf::after {
  content: 'DEV';
  position: absolute;
  top: -8px;
  right: -4px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 4px;
}
.btn-download-pdf:hover { background: #1a1008; border-color: var(--gold); }
.btn-download-pdf:disabled { opacity: 0.5; cursor: not-allowed; }

/* === DEV — DOWNLOAD PDF BUTTON === */
.btn-download-pdf {
  background: transparent;
  color: var(--ink-muted);
  border: 1.5px dashed rgba(200,155,74,0.35);
  font-size: 0.8rem;
  padding: 8px 16px;
  display: none;
}
.btn-download-pdf.visible { display: inline-flex; }
.btn-download-pdf:hover { background: var(--gold-pale); border-color: var(--gold); color: var(--ink); }

.pdf-generating {
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-family: 'Lora', serif;
  font-style: italic;
  margin-top: 1rem;
}
.pdf-generating.visible { display: flex; }
.pdf-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--parchment);
  border-top-color: var(--theme-colour);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === REGEN COVER BUTTON === */
.btn-regen-cover {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(44, 32, 24, 0.55);
  color: rgba(255, 248, 235, 0.9);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
  letter-spacing: 0.03em;
}
.btn-regen-cover:hover { background: rgba(44, 32, 24, 0.8); }

/* === COVER MODAL BUTTON SPINNER === */
.cover-btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn-make-cover.loading .cover-btn-spinner { display: inline-block; }
.btn-make-cover.loading #btnMakeCoverLabel { opacity: 0.7; }
.btn-make-cover.loading { cursor: wait; pointer-events: none; gap: 8px; }
.btn-skip-cover.disabled { opacity: 0.4; pointer-events: none; cursor: not-allowed; }

/* === ILLUSTRATION STYLE CARDS === */
.style-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 6px;
}

@media (max-width: 560px) {
  .style-cards { grid-template-columns: repeat(2, 1fr); }
}

.style-card {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(200,155,74,0.15);
  overflow: hidden;
  background: var(--warm-white);
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  user-select: none;
}
.style-card:hover { border-color: rgba(200,155,74,0.4); transform: translateY(-2px); }
.style-card.selected,
.style-card:has(input:checked) {
  border-color: var(--theme-colour);
  box-shadow: 0 0 0 2px var(--theme-mid);
}
.style-card input[type="radio"] { display: none; }

.style-card-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--parchment);
  position: relative;
  overflow: hidden;
}
.style-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.style-card-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.4;
}
/* Hide placeholder when image loads */
.style-card-img-wrap img:not([src=""]) ~ .style-card-placeholder { display: none; }
/* Show placeholder when image errors */
.style-card-img-wrap.no-img img { display: none; }
.style-card-img-wrap.no-img .style-card-placeholder { display: flex; opacity: 0.5; }

.style-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  padding: 7px 4px;
  letter-spacing: 0.03em;
}

/* ============================================================
   POSTER TYPE SELECTOR
   ============================================================ */
.poster-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 600px) { .poster-type-grid { grid-template-columns: 1fr; } }

.poster-type-card {
  border-radius: var(--radius);
  border: 2px solid rgba(200,155,74,0.15);
  background: var(--warm-white);
  padding: 1.5rem 1.25rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  user-select: none;
}
.poster-type-card input[type="radio"] { display: none; }
.poster-type-card:hover { border-color: rgba(200,155,74,0.4); transform: translateY(-3px); box-shadow: 0 8px 24px var(--shadow); }
.poster-type-card.selected,
.poster-type-card:has(input:checked) {
  border-color: var(--theme-colour);
  box-shadow: 0 0 0 2px var(--theme-mid), 0 8px 24px var(--shadow);
}
.poster-type-icon { font-size: 2rem; }
.poster-type-card { text-transform: none; letter-spacing: 0; font-weight: 400; }
.poster-type-title { font-family: 'Playfair Display', serif; font-size: 1rem; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; }
.poster-type-desc { font-size: 0.8rem; color: var(--ink-soft); font-family: 'Lora', serif; line-height: 1.5; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ============================================================
   POSTER OUTPUT
   ============================================================ */
.poster-output { display: none; }

.poster-preview-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 40px var(--shadow-md);
  border: 1.5px solid var(--theme-mid);
  background: var(--ink);
  display: inline-block;
  width: 100%;
  max-width: 500px;
}

.poster-preview-img {
  display: block;
  width: 100%;
  height: auto;
  animation: fadeInIllustration 0.7s ease forwards;
}

/* ============================================================
   HELP BUTTON & FAQ MODAL
   ============================================================ */

.btn-help {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--warm-white);
  border: 1.5px solid rgba(200, 155, 74, 0.35);
  color: var(--ink-muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 10px 22px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--shadow-md);
  transition: border-color 0.25s, color 0.25s, background 0.25s, transform 0.2s, box-shadow 0.25s;
}
.btn-help:hover {
  border-color: var(--gold);
  color: var(--ink-soft);
  background: var(--gold-pale);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--shadow-md);
}
.btn-help-icon {
  font-size: 11px;
  color: var(--gold);
  animation: spin-slow 12s linear infinite;
  display: inline-block;
}

/* === FAQ OVERLAY === */
.faq-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 32, 24, 0.52);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeInOverlay 0.25s ease forwards;
}
.faq-overlay.visible {
  display: flex;
}

@media (min-width: 560px) {
  .faq-overlay {
    align-items: center;
  }
}

/* === FAQ MODAL BOX === */
.faq-modal {
  background: var(--warm-white);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1.5px solid rgba(200, 155, 74, 0.18);
  box-shadow: 0 -8px 48px rgba(44, 32, 24, 0.18), 0 0 0 1px rgba(200,155,74,0.08);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUpModal 0.32s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  position: relative;
}
.faq-modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--rose) 50%, var(--lavender) 100%);
  border-radius: var(--radius) var(--radius) 0 0;
}

@media (min-width: 560px) {
  .faq-modal {
    border-radius: var(--radius);
    max-height: 80vh;
    animation: slideUpModal 0.32s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  }
  .faq-modal::before {
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* === FAQ HEADER === */
.faq-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.75rem 1.25rem;
  border-bottom: 1.5px solid rgba(200, 155, 74, 0.12);
  flex-shrink: 0;
}
.faq-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.faq-header-icon {
  font-size: 14px;
  color: var(--gold);
  animation: spin-slow 12s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.faq-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  font-style: italic;
}

.faq-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}
.faq-close:hover {
  color: var(--ink);
  background: var(--parchment);
}

/* === FAQ BODY / SCROLL AREA === */
.faq-modal-body {
  overflow-y: auto;
  padding: 0.5rem 0 1.25rem;
  flex: 1;
  overscroll-behavior: contain;
}
.faq-modal-body::-webkit-scrollbar { width: 4px; }
.faq-modal-body::-webkit-scrollbar-track { background: transparent; }
.faq-modal-body::-webkit-scrollbar-thumb { background: rgba(200,155,74,0.25); border-radius: 4px; }

/* === FAQ LIST === */
.faq-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.faq-item {
  border-bottom: 1px solid rgba(200, 155, 74, 0.1);
}
.faq-item:last-child {
  border-bottom: none;
}

/* === FAQ QUESTION (the clickable headline) === */
.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 1.1rem 1.75rem;
  text-align: left;
  font-family: 'Lora', serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.45;
  transition: color 0.2s, background 0.2s;
}
.faq-question:hover {
  color: var(--ink);
  background: rgba(200, 155, 74, 0.04);
}
.faq-item.open .faq-question {
  color: var(--ink);
}

/* === FAQ CHEVRON === */
.faq-chevron {
  flex-shrink: 0;
  color: var(--gold);
  opacity: 0.7;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  display: flex;
  align-items: center;
}
.faq-item.open .faq-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* === FAQ ANSWER (collapsible) === */
.faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.faq-item.open .faq-answer {
  grid-template-rows: 1fr;
}
.faq-answer-inner {
  overflow: hidden;
}
.faq-answer p {
  padding: 0 1.75rem 1.25rem;
  font-family: 'Lora', serif;
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--ink-muted);
  margin: 0;
}

/* === FAQ SUPPORT FOOTER & LINK === */
.faq-link {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(200, 155, 74, 0.4);
  text-underline-offset: 2px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.faq-link:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.faq-support {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0.25rem 1.75rem 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--gold-pale);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(200, 155, 74, 0.2);
}
.faq-support-icon {
  font-size: 11px;
  color: var(--gold);
  flex-shrink: 0;
  animation: spin-slow 12s linear infinite;
  display: inline-block;
}
.faq-support p {
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0;
  line-height: 1.5;
}

/* === DECORATIVE CORNER IMAGES === */
.deco-tree {
  position: fixed;
  bottom: 0;
  left: 0;
  width: clamp(260px, 30vw, 450px);
  height: auto;
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
  user-select: none;
}

.deco-foliage {
  position: fixed;
  top: 0;
  right: 0;
  width: clamp(260px, 30vw, 650px);
  height: auto;
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
  user-select: none;
}

/* ============================================================
   ILLUSTRATION WATERMARK & IMAGE PROTECTION
   ============================================================ */

/* Watermark sits over illustrations and poster preview */
.story-illustration,
.poster-preview-wrap {
  position: relative;
}

.illustration-watermark {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(44, 32, 24, 0.52);
  color: rgba(255, 248, 235, 0.85);
  font-family: 'Lora', serif;
  font-size: 0.72rem;
  font-style: italic;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: 50px;
  pointer-events: none;
  user-select: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Block right-click, drag-to-save on all story/poster images */
.story-illustration-img,
.poster-preview-img,
.story-cover-img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}



/* ──────────────────────────────────────────────────
   LANGUAGE SWITCHER
   ────────────────────────────────────────────────── */
.lang-switcher {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(253, 248, 240, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(200, 155, 74, 0.25);
  border-radius: 50px;
  padding: 5px 8px;
  box-shadow: 0 4px 14px rgba(44, 32, 24, 0.08);
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  padding: 0;
  line-height: 1;
}
.lang-btn:hover { background: rgba(200, 155, 74, 0.12); transform: scale(1.08); }
.lang-btn.active {
  background: rgba(200, 155, 74, 0.22);
  box-shadow: inset 0 0 0 1.5px rgba(200, 155, 74, 0.5);
}
@media (max-width: 600px) {
  .lang-switcher { top: 0.8rem; right: 0.8rem; padding: 4px 6px; }
  .lang-btn { width: 26px; height: 26px; font-size: 0.9rem; }
}
