/* ═══════════════════════════════════════════════════════
   Imahe — MANGA STUDIO 💥  (page-specific layout & flair)
   Mobile-first stacked; ≥1024px = two-page comic spread.
   ═══════════════════════════════════════════════════════ */

/* ---------- structure ---------- */
.manga-left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.manga-right { min-width: 0; }

@media (max-width: 1023.98px) {
  .manga-spread { display: flex; flex-direction: column; gap: 22px; }
}

/* ---------- header ---------- */
.manga-head { display: flex; flex-direction: column; align-items: flex-start; }
.manga-head .back-tab { margin-left: 8px; }
.manga-head .title-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.manga-head .screen-title { margin: 0; }
.manga-head .cost-badge { margin-left: auto; transform: rotate(-2deg); }

.panel-title .pt-hint {
  font-size: 10px; font-weight: 600; text-transform: none; letter-spacing: 0.02em;
  color: var(--newsprint-mute); margin-left: auto;
}

/* ---------- ① refs (compact) ---------- */
.manga-refs .dropzone { min-height: 74px; padding: 10px; gap: 3px; }
.refs-tip { margin-top: 8px; }
.refs-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.refs-duo .dz-thumbs { justify-content: center; }

/* ---------- ② style flip chips ---------- */
.style-flips { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; perspective: 500px; }
.style-flip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 13px 8px 11px;
  background: var(--speech-fill); color: var(--ink);
  border: var(--border-ink); border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--panel-shadow);
  font-family: var(--f-display); font-size: 21px; letter-spacing: 0.05em; line-height: 1;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.style-flip .sf-ico { font-size: 26px; }
.style-flip:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--panel-shadow); }
.style-flip.is-on { box-shadow: var(--shadow-harder); }
.style-flip--color.is-on {
  background: linear-gradient(135deg, #FFD9E1, #FFF3C9 52%, #D6F5F1);
  border-color: var(--riso-pink-ink);
}
/* the B&W chip lives in a desaturated world */
.style-flip--bw { filter: grayscale(1) saturate(0); }
.style-flip--bw.is-on { background: var(--ink); color: var(--paper); }
.style-flip.flipping { animation: sf-flip 0.35s ease-out; }
@keyframes sf-flip {
  0% { transform: rotateY(88deg); }
  100% { transform: rotateY(0deg); }
}

/* ---------- ③ stepper + mini comic-grid preview ---------- */
.step-row { display: flex; align-items: center; gap: 16px; }
.step-side { display: flex; flex-direction: column; gap: 4px; }
.step-ctrl { display: flex; align-items: center; gap: 12px; }
.step-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: var(--border-ink); background: var(--speech-fill); color: var(--ink);
  font-family: var(--f-display); font-size: 24px; line-height: 1;
  box-shadow: 2px 2px 0 var(--panel-shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}
.step-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--panel-shadow); }
.step-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.step-count { font-size: 32px; font-weight: 700; min-width: 36px; text-align: center; }

.mini-page {
  margin-left: auto;
  width: 112px; aspect-ratio: 2 / 3; flex: 0 0 auto;
  background: #fff; border: 2px solid var(--ink-line); border-radius: 6px;
  box-shadow: 2px 2px 0 var(--panel-shadow);
  padding: 5px; display: grid; gap: 5px;
}
.mini-page[data-count="1"] { grid-template: 1fr / 1fr; }
.mini-page[data-count="2"] { grid-template: 1fr 1fr / 1fr; }
.mini-page[data-count="3"],
.mini-page[data-count="4"] { grid-template: 1fr 1fr / 1fr 1fr; }
.mini-page[data-count="3"] .mini-box:first-child { grid-column: 1 / -1; }
.mini-page[data-count="5"],
.mini-page[data-count="6"] { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.mini-page[data-count="5"] .mini-box:nth-child(3) { grid-column: 1 / -1; }
.mini-box {
  border: 1.5px solid var(--ink-line); border-radius: 3px;
  background: var(--paper-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 11px; color: var(--newsprint-mute);
}
.mini-box.mini-pop { animation: mini-pop 0.28s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes mini-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ---------- ④ prompt ---------- */
.prompt-chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.prompt-chips .chip:disabled { opacity: 0.55; cursor: progress; box-shadow: none; transform: none; }
.dice-ico { display: inline-block; }
.scn-count {
  font-family: var(--f-mono); font-size: 10px; font-weight: 700;
  background: var(--paper-sunk); border: 1.5px solid var(--ink-line);
  border-radius: 999px; padding: 0 6px; margin-left: 2px;
}
.inky-think { margin-top: 10px; align-items: flex-start; }

/* story beats vs panel count disagreement */
.beat-note {
  margin-top: 8px; padding: 6px 10px;
  border: 2px dashed var(--riso-yellow-deep); border-radius: 10px;
  background: rgba(255, 197, 49, 0.14);
  color: var(--ink-soft); font-family: var(--f-head); font-weight: 600;
}

/* ---------- generate bar ---------- */
/* It lives inside .wiz-nav now, which already provides the sticky ink frame —
   so the bar itself is just a layout row. */
.gen-bar {
  display: flex; align-items: center; gap: 12px;
  flex: 1; min-width: 0;
}
.gen-bar .gb-info { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.gen-bar .gb-note { white-space: nowrap; }
.gen-bar .gen-go { flex: 1; min-width: 0; }
.gen-bar .gen-go::after { display: none; } /* no bubble tail inside the bar */

.shake-me { animation: shake 0.35s; }

/* ---------- ⑥ review ---------- */
.rev-panel { display: flex; flex-direction: column; gap: 12px; }
.rev-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 12px;
  align-items: baseline;
}
.rev-key {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--newsprint-mute);
}
.rev-val {
  font-family: var(--f-head); font-weight: 600; font-size: 13px;
  overflow-wrap: anywhere;
}
.rev-inky { align-items: center; }

/* ---------- right page: the printed comic sheet ---------- */
.manga-right-inner {
  display: flex; flex-direction: column; gap: 14px;
  background: #fff;
  border: var(--border-ink); border-radius: 10px;
  box-shadow: var(--shadow-hard);
  padding: 16px 14px 30px;
  position: relative;
}
.manga-right-inner::after {
  content: 'IMAHE COMICS'; position: absolute; bottom: 8px; right: 14px;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.18em;
  color: var(--newsprint-mute);
}
.rp-head { display: flex; align-items: center; justify-content: space-between; }
.rp-head .panel-title { margin-bottom: 0; }
.issue-stamp {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  border: 2px solid var(--ink-line); border-radius: 4px;
  padding: 1px 6px; color: var(--newsprint-mute);
  transform: rotate(3deg);
}

.gen-status { display: flex; flex-direction: column; gap: 10px; }

.story-title {
  font-size: 30px; margin: 2px auto; width: fit-content; max-width: 100%;
  text-align: center; padding: 0 8px;
  background: linear-gradient(transparent 60%, var(--riso-yellow) 60%, var(--riso-yellow) 92%, transparent 92%);
  transform: rotate(-1deg);
}

.manga-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; justify-items: center; }
.manga-results > * { width: 100%; }

/* page shape picker */
.aspect-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.aspect-chip { gap: 7px; }
.aspect-chip .ar-sub { font-size: 10px; opacity: 0.7; }
.ar-23 { width: 11px; height: 16px; }
.aspect-note { margin-top: 8px; }


/* finished panel */
.manga-panel-card {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  background: #fff;
  border: var(--border-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: 8px 8px 10px;
}
@media (hover: hover) {
  .manga-panel-card:hover { transform: rotate(0) translateY(-3px); transition: transform 0.15s ease-out; }
}
.mp-img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover;
  border: 2px solid var(--ink-line); border-radius: 8px;
  background: var(--paper-sunk);
}
.mp-num {
  position: absolute; top: -9px; left: -9px; z-index: 2;
  width: 27px; height: 27px;
  display: flex; align-items: center; justify-content: center;
  background: var(--riso-yellow);
  border: 2px solid var(--ink-line); border-radius: 8px;
  font-size: 15px; transform: rotate(-6deg);
  box-shadow: 2px 2px 0 var(--panel-shadow);
}
.mp-caption { font-weight: 600; }
.variant-dots { display: flex; justify-content: center; gap: 9px; padding-top: 2px; }
.v-dot {
  width: 26px; height: 26px; padding: 0;
  border-radius: 50%; border: 2px solid var(--ink-line);
  background: var(--speech-fill); color: var(--newsprint-mute);
  font-family: var(--f-mono); font-size: 11px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 1px 1px 0 var(--panel-shadow);
  transition: transform 0.1s, background 0.1s;
}
.v-dot.is-on {
  background: var(--riso-pink); color: #fff;
  border-color: var(--riso-pink-ink); transform: scale(1.15);
}

/* panel error */
.mp-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  min-height: 150px; padding: 16px;
  border: 2.5px dashed var(--danger-ink); border-radius: var(--radius);
  background: rgba(255, 77, 109, 0.08);
}
.mp-err-title { font-size: 26px; color: var(--danger-ink); }

/* CTA + empty state */
.cta-wrap {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 6px 0 14px;
}
.manga-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px 14px;
  border: 2.5px dashed var(--ink-line); border-radius: var(--radius-lg);
  background: rgba(247, 241, 225, 0.55);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════
   DESKTOP ≥1024px — true two-page spread:
   left page = studio controls · right page = printed comic
   ═══════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .manga-head .screen-title { font-size: 42px; }
  .manga-left { gap: 18px; }

  .manga-spread .page--right { padding: 30px 34px; }
  .manga-right-inner { padding: 24px 22px 36px; min-height: 72vh; }
  /* One column, centred. Two columns left a single finished page stuck in the
     left half of the sheet instead of sitting in the middle of it. */
  .manga-results { grid-template-columns: minmax(0, 1fr); gap: 22px; justify-items: center; }

  /* tabbar is gone on desktop — pin the bar near the true bottom */
  .gen-bar { bottom: 18px; }
}

/* ─── page-layout preview (single-page manga rework) ─── */
.layout-mini {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  aspect-ratio: var(--page-aspect, 2 / 3);
  width: 118px;
  background: var(--speech-fill);
  border: 2px solid var(--ink-line);
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}
.layout-box {
  border: 1.5px solid var(--ink-line);
  border-radius: 3px;
  background: var(--paper-sunk);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--newsprint-mute);
}
.layout-pop { animation: layout-pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes layout-pop { 0% { transform: scale(0.92) rotate(-2deg); } 100% { transform: scale(1) rotate(0); } }
.layout-name { margin-top: 8px; }

/* pending page card: sketch of the chosen layout, in the chosen shape */

/* finished page card */
.manga-page-card { max-width: 460px; margin: 0 auto; }
/* aspect-ratio:auto + object-fit:fill defeat the 2:3 crop inherited from
   .mp-img — a square or wide page must show at its own shape, not be cut. */
.mp-page {
  width: 100%; height: auto;
  aspect-ratio: auto; object-fit: contain;
  border: 2px solid var(--ink-line); border-radius: 10px;
}
.variant-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
