/* ============================================================= InstaComic
   Pitchman Labs palette: light pink -> lavender.
   ---------------------------------------------------------------------- */

:root {
  --pink: #ff8ec4;
  --pink-soft: #ffd6ea;
  --lavender: #a98bf0;
  --lavender-soft: #e2d8fb;
  --brand: linear-gradient(110deg, #ff8ec4 0%, #c79bf0 55%, #a98bf0 100%);
  --brand-soft: linear-gradient(140deg, #fff2f8 0%, #f6f0ff 55%, #efe9fe 100%);

  --ink: #2c2340;
  --ink-soft: #6b5f80;
  --line: #ece5f6;
  --card: #ffffff;
  --shadow: 0 18px 45px -20px rgba(96, 62, 150, 0.35);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--brand-soft);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

.gradient-text {
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------------- buttons --- */

button { font: inherit; cursor: pointer; border: 0; border-radius: 999px; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary {
  border-radius: 999px;
  padding: 13px 26px;
  color: #fff;
  font-weight: 650;
  background: var(--brand);
  box-shadow: 0 10px 24px -10px rgba(169, 139, 240, 0.9);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: saturate(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost {
  border-radius: 999px;
  padding: 11px 20px;
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-weight: 600;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--lavender-soft); }

/* -------------------------------------------------------------- fields --- */

label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 7px; color: var(--ink-soft); }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 13px 15px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 4px rgba(169, 139, 240, 0.16);
}
textarea { resize: vertical; line-height: 1.5; }

.field { margin-bottom: 18px; }

.error {
  display: none;
  margin-top: 14px;
  padding: 11px 14px;
  font-size: 14px;
  color: #9b2c52;
  background: #ffeef4;
  border: 1px solid #ffd0e0;
  border-radius: 11px;
}
.error.show { display: block; }

/* --------------------------------------------------------------- login --- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
}
.blob-1 { width: 420px; height: 420px; background: var(--pink-soft); top: -120px; left: -100px; }
.blob-2 { width: 460px; height: 460px; background: var(--lavender-soft); bottom: -160px; right: -120px; }

.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 40px 36px 34px;
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.login-logo { display: block; width: 100%; max-width: 290px; margin: 0 auto 30px; }
.login-tagline {
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 30px;
}
.login-card .btn-primary { width: 100%; margin-top: 6px; }

/* ---------------------------------------------------------------- shell --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar img { height: 34px; flex: 0 1 auto; min-width: 0; }
.topbar .spacer { flex: 1; min-width: 8px; }

/* Icon-only, fixed size, and never allowed to be squeezed off the screen. */
.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: #f7f2fd;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--lavender); background: #efe6fc; }

main { max-width: 1080px; margin: 0 auto; padding: 30px 20px 90px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-bottom: 22px;
}
.card-head { margin-bottom: 20px; }
.card-head h2 { font-size: 19px; }
.card-head p { font-size: 14px; color: var(--ink-soft); margin-top: 5px; }

.step-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
  color: #fff;
  background: var(--brand);
  margin-bottom: 10px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* Action buttons are centred, with clear breathing room above them so they
   never crowd the box that precedes them. */
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 28px;
}

/* --------------------------------------------------------------- photo --- */

.photo-row { display: flex; gap: 22px; align-items: flex-start; }
.photo-drop {
  flex: 0 0 190px;
  height: 240px;
  border-radius: 16px;
  border: 2px dashed var(--lavender-soft);
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  overflow: hidden;
  padding: 10px;
  transition: border-color 0.15s ease;
}
.photo-drop:hover, .photo-drop.dragover { border-color: var(--lavender); }
.photo-drop img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
}
.photo-fields { flex: 1; min-width: 0; }
.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }

/* ---------------------------------------------------------- storyboard --- */

.page-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: #fdfcff;
}
.page-card h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--lavender); }
.page-card .beat { font-size: 13.5px; color: var(--ink-soft); margin: 6px 0 16px; }

.frame-block { padding: 14px 0; border-top: 1px dashed var(--line); }
.frame-block:first-of-type { border-top: 0; padding-top: 0; }
.frame-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 10px; }
.frame-meta { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; line-height: 1.55; }
.frame-meta b { color: var(--ink); font-weight: 650; }

.bubble-row {
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.bubble-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.bubble-head select {
  flex: 0 0 auto;
  width: auto;
  min-width: 108px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 650;
}
.bubble-head .word-count { margin-left: auto; }
.bubble-row .del {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px;
  background: #fff2f6; color: #c2547d; font-weight: 700; line-height: 1;
}
/* Full width, wraps, grows with the text - dialogue is never cut off. */
.bubble-text {
  width: 100%;
  display: block;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.45;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  resize: none;
  overflow: hidden;
  min-height: 42px;
}
.link-btn {
  background: none; color: var(--lavender); font-size: 13px; font-weight: 650; padding: 4px 0;
}
.word-count { font-size: 11.5px; color: var(--ink-soft); flex: 0 0 auto; min-width: 34px; text-align: right; }
.word-count.over { color: #d0436f; font-weight: 700; }

/* ------------------------------------------------------------ progress --- */

.creating { text-align: center; padding: 34px 10px 26px; }
.creating h2 { font-size: 21px; margin-bottom: 8px; }
.creating .spinner.big {
  width: 34px;
  height: 34px;
  border-width: 3.5px;
  display: block;
  margin: 0 auto 18px;
}
.creating-note { font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.creating .progress-shell { max-width: 420px; margin-left: auto; margin-right: auto; }

.progress-shell { height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 16px 0 10px; }
.progress-fill { height: 100%; width: 0%; background: var(--brand); border-radius: 999px; transition: width 0.45s ease; }
.progress-note { font-size: 13.5px; color: var(--ink-soft); }

.hidden { display: none !important; }

.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
}
.spinner.dark { border-color: rgba(169, 139, 240, 0.3); border-top-color: var(--lavender); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 680px) {
  .row { grid-template-columns: 1fr; }
  .photo-row { flex-direction: column; }
  .photo-drop { flex: 0 0 auto; width: 100%; height: 300px; }
  main { padding: 22px 16px 70px; }
  .card { padding: 22px 18px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar img { height: 28px; }
}

a.btn-primary, a.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* --------------------------------------------------- login page footer --- */

.login-copyright {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-soft);
  opacity: 0.8;
}

/* Space between the last storyboard page and the submit buttons. */
.pages-list { margin-bottom: 10px; }

