/* ---------- tokens ---------- */
:root {
  --navy: #12213d;
  --ink: #0f172a;
  --ink-soft: #56607a;
  --line: #e3e7ef;
  --line-soft: #edf0f5;
  --bg: #f4f5f8;
  --card: #ffffff;
  --accent: #b78846;
  --accent-ink: #7a5a24;
  --accent-soft: #f8efdf;
  --ok: #1d8a5e;
  --ok-soft: #e7f6ef;
  --err: #c53434;
  --err-soft: #fdeceb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(15, 23, 42, 0.16);
  --shadow-lg: 0 24px 48px -16px rgba(15, 23, 42, 0.24);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { font-family: "Fraunces", Georgia, serif; margin: 0; }

.page {
  min-height: 100vh;
  background:
    radial-gradient(1200px 480px at 50% -240px, #1c2e52 0%, var(--navy) 52%, var(--navy) 100%);
  background-attachment: fixed;
}

/* ---------- header ---------- */
.top {
  padding: 22px 20px 96px;
}
.brand { display: flex; align-items: center; gap: 12px; max-width: 480px; margin: 0 auto; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(160deg, var(--accent) 0%, #93691f 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: "Fraunces", serif; font-weight: 600; font-size: 18px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; color: #f2f4f9; line-height: 1.3; }
.brand-text strong { font-size: 15px; font-weight: 600; }
.brand-text span { font-size: 12.5px; color: #a9b3ca; }

/* ---------- container ---------- */
.container {
  max-width: 480px;
  margin: -76px auto 0;
  padding: 0 16px 48px;
  position: relative;
}

.hero { padding: 4px 6px 22px; color: #fff; }
.hero h1 { font-size: 25px; font-weight: 600; color: #fff; }
.hero p { margin: 8px 0 0; font-size: 14.5px; color: #c4cbdd; line-height: 1.5; }

/* ---------- panels ---------- */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}
.panel-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  margin-bottom: 18px;
}
.panel-index {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-hint { font-size: 13px; color: var(--ink-soft); margin: -6px 0 16px; line-height: 1.5; }

/* ---------- floating-label fields ---------- */
.field { position: relative; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { margin-bottom: 0; }

.field input {
  width: 100%;
  padding: 18px 14px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfbfc;
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.field label {
  position: absolute;
  left: 15px;
  top: 17px;
  font-size: 15px;
  color: var(--ink-soft);
  pointer-events: none;
  transform-origin: left top;
  transition: transform .15s ease, color .15s ease, top .15s ease;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 9px;
  transform: scale(0.74);
  color: var(--accent-ink);
}
.field input::placeholder { color: transparent; }

/* ---------- camera ---------- */
.fotos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.fotos-grid:empty { margin-bottom: 0; }
.foto-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line-soft);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-remover {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.foto-count {
  position: absolute;
  bottom: 6px; left: 6px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.btn-camera {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed #c9b280;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-camera:active { background: #f1e2c4; }

/* ---------- buttons ---------- */
.btn-primary {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 17px;
  margin-top: 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--navy) 0%, #0a1626 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  text-decoration: none;
  box-sizing: border-box;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-secundario {
  width: 100%;
  padding: 15px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- lock screen ---------- */
.lock {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 26px 30px;
  text-align: center;
  margin-top: 8px;
}
.lock-icon {
  width: 52px; height: 52px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.lock h1 { font-size: 21px; }
.lock p { font-size: 13.5px; color: var(--ink-soft); margin: 8px 0 24px; }
.lock form { text-align: left; }
.field-pin input { text-align: center; letter-spacing: 4px; font-weight: 600; }
.lock-erro { color: var(--err); font-size: 13px; margin: 16px 0 0; font-weight: 500; }

/* ---------- result ---------- */
.result {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 26px 30px;
  text-align: center;
  margin-top: 8px;
  animation: pop .25s ease;
}
.result-icon {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  display: flex; align-items: center; justify-content: center;
}
.result h2 { font-size: 22px; }
.result p { font-size: 14px; color: var(--ink-soft); margin: 8px 0 26px; }
.btn-link { display: flex; }

/* ---------- error banner ---------- */
.erro-banner {
  background: var(--err-soft);
  color: var(--err);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  font-weight: 500;
  margin-top: 16px;
  text-align: center;
}

/* ---------- camera customizada com guia ---------- */
.camera-view {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
}
.camera-view video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 24px;
}
.camera-guia {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 2 / 1;
  border: 2.5px solid #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.55);
}
.camera-dica {
  margin-top: 16px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
  border-radius: 20px;
}
.camera-controles {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 28px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
}
.camera-fechar {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.camera-disparo {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.camera-disparo:active { transform: scale(0.92); }
.camera-espaco { width: 42px; height: 42px; }

.camera-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.camera-flash.piscar {
  animation: flash .35s ease-out;
}
@keyframes flash {
  0% { opacity: .85; }
  100% { opacity: 0; }
}

.camera-contador {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 20px;
  transition: transform .15s ease;
}
.camera-contador.pulsar {
  animation: contadorPulsar .35s ease-out;
}
@keyframes contadorPulsar {
  0% { transform: translateX(-50%) scale(1.15); }
  100% { transform: translateX(-50%) scale(1); }
}

/* trava a captura em retrato: em paisagem escondemos video/controles e
   pedimos pro usuario girar de volta, em vez de deixar os controles
   sobrepondo a tela (a etiqueta nao precisa de paisagem mesmo) */
.camera-girar {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #000;
  color: #fff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 0 40px;
}
.camera-girar p { font-size: 14px; color: #c4cbdd; margin: 0; max-width: 240px; }

@media (orientation: landscape) and (max-height: 500px) {
  .camera-girar { display: flex; }
}

/* ---------- responsive ---------- */
@media (max-width: 360px) {
  .field-row { grid-template-columns: 1fr; }
  .fotos-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 640px) {
  .container { max-width: 560px; }
  .panel { padding: 28px 28px 30px; }
}
