:root {
  --fundo: #0b0b0f;
  --superficie: #16161d;
  --borda: #26262f;
  --texto: #f2f2f5;
  --fraco: #8b8b98;
  --acento: #d8c48a;
  --acento-escuro: #b39f66;
  --perigo: #e0685f;
  --raio: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--fundo);
  color: var(--texto);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.tela {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.tela.ativa { display: flex; }

.centro {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 26px;
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- entrada ---------- */
.marca {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 22px 26px;
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fraco);
}
.ponto {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--acento);
}

h1 {
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.02em;
}
h1 em { font-style: normal; color: var(--acento); }

.sub {
  margin-top: 16px;
  color: var(--fraco);
  font-size: 15.5px;
  max-width: 34ch;
}

.consentimento {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 34px 0 18px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--fraco);
  cursor: pointer;
}
.consentimento input {
  appearance: none;
  flex: 0 0 20px;
  width: 20px; height: 20px;
  margin-top: 1px;
  border: 1.5px solid var(--borda);
  border-radius: 6px;
  background: var(--superficie);
  transition: .15s;
}
.consentimento input:checked {
  background: var(--acento);
  border-color: var(--acento);
  box-shadow: inset 0 0 0 3.5px var(--fundo);
}

.principal {
  width: 100%;
  padding: 17px;
  border: 0;
  border-radius: var(--raio);
  background: var(--acento);
  color: #14140f;
  font: 600 16px/1 inherit;
  cursor: pointer;
  transition: .15s;
}
.principal:disabled { background: var(--borda); color: #55555f; cursor: not-allowed; }
.principal:active:not(:disabled) { transform: scale(.985); background: var(--acento-escuro); }
.principal.compacto { width: auto; padding: 14px 26px; }

.rodape {
  margin-top: 26px;
  font-size: 12.5px;
  color: #55555f;
  text-align: center;
}

/* ---------- topo ---------- */
.topo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--borda);
}
.voltar {
  border: 0;
  background: none;
  color: var(--fraco);
  font: 500 14px/1 inherit;
  padding: 8px 2px;
  cursor: pointer;
}
.titulo-topo { font-size: 14px; color: var(--fraco); margin-left: auto; }

/* ---------- camera ---------- */
.palco {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
#video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.guia {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -54%);
  width: min(62vw, 250px);
  aspect-ratio: 3 / 4;
  border: 2px dashed rgba(216, 196, 138, .55);
  border-radius: 50% 50% 46% 46%;
  pointer-events: none;
}

.acoes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 20px 30px;
}
.obturador {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 3px solid var(--acento);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: .12s;
}
.obturador::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--acento);
  transition: .12s;
}
.obturador:active::after { inset: 11px; }
.secundaria {
  color: var(--fraco);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* ---------- carregando ---------- */
.pulso {
  width: 58px; height: 58px;
  margin: 0 auto 24px;
  border-radius: 50%;
  border: 2px solid var(--borda);
  border-top-color: var(--acento);
  animation: girar .85s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.status { text-align: center; color: var(--fraco); font-size: 15px; }

/* ---------- resultado ---------- */
.ajuste {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--borda);
  font-size: 13px;
  color: var(--fraco);
}
.ajuste input[type=range] {
  flex: 1;
  appearance: none;
  height: 3px;
  border-radius: 3px;
  background: var(--borda);
}
.ajuste input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--acento);
  cursor: pointer;
}
.ajuste output {
  font-variant-numeric: tabular-nums;
  color: var(--texto);
  min-width: 34px;
  text-align: right;
}

.grid {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  /* sem isto as linhas implicitas dividem a altura do container e se sobrepoem */
  grid-auto-rows: max-content;
  gap: 3px;
  padding: 3px 3px 96px;
  align-content: start;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

.item {
  position: relative;
  aspect-ratio: 1;
  background: var(--superficie);
  overflow: hidden;
  cursor: pointer;
}
.item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none; /* o clique pertence ao item, nao a imagem */
}
.item img.carregada { opacity: 1; }
.item .score {
  position: absolute;
  left: 5px; bottom: 5px;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 20px;
  background: rgba(0,0,0,.65);
  color: #cfcfd8;
  font-variant-numeric: tabular-nums;
}
.item .marca-sel {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.8);
  background: rgba(0,0,0,.4);
  cursor: pointer;
}
/* area de toque de 44px sem aumentar o circulo visivel */
.item .marca-sel::after {
  content: "";
  position: absolute;
  inset: -11px;
}
.item.sel { outline: 2.5px solid var(--acento); outline-offset: -2.5px; }
.item.sel .marca-sel {
  background: var(--acento);
  border-color: var(--acento);
  box-shadow: inset 0 0 0 3px var(--fundo);
}

.vazio { padding: 60px 30px; text-align: center; color: var(--fraco); }
.vazio .dica { margin-top: 10px; font-size: 13.5px; color: #55555f; }

.barra {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--fundo) 62%, transparent);
}
.grupo-baixar { display: flex; align-items: center; gap: 8px; }
#qualidade {
  appearance: none;
  border: 1px solid var(--borda);
  background: var(--superficie);
  color: var(--fraco);
  padding: 13px 12px;
  border-radius: var(--raio);
  font: 500 13px/1 inherit;
  cursor: pointer;
}

.fantasma {
  border: 1px solid var(--borda);
  background: var(--superficie);
  color: var(--texto);
  padding: 13px 18px;
  border-radius: var(--raio);
  font: 500 14px/1 inherit;
  cursor: pointer;
}

.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 88vw;
  padding: 13px 20px;
  border-radius: 11px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  font-size: 14px;
  z-index: 50;
  animation: subir .22s ease-out;
}
.aviso.erro { border-color: var(--perigo); color: #f0a49e; }
@keyframes subir { from { opacity: 0; transform: translate(-50%, 12px); } }

/* visualizador */
.lupa {
  position: fixed;
  inset: 0;
  background: rgba(6,6,9,.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.lupa img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.lupa .fechar {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top)); right: 18px;
  border: 0; background: none; color: var(--texto);
  font-size: 26px; cursor: pointer; line-height: 1;
}
.lupa .baixar-uma {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom));
  padding: 13px 28px;
  border-radius: var(--raio);
  border: 0;
  background: var(--acento);
  color: #14140f;
  font: 600 15px/1 inherit;
  cursor: pointer;
}
