/* Story Gift v0.10.0. Cream paper, plum ink, warm coral — a bedtime book, not a dashboard. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
:root {
  --paper: #fff7ea; --paper-2: #fffdf7; --ink: #3b2a4a; --ink-soft: #685873; --ink-faint: #75677d;
  --coral: #e8735a; --coral-dark: #c95a42; --teal: #3f8f8a; --gold: #e9b94a; --line: rgba(59,42,74,0.14);
  --success: #2f766f; --warning: #9a5c19; --danger: #a84736; --focus: #7654a8;
}
body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: radial-gradient(ellipse at top, rgba(233,185,74,0.18) 0%, transparent 55%), linear-gradient(180deg, #fff7ea 0%, #fdf1e4 100%);
  color: var(--ink); min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.55;
}
a { color: var(--coral-dark); text-decoration: none; } a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

.app-header {
  display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line); background: rgba(255,247,234,0.85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10;
}
.app-header .brand { display: flex; align-items: center; gap: 0.55rem; font-family: 'Fraunces', Georgia, serif; font-size: 1.3rem; }
.brand-button { border: 0; color: inherit; padding: 0; background: transparent; text-align: left; }
.app-header .brand .moon { font-size: 1.3rem; }
.app-header .brand strong { color: var(--ink); font-weight: 700; }
.brand-product { color: var(--ink-faint); font-size: 0.9rem; font-family: 'Nunito', sans-serif; }

main { max-width: 760px; margin: 0 auto; padding: 1.4rem 1.25rem 3rem; }
footer { margin-top: 2.5rem; text-align: center; font-size: 0.78rem; color: #75677d; }
.top-nav { display: flex; align-items: center; gap: 0.3rem; }
.nav-link { min-height: 44px; border: 0; border-radius: 10px; padding: 0.65rem 0.8rem; background: transparent; color: var(--ink-soft); font-weight: 700; }
.nav-link:hover, .nav-link.active { color: var(--ink); background: rgba(59,42,74,0.07); }

.stepper { list-style: none; display: flex; gap: 0.35rem; padding: 0; margin: 0 0 1.2rem; }
.stepper li { flex: 1; font-size: 0.7rem; color: var(--ink-faint); display: flex; align-items: center; gap: 0.3rem; border-top: 3px solid var(--line); padding-top: 0.45rem; }
.stepper li span { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; background: rgba(59,42,74,0.08); flex-shrink: 0; }
.stepper li.active { color: var(--ink); border-top-color: var(--coral); }
.stepper li.active span { background: var(--coral); color: #fff; font-weight: 700; }
.stepper li.done { color: var(--ink-soft); border-top-color: var(--teal); }
.stepper li.done span { background: var(--teal); color: #fff; }
@media (max-width: 480px) { .stepper li { font-size: 0; gap: 0; } .stepper li span { font-size: 0.7rem; } }

.section-title { font-family: 'Fraunces', Georgia, serif; font-size: 1.75rem; margin: 0 0 0.3rem; font-weight: 700; line-height: 1.15; }
.section-sub { color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 1.1rem; }
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: 0.9rem; box-shadow: 0 2px 10px rgba(59,42,74,0.05); }
.card.note { font-size: 0.9rem; color: var(--ink-soft); }
.card.warn { border-color: var(--coral); background: #fff1ec; }

label { display: block; font-size: 0.86rem; font-weight: 700; color: var(--ink); margin: 0.9rem 0 0.35rem; }
label .hint { display: block; font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.1rem; font-weight: 400; }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 0.75rem 0.9rem; background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 1rem; font-family: inherit; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 3px rgba(232,115,90,0.15); }
input:disabled, select:disabled, textarea:disabled { color: var(--ink-soft); background: #f5efe7; opacity: 1; -webkit-text-fill-color: var(--ink-soft); }
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.row-3 { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr; gap: 0.5rem; }
@media (max-width: 420px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.3rem; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 0.45rem 0.85rem; font-size: 0.88rem; font-weight: 600; }
.chip.on { background: #b54832; color: #fff; border-color: #b54832; }
.chip.teal.on { background: var(--teal); border-color: var(--teal); }

.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.75rem 1.1rem; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 0.95rem; font-weight: 700; text-decoration: none; transition: background-color 0.15s, border-color 0.15s, color 0.15s; -webkit-tap-highlight-color: transparent; }
.btn:hover, .btn:active { background: #fdf1e4; text-decoration: none; }
.btn.primary { background: #b54832; border-color: #b54832; color: #fff; }
.btn.primary:hover { background: #963b2a; }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.full { width: 100%; } .btn.big { min-height: 52px; padding: 1rem 1.2rem; font-size: 1.05rem; } .btn.tiny { min-height: 44px; padding: 0.55rem 0.75rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.working { background: var(--coral); color: #fff; border-color: var(--coral); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: 0.6rem; margin-top: 1.2rem; }
.actions .btn { flex: 1; }

.cast-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.45rem; align-items: center; margin-top: 0.5rem; }
.cast-row input { padding: 0.6rem 0.7rem; font-size: 0.92rem; }
.cast-row .x { border: none; background: transparent; color: var(--ink-faint); font-size: 1.2rem; padding: 0 0.3rem; }
.cast-list .who { font-size: 0.8rem; color: var(--ink-faint); }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: 10px; font-size: 0.9rem; z-index: 50; max-width: 90vw; text-align: center; }

/* ---- making it ---- */
.progress { text-align: center; padding: 2rem 0.5rem; }
.progress .moon-big { font-size: 3rem; animation: float 2.4s ease-in-out infinite; display: block; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.progress .step { font-family: 'Fraunces', Georgia, serif; font-size: 1.3rem; margin: 0.8rem 0 0.3rem; }
.bar { height: 8px; background: rgba(59,42,74,0.1); border-radius: 999px; overflow: hidden; margin: 1rem auto 0; max-width: 320px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold)); width: 5%; transition: width 0.6s ease; }

/* ---- the book ---- */
.book { background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 8px 30px rgba(59,42,74,0.10); }
.book .pic { aspect-ratio: 4 / 3; background: #f3e7d8; display: flex; align-items: center; justify-content: center; position: relative; }
.book .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book .pic .placeholder { color: var(--ink-faint); font-size: 0.9rem; }
.book .page-text { padding: 1.2rem 1.3rem 0.6rem; font-family: 'Fraunces', Georgia, serif; font-size: 1.28rem; line-height: 1.65; }
.book .page-text p { margin: 0 0 0.9em; }
.book .page-text.big { font-size: 1.5rem; line-height: 1.7; }
.book .cover-title { font-family: 'Fraunces', Georgia, serif; font-size: 2rem; text-align: center; padding: 1.2rem 1.2rem 0.3rem; font-weight: 700; line-height: 1.15; }
.book .cover-sub { text-align: center; color: var(--ink-soft); padding: 0 1.2rem 1rem; }
.book .moral { margin: 0 1.3rem 1rem; padding: 0.8rem 1rem; border-left: 4px solid var(--gold); background: #fff8e6; border-radius: 8px; font-size: 0.98rem; }
.book .moral strong { color: var(--coral-dark); }
.book-nav { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 1rem 1rem; gap: 0.6rem; }
.book-nav .pageno { color: var(--ink-faint); font-size: 0.85rem; white-space: nowrap; }
.book-nav .btn { min-width: 6.5rem; }
.reader-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0; }
.reader-tools .btn { flex: 1; min-width: 8rem; }
.the-end { text-align: center; font-family: 'Fraunces', Georgia, serif; font-size: 1.4rem; padding: 1rem; color: var(--ink-soft); }
.share-box { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.share-box input { font-size: 0.85rem; }

@media print {
  .app-header, .stepper, footer, .reader-tools, .book-nav, .toast, .actions, .card.note { display: none !important; }
  body { background: #fff; }
  .book { box-shadow: none; border: none; }
  .print-page { page-break-after: always; }
  .print-page .pic { aspect-ratio: 4 / 3; }
  .print-page .page-text { font-size: 1.2rem; }
}

.photo-field { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; }
.photo-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1.5px solid var(--line); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.eyebrow { margin: 0 0 0.3rem; color: var(--coral-dark); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.screen-head { margin: 0 0 1.3rem; }
.screen-head .section-title { font-size: clamp(1.9rem, 7vw, 2.35rem); }
.screen-head .section-sub { max-width: 42rem; }
.owner-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1rem; border: 1px solid rgba(63,143,138,.3); border-radius: 14px; background: #edf8f6; margin-bottom: 1.15rem; }
.owner-banner strong { display: block; }
.status-seal { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .65rem; border-radius: 999px; background: #e4f3f1; color: var(--success); font-size: .82rem; font-weight: 800; }
.status-seal.draft { background: #fff4d8; color: var(--warning); }

.story-empty { text-align: center; padding: 2rem 1.2rem; border: 1px dashed rgba(59,42,74,.25); border-radius: 18px; background: rgba(255,253,247,.72); }
.story-empty .moon-big { display: block; font-size: 2.7rem; margin-bottom: .5rem; }
.season-list { display: grid; gap: 1.1rem; }
.season-card { position: relative; overflow: hidden; padding: 1.2rem 1.2rem 1.2rem 1.35rem; border-radius: 20px; }
.season-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(var(--gold), var(--coral)); }
.season-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: .8rem; }
.season-heading h2 { font: 700 1.35rem/1.2 'Fraunces', Georgia, serif; margin: 0; }
.season-meta { color: var(--ink-soft); font-size: .88rem; margin-top: .25rem; }
.timeline { position: relative; margin-left: .7rem; padding-left: 1.3rem; }
.timeline::before { content: ''; position: absolute; top: .8rem; bottom: .8rem; left: .22rem; width: 2px; background: rgba(233,185,74,.65); }
.episode-row { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .85rem; align-items: center; min-height: 70px; padding: .65rem 0; }
.episode-row::before { content: ''; position: absolute; left: -1.43rem; top: 1.45rem; width: 11px; height: 11px; border-radius: 50%; background: var(--paper-2); border: 3px solid var(--gold); }
.episode-row.read::before { background: var(--teal); border-color: var(--teal); }
.episode-kicker { color: var(--ink-faint); font-size: .78rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.episode-title { margin: .08rem 0 0; font: 700 1.04rem/1.25 'Fraunces', Georgia, serif; }
.episode-row .btn { min-width: 150px; }
.episode-actions { display: flex; align-items: center; gap: .45rem; }
.share-menu { position: relative; }
.share-menu > summary { list-style: none; }
.share-menu > summary::-webkit-details-marker { display: none; }
.share-popover { position: absolute; z-index: 20; right: 0; top: calc(100% + .4rem); width: 190px; display: grid; gap: .35rem; padding: .55rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); box-shadow: 0 12px 28px rgba(59,42,74,.16); }
.share-popover .btn { min-width: 0; justify-content: flex-start; }

.setup-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.setup-tile { min-height: 112px; justify-content: flex-start; align-items: flex-start; flex-direction: column; text-align: left; padding: 1rem; background: var(--paper-2); }
.setup-tile .setup-icon { font-size: 1.45rem; }
.setup-tile .setup-name { font: 700 1.08rem/1.2 'Fraunces', Georgia, serif; }
.setup-tile .setup-summary { color: var(--ink-soft); font-size: .82rem; font-weight: 600; }
.setup-tile.complete { border-color: rgba(63,143,138,.45); }
.setup-review { display: grid; gap: .65rem; margin: .8rem 0; }
.review-line { display: grid; grid-template-columns: 9rem 1fr; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.review-line strong { color: var(--ink-soft); font-size: .84rem; }
.review-entity { display: flex; align-items: center; gap: .65rem; margin: 0 0 .55rem; color: var(--ink); }
.review-entity strong { color: var(--ink); font-size: .95rem; }
.locked-panel { border: 1px solid rgba(63,143,138,.35); background: #edf8f6; }
.danger-note { border-color: rgba(168,71,54,.35); background: #fff3ef; }
.inline-form { display: flex; gap: .55rem; align-items: end; }
.inline-form > div { flex: 1; }
.private-mark { color: var(--ink-soft); font-size: .8rem; margin-top: .5rem; }
.source-locked { color: var(--success); font-size: .8rem; font-weight: 800; line-height: 1.25; }
.source-locked-note { margin: 0 0 .55rem; padding: .55rem .7rem; border-radius: 9px; background: #edf8f6; color: var(--success); font-size: .84rem; font-weight: 700; }
.read-only-value { min-height: 44px; display: flex; align-items: center; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #f5efe7; color: var(--ink-soft); }

.design-panel { margin-top: -.25rem; border-color: rgba(63,143,138,.28); background: #fffaf1; }
.design-panel.status-locked { background: #edf8f6; }
.design-panel h3 { margin: 0; font: 700 1.15rem/1.25 'Fraunces', Georgia, serif; }
.design-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.design-panel-head .section-sub { margin: .18rem 0 0; }
.design-status { flex: 0 0 auto; padding: .28rem .58rem; border-radius: 999px; background: #f2e7d8; color: var(--ink-soft); font-size: .75rem; font-weight: 800; }
.design-status.locked { background: #dcefeb; color: var(--success); }
.design-status.ready { background: #fff0c8; color: var(--warning); }
.design-status.failed { background: #fbe2dc; color: var(--danger); }
.design-candidates { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; }
.design-choice { min-width: 0; overflow: hidden; border: 2px solid var(--line); border-radius: 13px; background: #fff; }
.design-choice.chosen { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(63,143,138,.12); }
.design-choice .btn { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding-inline: .35rem; font-size: .82rem; }
.design-image-button { display: block; width: 100%; padding: 0; border: 0; background: #efe5d8; cursor: zoom-in; }
.design-candidate-image { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.design-lock-action { margin-top: .8rem; }
.design-locked { display: grid; grid-template-columns: minmax(130px,220px) 1fr; gap: 1rem; align-items: center; }
.design-locked p, .design-wait p, .design-error p { margin: .15rem 0 0; color: var(--ink-soft); font-size: .88rem; }
.design-locked-image { display: block; width: 100%; max-height: 280px; object-fit: contain; border-radius: 12px; background: #efe5d8; }
.design-wait { display: flex; align-items: center; gap: .8rem; padding: .85rem; border-radius: 11px; background: #fff4d8; }
.spinner.dark { flex: 0 0 auto; border-color: rgba(59,42,74,.2); border-top-color: var(--coral-dark); }
.design-help { margin: 0; padding: .75rem; border-radius: 10px; background: #fff4d8; color: var(--warning); }
.design-error { margin: 0; padding: .75rem; border-radius: 10px; background: #fff1ec; color: var(--danger); }
.design-dialog { width: min(100%,680px); max-height: calc(100vh - 2rem); overflow-y: auto; }
.design-full-image { display: block; width: 100%; max-height: 62vh; margin: .75rem auto; object-fit: contain; border-radius: 13px; background: #efe5d8; }
.image-unavailable { min-height: 150px; }
.review-design-thumb { width: 72px; height: 88px; object-fit: cover; flex: 0 0 auto; border-radius: 10px; border: 2px solid rgba(63,143,138,.45); }
.design-ready p { margin: .25rem 0 0; }
.design-missing-list { margin: .55rem 0 0; padding-left: 1.25rem; color: var(--ink-soft); }
.design-missing-list li + li { margin-top: .25rem; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 1rem; background: rgba(35,24,43,.62); }
.dialog { width: min(100%, 440px); border-radius: 18px; padding: 1.25rem; background: var(--paper-2); box-shadow: 0 20px 60px rgba(35,24,43,.25); }
.dialog h2 { margin: 0 0 .45rem; font: 700 1.4rem/1.2 'Fraunces',Georgia,serif; }
.dialog .actions { margin-top: 1rem; }

@media (max-width: 640px) {
  .app-header { align-items: flex-start; padding: .75rem 1rem; }
  .brand-product { display: none; }
  .top-nav { align-items: stretch; }
  .nav-link { padding: .55rem .6rem; font-size: .84rem; }
  main { padding: 1.05rem 1rem 2.5rem; }
  .setup-grid { grid-template-columns: 1fr; }
  .season-heading, .owner-banner { align-items: stretch; flex-direction: column; }
  .episode-row { grid-template-columns: 1fr; padding: .8rem 0 1rem; }
  .episode-row .btn { width: 100%; }
  .episode-actions { align-items: stretch; flex-direction: column; }
  .share-popover { position: static; width: 100%; margin-top: .4rem; }
  .actions, .inline-form, .reader-tools { flex-direction: column; }
  .actions .btn, .inline-form .btn, .reader-tools .btn { width: 100%; }
  .review-line { grid-template-columns: 1fr; gap: .15rem; }
  .design-panel-head { align-items: stretch; flex-direction: column; }
  .design-status { align-self: flex-start; }
  .design-candidates { grid-template-columns: 1fr; }
  .design-choice { display: grid; grid-template-columns: minmax(0,1fr) 9rem; align-items: stretch; }
  .design-choice .btn { border-top: 0; border-left: 1px solid var(--line); }
  .design-candidate-image { aspect-ratio: 5 / 4; }
  .design-locked { grid-template-columns: 1fr; }
  .design-locked-image { max-height: 380px; }
}

@media (max-width: 380px) {
  .design-choice { grid-template-columns: 1fr; }
  .design-choice .btn { border-left: 0; border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
