:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, sans-serif;
  color: #161e2e;
  background: #fff;
  --muted: #596273;
  --accent: #f97316;
  --accent-text: #b6450b;
  --line: #e6e8ed;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
main { max-width: 33rem; margin: 0 auto; padding: max(1.15rem, env(safe-area-inset-top)) 1rem max(1.2rem, env(safe-area-inset-bottom)); }
header { padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.brand { margin: 0 0 .35rem; color: var(--accent-text); font-weight: 800; letter-spacing: -.025em; }
h1, h2 { margin: 0; letter-spacing: -.035em; line-height: 1.1; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; }
p { margin: .45rem 0 0; line-height: 1.4; }
.progress, .step-heading p { color: var(--muted); }
.step-heading { margin: .95rem 0; }
.webcam-choice { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; color: var(--muted); font-size: .875rem; }
.webcam-choice select { flex: 1; min-width: 0; min-height: 2.5rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: .65rem; background: #fff; color: #161e2e; font: inherit; }
.webcam-choice select:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.camera-stage { position: relative; overflow: hidden; aspect-ratio: 4 / 5; max-height: 54dvh; border: 1px solid var(--line); border-radius: 1rem; background: #f4f5f7; }
video, #preview, #preview-frame { width: 100%; height: 100%; object-fit: contain; display: block; }
video { object-fit: cover; }
.photo-details { font-size: .9rem; color: var(--muted); }
.photo-details[data-warning="true"] {
  padding: .6rem .75rem;
  border: 1px solid #ffdcc6;
  border-radius: .65rem;
  background: #fff6ef;
  color: var(--accent-text);
}
.guide {
  --guide-ink: #ffe3d1;
  --guide-shadow: rgb(20 11 7 / 70%);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  container-type: size;
  pointer-events: none;
}
.guide-frame {
  --phone-height: min(78cqh, 112cqw);
  position: relative;
  width: 48%;
  height: 78%;
  width: calc(var(--phone-height) * .48);
  height: var(--phone-height);
  border: 2px dashed var(--guide-ink);
  border-radius: 12% / 6%;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 23%);
}
.guide-frame > * { display: none; }
.guide-island, .guide-left-buttons span, .guide-power, .guide-camera-module,
.guide-camera-module span, .guide-port {
  border: 1px solid var(--guide-ink);
  box-shadow: 0 0 2px var(--guide-shadow);
}

.guide[data-angle="frente"] .guide-island {
  position: absolute;
  inset: 4% 34% auto;
  display: block;
  height: 4%;
  border-radius: 999px;
  background: rgb(26 16 12 / 38%);
}
.guide[data-angle="frente"] .guide-left-buttons,
.guide[data-angle="esquerda"] .guide-left-buttons {
  position: absolute;
  top: 18%;
  bottom: 0;
  left: -5px;
  display: flex;
  flex-direction: column;
  gap: .38rem;
  width: 5px;
}
.guide-left-buttons span { height: 8%; border-radius: 999px; }
.guide-left-buttons span:first-child { height: 4%; }

.guide[data-angle="traseira"] .guide-camera-module {
  position: absolute;
  inset: 4% auto auto 8%;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  align-items: center;
  justify-items: center;
  width: 42%;
  aspect-ratio: 1;
  padding: 5%;
  border-radius: 25%;
}
.guide-camera-module span { width: 90%; aspect-ratio: 1; border-radius: 50%; }
.guide-camera-module span:nth-child(2) { grid-column: 1; grid-row: 2; }
.guide-camera-module span:nth-child(3) { grid-column: 2; grid-row: 1 / -1; }

.guide:is([data-angle="esquerda"], [data-angle="direita"]) .guide-frame {
  width: 9%;
  width: calc(var(--phone-height) * .095);
  border-radius: .5rem;
}
.guide[data-angle="esquerda"] .guide-left-buttons { inset-inline: 20%; width: auto; }
.guide[data-angle="direita"] .guide-power {
  position: absolute;
  inset: 27% 20% auto;
  display: block;
  height: 14%;
  border-radius: 999px;
}

.guide:is([data-angle="embaixo"], [data-angle="em-cima"]) .guide-frame {
  width: 78%;
  width: min(78cqw, 66cqh);
  height: 12%;
  height: min(12cqh, 14cqw);
  border-radius: .65rem;
}
.guide[data-angle="embaixo"] .guide-bottom-hardware {
  position: absolute;
  inset: 0 8%;
  display: grid;
  grid-template-columns: 1fr minmax(1.5rem, 26%) 1fr;
  align-items: center;
  justify-items: center;
  gap: 5%;
}
.guide-port { width: 100%; height: 36%; border-radius: 999px; }
.guide-grille {
  --hole-spacing: clamp(5px, 1.7cqw, 9px);
  width: calc(var(--hole-spacing) * 4);
  max-width: 100%;
  height: 5px;
  background: radial-gradient(circle at center, var(--guide-ink) 1px, var(--guide-shadow) 1.6px, transparent 2.3px) 0 center / var(--hole-spacing) 100% repeat-x;
}
.actions { display: grid; gap: .55rem; margin-top: .9rem; }
button, .file-choice { min-height: 3rem; width: 100%; padding: .65rem; display: grid; align-items: center; justify-items: center; border-radius: .65rem; border: 1px solid transparent; color: #1f1208; background: var(--accent); font: inherit; font-weight: 750; text-align: center; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, .file-choice:focus-within { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.secondary { background: #fff; border-color: var(--line); color: #161e2e; }
.file-choice { position: relative; }
.file-choice input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.message { color: var(--muted); margin-top: .85rem; }
.message[data-error="true"] { color: #b42318; }
#retry { margin-top: .75rem; }

main.is-complete {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
}
.completion { max-width: 24rem; text-align: center; }
.completion-mark {
  display: grid;
  width: clamp(5.5rem, 24vw, 7rem);
  aspect-ratio: 1;
  margin: 0 auto 1.5rem;
  place-items: center;
  border: 1px solid #ffdcc6;
  border-radius: 50%;
  background: #fff4ec;
  color: var(--accent-text);
}
.completion-mark::before {
  content: "";
  width: 1.4rem;
  height: 2.65rem;
  border: solid currentColor;
  border-width: 0 .35rem .35rem 0;
  transform: translateY(-.25rem) rotate(45deg);
}
.completion h1 { font-size: clamp(1.9rem, 7vw, 2.4rem); }
.completion h1:focus { outline: none; }
.completion p { margin-top: .7rem; color: var(--muted); }
.retake-options { margin: 1.45rem auto 0; }
.retake-options summary { color: var(--accent-text); font-weight: 650; cursor: pointer; }
.retake-options > div { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-top: .75rem; }
.retake-options button { min-height: 2.75rem; font-size: .875rem; }
#retake-message:empty { display: none; }
