:root {
  --bg: #121212;
  --surface: #1c1b1a;
  --surface-2: #2a2927;
  --line: #3a3835;
  --text: #f2efea;
  --muted: #b3aea6;
  --faint: #8e8981;
  --accent: #f0b44c;
  --accent-ink: #1a1408;
  --ok-bg: #22301f; --ok: #a9d79b;
  --buy-bg: #3a2c14; --buy: #f0c877;
  --lim-bg: #1c2a36; --lim: #9cc6e4;
  --danger: #e8a07a;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Manrope, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: var(--accent); }
a:hover { color: #ffd08a; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Archivo, system-ui, sans-serif; font-weight: 700; margin: 0; line-height: 1.15; }

.wrap { max-width: 640px; margin: 0 auto; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 10px; font-size: 14px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; padding: max(48px, env(safe-area-inset-top)) 28px 32px; max-width: 460px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Archivo, sans-serif; font-weight: 700; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; }
.brand img { height: 32px; width: auto; }
.mosaic { height: 220px; margin-top: 36px; border-radius: 16px; background: #1f1e1c; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 6px; }
.mosaic div { border-radius: 10px; }
.mosaic div:nth-child(1) { background: #3a3530; }
.mosaic div:nth-child(2) { background: #5b5249; grid-row: span 2; }
.mosaic div:nth-child(3) { background: #2c2b29; }
.mosaic div:nth-child(4) { background: #46413a; }
.mosaic div:nth-child(5) { background: #6a6058; }
.login h1 { font-size: 30px; margin: 32px 0 8px; }
.login p.lead { margin: 0; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  height: 52px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: 600 17px Manrope, sans-serif; padding: 0 16px; width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.input-code { letter-spacing: .08em; text-transform: uppercase; }
.input-pin { letter-spacing: .3em; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0; }
.login .foot { margin-top: auto; padding-top: 28px; font-size: 13px; color: var(--faint); text-align: center; }

/* ---------- galeria ---------- */
.gallery { display: flex; flex-direction: column; min-height: 100dvh; }
.top { padding: max(20px, env(safe-area-inset-top)) 20px 12px; display: flex; flex-direction: column; gap: 6px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.top .brand { font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.badge-pacote { background: var(--ok-bg); color: var(--ok); }
.badge-avulsa { background: var(--buy-bg); color: var(--buy); }
.badge-limite { background: var(--lim-bg); color: var(--lim); }
.top h1 { font-size: 26px; margin-top: 6px; }
.sub { font-size: 14px; color: var(--muted); }

.counter { margin: 4px 20px 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.counter-row { display: flex; justify-content: space-between; align-items: baseline; }
.counter-num { font-family: Archivo, sans-serif; font-weight: 700; font-size: 22px; }
.counter-num span { font-size: 15px; color: var(--muted); font-weight: 500; }
.bar { height: 8px; border-radius: 999px; background: #2e2c2a; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.hint { font-size: 13px; color: var(--faint); }

.tabs { display: flex; gap: 8px; padding: 0 20px 12px; overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; background: var(--bg); z-index: 5; padding-top: 8px; }
.tab { flex: none; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface-2); border-color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0 20px 24px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.tile img, .viewer img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; pointer-events: none;
}
.tile-open { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; padding: 0; }
.icon-btn {
  position: absolute; width: 38px; height: 38px; border: 0; border-radius: 999px;
  background: rgba(0, 0, 0, .42); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.fav { top: 4px; right: 4px; }
.icon-btn.save { bottom: 4px; right: 4px; }
.chip { position: absolute; top: 6px; left: 6px; z-index: 2; width: 28px; height: 28px; border-radius: 999px; display: flex; align-items: center; justify-content: center; background: var(--ok-bg); color: var(--ok); }
.chip svg { width: 14px; height: 14px; }
.chip.wait { background: var(--buy-bg); color: var(--buy); }

.empty { text-align: center; color: var(--faint); padding: 48px 32px; font-size: 15px; }
.note { text-align: center; color: var(--faint); font-size: 13px; padding: 0 24px 24px; }

.dock {
  position: sticky; bottom: 0; margin-top: auto; z-index: 6;
  padding: 14px 20px max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--surface-2); background: #161615;
  display: flex; flex-direction: column; gap: 10px;
}
.dock-row { display: flex; gap: 10px; align-items: center; }
.dock-row .btn { flex: 1; }
.dock-total { flex: 1; display: flex; flex-direction: column; }
.dock-total small { font-size: 13px; color: var(--muted); }
.dock-total strong { font-family: Archivo, sans-serif; font-size: 22px; }
.dock .btn-primary.fit { flex: none; }
.dock p { margin: 0; font-size: 14px; color: var(--muted); }
.dock p strong { color: var(--text); }
.dock h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }

/* proteção: esconde as fotos quando a janela perde o foco */
body.shield .tile img, body.shield .viewer img { filter: blur(24px); }

/* ---------- visualizador ---------- */
.viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
.viewer-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.viewer-stage img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; background: rgba(0,0,0,.3); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.viewer-nav.prev { left: 0; border-radius: 0 10px 10px 0; }
.viewer-nav.next { right: 0; border-radius: 10px 0 0 10px; }
.viewer-bottom { display: flex; gap: 10px; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); }
.viewer-bottom .btn { flex: 1; }
.viewer .icon-btn { position: static; }
.viewer-count { font-size: 14px; color: var(--muted); }

/* ---------- folha inferior ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; padding: 24px 20px max(28px, env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { font-size: 20px; }
.sheet p { margin: 0; color: var(--muted); font-size: 15px; }
.sheet .dock-row { margin-top: 8px; }
.progress { height: 6px; border-radius: 999px; background: #2e2c2a; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 40px); text-align: center; }
#toast.show { opacity: 1; }

.center-msg { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 32px; text-align: center; max-width: 460px; margin: 0 auto; }
.center-msg p { color: var(--muted); margin: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }
