/* Mastory Learner — shared kid-friendly UI */
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

:root {
  --bg-top: #fff4d6;
  --bg-mid: #dbeafe;
  --bg-bottom: #ede9fe;
  --ink: #1e1b4b;
  --muted: #64748b;
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-light: #c7d2fe;
  --card: rgba(255, 255, 255, 0.9);
  --card-border: rgba(255, 255, 255, 0.95);
  --shadow: 0 16px 40px rgba(79, 70, 229, 0.1), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 8px 22px rgba(99, 102, 241, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --danger: #e11d48;
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

* {
  box-sizing: border-box;
}

.hidden,
[hidden] {
  display: none !important;
}

/* Protected pages stay blank until auth.js confirms a signed-in user. */
.protected-content,
#page-wrapper.protected-content {
  display: none !important;
}

.auth-loading {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Nunito", "Segoe UI", Tahoma, Arial, sans-serif;
  color: #1f2937;
  background:
    radial-gradient(ellipse 120% 70% at 50% -15%, rgba(251, 191, 36, 0.14), transparent 55%),
    linear-gradient(165deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.65) 0%, transparent 22%),
    radial-gradient(circle at 88% 12%, rgba(255, 255, 255, 0.45) 0%, transparent 18%),
    radial-gradient(circle at 72% 82%, rgba(199, 210, 254, 0.35) 0%, transparent 28%);
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 780px;
  margin: 0;
  padding: 32px 20px 56px;
  align-self: center;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
}

.site-header {
  margin-bottom: 28px;
  text-align: center;
  padding: 8px 0 4px;
}

.logo {
  margin: 0;
  font-size: 2.4rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--brand);
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 20px;
  margin-top: 16px;
}

.top-nav a {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(99, 102, 241, 0.14);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.06);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}

.nav-user-email {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  overflow-wrap: anywhere;
}

.top-nav .btn-logout {
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.15);
}

.top-nav .nav-user-email {
  flex-basis: 100%;
  text-align: center;
  margin-top: 4px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 26px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.panel + .panel {
  margin-top: 20px;
}

label.field-label,
.prompt-label {
  display: block;
  margin: 0 0 8px;
  font-weight: 600;
  color: #334155;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.controls {
  margin: 16px 0 0;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 140px;
  min-width: 0;
  font-weight: 600;
  color: #334155;
  font-size: 0.9rem;
}

select {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.btn-row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

button,
.btn {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.32);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(99, 102, 241, 0.38);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  border: 2px solid #e2e8f0;
  box-shadow: var(--shadow-soft);
}

.btn-secondary:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
  border-color: var(--brand-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

#story,
.story-body,
.story-preview {
  white-space: pre-wrap;
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#story {
  min-height: 120px;
  padding: 4px 2px;
}

#story:not(.empty):not(.loading):not(.error):not(.safety-warning) {
  background: linear-gradient(135deg, rgba(255, 247, 230, 0.55) 0%, rgba(244, 236, 255, 0.45) 100%);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
}

#story.empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

#story.loading {
  color: var(--muted);
  font-style: normal;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 120px;
}

.story-loading-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
}

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

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  animation: loading-dot 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loading-dot {
  0%,
  80%,
  100% {
    transform: scale(0.65);
    opacity: 0.35;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

#story.error {
  color: var(--danger);
  font-style: normal;
}

#story.error a {
  color: var(--brand);
  font-weight: 700;
}

#story.safety-warning {
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 12px;
  padding: 16px;
  font-style: normal;
}

#story.safety-warning a {
  color: #9a3412;
  font-weight: 700;
}

.safety-note {
  margin: 8px 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand);
}

.auth-status {
  margin: 12px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
}

.auth-status a {
  color: var(--brand);
  text-decoration: none;
}

.auth-status a:hover {
  text-decoration: underline;
}

/* Ordered child flow on the creator page */
.flow-steps {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  counter-reset: flow;
}

.flow-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: linear-gradient(135deg, rgba(255, 247, 230, 0.85) 0%, rgba(244, 236, 255, 0.85) 100%);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
}

.flow-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.flow-steps strong {
  color: var(--ink);
}

/* Welcome / entrance page */
.welcome-wrap {
  position: relative;
  z-index: 1;
}

.welcome-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 32px;
}

.welcome-card h1 {
  margin: 0 0 12px;
  width: 100%;
}

.welcome-card > p:not(.auth-message):not(.reset-lead) {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  max-width: 420px;
}

/* Auth + choose — centered form stack */
.auth-stack,
.choose-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  margin: 24px auto;
}

.auth-stack--wide {
  max-width: 360px;
}

.auth-hint {
  margin: -4px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: left;
}

.auth-checks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #475569;
  cursor: pointer;
}

.auth-check input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--brand);
}

.auth-check a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.auth-check a:hover {
  text-decoration: underline;
}

.verify-lead,
.verify-help,
.verify-email-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  max-width: 420px;
}

.verify-email-line {
  margin-top: 8px;
  font-size: 0.95rem;
}

.verify-help {
  margin-top: 12px;
  font-size: 0.9rem;
}

.profile-verify-note {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.9rem;
  line-height: 1.45;
}

.profile-verify-note a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.profile-verify-note a:hover {
  text-decoration: underline;
}

.auth-fields {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: 100%;
}

.password-field {
  position: relative;
  width: 100%;
}

.password-field .auth-input {
  padding-right: 4.5rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.password-toggle:hover {
  background: rgba(124, 92, 255, 0.08);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.password-toggle[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  opacity: 0.85;
  cursor: wait;
}

.auth-input,
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.auth-link {
  margin: 0;
  font-size: 0.9rem;
}

.auth-link a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

.choose-actions .welcome-enter,
.choose-actions .btn,
.auth-stack .welcome-enter,
.auth-stack .btn {
  width: 100%;
  text-align: center;
}

.auth-page .welcome-card h1 {
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  color: var(--ink);
}

.welcome-auth-notice {
  max-width: 360px;
  margin: 12px auto 0;
}

.auth-page .reset-lead,
.auth-page .verify-lead,
.auth-page .verify-help,
.auth-page .verify-email-line {
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.reset-fallback {
  margin-top: 4px;
}

.auth-message {
  margin: 0 auto 16px;
  max-width: 300px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

.auth-stack .auth-message {
  margin: 0;
}

.auth-message--error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.auth-message--success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.profile-panel {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.profile-lead {
  margin: 0 0 24px;
  color: var(--muted);
  text-align: center;
}

.profile-details {
  margin: 0 auto 24px;
  display: grid;
  gap: 16px;
  max-width: 360px;
  width: 100%;
  text-align: left;
}

.profile-detail {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.profile-detail dt {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-detail dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

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

.profile-message {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.profile-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
}

.profile-section--alt {
  text-align: center;
}

.profile-section h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--ink);
  text-align: center;
}

.profile-section-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: center;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
  margin: 0 auto;
}

.profile-label {
  display: block;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}

.profile-delete-check {
  margin: 0;
}

.profile-danger {
  margin-top: 32px;
  padding: 20px 18px 22px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fff5f5;
}

.profile-danger h2 {
  color: #991b1b;
}

.profile-danger .profile-section-lead {
  color: #9f1239;
}

.grownup-gate {
  text-align: center;
}

.grownup-gate-panel {
  max-width: 360px;
  margin: 0 auto;
  text-align: center;
}

.grownup-gate-panel.hidden {
  display: none;
}

.grownup-pin-input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  font-weight: 800;
  padding-left: 1.25em;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 20px;
}

.pin-key {
  min-height: 52px;
  border: 2px solid rgba(99, 102, 241, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease, background 0.12s ease;
}

.pin-key:hover {
  background: #fff;
  transform: translateY(-1px);
}

.pin-key--action {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.grownup-gate-message {
  max-width: 360px;
  margin: 16px auto 0;
}

.reset-lead {
  margin: 0 0 20px;
  color: var(--muted);
}

.reset-form {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  text-align: center;
}

.reset-email-line {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.reset-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
}

.reset-input {
  width: 100%;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}

.reset-submit {
  width: 100%;
  margin-top: 4px;
}

.reset-fallback {
  margin: 20px 0 0;
  font-size: 0.9rem;
}

.reset-fallback a {
  color: var(--brand);
  text-decoration: none;
}

.reset-fallback a:hover {
  text-decoration: underline;
}

.welcome-kicker {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.welcome-logo {
  margin: 0 0 16px;
  font-size: 2.8rem;
}

.welcome-lead {
  margin: 0 auto 28px;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.05rem;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
  text-align: center;
}

.welcome-step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 247, 230, 0.9) 0%, rgba(244, 236, 255, 0.9) 100%);
  padding: 20px 16px;
  border-radius: 18px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  box-shadow: var(--shadow-soft);
}

.step-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.welcome-step p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
  font-size: 0.95rem;
}

.welcome-step strong {
  color: var(--ink);
}

.brand-link {
  display: block;
  text-decoration: none;
}

.site-brand-logo {
  width: min(240px, 72vw);
  height: auto;
  display: block;
  margin: 0 auto 12px;
  filter: drop-shadow(0 8px 16px rgba(99, 102, 241, 0.12));
}

.social-links {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.social-links li {
  background: linear-gradient(135deg, #fff7e6 0%, #f4ecff 100%);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  padding: 14px 16px;
  color: #475569;
  font-size: 0.95rem;
  text-align: center;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: none;
}

.social-links a:hover {
  text-decoration: underline;
}

.social-links img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.welcome-tagline {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
  text-align: center;
  width: 100%;
}

.welcome-pronounce {
  margin: 0 0 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: center;
  width: 100%;
}

.welcome-safe {
  margin: 18px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
}

.welcome-enter {
  font-size: 1.2rem;
  font-weight: 800;
  padding: 16px 48px;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
  white-space: normal;
  line-height: 1.35;
}

.welcome-enter:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(99, 102, 241, 0.42);
}

.enter-spark {
  display: inline-block;
  margin-left: 6px;
  animation: spark-pulse 1.6s ease-in-out infinite;
}

@keyframes spark-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.25) rotate(15deg); opacity: 0.7; }
}

.footer-dot {
  margin: 0 10px;
  color: var(--muted);
}

/* Playful floating background (welcome page) */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  filter: blur(2px);
}

.cloud-1 { width: 120px; height: 40px; top: 12%; left: 8%; }
.cloud-2 { width: 90px; height: 30px; top: 28%; right: 10%; }
.cloud-3 { width: 150px; height: 46px; bottom: 16%; left: 14%; }

.twinkle {
  position: absolute;
  color: #fbbf24;
  font-size: 1.25rem;
  opacity: 0.8;
  animation: twinkle 3s ease-in-out infinite;
}

.twinkle-1 { top: 18%; right: 22%; animation-delay: 0s; }
.twinkle-2 { top: 40%; left: 12%; color: #818cf8; animation-delay: 0.6s; }
.twinkle-3 { bottom: 24%; right: 16%; animation-delay: 1.2s; }
.twinkle-4 { top: 64%; left: 22%; color: #f472b6; animation-delay: 1.8s; }
.twinkle-5 { bottom: 12%; right: 30%; animation-delay: 2.4s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 0.9; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .enter-spark,
  .twinkle,
  .loading-dots span {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.welcome-footer a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.welcome-footer a:hover {
  text-decoration: underline;
}

.questions-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  text-align: left;
}

.questions-section.hidden {
  display: none;
}

.questions-section h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--ink);
}

.questions-section ol {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.7;
  color: #334155;
}

.questions-section li + li {
  margin-top: 8px;
}

.grownups-intro,
.legal-card {
  overflow-wrap: anywhere;
  max-width: 100%;
}

.grownups-intro {
  font-size: 1.05rem;
  color: #334155 !important;
  background: linear-gradient(135deg, rgba(255, 247, 230, 0.9) 0%, rgba(244, 236, 255, 0.9) 100%);
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  box-shadow: var(--shadow-soft);
}

.legal-card .section {
  margin-top: 24px;
}

.legal-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--ink);
}

.legal-card p {
  margin: 0 0 8px;
  color: #475569;
  line-height: 1.7;
}

.legal-card ul {
  margin: 8px 0 0;
  padding-left: 1.25rem;
  color: #475569;
  line-height: 1.6;
}

.legal-card li + li {
  margin-top: 6px;
}

.story-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 22px;
  margin-top: 18px;
  line-height: 1.65;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(79, 70, 229, 0.14);
}

.story-card-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: var(--ink);
  line-height: 1.3;
  text-align: center;
}

.story-card .meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  justify-content: center;
}

.story-date {
  font-weight: 600;
  color: #475569;
}

.story-tags {
  text-transform: capitalize;
}

.story-card .story-preview {
  color: #334155;
  margin: 12px 0 16px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.reader-title {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  color: var(--ink);
  overflow-wrap: anywhere;
  line-height: 1.25;
  text-align: center;
}

.reader-meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
}

.status {
  margin-top: 12px;
  font-size: 14px;
  color: #059669;
  min-height: 1.25em;
  text-align: center;
}

footer,
.site-footer,
.welcome-footer {
  margin-top: auto;
  padding-top: 28px;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
  width: 100%;
}

footer a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.loading-text,
#stories {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

@media (max-width: 768px) {
  .wrap {
    padding: 24px 16px 40px;
  }

  .panel {
    padding: 18px;
  }

  .welcome-steps,
  .flow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-card {
    padding: 18px;
  }
}

@media (max-width: 540px) {
  .wrap {
    padding: 20px 14px 32px;
  }

  .logo {
    font-size: 2rem;
  }

  .panel {
    padding: 16px;
  }

  .controls {
    flex-direction: column;
  }

  .controls label {
    flex: 1 1 auto;
    width: 100%;
  }

  .welcome-card {
    padding: 28px 18px;
  }

  .welcome-steps,
  .flow-steps {
    grid-template-columns: 1fr;
  }

  .welcome-step {
    flex-direction: row;
    text-align: left;
    align-items: center;
    gap: 14px;
  }

  .welcome-enter {
    display: block;
    width: 100%;
    max-width: 100%;
    text-align: center;
    padding-left: 20px;
    padding-right: 20px;
  }

  .btn-row {
    width: 100%;
  }

  .btn-row button,
  .btn-row .btn,
  .card-actions .btn,
  .card-actions button,
  .story-actions button {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }

  .card-actions,
  .story-actions {
    width: 100%;
  }

  footer,
  .site-footer,
  .welcome-footer {
    font-size: 0.8rem;
    padding-top: 24px;
  }
}

@media (max-width: 380px) {
  .wrap {
    padding: 16px 12px 28px;
  }

  .footer-dot {
    display: none;
  }

  footer a,
  .site-footer a,
  .welcome-footer a {
    display: block;
    margin: 4px 0;
  }
}
