:root {
  --bg: #0f0e0d;
  --surface: #191816;
  --surface-2: #23211e;
  --line: #34312c;
  --text: #f4efe6;
  --muted: #a39d92;
  --accent: #e9b949;
  --accent-ink: #1a1405;
  --danger: #ff7a6b;
  --ok: #7fd49a;
  --radius: 16px;
  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px 16px 64px; }
.wrap.wide { max-width: 1100px; }

.brand {
  font-family: var(--display); font-weight: 800; letter-spacing: 0.22em; font-size: 13px;
  text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px;
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

h1 { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 8vw, 46px); line-height: 1.02;
  letter-spacing: -0.02em; margin: 28px 0 10px; }
h2 { font-family: var(--display); font-weight: 700; font-size: 20px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 14px; }

label.field { display: block; font-size: 14px; color: var(--muted); }
label.field input, .input {
  display: block; width: 100%; margin-top: 6px; padding: 14px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); outline: none; font-size: 16px;
}
label.field input:focus, .input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 14px 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; text-decoration: none; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--accent); }

.selfie-box {
  position: relative; aspect-ratio: 1; width: 100%; max-width: 260px; margin: 0 auto; border-radius: 50%;
  border: 2px dashed var(--line); display: grid; place-items: center; overflow: hidden; background: var(--surface-2);
  cursor: pointer; color: var(--muted); text-align: center; font-size: 14px;
}
.selfie-box img, .selfie-box video, .selfie-box canvas { width: 100%; height: 100%; object-fit: cover; }
.mirror { transform: scaleX(-1); }
.selfie-box.has { border-style: solid; border-color: var(--accent); }

.msg { font-size: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.grid button { padding: 0; border: 0; background: var(--surface-2); border-radius: 10px; overflow: hidden; cursor: pointer; aspect-ratio: 3/4; }
.grid img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); } }
/* Guest results: justified rows, each photo at its own shape (no cropping). --r = width / height. */
/* Native photo shapes as even columns (2 on phones, 3 wider): every photo uncropped, no ragged rows or orphans. */
.grid.native { display: block; columns: 2; column-gap: 8px; }
.grid.native button { display: block; width: 100%; margin: 0 0 8px; break-inside: avoid; aspect-ratio: var(--r, 0.75); }
.grid.native img { object-fit: cover; display: block; }
@media (min-width: 700px) { .grid.native { columns: 3; } }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 50; display: flex; flex-direction: column; }
.lightbox { background: #000; }
/* The photo always fits between the top of the screen and the button bar, whatever its shape. */
.lightbox .stage { flex: 1; position: relative; min-height: 0; }
.lightbox .stage img { position: absolute; inset: calc(10px + env(safe-area-inset-top)) 10px 0; width: calc(100% - 20px); height: calc(100% - 10px - env(safe-area-inset-top)); object-fit: contain; }
.lightbox .bar { flex: none; display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #000; }
.lightbox .lb-n { font-size: 13px; color: var(--muted); min-width: 3.5em; text-align: center; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill-todo { cursor: pointer; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); font: inherit; font-size: 12px; }
.pill.live { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); max-height: 160px; overflow: auto;
  background: var(--surface-2); border-radius: 10px; padding: 10px; white-space: pre-wrap; }
.footer { margin-top: 40px; font-size: 12px; color: var(--muted); text-align: center; }
.footer a { color: var(--muted); }
.events { display: grid; gap: 14px; }
.qr img { width: 140px; height: 140px; border-radius: 8px; background: #fff; padding: 6px; }
.prose h2 { margin-top: 28px; }
.prose p, .prose li { color: #d9d3c8; }

/* People (admin) */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.person { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; }
.person-pick { position: absolute; top: 14px; left: 14px; z-index: 1; }
.person-pick input { width: 20px; height: 20px; accent-color: var(--accent); }
.person-face { display: block; width: 100%; aspect-ratio: 1; border: 0; border-radius: 10px; background-color: var(--line); background-repeat: no-repeat; cursor: pointer; padding: 0; }
.person-face.big { cursor: default; }
.person-name { margin-top: 0 !important; padding: 8px 10px !important; font-size: 14px !important; }
.person-photo { display: grid; }
#personGrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.suggest-card { display: grid; gap: 12px; max-width: 560px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; animation: sp-in .18s ease-out; }
@keyframes sp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sp-head { display: flex; align-items: center; gap: 10px; }
.sp-conf { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.sp-conf.hi { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.sp-conf.mid { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.sp-conf.lo { color: var(--muted); }
.sp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sp-side { display: grid; gap: 6px; align-content: start; }
.sp-side .person-face { cursor: default; }
.sp-main { border-radius: 12px; }
.sp-more { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.suggest-card .row .btn { flex: 1; }

/* Admin: upload button + phone layout */
.upload-btn { align-self: flex-start; padding: 16px 28px; font-size: 17px; }
.mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 700px) {
  #event:not(.hidden) { display: flex; flex-direction: column; padding-bottom: 80px; }
  #uploadCard { order: 1; } #progressCard { order: 2; } #peopleCard { order: 3; } #liveCard { order: 4; }
  .upload-btn { display: flex; width: 100%; padding: 20px; font-size: 19px; }
  #back { align-self: flex-start; }
  #phoneTip { margin-top: 4px !important; }
  .card { padding: 16px; }
  .events .card { flex-direction: column; }
  .events .card > .row:last-child { justify-content: flex-start !important; }
  .qr img { width: 110px; height: 110px; }
  .people { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .log { max-height: 120px; }
  h1 { margin-top: 18px; }
}

/* Tip sheet (guest page) */
.tip-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .tip-back { align-items: center; } }
.tip-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.tip-opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 600 15px var(--body);
  text-decoration: none; cursor: pointer; box-sizing: border-box; }
.tip-opt:first-child { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tip-opt:first-child .muted { color: var(--accent-ink); opacity: .7; }

/* "Want this for your event?" banner on guest pages */
.promo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 12px; color: var(--text); text-decoration: none; font-size: 13px; line-height: 1.4; background: rgba(233, 185, 73, 0.08); }
.promo strong { color: var(--accent); }
.promo-go { flex: none; font-weight: 600; color: var(--accent); white-space: nowrap; }
.promo:active { transform: scale(0.99); }

/* Download sheet + "pick 3 to edit" (guest page) */
.dl-card { max-height: calc(100vh - 32px); overflow-y: auto; }
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 46vh; overflow-y: auto; }
.pick-grid button { position: relative; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); cursor: pointer; }
.pick-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-grid button.on { border-color: var(--accent); }
.pick-grid button.on::after { content: attr(data-n); position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 700 12px/22px var(--body); text-align: center; }
.pick-note { width: 100%; box-sizing: border-box; margin-top: 12px; resize: vertical; font: 16px var(--body); }
.help-card { margin-top: 28px; }

/* Guest page: no accidental zoom on phones (double-tap on buttons/photos, focusing fields) */
html, body, button, a, .grid, .pick-grid, .lightbox { touch-action: manipulation; }
.btn-spin { display: inline-block; width: 16px; height: 16px; margin-right: 10px; vertical-align: -3px; border-radius: 50%;
  border: 2px solid rgba(26, 20, 5, .25); border-top-color: var(--accent-ink); animation: spin 0.8s linear infinite; }

/* Admin: downloads list */
.dl-list { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; }
.dl-row { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 10px; background: var(--surface-2); }
.dl-thumb { width: 48px; height: 48px; flex: none; border-radius: 8px; object-fit: cover; background: var(--line); }
.dl-text { display: flex; flex-direction: column; min-width: 0; }
.dl-text strong, .dl-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Admin: event dashboard */
.tabs { display: flex; gap: 6px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font: 600 15px var(--body); cursor: pointer; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile-v { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }
.tile-l { margin-top: 8px; font-weight: 600; font-size: 14px; }
.tile-n { margin-top: 2px; font-size: 12px; color: var(--muted); }
.chart-svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--body); }
.bar-a { fill: var(--accent); }
.bar-b { fill: #7fb5a8; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-a { background: var(--accent); } .sw-b { background: #7fb5a8; }
.dash-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .dash-cols { grid-template-columns: 1fr; } }
.top-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.top-photo { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.top-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.top-count { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff; font: 600 12px var(--body); padding: 3px 7px; border-radius: 999px; }
.up-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.up-row strong, .up-row span { overflow: hidden; text-overflow: ellipsis; }
.chip { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; font: 600 13px var(--body); cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.table-wrap { overflow-x: auto; }
.gtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.gtable th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gtable td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gtable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.gtable th:nth-child(2), .gtable th:nth-child(3), .gtable th:nth-child(4) { text-align: right; }
.gtable td.warn { color: #e8826d; }
.gtable .g-email { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* Admin: blurry review */
.blur-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.blur-item { display: flex; flex-direction: column; gap: 6px; }
.blur-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: var(--surface-2); }
.blur-item .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-act { cursor: pointer; border-color: var(--accent); }

/* Admin: scan report + funnel */
.dash-cols.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .dash-cols.even { grid-template-columns: 1fr; } }
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv-row:last-child { border-bottom: 0; }
.kv-k { color: var(--muted); }
.kv-v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.sizebar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.seg { display: block; height: 100%; }
.seg-tiny { background: #5b5750; } .seg-small { background: #8a7a52; } .seg-medium { background: #c49a3c; } .seg-large { background: var(--accent); }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.fn-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.fn-l { color: var(--muted); }
.fn-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.fn-bar { height: 100%; background: var(--accent); border-radius: 999px; }
.fn-v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
