/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans HK', 'PingFang HK', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
  transition: background 0.3s, color 0.3s;
}

/* ===== LIGHT THEME (default) ===== */
:root, [data-theme="light"] {
  --bg-page: #F2E2C0;
  --bg-app: linear-gradient(180deg, #FFF7E8 0%, #FFEFD0 60%, #FFE0A8 100%);
  --bg-card: #ffffff;
  --bg-card-soft: rgba(255,255,255,0.85);
  --bg-card-glass: rgba(255,255,255,0.6);
  --bg-topbar: rgba(255, 247, 232, 0.85);
  --bg-tabbar: rgba(255, 247, 232, 0.96);
  --bg-foot-fade: linear-gradient(180deg, transparent 0%, #FFEFD0 30%);
  --bg-empty: rgba(255,255,255,0.5);
  --bg-empty-border: var(--cream-400);

  --cream-50: #FFFCF3;
  --cream-100: #FFF7E8;
  --cream-200: #FFEFD0;
  --cream-300: #FFE0A8;
  --cream-400: #FFD188;
  --honey: #E89A3F;
  --honey-dark: #C97A2D;

  --ink-900: #3A2A14;
  --ink-700: #5A4220;
  --ink-500: #8A6B3E;
  --ink-300: #B89A6E;
  --ink-on-primary: #FFFCF3;

  --hero-grad: linear-gradient(160deg, #FFF1D6 0%, #FFD188 100%);
  --tip-grad: linear-gradient(135deg, #FFF1D6, #FFE0B0);
  --parent-tip-grad: linear-gradient(135deg, #FFF1D6, #FFE0B0);

  --pink: #FFB199;
  --mint: #A8D8B4;
  --sky: #B8D4E8;
  --lavender: #D4BFF0;
  --error: #D9534F;
  --error-bg: #FFE6E6;
  --border-soft: rgba(232, 154, 63, 0.15);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-hero: 0 8px 30px rgba(232,154,63,0.18);
  --primary-bg: var(--ink-900);
  --primary-fg: var(--cream-50);
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
  --bg-page: #0E0820;
  --bg-app: linear-gradient(180deg, #1A1140 0%, #261A55 60%, #2F2168 100%);
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-soft: rgba(255,255,255,0.08);
  --bg-card-glass: rgba(255,255,255,0.05);
  --bg-topbar: rgba(26, 17, 64, 0.75);
  --bg-tabbar: rgba(26, 17, 64, 0.92);
  --bg-foot-fade: linear-gradient(180deg, transparent 0%, #261A55 40%);
  --bg-empty: rgba(255,255,255,0.04);
  --bg-empty-border: rgba(255,212,107,0.3);

  --cream-50: #FFF7E1;
  --cream-100: rgba(255,255,255,0.10);
  --cream-200: rgba(255,255,255,0.08);
  --cream-300: rgba(255,255,255,0.14);
  --cream-400: rgba(255,212,107,0.4);
  --honey: #FFD46B;
  --honey-dark: #FFB347;

  --ink-900: #FFF7E1;
  --ink-700: #E8D9B8;
  --ink-500: #B8A88A;
  --ink-300: #8B7C5E;
  --ink-on-primary: #1A1140;

  --hero-grad: linear-gradient(160deg, #2A1F60 0%, #4B2E8A 100%);
  --tip-grad: linear-gradient(135deg, rgba(255,212,107,0.15), rgba(180,135,250,0.15));
  --parent-tip-grad: linear-gradient(135deg, rgba(255,212,107,0.18), rgba(180,135,250,0.18));

  --pink: #FFB199;
  --mint: #8FE0B7;
  --sky: #95C8F2;
  --lavender: #C9B0F5;
  --error: #FF8B85;
  --error-bg: rgba(255,139,133,0.15);
  --border-soft: rgba(255,212,107,0.18);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-hero: 0 8px 30px rgba(0,0,0,0.4);
  --primary-bg: var(--honey);
  --primary-fg: #1A1140;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; font-size: 16px; }

.app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.08);
  transition: background 0.3s;
}

@media (min-width: 520px) {
  body { padding: 16px 0; }
  [data-theme="light"] body { background: #2D1F0F; }
  [data-theme="dark"] body { background: #050214; }
  .app { border-radius: 36px; overflow: hidden; min-height: calc(100vh - 32px); }
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 8px) 16px 8px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-logo { font-size: 32px; }
.brand-name { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px; line-height: 1; color: var(--ink-900); }
.brand-sub { font-size: 11px; color: var(--ink-500); margin-top: 3px; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--bg-card-glass);
  color: var(--ink-900);
  transition: transform 0.15s;
}
.icon-btn:active { transform: scale(0.92); }

/* ===== Screen / Pages ===== */
.screen { flex: 1; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.page-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 24px; margin: 8px 0 16px; color: var(--ink-900); }

/* ===== HOME ===== */
.hero {
  position: relative;
  background: var(--hero-grad);
  border-radius: 28px;
  padding: 24px 20px 22px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-hero);
}
.hero-stars {
  position: absolute; inset: 0;
  pointer-events: none;
  font-size: 20px;
  color: rgba(255,255,255,0.7);
}
.hero-stars span {
  position: absolute;
  animation: twinkle 3s infinite ease-in-out;
}
.hero-stars span:nth-child(1) { top: 14px; left: 22px; animation-delay: 0s; }
.hero-stars span:nth-child(2) { top: 26px; right: 30px; animation-delay: 0.8s; }
.hero-stars span:nth-child(3) { bottom: 30px; left: 80%; animation-delay: 1.5s; font-size: 14px; }
.hero-stars span:nth-child(4) { top: 50%; left: 12px; animation-delay: 2.2s; font-size: 12px; }
@keyframes twinkle { 0%, 100% { opacity: 0.4; transform: scale(1); } 50% { opacity: 1; transform: scale(1.2); } }

.hero-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 24px;
  line-height: 1.3;
  color: var(--ink-900);
  position: relative;
  z-index: 1;
}
[data-theme="dark"] .hero-title { color: #FFF7E1; }
[data-theme="dark"] .hero-sub { color: rgba(255,247,225,0.85); }
.hero-sub { font-size: 13px; color: var(--ink-700); margin-top: 8px; position: relative; }

.hero-actions { display: flex; gap: 8px; margin-top: 16px; }
.cta-primary {
  background: var(--primary-bg);
  color: var(--primary-fg);
  border-radius: 16px;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta-primary:active { transform: scale(0.97); }
.cta-primary.big { flex: 1.4; padding: 16px; font-size: 16px; box-shadow: 0 4px 14px rgba(0,0,0,0.18); }

.cta-secondary {
  flex: 1;
  background: rgba(255,255,255,0.4);
  color: var(--ink-900);
  border-radius: 16px;
  padding: 16px 12px;
  font-weight: 700;
  font-size: 16px;
  border: 1.5px solid rgba(255,255,255,0.5);
  transition: transform 0.15s;
}
[data-theme="dark"] .cta-secondary {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,212,107,0.4);
  color: #FFF7E1;
}
.cta-secondary:active { transform: scale(0.97); }
.cta-secondary.big { padding: 16px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 12px;
}
.section-head h3 { font-size: 16px; margin: 0; color: var(--ink-900); }
.link-btn { color: var(--honey-dark); font-size: 13px; font-weight: 600; }
[data-theme="dark"] .link-btn { color: var(--honey); }

.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow-card);
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.recent-emoji {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 28px;
  background: linear-gradient(135deg, var(--cream-200), var(--cream-300));
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.recent-info { flex: 1; min-width: 0; }
.recent-title { font-weight: 700; font-size: 15px; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-tags { font-size: 11px; color: var(--ink-500); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state {
  background: var(--bg-empty);
  border-radius: 18px;
  padding: 24px 16px;
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
  border: 1px dashed var(--bg-empty-border);
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quick-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s;
}
.quick-card:active { transform: scale(0.96); }
.quick-emoji { font-size: 36px; }
.quick-name { font-size: 13px; font-weight: 600; color: var(--ink-900); }

.tip-card {
  background: var(--tip-grad);
  border-radius: 18px;
  padding: 14px;
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.tip-emoji { font-size: 26px; }
.tip-title { font-weight: 700; font-size: 13px; color: var(--ink-900); margin-bottom: 4px; }
.tip-text { font-size: 12px; color: var(--ink-700); line-height: 1.5; }

/* ===== BUILDER ===== */
.builder-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px;
}
.back-btn {
  background: var(--bg-card-glass);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-700);
}
.progress-wrap { flex: 1; }
.progress-bar { height: 6px; background: var(--bg-card-glass); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--honey); transition: width 0.3s; border-radius: 6px; }
.step-dots { display: flex; gap: 4px; margin-top: 6px; justify-content: center; }
.step-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(0,0,0,0.15); }
[data-theme="dark"] .step-dots span { background: rgba(255,255,255,0.18); }
.step-dots span.active { background: var(--honey); }
.step-dots span.done { background: var(--ink-700); }

.mode-toggle {
  background: var(--primary-bg);
  color: var(--primary-fg);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 56px;
}

.builder-body { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.step-headline {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--ink-900);
  margin-bottom: 6px;
  text-align: center;
}
.step-sub { font-size: 13px; color: var(--ink-500); text-align: center; margin-bottom: 22px; }

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option-card {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  transition: all 0.18s;
  position: relative;
  min-height: 100px;
  color: var(--ink-900);
}
.option-card:active { transform: scale(0.96); }
.option-card.selected {
  border-color: var(--honey);
  box-shadow: 0 4px 16px rgba(232,154,63,0.25);
}
[data-theme="light"] .option-card.selected {
  background: linear-gradient(180deg, #fff, var(--cream-100));
}
[data-theme="dark"] .option-card.selected {
  background: rgba(255,212,107,0.15);
}
.option-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--honey);
  color: var(--ink-on-primary);
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 800;
}
.option-emoji { font-size: 32px; }
.option-name { font-weight: 700; font-size: 14px; color: var(--ink-900); }
.option-desc { font-size: 11px; color: var(--ink-500); line-height: 1.4; }

/* Hero name input */
.hero-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid var(--cream-300);
  background: var(--bg-card);
  color: var(--ink-900);
  font-size: 16px;
  margin-top: 10px;
}
.hero-input:focus { outline: none; border-color: var(--honey); }
.length-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.summary-card {
  background: var(--bg-card-soft);
  border-radius: 18px;
  padding: 14px 16px;
  margin-top: 16px;
}
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.summary-row b { font-weight: 700; color: var(--ink-900); }
.summary-row span { color: var(--ink-700); text-align: right; max-width: 60%; }

.builder-foot {
  position: sticky;
  bottom: 80px;
  display: flex;
  gap: 10px;
  padding: 16px 0 0;
  background: var(--bg-foot-fade);
}

.btn-primary, .btn-secondary, .btn-danger {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.15s;
}
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; }
.btn-secondary { background: var(--bg-card-soft); color: var(--ink-900); }
.btn-danger { background: var(--error-bg); color: var(--error); width: 100%; flex: none; }

/* ===== LOADING ===== */
.page-loading { min-height: 70vh; display: grid; place-items: center; }
.loading-content { text-align: center; }
.moon-bob {
  font-size: 80px;
  animation: bob 1.4s ease-in-out infinite;
  display: inline-block;
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-12px) rotate(5deg); } }
.loading-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink-900);
  margin: 18px 0 24px;
}
.loading-steps { display: flex; flex-direction: column; gap: 10px; }
.lstep {
  background: var(--bg-card-glass);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--ink-500);
  transition: all 0.3s;
}
.lstep.active {
  background: var(--bg-card);
  color: var(--ink-900);
  font-weight: 700;
  transform: scale(1.03);
  box-shadow: 0 4px 14px rgba(232,154,63,0.2);
}
.lstep.done { color: var(--ink-700); }
.lstep.done::before { content: '✓ '; color: var(--honey); font-weight: 800; }

/* ===== STORY VIEW ===== */
.story-cover {
  position: relative;
  height: 240px;
  border-radius: 24px;
  display: grid; place-items: center;
  margin-bottom: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #FFD188 0%, #E89A3F 100%);
}
.cover-emoji { font-size: 110px; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2)); }
.cover-image {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.story-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 18px;
  z-index: 2;
}

.story-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.story-meta .chip {
  background: var(--bg-card-soft);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--ink-700);
  font-weight: 600;
}

.story-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 26px;
  line-height: 1.2;
  color: var(--ink-900);
  margin: 8px 0 16px;
}

.story-body {
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink-900);
}
.story-body p { margin: 0 0 16px; }
.story-body p:first-child::first-letter {
  font-family: 'Baloo 2', sans-serif;
  float: left;
  font-size: 56px;
  line-height: 0.9;
  font-weight: 800;
  color: var(--honey);
  margin: 6px 8px 0 0;
}

.parent-tip {
  background: var(--parent-tip-grad);
  border-radius: 18px;
  padding: 14px 16px;
  margin: 20px 0;
}
.parent-tip-head { font-weight: 800; font-size: 14px; color: var(--ink-900); margin-bottom: 6px; }
.parent-tip-body { font-size: 13px; color: var(--ink-700); line-height: 1.6; }

.story-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}
.action-btn {
  background: var(--bg-card-soft);
  border-radius: 14px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-900);
}
.action-btn span:first-child { font-size: 20px; }

/* ===== LIBRARY ===== */
.filter-row {
  display: flex; gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 16px;
  padding: 0 16px 4px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  background: var(--bg-card-soft);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-chip.active { background: var(--primary-bg); color: var(--primary-fg); }

.library-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.lib-card {
  background: var(--bg-card);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  text-align: left;
  transition: transform 0.15s;
}
.lib-card:active { transform: scale(0.97); }
.lib-cover {
  height: 110px;
  display: grid; place-items: center;
  font-size: 48px;
  position: relative;
  background-size: cover;
  background-position: center;
}
.lib-fav { position: absolute; top: 6px; right: 8px; font-size: 14px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.lib-info { padding: 10px 12px 12px; }
.lib-title { font-weight: 700; font-size: 13px; line-height: 1.3; color: var(--ink-900); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-tags { font-size: 10px; color: var(--ink-500); margin-top: 4px; }

.storage-bar {
  margin-top: 24px;
  background: var(--bg-card-soft);
  border-radius: 18px;
  padding: 14px 16px;
}
.storage-label { font-size: 12px; color: var(--ink-700); margin-bottom: 8px; font-weight: 600; }
.storage-meter { height: 6px; background: rgba(0,0,0,0.08); border-radius: 6px; overflow: hidden; }
[data-theme="dark"] .storage-meter { background: rgba(255,255,255,0.1); }
.storage-fill { height: 100%; background: linear-gradient(90deg, var(--mint), var(--honey)); border-radius: 6px; transition: width 0.3s; }
.storage-text { font-size: 11px; color: var(--ink-500); margin-top: 6px; text-align: right; }

/* ===== SETTINGS ===== */
.setting-card {
  background: var(--bg-card-soft);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.setting-label { font-weight: 800; font-size: 15px; color: var(--ink-900); margin-bottom: 6px; }
.setting-help { font-size: 12px; color: var(--ink-500); line-height: 1.5; margin-bottom: 12px; }
.setting-help a { color: var(--honey-dark); }
[data-theme="dark"] .setting-help a { color: var(--honey); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-700); margin-bottom: 6px; }
.form-row input, .form-row select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--cream-300);
  background: var(--bg-card);
  color: var(--ink-900);
}
[data-theme="dark"] .form-row input, [data-theme="dark"] .form-row select {
  background: rgba(255,255,255,0.06);
  color: var(--ink-900);
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--honey); }
.setting-card .btn-secondary { width: 100%; flex: none; margin-bottom: 8px; }
.setting-card .btn-primary { width: 100%; }

/* ===== TABBAR ===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-tabbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 0 max(env(safe-area-inset-bottom), 6px);
  z-index: 100;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 10px;
  color: var(--ink-500);
  font-weight: 600;
  transition: all 0.15s;
}
.tab span:first-child { font-size: 22px; }
.tab.active { color: var(--ink-900); }
.tab.active span:first-child { transform: scale(1.15); }
.tab:active { transform: scale(0.94); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-900);
  color: var(--ink-on-primary);
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== MODAL (cover approval) ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 300;
  display: grid;
  place-items: end center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-app);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px max(20px, env(safe-area-inset-bottom));
  animation: slideUp 0.28s ease;
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 520px) {
  .modal { place-items: center; }
  .modal-card { border-radius: 24px; max-height: 80vh; }
}
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title { font-weight: 800; font-size: 17px; color: var(--ink-900); }
.modal-body { margin-bottom: 14px; }
.modal-foot { display: flex; gap: 8px; }

.cover-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  background: var(--bg-card-glass);
  display: grid; place-items: center;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-loading {
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--cream-300);
  border-top-color: var(--honey);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.cover-prompt {
  font-size: 12px;
  color: var(--ink-700);
  background: var(--bg-card-glass);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.cover-hint { font-size: 11px; color: var(--ink-500); text-align: center; }

/* ===== Hide builder foot in summary step ===== */
.page-builder.no-foot .builder-foot { display: none; }
