:root {
  color-scheme: light;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --wash: #f5f7fa;
  --accent: #175cd3;
  --accent-dark: #1849a9;
  --danger: #b42318;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--wash); color: var(--ink); min-width: 320px; }
a { color: var(--accent-dark); }
button, input { font: inherit; }
.topbar { height: 64px; padding: env(safe-area-inset-top) 18px 0; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: white; background: var(--ink); font-size: 15px; }
.secure-pill { color: #344054; background: #eef2f6; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 700; }
.shell { width: min(100%, 540px); margin: 0 auto; padding: 26px 16px 48px; }
.hero { padding: 6px 3px 18px; }
.event-label, .eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(32px, 10vw, 46px); line-height: 1.12; letter-spacing: -.045em; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.025em; }
.lead { margin: 12px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.event-status { margin: 9px 0 0; color: #175cd3; font-size: 12px; font-weight: 700; }
.browser-warning { margin: 0 0 14px; padding: 15px; border: 1px solid #fedf89; border-radius: 16px; background: #fffaeb; color: #7a2e0e; }
.browser-warning p { margin: 5px 0 2px; color: #93370d; font-size: 13px; line-height: 1.5; }
.browser-warning .text-button { text-align: left; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 10px 28px rgba(16,24,40,.06); }
.search-card { padding: 14px; }
.camera-box { min-height: 238px; background: #eef2f6; border: 2px dashed #b8c0cc; border-radius: 17px; display: grid; place-items: center; overflow: hidden; cursor: pointer; }
.camera-box:focus-within { outline: 3px solid rgba(23,92,211,.22); }
.camera-empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 24px; }
.camera-empty strong { font-size: 21px; }
.camera-empty small { color: var(--muted); line-height: 1.5; }
.camera-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--ink); color: white; display: grid; place-items: center; border: 9px solid white; box-shadow: 0 4px 16px rgba(16,24,40,.18); }
#selfie-preview, #camera-video { width: 100%; height: 280px; object-fit: cover; }
#camera-video { transform: scaleX(-1); background: #101828; }
.camera-actions { display: grid; gap: 4px; margin-top: 14px; }
.consent-copy { margin: 13px 4px; color: #475467; font-size: 12px; line-height: 1.55; text-align: center; }
.consent-row { margin: 16px 2px; display: grid; grid-template-columns: 22px 1fr; gap: 10px; color: #344054; font-size: 13px; line-height: 1.55; }
.consent-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }
.primary-button, .secondary-button { min-height: 52px; border-radius: 14px; padding: 13px 18px; display: flex; justify-content: center; align-items: center; text-decoration: none; font-weight: 800; width: 100%; }
.primary-button { border: 0; color: white; background: var(--accent); }
.primary-button:not(:disabled):active { background: var(--accent-dark); transform: translateY(1px); }
.primary-button:disabled { background: #cbd5e1; color: #667085; }
.secondary-button { border: 1px solid #b2ccff; color: var(--accent-dark); background: #eff4ff; }
.legal-note { margin: 13px 4px 1px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; }
.status-panel { margin-top: 16px; padding: 18px; border-radius: 18px; background: #eff8ff; border: 1px solid #b2ddff; display: flex; align-items: center; gap: 14px; }
.status-panel p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; flex: 0 0 auto; border: 3px solid #b2ddff; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.results { margin-top: 24px; }
.results-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.text-button { border: 0; background: transparent; color: var(--accent-dark); font-weight: 800; padding: 8px 0; }
#download-all { margin-bottom: 12px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo-card { min-width: 0; overflow: hidden; border-radius: 13px; background: #e4e7ec; aspect-ratio: 4 / 3; position: relative; }
.photo-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-error { height: 100%; margin: 0; padding: 18px; display: grid; place-items: center; text-align: center; color: #667085; font-size: 14px; }
.photo-card a { position: absolute; right: 7px; bottom: 7px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; color: white; background: rgba(16,24,40,.82); font-size: 18px; }
.empty-state, .error-state { margin-top: 18px; padding: 24px 20px; text-align: center; }
.empty-state p, .error-state p { color: var(--muted); line-height: 1.65; }
.error-state h2 { color: var(--danger); }
footer { padding: 24px 16px calc(30px + env(safe-area-inset-bottom)); color: var(--muted); text-align: center; font-size: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

@media (min-width: 760px) {
  .shell { padding-top: 44px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
}

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
