:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --card: #1e2235;
  --border: #2d3148;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #4f8ef7;
  --accent-dark: #1e3a5f;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.4; min-height: 100vh;
  -webkit-font-smoothing: antialiased; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* HEADER */
#app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--accent-dark); color: #fff;
  border-bottom: 1px solid var(--border);
}
.hdr-left { display: flex; flex-direction: column; gap: 2px; }
.hdr-event { font-size: 13px; font-weight: 700; }
.hdr-user { font-size: 10px; opacity: 0.75; }
.hdr-right { display: flex; align-items: center; gap: 10px; font-size: 12px; }
#online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
#online-dot.offline { background: var(--red); }
#queue-badge { padding: 3px 9px; background: var(--yellow); color: #000; border-radius: 10px; font-size: 11px; font-weight: 700; }
.icon-btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px; cursor: pointer; padding: 0; line-height: 1; }
.icon-btn:active { background: rgba(255,255,255,.15); }

/* VIEWS */
#app { padding: 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.view-full { padding: 0; }
/* Use 100dvh (dynamic viewport height) instead of 100vh so the layout shrinks
   when Chrome Android shows the URL bar — keeps the Capture button on-screen
   without forcing a scroll. Critical for the camera screens because scrolling
   collapses the URL bar mid-capture, which reflows .cam-wrap, which changes
   the object-fit: cover visible region, which changes what's actually inside
   the framing rectangle vs what the user framed BEFORE the scroll. Use height
   (not min-height) so the layout never overflows the visible viewport. */
.view-full.active { display: flex; flex-direction: column; height: calc(100dvh - 56px); }

h1 { font-size: 22px; margin: 12px 0 4px; text-align: center; }
h2 { font-size: 18px; margin: 8px 0 4px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.subtle { font-size: 12px; color: var(--muted); text-align: center; margin: 4px 0 20px; }

/* INPUTS */
.input { width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; /* 16px prevents iOS auto-zoom on focus */ }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
/* A textarea carrying .input needs three things an <input> never does: the
   page font (a bare textarea inherits the browser's monospace default), a
   readable line-height for wrapped text, and a floor on its height so the
   note field is big enough to re-read before saving. resize:vertical lets a
   rep pull it taller for a long note; horizontal resize is blocked so it can
   never exceed the phone's width. */
textarea.input { font-family: inherit; line-height: 1.45; min-height: 112px;
  resize: vertical; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; text-transform: uppercase; font-weight: 700;
  color: var(--muted); margin-bottom: 5px; letter-spacing: 1px; }

/* BUTTONS */
.btn { padding: 10px 18px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-secondary { background: transparent; }
.btn-big { padding: 16px 24px; font-size: 16px; }

/* LOGIN FORM */
#login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
#login-form .input { padding: 14px; }
.err { color: var(--red); font-size: 13px; text-align: center; min-height: 18px; }

/* EVENT PICKER */
#event-list { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.event-card { padding: 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; }
.event-card:active { background: var(--card); }
.event-card .ev-name { font-size: 16px; font-weight: 700; }
.event-card .ev-dates { font-size: 12px; color: var(--muted); margin-top: 2px; }
.event-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,142,247,.3); }
.event-card.current::after { content: "ACTIVE"; float: right; font-size: 10px; font-weight: 700;
  background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 8px; }

/* HOME */
.home-actions { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 16px 0; }
@media (min-width: 480px) { .home-actions { grid-template-columns: 1fr 1fr 1fr; } }
.mega-btn { padding: 28px 16px; border: 2px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); cursor: pointer; text-align: center; }
.mega-btn:active { background: var(--card); transform: scale(0.97); }
.mega-icon { font-size: 40px; margin-bottom: 8px; }
.mega-label { font-size: 14px; font-weight: 700; }

.home-recent { margin-top: 24px; }
.home-recent ul { list-style: none; padding: 0; margin: 0; }
.home-recent li { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 6px; font-size: 13px; background: var(--surface); }
.home-recent li .rl-name { font-weight: 600; }
.home-recent li .rl-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* CAMERA VIEWS */
.cam-wrap { position: relative; flex: 1; background: #000; overflow: hidden; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; }
.cam-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; flex-direction: column; }
.cam-frame { width: 70%; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.8);
  border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0,0,0,.5); }
.card-frame { width: 85%; aspect-ratio: 1.6; border-radius: 10px; }
.cam-hint { color: #fff; font-size: 13px; margin-top: 20px;
  background: rgba(0,0,0,.6); padding: 6px 14px; border-radius: 14px; }
.cam-actions { padding: 14px; display: flex; gap: 10px; justify-content: center;
  background: var(--bg); }

/* PILLS */
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 10px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.pill:active { transform: scale(0.96); }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.on[data-val="hot"] { background: var(--red); border-color: var(--red); }
.pill.on[data-val="warm"] { background: var(--yellow); border-color: var(--yellow); color: #000; }
.pill.on[data-val="cold"] { background: var(--accent); border-color: var(--accent); }

/* FORM ACTIONS */
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px;
  position: sticky; bottom: 0; background: var(--bg); padding: 12px 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

/* BANNER (OCR note / warnings) */
.banner { padding: 10px 12px; background: rgba(245,158,11,.15); border-left: 3px solid var(--yellow);
  font-size: 12px; border-radius: 0 6px 6px 0; margin-bottom: 12px; }

/* TOAST */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; padding: 12px 20px; border-radius: 8px;
  font-weight: 600; z-index: 200; box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: slide-up 0.3s ease; }
.toast.err { background: var(--red); }
@keyframes slide-up { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
