:root {
  --bg: #13111c;
  --surface: #1d1a2b;
  --surface-2: #26223a;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f1ff;
  --muted: #a9a3c4;
  --accent: #ff4f87;
  --accent-2: #b15cff;
  --good: #34d399;
  --bad: #ff6b6b;
  --radius: 16px;
  color-scheme: dark;
}
body[data-audience="random"] { --accent: #7c6cff; --accent-2: #22c3e6; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.45 "Quicksand", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; margin: 4px 0 14px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 46px;
  font: 700 1rem "Quicksand", sans-serif;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 0.9rem; }
.btn.block { width: 100%; }
.btn.primary, .btn.publish {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.btn.ghost { background: transparent; border-color: var(--line); }
.btn:focus-visible, .icon-btn:focus-visible, .anim:focus-visible, .img-add:focus-visible, .stepper button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.3; }
.icon-btn.danger:hover { background: rgba(255, 107, 107, 0.18); border-color: rgba(255, 107, 107, 0.5); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.login-bg { position: absolute; inset: 0; }
.login-card {
  position: relative;
  width: min(100%, 380px);
  padding: 28px 24px;
  border-radius: 24px;
  background: rgba(20, 16, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-card h1 { font-family: "Dancing Script", cursive; font-size: 2.4rem; }
.login-card .field { text-align: left; margin-top: 18px; }
.logo { font-size: 2.6rem; }
.error { color: var(--bad); min-height: 1.3em; margin: 8px 0; font-weight: 600; }

/* ---------- layout ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(19, 17, 28, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.05rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }

.audience {
  border: 0;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.audience legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.aud-opt { position: relative; cursor: pointer; }
.aud-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.aud-opt > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}
.aud-opt > span::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  margin-bottom: 4px;
  transition: border 0.15s;
}
.aud-opt small { color: var(--muted); font-size: 0.78rem; word-break: break-all; }
.aud-opt input:checked + span { border-color: var(--accent); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface)); }
.aud-opt input:checked + span::before { border: 6px solid var(--accent); }
.aud-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 2px 14px;
}
.status a { color: var(--text); font-weight: 700; }

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  position: sticky;
  top: 58px;
  z-index: 15;
  background: var(--bg);
  padding: 6px 0;
}
.stepper button {
  appearance: none;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  border-radius: 12px;
  padding: 8px 6px;
  font: 700 0.85rem "Quicksand", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-height: 44px;
}
.stepper i {
  font-style: normal;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 0.8rem;
}
.stepper button.on { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--accent); }
.stepper button.on i { background: var(--accent); }
.stepper button.done i { background: var(--good); color: #052e1c; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.card.empty { text-align: center; }
.empty-icon { font-size: 2.4rem; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span { font-weight: 700; font-size: 0.9rem; }
.field small { color: var(--muted); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  font: 600 16px "Quicksand", sans-serif; /* 16px: no iOS zoom on focus */
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 46px;
  outline: none;
  transition: border-color 0.15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 2px 0 14px; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 48px; height: 28px; flex: 0 0 48px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; transition: background 0.2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- image slots ---------- */
.img-slot { position: relative; border-radius: 14px; overflow: hidden; background: var(--bg); border: 1.5px dashed rgba(255, 255, 255, 0.22); }
.img-slot.filled { border-style: solid; border-color: var(--line); }
.img-slot.big { width: 100%; aspect-ratio: 16 / 9; max-height: 260px; }
.img-slot.small { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 12px; }
.img-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-add {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 0.9rem "Quicksand", sans-serif;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.img-add-icon { font-size: 1.6rem; }
.img-slot.small .img-add-icon { font-size: 1.2rem; }
.img-act {
  position: absolute;
  top: 6px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}
.img-act.change { right: 46px; }
.img-act.remove { right: 6px; }
.img-slot.small .img-act { width: 22px; height: 22px; top: 2px; font-size: 0.65rem; }
.img-slot.small .img-act.change { right: auto; left: 2px; }
.img-slot.small .img-act.remove { right: 2px; }
.spinner { display: none; }
.img-slot.loading .spinner {
  display: block;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55) radial-gradient(circle, transparent 0 14px, transparent 15px);
}
.img-slot.loading .spinner::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  margin: -12px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- animations picker + preview ---------- */
.anim-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.anim {
  appearance: none;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 4px;
  font: 700 0.82rem "Quicksand", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  min-height: 72px;
}
.anim-icon { font-size: 1.6rem; }
.anim.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }

.preview {
  position: relative;
  aspect-ratio: 9 / 13;
  max-height: 520px;
  width: 100%;
  max-width: 360px;
  margin: 4px auto 0;
  border-radius: 22px;
  overflow: hidden;
  border: 6px solid #000;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
}
.preview-card { position: relative; z-index: 1; text-align: center; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview-photo {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  -webkit-mask-image: radial-gradient(ellipse 72% 72% at 50% 50%, #000 62%, rgba(0, 0, 0, 0.6) 80%, transparent 100%);
          mask-image: radial-gradient(ellipse 72% 72% at 50% 50%, #000 62%, rgba(0, 0, 0, 0.6) 80%, transparent 100%);
}
.preview-photo:has(img) { border: 0; }
.preview-photo img { width: 100%; height: 100%; object-fit: cover; }
.preview-q {
  font-family: "Dancing Script", cursive;
  font-size: 1.7rem;
  line-height: 1.15;
  text-shadow: 0 3px 16px rgba(var(--ep-glow), 0.6);
  overflow-wrap: anywhere;
}
.preview-btns { display: flex; gap: 8px; }
.preview-btns span { padding: 7px 16px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; }
.pv-yes { background: var(--ep-accent); }
.pv-no { background: rgba(255, 255, 255, 0.16); }

/* ---------- steps ---------- */
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.step-tools { display: flex; gap: 6px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: center; gap: 8px; }
.opt input { flex: 1; min-width: 0; }
.add-opt { margin-top: 4px; }
.add-step {
  border: 2px dashed rgba(255, 255, 255, 0.25);
  background: transparent;
  min-height: 58px;
  font-size: 1.05rem;
}
.add-step:hover { border-color: var(--accent); }

/* ---------- summary ---------- */
.sum { list-style: none; padding: 0; margin: 10px 0; }
.sum li { padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sum li:last-child { border-bottom: 0; }
.sum b { color: var(--muted); }

.errors {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.45);
  color: #ffd6d6;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- bottom bar ---------- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(19, 17, 28, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.dirty { font-size: 0.8rem; color: var(--good); text-align: center; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dirty.on { color: #fbbf24; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 20px);
  background: #000;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: #065f46; }
.toast.bad { background: #7f1d1d; }

@media (max-width: 480px) {
  .stepper span { font-size: 0.75rem; }
  .row { grid-template-columns: 1fr; gap: 0; }
  .audience b { font-size: 0.92rem; }
  .bottombar .btn { padding: 10px 16px; }
}
@media (min-width: 720px) {
  .anim-grid { grid-template-columns: repeat(5, 1fr); }
  .wrap { padding-top: 24px; }
}

/* ---------- credit ---------- */
.credit { margin: 28px 0 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.credit a { color: var(--accent); font-weight: 700; text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.login .credit { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; z-index: 1; }
