:root {
  --navy-deep: #081b32;
  --navy: #0e2a4a;
  --navy-light: #133b63;
  --navy-lighter: #1c4d7d;
  --line: #244a72;
  --sky: #3aa8e0;
  --sky-light: #6fc3ee;
  --yellow: #ffd400;
  --yellow-deep: #ffb300;
  --ink: #ffffff;
  --ink-dim: #b9cbe6;
  --ink-faint: #7f9dc2;
  --danger: #e05252;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--navy-deep);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input { font-family: inherit; }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(18px + var(--safe-top)) 18px calc(96px + var(--safe-bottom));
  position: relative;
}

/* ---- topo com onda decorativa, ecoando a arte da campanha ---- */
/* confinado a altura do cabecalho (badge + titulo + subtitulo), nunca alcanca
   o conteudo abaixo dos pontos de progresso */
.top-bg {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 150px;
  background: linear-gradient(160deg, var(--navy-light) 0%, var(--navy) 60%, var(--navy-deep) 100%);
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.top-bg svg { position: absolute; bottom: -2px; left: 0; width: 100%; height: auto; opacity: .5; }

header { text-align: center; padding-top: 6px; margin-bottom: 22px; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,212,0,.12);
  border: 1px solid rgba(255,212,0,.35);
  color: var(--yellow);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -.01em; }
.subtitle { color: var(--ink-dim); font-size: 14px; margin: 0; line-height: 1.4; }
h2 { font-size: 18px; margin: 0 0 4px; }
.hidden { display: none !important; }

/* ---- indicador de progresso (estilo onboarding nativo) ---- */
.progress-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 22px;
}
.progress-dots span {
  height: 6px;
  width: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: width .25s ease, background .25s ease;
}
.progress-dots span.active { width: 22px; background: var(--yellow); }
.progress-dots span.done { background: var(--sky); }

.step { animation: step-in .32s cubic-bezier(.22,.9,.32,1); }
@keyframes step-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.tpl-card {
  background: var(--navy-light);
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
.tpl-card:active { transform: scale(.96); }
.tpl-card.selected { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,212,0,.18), 0 6px 16px rgba(0,0,0,.25); }
.tpl-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  background: var(--navy);
}
.tpl-card .tpl-title {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 9px;
  line-height: 1.3;
  color: var(--ink-dim);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.06);
  border: none;
  color: var(--ink-dim);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  margin-bottom: 18px;
}
.back-btn:active { transform: scale(.96); }
.hint { color: var(--ink-dim); font-size: 13.5px; margin: 4px 0 18px; line-height: 1.5; }

.preview-box {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.preview-box img {
  width: 220px;
  height: 220px;
  border-radius: 24px;
  object-fit: cover;
  box-shadow: 0 14px 34px rgba(0,0,0,.4);
  border: 3px solid var(--navy-light);
}

/* ---- card de captura de foto, estilo camera sheet ---- */
.capture-card {
  border: 2px dashed var(--navy-lighter);
  border-radius: 22px;
  background: rgba(255,255,255,.03);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.capture-card:active { transform: scale(.98); }
.capture-card .capture-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--yellow), var(--yellow-deep));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(255,180,0,.28);
}
.capture-card .capture-icon svg { width: 26px; height: 26px; }
.capture-card .capture-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.capture-card .capture-sub { font-size: 12.5px; color: var(--ink-faint); }

#photo-preview-wrap { margin-top: 4px; text-align: center; }
.photo-preview-frame {
  position: relative;
  width: 180px;
  margin: 0 auto 6px;
}
#photo-preview {
  width: 180px;
  height: 180px;
  border-radius: 999px;
  object-fit: cover;
  display: block;
  border: 3px solid var(--sky);
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.retake-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--sky-light);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}
.retake-btn:active { opacity: .7; }

/* ---- barra de acao fixa no rodape, estilo app nativo ---- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px 18px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(8,27,50,0) 0%, var(--navy-deep) 30%);
  display: flex;
  justify-content: center;
  z-index: 40;
}
.bottom-bar-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 10px;
}
.bottom-bar-inner.bottom-bar-stack {
  flex-direction: column;
}
.bottom-bar-inner.bottom-bar-stack .actions-row {
  display: flex;
  gap: 10px;
}

.primary-btn, .secondary-btn, .icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-align: center;
  padding: 15px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: transform .1s ease, opacity .15s ease;
}
.primary-btn:active, .secondary-btn:active, .icon-btn:active { transform: scale(.97); }
.primary-btn {
  background: linear-gradient(135deg, var(--yellow), var(--yellow-deep));
  color: var(--navy-deep);
  box-shadow: 0 10px 24px rgba(255,180,0,.28);
}
.primary-btn[disabled] { opacity: .5; pointer-events: none; }
.secondary-btn {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid var(--line);
}
.icon-btn {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid var(--line);
  flex: 0 0 54px;
  width: 54px;
  padding: 0;
  height: 54px;
}
.icon-btn svg { width: 20px; height: 20px; }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,27,50,.92);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
  text-align: center;
  padding: 0 30px;
}
.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--navy-light);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { font-weight: 600; }
.loading-overlay .loading-sub { color: var(--ink-dim); font-size: 13px; font-weight: 400; margin-top: -10px; }

/* ---- resultado ---- */
.result-frame {
  position: relative;
  width: 100%;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 20px 46px rgba(0,0,0,.45);
  margin-bottom: 10px;
  border: 1px solid var(--line);
}
.result-frame img { width: 100%; display: block; }
.success-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--sky-light);
  font-size: 13.5px;
  font-weight: 700;
  margin: 4px 0 18px;
}
.success-badge svg { width: 18px; height: 18px; flex: none; }

/* ---- admin (sem alteracao de identidade, so reaproveita as variaveis) ---- */
.admin-wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
.admin-table img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.form-box {
  background: var(--navy-light);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}
.form-box label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--ink-dim); }
.form-box input[type=text], .form-box input[type=file], .form-box input[type=number] {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #2c5586;
  background: var(--navy-deep);
  color: #fff;
}
.editor-canvas-wrap { position: relative; display: inline-block; margin-top: 12px; max-width: 100%; }
.editor-canvas-wrap img { max-width: 100%; display: block; border-radius: 8px; }
.editor-canvas-wrap img#editor-img-front {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.placement-box {
  position: absolute;
  border: 2px dashed var(--yellow);
  background: rgba(255,212,0,.15);
  cursor: move;
  z-index: 2;
}
.placement-box .handle {
  position: absolute;
  right: -6px; bottom: -6px;
  width: 14px; height: 14px;
  background: var(--yellow);
  border-radius: 3px;
  cursor: nwse-resize;
}
.face-box {
  border-color: var(--sky);
  background: rgba(77,163,255,.2);
  z-index: 3;
}
.face-box .handle {
  background: var(--sky);
}
.small-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  background: var(--yellow);
  color: var(--navy-deep);
  font-weight: 600;
}
.danger-btn { background: var(--danger); color: #fff; }
.top-actions { display: flex; justify-content: space-between; align-items: center; }
