:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #707070;
  --paper: #ffffff;
  --soft: #f4f4f4;
  --line: #dedede;
  --muse: #ff4778;
  --success: #19a766;
  --warning: #e8a21a;
  --danger: #dc3d4b;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.hidden { display: none !important; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.brand { font-size: 19px; font-weight: 800; }
.product { margin-top: 2px; color: var(--muse); font-size: 12px; font-weight: 800; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 22px;
}

.login-view {
  display: flex;
  min-height: calc(100dvh - 110px);
  flex-direction: column;
  justify-content: center;
  padding: 28px 0 64px;
}

.event-mark { color: var(--muse); font-size: 13px; font-weight: 800; }
h1 { margin: 12px 0 32px; font-size: 34px; line-height: 1.08; }

.login-form { display: grid; gap: 10px; }
.login-form label { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-form input {
  width: 100%;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  text-align: center;
}
.login-form input:focus { border-color: var(--muse); outline: 2px solid rgba(255, 71, 120, 0.18); }

.primary-button, .secondary-button {
  min-height: 52px;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 800;
}
.primary-button { border: 1px solid var(--muse); background: var(--muse); color: white; }
.secondary-button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.form-error { min-height: 22px; margin: 12px 0 0; color: var(--danger); font-size: 14px; }

.scanner-view { padding-top: 16px; }
.stats-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 16px;
}
.stats-band div { display: flex; align-items: baseline; gap: 8px; }
.stats-band div:last-child { justify-content: flex-end; }
.stats-band strong { font-size: 27px; }
.stats-band span { color: var(--muted); font-size: 13px; }

.scanner-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: #111;
  aspect-ratio: 1 / 1;
}
#reader { width: 100%; height: 100%; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
#reader img { display: none; }
.scan-frame {
  position: absolute;
  inset: 16%;
  z-index: 3;
  border: 3px solid white;
  border-radius: 6px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.camera-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  color: white;
  text-align: center;
}
.camera-placeholder span { font-size: 54px; }
.camera-placeholder p { margin: 8px 0 0; font-weight: 700; }
.scanner-controls { display: grid; gap: 10px; margin-top: 14px; }

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  color: white;
  text-align: center;
}
.result-overlay.accepted { background: var(--success); }
.result-overlay.already_used { background: var(--warning); }
.result-overlay.invalid, .result-overlay.error { background: var(--danger); }
.result-symbol {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-size: 54px;
  font-weight: 800;
}
.result-overlay h2 { margin: 22px 0 10px; font-size: 34px; }
.result-person { margin: 0; font-size: 20px; font-weight: 700; }
.result-meta { margin: 10px 0 0; font-size: 14px; opacity: 0.9; }

@media (min-width: 760px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .scanner-stage { aspect-ratio: 4 / 3; }
}
