/* =========================================================================
   Wonderdoodle: Create flow (front-end demo, no backend)
   Matches the editorial Wonderbly-style system in styles.css
   ========================================================================= */

.create {
  background: var(--cream);
  min-height: calc(100vh - var(--nav-h));
}

/* Stepper -------------------------------------------------------------- */
.stepper { padding: 34px 0 6px; }
.stepper__track {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto;
}
.stepper__node { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.stepper__dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper);
  border: 2px solid var(--line-strong);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  flex: none;
  transition: all 0.2s ease;
}
.stepper__label { font-size: 0.9rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.stepper__line { flex: 1 1 auto; height: 2px; background: var(--line-strong); border-radius: 0; min-width: 12px; }
.stepper__node.is-active .stepper__dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.stepper__node.is-active .stepper__label { color: var(--ink); }
.stepper__node.is-done .stepper__dot { background: var(--green); border-color: var(--green); color: #fff; }
.stepper__node.is-done .stepper__label { color: var(--ink-soft); }
@media (max-width: 760px) { .stepper__label { display: none; } }

/* Layout --------------------------------------------------------------- */
/* Close the builder -----------------------------------------------------
   Far right, past the actions, as a plain ✕. It used to sit before them as a
   back-arrow stacked over the word "Exit", which read as a step-back control
   inside the flow rather than a way out of it, and the brand mark already
   goes home, so it never needed the extra weight. */
.nav__close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  margin-left: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav__close:hover { color: var(--ink); background: var(--cream-2); }
.nav__close:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Account chip ---------------------------------------------------------- */
.account { position: relative; }
.account.is-hidden { display: none; }
.account__btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--green-soft);
  color: var(--green-dark);
  font: 600 0.82rem/1 var(--font-body);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: border-color 0.15s ease;
}
.account__btn:hover { border-color: var(--green); }
.account__btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.account__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 10px;
  z-index: 40;
  text-align: left;
}
.account__menu.is-hidden { display: none; }
.account__email {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}
.account__link {
  display: block;
  border-top: 1px solid var(--line);
  padding: 8px 4px;
  font: 600 0.85rem/1.3 var(--font-body);
  color: var(--ink);
  text-decoration: none;
}
.account__link:hover { color: var(--green-dark); }
.account__signout {
  width: 100%;
  border: 0;
  background: none;
  border-top: 1px solid var(--line);
  padding: 8px 4px 2px;
  font: 600 0.85rem/1 var(--font-body);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.account__signout:hover { color: var(--green-dark); }

.builder {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 46px;
  align-items: start;
  padding: 30px 0 90px;
}
.builder > * { min-width: 0; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; gap: 30px; } }

.final-intro {
  max-width: 760px;
  margin: 34px auto 0;
  text-align: center;
}
.final-intro.is-hidden { display: none; }
.final-intro h2 { margin: 8px 0 10px; }
.final-intro .step-intro { max-width: 650px; margin-inline: auto; }

/* Step five is led by the finished object: intro, book, then order summary. */
.builder.is-final { grid-template-columns: 1fr; gap: 26px; padding-top: 24px; }
.builder.is-final .preview { position: static; }
.builder.is-final .preview__stage { padding: 32px; }
.builder.is-final .panel { width: min(100%, 760px); margin: 0 auto; }
.builder.is-final:not(.is-reading) .preview__book { width: min(430px, 78vw); }

/* Reading mode ----------------------------------------------------------
   Once the pages exist, the cover becomes a quiet two-page printed spread. */
.builder.is-reading { grid-template-columns: 1fr; gap: 34px; }
.builder.is-reading .preview { position: static; }
.builder.is-reading .preview__book {
  width: min(100%, 1120px);
  aspect-ratio: auto;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
}
.builder.is-reading .preview__book::before { display: none; }
.builder.is-reading .preview__book:hover { transform: none; }
.builder.is-reading .preview__cover { display: none; }
.builder.is-reading .preview__stage { padding: clamp(14px, 3vw, 34px); }

/* Live preview (sticky) ------------------------------------------------ */
.preview { position: sticky; top: calc(var(--nav-h) + 20px); }
.preview__stage {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 34px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.preview__book {
  position: relative;
  width: 78%;
  margin: 0 auto 22px;
  aspect-ratio: 4 / 5;
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s ease;
}
.preview__book::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.20), rgba(0,0,0,0));
  z-index: 3;
}
.preview__book:hover { transform: rotate(-1deg) scale(1.02); }
.preview__cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 22px 18px;
  background: var(--peach);
  transition: background 0.4s ease;
}
.preview__cover-top { width: 100%; }
.preview__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--ink);
  margin: 0;
}
.preview__sub {
  font-family: var(--font-body);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 8px;
}
.preview__art {
  width: 62%;
  aspect-ratio: 1;
  border-radius: 0;
  background: rgba(255,255,255,0.55);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 6px 0;
}
.preview__art img { width: 84%; height: 84%; object-fit: contain; }
.preview__art--empty { color: var(--muted); }

/* Cover cast: the approved character canons standing directly on the cover
   colour. The flat identity-card backdrop is keyed out in JS (cutOutCanon), so
   no blend mode is needed, and none is used, because `multiply` would darken
   the characters themselves against the cover tint. */
.preview__art--cast { background: transparent; display: flex; align-items: flex-end; justify-content: center; gap: 0; }
.preview__art--cast img {
  width: auto;
  height: 100%;
  flex: 1 1 0;
  min-width: 0;
  object-fit: contain;
}
.preview__art--cast.is-multi img { height: 88%; }
.preview__meta-note {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.75;
  min-height: 0.8em;
}
.preview__byline { font-family: var(--font-body); font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; }
.preview__caption { font-size: 0.86rem; color: var(--muted); }
.preview__meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.preview__meta.is-hidden { display: none; }
.chip-mini {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--cream-2);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
}

/* Panel / steps -------------------------------------------------------- */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 520px) { .panel { padding: 26px 22px; } }

.step-pane { display: none; animation: fade 0.35s ease; }
.step-pane.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.step-kicker {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}
.step-pane h2 { font-size: 1.8rem; margin-bottom: 8px; }
.step-pane > p.step-intro { color: var(--ink-soft); margin-bottom: 26px; max-width: 46ch; }

.field { margin-bottom: 22px; }
.field > label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; color: var(--ink); }
.field .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.input, .textarea, .select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--cream);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 13px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--green);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(28, 74, 58, 0.14);
}
.textarea { resize: vertical; min-height: 96px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 460px) { .row-2 { grid-template-columns: 1fr; } }

/* Upload dropzone ------------------------------------------------------ */
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--cream);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--green); background: #fff; }
.dropzone__icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: grid; place-items: center;
  margin: 0 auto 16px;
}
.dropzone h3 { font-size: 1.2rem; margin-bottom: 4px; }
.dropzone p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.dropzone__btn { margin-top: 16px; display: inline-block; font-weight: 600; color: var(--green); text-decoration: underline; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__x {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(30,27,22,0.72);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 12px;
  line-height: 1;
}
.thumb--sample::after {
  content: "sample";
  position: absolute;
  bottom: 6px; left: 6px;
  background: var(--butter);
  color: var(--ink);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Yes / no choice ------------------------------------------------------ */
.choice { display: flex; gap: 10px; }
.choice__opt {
  border: 1.5px solid var(--line-strong);
  background: var(--cream);
  color: var(--ink-soft);
  border-radius: var(--radius);
  padding: 9px 24px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.choice__opt:hover { border-color: var(--green); color: var(--ink); }
.choice__opt.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.choice__opt:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* The child's name, age and message, revealed only by "yes" above. */
.dedication-details.is-hidden { display: none; }

/* Sub-section heading inside a step (e.g. style under theme) */
.substep-title {
  margin: 40px 0 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}
.substep-intro { color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 18px; max-width: 52ch; }
.field-note { margin-top: 16px; color: var(--muted); font-size: 0.84rem; max-width: 54ch; }
.required-choice {
  scroll-margin-top: calc(var(--nav-h) + 28px);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.required-choice + .required-choice { margin-top: 40px; }
.required-choice + .required-choice .substep-title { margin-top: 0; }
.required-mark { color: #a33a2a; font-family: var(--font-body); font-size: 0.78em; vertical-align: 0.16em; }
.story-idea {
  margin-top: 18px;
  padding: clamp(16px, 2.4vw, 24px);
  border: 1px solid var(--line-strong);
  background: #fff;
}
.story-idea label { display: block; margin-bottom: 8px; color: var(--ink); font-weight: 700; }
.story-idea__meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}
.story-idea__meta span:first-child { max-width: 62ch; }
.story-idea__meta span:last-child { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.required-choice.has-error {
  margin-inline: -14px;
  padding: 14px;
  border-left: 3px solid #a33a2a;
  background: #fff8f4;
}
.choice-error { margin: 10px 0 0; color: #8b3025; font-size: 0.84rem; font-weight: 600; }
.choice-error.is-hidden { display: none; }

/* Pickers -------------------------------------------------------------
   One card component for both theme (text) and style (artwork). Selection
   reads as a quiet ink border rather than a colour wash, so the artwork,
   not the UI, carries the colour on this screen. */
.picker { display: grid; gap: 12px; }
.picker--text { grid-template-columns: repeat(3, 1fr); }
.picker--art { grid-template-columns: repeat(3, 1fr); margin-bottom: 2px; }
@media (max-width: 620px) {
  .picker--text, .picker--art { grid-template-columns: repeat(2, 1fr); }
}

.pick {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.pick:hover { border-color: var(--ink-soft); }
.pick:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.pick.is-on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
/* Selected tick, top-right: no layout shift, no colour wash. */
.pick.is-on::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 10px 10px no-repeat;
}
.picker--art .pick.is-on::after { top: 8px; right: 8px; }

.pick__name { font-weight: 600; font-size: 0.93rem; line-height: 1.35; }
.pick__desc { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

/* Style cards: artwork sample fills the card, caption sits beneath. */
.picker--art .pick { padding: 8px 8px 11px; gap: 0; }
.pick__art {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--peach); /* holds the card's shape while the sample loads */
  margin-bottom: 9px;
}
.pick__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker--art .pick__name { padding: 0 4px; }
.picker--art .pick__desc { padding: 0 4px; }
/* Colour swatches (cover) ---------------------------------------------- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--paper);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.swatch:hover { transform: translateY(-1px); }
.swatch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.swatch.is-on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }

/* Format options ------------------------------------------------------- */
.formats { display: flex; flex-direction: column; gap: 12px; }
.format {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  background: var(--paper);
  transition: all 0.15s ease;
}
.format:hover { border-color: var(--green); }
.format.is-on { border-color: var(--green); background: var(--green-soft); }
.format__radio {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex: none;
  display: grid; place-items: center;
  transition: border-color 0.15s ease;
}
.format.is-on .format__radio { border-color: var(--green); }
.format.is-on .format__radio::after { content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--green); }
.format__body { flex: 1; }
.format__body b { display: block; font-size: 1rem; }
.format__body span { font-size: 0.85rem; color: var(--muted); }
.format__price { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; color: var(--ink); }

/* Footer nav ----------------------------------------------------------- */
.panel__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.panel__nav .btn--ghost.is-hidden { visibility: hidden; }

/* Final review --------------------------------------------------------- */
.summary {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 22px 0;
}
.summary__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.summary__row:last-child { border-bottom: 0; }
.summary__row span:first-child { color: var(--muted); }
.summary__row span:last-child { color: var(--ink); font-weight: 600; text-align: right; }
.summary__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 2px solid var(--line-strong);
}
.summary__total b { font-family: var(--font-display); font-size: 1.7rem; }
.reassure { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.reassure span { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; color: var(--ink-soft); }
.reassure svg { color: var(--green); flex: none; }

/* Auth gate ------------------------------------------------------------ */
.auth {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(30, 27, 22, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth.is-hidden { display: none; }
.auth__card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
}
.auth__card h3 { font-size: 1.5rem; margin-bottom: 6px; }
.auth__intro { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 20px; }
.auth__tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.auth__tab {
  flex: 1;
  border: 1.5px solid var(--line-strong);
  background: var(--cream);
  color: var(--ink-soft);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth__tab.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.auth__error {
  color: #A33A2A;
  background: #FBE7D3;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin: 0 0 16px;
}
.auth__error.is-hidden { display: none; }
.nav__user { font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }
@media (max-width: 700px) { .nav__user { display: none; } }

.linklike {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--green);
  text-decoration: underline;
  cursor: pointer;
}

/* Upload extras --------------------------------------------------------- */
.sample-row { margin: 14px 0 0; font-size: 0.9rem; color: var(--muted); }
.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--cream-2);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.consent input { margin-top: 3px; accent-color: var(--green); width: 17px; height: 17px; flex: none; }

.thumb__status {
  position: absolute;
  bottom: 6px; left: 6px;
  background: rgba(30, 27, 22, 0.72);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.thumb--processed .thumb__status { background: var(--green); }
.thumb--failed .thumb__status, .thumb--quarantined .thumb__status { background: #A33A2A; }
.thumb--uploading img, .thumb--processing img { opacity: 0.55; }

/* Character extraction / picker ----------------------------------------- */
.extract-status { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 20px; min-height: 1.2em; }
.ok-badge {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: -4px;
}
.charpick { display: flex; flex-wrap: wrap; gap: 10px; }
.charpick__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 7px 14px 7px 7px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.charpick__item img { width: 34px; height: 34px; border-radius: var(--radius-sm); object-fit: cover; }
.charpick__item:hover { border-color: var(--green); }
.charpick__item.is-on { border-color: var(--green); background: var(--green-soft); }

/* Build progress (step 5) ------------------------------------------------ */
.build {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.build.is-hidden { display: none; }
.build__timing { margin: 0 0 18px; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.build__list { display: flex; flex-direction: column; gap: 14px; }
.build__step { display: flex; align-items: center; gap: 12px; font-size: 0.95rem; color: var(--muted); }
.build__step em { font-style: normal; color: var(--muted); font-size: 0.85rem; }
.build__icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--line-strong);
  font-size: 0.72rem;
  font-weight: 700;
  flex: none;
  color: var(--muted);
}
.build__step--running { color: var(--ink); font-weight: 600; }
.build__step--running .build__icon { border-color: var(--green); }
.build__step--done { color: var(--ink-soft); }
.build__step--done .build__icon { background: var(--green); border-color: var(--green); color: #fff; }
.build__step--failed { color: #A33A2A; font-weight: 600; }
.build__step--failed .build__icon { background: #A33A2A; border-color: #A33A2A; color: #fff; }
.build__error { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.build__error.is-hidden { display: none; }
.build__error p { color: #A33A2A; font-size: 0.92rem; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: wdspin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes wdspin { to { transform: rotate(360deg); } }

/* The opened book ------------------------------------------------------- */
.reader.is-hidden { display: none; }
.reader { width: 100%; overflow-x: auto; padding: 18px 8px 24px; scroll-snap-type: x proximity; }
.reader__spread {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-width: 620px;
  margin: 0 auto;
  filter: drop-shadow(0 20px 26px rgba(28, 38, 33, 0.16));
}
.reader__spread::after {
  content: "";
  position: absolute;
  z-index: 4;
  top: 1.5%;
  bottom: 1.5%;
  left: 50%;
  width: 22px;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(40, 35, 28, 0.13), rgba(255, 255, 255, 0.3), rgba(40, 35, 28, 0.1), transparent);
}
.reader__page {
  position: relative;
  min-width: 0;
  aspect-ratio: 4 / 5;
  display: grid;
  grid-template-rows: minmax(0, 23%) minmax(0, 54%) minmax(0, 23%);
  background: #fffdf8;
  border: 1px solid #ddd6ca;
  overflow: hidden;
  scroll-snap-align: start;
}
.reader__page--left {
  border-radius: 0;
  box-shadow: inset -20px 0 28px -28px rgba(32, 27, 22, 0.55);
}
.reader__page--right {
  border-radius: 0;
  box-shadow: inset 20px 0 28px -28px rgba(32, 27, 22, 0.55);
}
.reader__page.is-blank { background: #faf7ef; }
.reader__page.is-blank > * { visibility: hidden; }
.reader__art {
  position: relative;
  min-height: 0;
  margin: 0 clamp(12px, 2.6vw, 30px);
  background: #fff;
  overflow: hidden;
}
.reader__art img { width: 100%; height: 100%; object-fit: contain; display: block; }
.reader__text {
  min-height: 0;
  padding: clamp(9px, 1.5vw, 18px) clamp(19px, 3.4vw, 42px);
  display: flex;
  flex-direction: column;
  text-align: center;
  color: #332f29;
}
.reader__text p {
  margin: 0;
  overflow: auto;
  font-family: var(--reader-font, Bembo, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif);
  font-size: clamp(0.7rem, 1.3vw, 1.02rem);
  font-weight: 400;
  line-height: 1.44;
  letter-spacing: 0.006em;
  text-wrap: balance;
}
.reader__text--top { justify-content: flex-end; }
.reader__text--bottom { justify-content: flex-start; }
.reader__page.is-white-cutout .reader__text p { width: 100%; text-align: center; }
.reader__page.is-white-cutout.text-top { grid-template-rows: minmax(0, 28%) minmax(0, 72%); }
.reader__page.is-white-cutout.text-top .reader__text--top { grid-row: 1; }
.reader__page.is-white-cutout.text-top .reader__art { grid-row: 2; }
.reader__page.is-white-cutout.text-top .reader__text--bottom {
  position: absolute;
  right: clamp(12px, 2vw, 24px);
  bottom: clamp(8px, 1.4vw, 16px);
  padding: 0;
}
.reader__page.is-white-cutout.text-top .reader__text--bottom p { display: none; }
.reader__page.is-white-cutout.text-top .reader__text--bottom span { margin: 0; padding: 0; }
.reader__page.is-white-cutout.text-bottom { grid-template-rows: minmax(0, 72%) minmax(0, 28%); }
.reader__page.is-white-cutout.text-bottom .reader__text--top { display: none; }
.reader__page.is-white-cutout.text-bottom .reader__art { grid-row: 1; }
.reader__page.is-white-cutout.text-bottom .reader__text--bottom { grid-row: 2; }
.reader__page.is-full-scene { grid-template-rows: minmax(0, 68%) minmax(0, 32%); }
.reader__page.is-full-scene .reader__text--top { display: none; }
.reader__page.is-full-scene .reader__art {
  grid-row: 1;
  margin: clamp(10px, 2.2vw, 24px) clamp(10px, 2.2vw, 24px) 0;
  background: var(--cream-2);
}
.reader__page.is-full-scene .reader__art img { object-fit: cover; }
.reader__page.is-full-scene .reader__text--bottom {
  grid-row: 2;
  padding: clamp(12px, 2vw, 24px) clamp(17px, 3vw, 36px) clamp(12px, 2vw, 22px);
  text-align: left;
}
.reader__page.is-full-scene .reader__text--bottom p { text-align: left; text-wrap: pretty; }
.reader__text span {
  margin-top: auto;
  padding-top: 8px;
  text-align: center;
  font-size: clamp(0.58rem, 0.9vw, 0.72rem);
  color: var(--muted);
}
.reader__busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.reader__busy.is-hidden { display: none; }

.reader__controls { margin-top: 20px; display: grid; gap: 14px; justify-items: center; }
.reader__controls.is-hidden { display: none; }
.reader__font { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 0.82rem; font-weight: 600; }
.reader__font-select {
  min-width: 170px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 30px 8px 10px;
  font: 500 0.84rem/1.2 var(--font-body);
}
.reader__font-select:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.reader__nav { display: flex; align-items: center; gap: 8px; }
.reader__arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}
.reader__arrow:hover:not(:disabled) { border-color: var(--green); }
.reader__arrow:disabled { opacity: 0.32; cursor: default; }
.reader__arrow:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.reader__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 116px;
  text-align: center;
}
.reader__redraw {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.reader__redraws { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.reader__redraw[hidden] { display: none; }
.reader__redraw:hover:not(:disabled) { color: var(--green-dark); border-color: var(--green); background: var(--green-soft); }
.reader__redraw:disabled { opacity: 0.5; cursor: default; }
.reader__redraw:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

@media (max-width: 700px) {
  .builder.is-final .preview__stage { padding-inline: 10px; }
  .reader { padding-inline: 0; }
  .reader__spread { width: 620px; }
}

/* Export result ---------------------------------------------------------- */
.export-result { margin-bottom: 22px; }
.export-result.is-hidden { display: none; }
.export-result__card {
  background: var(--green-soft);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.export-result__card h3 { margin-bottom: 6px; }
.export-result__tick {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  margin-bottom: 14px;
}
.export-result__card .btn { margin-top: 8px; }
.export-result__note { font-size: 0.85rem; color: var(--ink-soft); margin: 12px 0 0; }
.export-result__err { color: #A33A2A; font-size: 0.92rem; }
.field.is-hidden { display: none; }

/* Toast ---------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, calc(100% + 48px));
  background: var(--ink);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.92rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.is-show { transform: translate(-50%, 0); }

/* Early setup, upload validation and canon feedback ---------------------- */
.inline-error {
  margin: 12px 0 0;
  padding: 10px 13px;
  border: 1px solid #e7b8a8;
  border-radius: var(--radius-sm);
  background: #fff1e9;
  color: #8b3025;
  font-size: 0.86rem;
}
.inline-error.is-hidden { display: none; }
.setup-fields { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.setup-fields .substep-title { margin-top: 8px; }
.canon-progress {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: -8px 0 20px;
  padding: 9px 12px;
  border-radius: 0;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 600;
}
.canon-progress.is-hidden { display: none; }

/* Payment and in-site decisions ----------------------------------------- */
.preview-paywall {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 14px;
  align-items: start;
  margin: 22px 0;
  padding: 22px;
  border: 1px solid #b9d3d9;
  border-radius: var(--radius);
  background: #eef6f7;
}
.preview-paywall.is-hidden { display: none; }
.preview-paywall.is-attention { border-color: var(--green); box-shadow: 0 0 0 3px rgba(54, 117, 136, 0.13); }
.preview-paywall__icon {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--green);
  border: 1px solid #c9ddd4;
}
.preview-paywall .step-kicker { margin: 0 0 4px; }
.preview-paywall h3 { margin: 0 0 7px; font-size: 1.28rem; }
.preview-paywall p:not(.step-kicker) { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.preview-paywall .btn { grid-column: 2; justify-self: start; margin-top: 16px; }
.preview-paywall .preview-paywall__secure { grid-column: 2; margin-top: 9px; font-size: 0.76rem; color: var(--muted); }
@media (max-width: 520px) {
  .preview-paywall { grid-template-columns: 1fr; }
  .preview-paywall__icon { grid-row: auto; margin-bottom: 12px; }
  .preview-paywall .btn, .preview-paywall .preview-paywall__secure { grid-column: 1; }
}
.site-dialog {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 27, 22, 0.48);
  backdrop-filter: blur(3px);
}
.site-dialog.is-hidden { display: none; }
.site-dialog__card {
  position: relative;
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}
.site-dialog__card h3 { margin: 0 28px 8px 0; font-size: 1.45rem; }
.site-dialog__card > p:not(.step-kicker) { margin: 0; color: var(--ink-soft); line-height: 1.55; }
.site-dialog__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: 400 1.5rem/1 var(--font-body);
  cursor: pointer;
}
.site-dialog__close:hover { background: var(--cream-2); color: var(--ink); }
.site-dialog__actions { display: grid; gap: 10px; margin-top: 24px; }
.site-dialog__card--wait { text-align: center; max-width: 400px; }
.site-dialog__card--wait h3 { margin: 18px 0 8px; }
.wait-orbit {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.wait-orbit span {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--green);
  transform-origin: 5px 22px;
  animation: wait-orbit 1.4s linear infinite;
}
@keyframes wait-orbit { to { transform: rotate(360deg); } }
.showcase-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
}
.showcase-consent input { margin-top: 4px; accent-color: var(--green); }
.showcase-consent span { display: grid; gap: 3px; }
.showcase-consent b { font-size: 0.94rem; }
.showcase-consent small,
.discount-field small { color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.discount-field { display: grid; gap: 7px; width: 100%; }
.discount-field label { font-size: 0.82rem; font-weight: 700; }
