/* StarView Events — staff interface ("the deck").
   Neutral hardware for running the night; color is reserved for state
   (REC red = live, amber = time running out, green = arrived) and for each
   event's own theme ("the cassette"), which only appears as its spine. */

:root {
  --deck: #eceef1;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --ink: #16181d;
  --ink-2: #353a43;
  --muted: #5b6370;
  --line: #d3d8de;
  --field: #7d8794;
  --rec: #e0322b;
  --rec-text: #c4271f;
  --rec-soft: #fcebea;
  --amber: #f0a202;
  --amber-text: #9a6700;
  --go: #167a45;
  --go-soft: #e4f3ea;
  --focus: #2b59c3;
  --font: 'Atkinson Hyperlegible Next Variable', 'Vazirmatn Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 6px;
  --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 1rem/1.5 var(--font);
  color: var(--ink);
  background: var(--deck);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.875rem; font-weight: 750; }
h2 { font-size: 1.25rem; font-weight: 700; margin-top: 0; }
h3 { font-size: 1.0625rem; font-weight: 700; }
p { margin: 0 0 1rem; max-width: 70ch; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.muted { color: var(--muted); }
.lede { color: var(--ink-2); font-size: 1.0625rem; margin-bottom: 1.5rem; }
.error { color: var(--rec-text); font-weight: 600; }
[dir=auto], .bidi { unicode-bidi: plaintext; }

/* ---------- Top bar and event navigation ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  min-height: 56px; padding: .5rem 1.25rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.wordmark { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; font-size: 1.0625rem; white-space: nowrap; }
.wordmark span { font-weight: 400; color: var(--muted); }
.topbar-event {
  display: flex; align-items: center; gap: .6rem; min-width: 0;
  text-decoration: none; font-weight: 700;
  padding-left: 1.25rem; border-left: 1px solid var(--line);
}
.topbar-event span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: .9375rem; }
.topbar-user form { margin: 0; }
.linkish {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.linkish:hover { color: var(--ink); }

.eventnav {
  display: flex; gap: .25rem; padding: 0 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.eventnav a {
  padding: .7rem .8rem .6rem; text-decoration: none; color: var(--muted);
  border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600;
}
.eventnav a:hover { color: var(--ink); }
.eventnav a[aria-current=page] { color: var(--ink); border-bottom-color: var(--ink); }

.main { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }

/* ---------- The cassette spine: an event's three colors ---------- */
.spine { display: inline-grid; grid-template-columns: 10px 5px 4px; height: 22px; border-radius: 3px; overflow: hidden; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.spine i:nth-child(1) { background: var(--brand); }
.spine i:nth-child(2) { background: var(--accent); }
.spine i:nth-child(3) { background: var(--bg); }

/* ---------- Event list as cassette labels ---------- */
.newevent { margin: 1rem 0 2rem; max-width: 640px; }
.newevent label { font-weight: 700; }
.tapes { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tape {
  display: grid; grid-template-columns: 52px 1fr; min-height: 168px;
  background: var(--bg); color: var(--text);
  border-radius: 10px; overflow: hidden; text-decoration: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.10);
  transition: transform .15s ease-out;
}
.tape:hover { transform: translateY(-2px); }
.tape .spine { display: grid; grid-template-columns: none; grid-template-rows: 1fr 18px 8px; height: auto; width: 100%; border-radius: 0; box-shadow: inset -1px 0 0 rgba(0,0,0,.1); }
.tape-body { display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.2rem 1rem; min-width: 0; }
.tape-title { font-family: var(--font-heading); font-size: 1.6rem; line-height: 1.1; font-weight: 700; margin-bottom: .35rem; overflow-wrap: anywhere; }
.tape-meta { font-family: var(--font-body); color: var(--muted); font-size: .9375rem; }
.tape-role {
  margin-top: auto; padding-top: .75rem; font-family: var(--font-body); font-size: .875rem;
  color: var(--muted); border-top: 1px dashed var(--line);
}
@media (prefers-reduced-motion: reduce) { .tape { transition: none; } .tape:hover { transform: none; } }

/* ---------- Panels, layout helpers ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel.quiet { background: var(--panel-2); }
.split { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.grid2 { display: grid; gap: 0 1.5rem; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 0 1.25rem; grid-template-columns: 2fr 2fr 1fr; align-items: end; }
.span2 { grid-column: 1 / -1; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.row form { margin: 0; }
.inline { display: flex; gap: .5rem; align-items: stretch; }
.inline input { flex: 1; min-width: 0; }
.eventhead { margin-bottom: 1.5rem; }
.plainlist { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.empty { padding: 2.5rem 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--ink-2); }
.empty p:last-child { margin-bottom: 0; }
@media (max-width: 760px) {
  .split, .grid2, .grid3 { grid-template-columns: 1fr; }
  .main { padding: 1.25rem 1rem 4rem; }
  h1 { font-size: 1.5rem; }
  .topbar { flex-wrap: wrap; gap: .5rem 1rem; }
  .topbar-event { border-left: 0; padding-left: 0; order: 3; width: 100%; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
label, legend { display: block; font-weight: 700; margin-bottom: .3rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1.75rem; min-width: 0; }
legend { font-size: 1.0625rem; margin-bottom: .75rem; }
.hint { color: var(--muted); font-size: .9375rem; margin: .3rem 0 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=datetime-local], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .75rem;
  border: 1px solid var(--field); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit;
}
textarea { min-height: 0; resize: vertical; }
select { width: auto; padding-right: 2rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.field.check { display: flex; gap: .6rem; align-items: center; }
.field.check label { margin: 0; font-weight: 600; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; flex: none; }
.affix { display: flex; align-items: stretch; }
.affix span { display: flex; align-items: center; padding: 0 .6rem; border: 1px solid var(--field); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--panel-2); color: var(--muted); }
.affix input { border-radius: 0 var(--radius) var(--radius) 0; }
.copyline { display: flex; gap: .5rem; margin: .75rem 0; max-width: 640px; }
.copyline input { flex: 1; min-width: 0; font-size: .9375rem; color: var(--ink-2); background: var(--panel-2); }
details.more { margin-top: 1rem; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.more form { margin-top: .75rem; max-width: 420px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .45rem 1.05rem;
  border: 1px solid var(--field); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 700; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2d323b; }
.btn.danger { color: var(--rec-text); border-color: currentColor; }
.btn.danger:hover { background: var(--rec-soft); }
.btn.go { background: var(--go); border-color: var(--go); color: #fff; }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .9375rem; }
.btn.wide { width: 100%; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table th { text-align: left; font-size: .875rem; color: var(--muted); font-weight: 700; padding: .65rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions form { display: inline-block; margin: 0 0 0 .5rem; }
.table td form { margin: 0; }
.table tr.is-off td { color: var(--muted); }
.tag { display: inline-block; font-size: .8125rem; font-weight: 700; padding: .05rem .45rem; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); vertical-align: 1px; }
.tag.walkin { background: #fff4d6; border-color: #e8c96a; color: #6b4d00; }
@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .table td { border: 0; padding: .3rem 1rem; }
  .table td.actions { text-align: left; }
  .table td.actions form { margin: 0 .5rem 0 0; }
}

/* ---------- Flash, toast ---------- */
.flash { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--go); border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1.5rem; }
.flash p { margin: 0; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100% - 2rem)); }
.toast-msg { margin: 0; padding: .8rem 1.1rem; border-radius: var(--radius); background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast-msg.error { background: var(--rec-text); }

/* ---------- Sign-in style pages ---------- */
.bare-main { max-width: 440px; margin: 0 auto; padding: 3rem 1.25rem; }
.bare-main > .wordmark { display: inline-block; margin-bottom: 1.5rem; }
.auth h1 { font-size: 1.6rem; margin-bottom: 1rem; }
.auth-event { display: flex; gap: .6rem; align-items: center; font-weight: 700; margin-bottom: 1rem; }
.pin-input { font-size: 1.75rem; letter-spacing: .3em; text-align: center; }

/* ---------- Roles ---------- */
.role-help { margin: 0; display: grid; gap: .75rem; }
.role-help dt { font-weight: 700; }
.role-help dd { margin: 0; color: var(--ink-2); }

/* ---------- Door PIN ---------- */
.pin { font-size: 2.5rem; font-weight: 800; letter-spacing: .25em; margin: .5rem 0; }
.danger-zone { border-color: #e6b3b0; }
.danger-zone h2 { color: var(--rec-text); }

/* ---------- Theme editor ---------- */
.theme-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 2rem; align-items: start; }
@media (max-width: 960px) { .theme-editor { grid-template-columns: 1fr; } .theme-preview { order: -1; } }
.theme-preview { position: sticky; top: 1rem; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.palette {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: .9375rem; text-align: left; cursor: pointer; color: var(--ink);
}
.palette:hover { border-color: var(--field); }
.palette[aria-pressed=true] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
/* A palette as a tiny screen: its background with a brand and an accent bar. */
.palette-tile { display: grid; align-content: center; gap: 4px; width: 44px; height: 30px; padding: 0 6px; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.18); }
.palette-tile i { display: block; height: 5px; border-radius: 0 2px 2px 0; }
.palette-tile i:last-child { width: 62%; }
.theme-editor:not([data-scheme=dark]) .is-dark, .theme-editor[data-scheme=dark] .is-light { display: none; }
.schemes { display: inline-flex; border: 1px solid var(--field); border-radius: var(--radius); overflow: hidden; margin: .1rem 0 .4rem; }
.scheme { position: relative; display: grid; padding: .4rem 1rem; margin: 0; cursor: pointer; line-height: 1.25; }
.scheme + .scheme { border-left: 1px solid var(--field); }
.scheme input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.scheme small { color: var(--muted); font-size: .8125rem; }
.scheme:has(input:checked) { background: var(--ink); color: #fff; }
.scheme:has(input:checked) small { color: #d4d8de; }
.scheme:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.schemes + .hint { margin: 0 0 .75rem; max-width: 60ch; }
/* How the theme holds up on a projector. */
.tcheck { margin-top: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tcheck h3 { margin: 0 0 .6rem; font-size: 1rem; }
.tcheck p { margin: .5rem 0 0; }
.tcheck .low { color: var(--rec-text); font-weight: 600; }
.tcheck-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.tcheck-rows li { display: grid; grid-template-columns: 1fr auto 7rem; gap: .75rem; align-items: center; }
.tcheck-rows b { font-variant-numeric: tabular-nums; }
.tcheck-rows .ok .tcheck-mark { color: var(--go); }
.tcheck-mark .icon { width: 18px; height: 18px; vertical-align: -4px; }
.tcheck-moved { margin: .3rem 0 0; padding-left: 1.1rem; }
.tcheck-moved li { font-variant-numeric: tabular-nums; }
.chip { display: inline-block; width: .95em; height: .95em; border-radius: 2px; vertical-align: -.12em; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.colors .colorfield { display: grid; grid-template-columns: 52px 1fr; gap: .9rem; align-items: start; margin-bottom: 1rem; }
.colorfield input[type=color] { width: 52px; height: 52px; padding: 0; border: 1px solid var(--field); border-radius: var(--radius); background: none; cursor: pointer; margin-top: 4px; }
.colorfield input[type=text] { max-width: 180px; font-variant-numeric: tabular-nums; }
.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.font-option { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .5rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 600; margin: 0; }
.font-option:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.font-option input { grid-row: 1 / 3; }
.font-sample { font-size: 1.6rem; line-height: 1; font-weight: 600; }

/* The preview uses the event theme variables set on .preview by the server. */
.preview { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; align-items: end; padding: 1.25rem; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.pv-phone { background: var(--bg); color: var(--text); border-radius: 22px; border: 6px solid #22252b; overflow: hidden; font-family: var(--font-body); min-height: 340px; display: flex; flex-direction: column; }
.pv-top { padding: .55rem .8rem; font-size: .75rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-body { padding: .8rem; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.pv-q { font-family: var(--font-heading); font-size: 1.15rem; line-height: 1.15; font-weight: 700; margin: 0 0 .35rem; }
.pv-opt { padding: .55rem .65rem; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); font-size: .8125rem; }
.pv-opt.picked { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); font-weight: 700; }
.pv-btn { margin-top: auto; padding: .6rem; border-radius: 8px; background: var(--brand); color: var(--on-brand); text-align: center; font-weight: 700; font-size: .875rem; }
.pv-screen { position: relative; aspect-ratio: 16 / 9; background: var(--bg); color: var(--text); border-radius: 6px; border: 6px solid #22252b; padding: 6% 30% 6% 6%; font-family: var(--font-body); display: flex; flex-direction: column; justify-content: center; gap: 4%; }
.pv-sq { font-family: var(--font-heading); font-weight: 700; font-size: clamp(.8rem, 1.6vw, 1.15rem); line-height: 1.1; margin: 0 0 2%; }
.pv-res { display: grid; grid-template-columns: 1fr auto; row-gap: 3px; font-size: clamp(.55rem, .9vw, .75rem); }
.pv-res i { grid-column: 1 / -1; height: 7px; width: var(--v); background: var(--dim); border-radius: 0 4px 4px 0; }
.pv-res.top i { background: var(--highlight); }
.pv-res.top { font-weight: 700; }
.pv-res b { font-weight: 700; }
/* QR codes are always dark on white, whatever the theme: scanners need it. */
.pv-qr { position: absolute; right: 6%; top: 50%; translate: 0 -50%; width: 18%; aspect-ratio: 1; background:
  conic-gradient(from 90deg at 30% 30%, #000 25%, transparent 0) 0 0 / 25% 25%, #fff;
  border: 4px solid #fff; border-radius: 3px; }
@media (max-width: 520px) { .preview { grid-template-columns: 1fr; } .pv-phone { max-width: 220px; } }

/* ---------- Guest list ---------- */
.strong { font-weight: 700; }
.breakall { overflow-wrap: anywhere; }
.extras { display: flex; flex-wrap: wrap; gap: .1rem 1rem; font-size: .875rem; margin-top: .15rem; }
.arrived { color: var(--go); font-weight: 700; }
.filterbar { max-width: 480px; margin-top: .5rem; }
.narrow { max-width: 420px; }
details.panel > summary { font-weight: 700; cursor: pointer; }
details.panel[open] > summary { margin-bottom: 1rem; }
.addone { margin-top: .5rem; }

/* ---------- Column mapping ---------- */
.tablescroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tablescroll .table { border: 0; }
.mapping th { vertical-align: top; min-width: 170px; background: var(--panel); }
.mapping .colhead { display: block; color: var(--ink); font-size: .9375rem; margin-bottom: .4rem; }
.mapping select { width: 100%; }
.mapping td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.stickybar { position: sticky; bottom: 0; background: var(--deck); padding: 1rem 0; margin-top: 1rem; border-top: 1px solid var(--line); }
.stickybar .hint { margin: 0; }

/* ---------- Door ---------- */
.main-door { max-width: 760px; padding-top: 0; }
.door-head { position: sticky; top: 0; z-index: 5; background: var(--deck); padding: 1rem 0 .85rem; }
.door-count { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .7rem; }
.door-present { font-size: 1.15rem; font-weight: 700; }
.door-present b { font-size: 2.75rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.door-of { color: var(--ink-2); }
.door-meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: .65rem 0 .9rem; }
.door-meter i { display: block; height: 100%; background: var(--go); transition: width .3s ease-out; }
input.door-q { font-size: 1.125rem; min-height: 54px; padding: .6rem .9rem; border-width: 2px; border-color: var(--ink); }
.door-offline { margin: .6rem 0 0; padding: .5rem .75rem; border-radius: var(--radius); background: var(--rec-soft); color: var(--rec-text); font-weight: 700; }
.door-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.door-list:empty { display: none; }
.guest { display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; min-height: 66px; border-bottom: 1px solid var(--line); }
.guest:last-child { border-bottom: 0; }
.guest[hidden] { display: none; }
.guest.is-in { background: var(--go-soft); }
.guest-who { flex: 1; min-width: 0; }
.guest-name { font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; margin-right: .4rem; }
.guest-sub { display: flex; flex-wrap: wrap; gap: 0 .9rem; color: var(--muted); font-size: .9375rem; overflow-wrap: anywhere; }
.guest-act { flex: none; display: flex; align-items: center; gap: .9rem; }
.guest-act .btn { min-width: 116px; min-height: 48px; }
.guest-in { display: inline-flex; align-items: center; gap: .3rem; color: var(--go); font-weight: 800; }
.guest-in svg { width: 20px; height: 20px; }
.door-none { padding: 1rem 0; color: var(--ink-2); }
.door-walkin { margin-top: 1rem; min-height: 52px; }
.dialog { border: 0; border-radius: 10px; padding: 1.5rem; width: min(560px, calc(100% - 1.5rem)); color: var(--ink); }
.dialog::backdrop { background: rgba(14, 16, 20, .55); }
.dialog h2 { margin-bottom: .25rem; }
.dialog .hint { margin-bottom: 1rem; }
.walkin-error { margin: 0 0 1rem; padding: .6rem .8rem; border-radius: var(--radius); background: var(--rec-soft); color: var(--rec-text); font-weight: 600; }
@media (max-width: 520px) {
  .guest { gap: .6rem; padding: .6rem .75rem; }
  .guest-act { flex-direction: column; align-items: flex-end; gap: .2rem; }
  .guest-act .btn { min-width: 96px; padding: .4rem .7rem; }
  .guest-sub { font-size: .875rem; }
  .main-door { padding-left: .75rem; padding-right: .75rem; }
  .topbar { padding: .4rem .75rem; }
}
@media (prefers-reduced-motion: reduce) { .door-meter i { transition: none; } }

/* ---------- Overview ---------- */
.bigline { font-size: 1.125rem; margin-bottom: .25rem; }
.bigline b { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.02em; margin-right: .15rem; }

/* ---------- Form status: the REC lamp lights while a form takes answers ---------- */
.status { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; color: var(--muted); }
.status.live { color: var(--rec-text); }
.lamp { width: 10px; height: 10px; border-radius: 50%; background: #b8bec6; flex: none; }
.status.live .lamp, .run[data-status=open] .runstate .lamp, .btn.rec .lamp { background: var(--rec); box-shadow: 0 0 0 3px rgba(224, 50, 43, .18); }
.run[data-status=open] .runstate .lamp { animation: rec 1.6s ease-in-out infinite; }
@keyframes rec { 50% { box-shadow: 0 0 0 7px rgba(224, 50, 43, .08); } }
@media (prefers-reduced-motion: reduce) { .run[data-status=open] .runstate .lamp { animation: none; } }
.code { font-weight: 800; letter-spacing: .12em; }

/* ---------- Forms list ---------- */
.eventlink { display: grid; grid-template-columns: 168px 1fr; gap: 1.5rem; align-items: start; }
.eventlink-qr { width: 168px; height: 168px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
@media (max-width: 640px) { .eventlink { grid-template-columns: 1fr; } }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.preset { display: flex; flex-direction: column; gap: .3rem; padding: .9rem 1rem; text-align: left; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--field); border-radius: var(--radius); font: inherit; }
.preset:hover { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.preset b { font-size: 1.0625rem; }
.preset span { color: var(--muted); font-size: .9375rem; }

/* ---------- Builder ---------- */
.pagehead { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.pagehead h1 { margin: 0; }
.push { margin-left: auto; }
.saved { color: var(--go); font-weight: 700; font-size: .9375rem; min-width: 4rem; }
.warn { background: #fff4d6; border: 1px solid #e8c96a; color: #5c4300; padding: .75rem 1rem; border-radius: var(--radius); font-weight: 600; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .modes { grid-template-columns: 1fr; } }
.choicecard { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1rem; border: 1px solid var(--field); border-radius: var(--radius); cursor: pointer; font-weight: 400; margin: 0; }
.choicecard input { margin-top: .2rem; }
.choicecard b { display: block; }
.choicecard span span { color: var(--muted); font-size: .9375rem; }
.choicecard:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.infofields { display: grid; gap: .6rem; }
.inforow { display: grid; grid-template-columns: minmax(0, 2fr) auto auto auto; gap: .6rem; align-items: center; }
.inforow .check, .qcard-foot .check { display: flex; gap: .4rem; align-items: center; margin: 0; font-weight: 600; white-space: nowrap; }
@media (max-width: 640px) { .inforow { grid-template-columns: 1fr 1fr; } }
.addinfo { margin-top: .4rem; }
.questions { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.qcard { margin: 0; }
.qcard-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.qnum { font-weight: 800; }
.qcard-tools { margin-left: auto; display: flex; gap: .35rem; align-items: center; }
.optlist { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .5rem; }
.optrow { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto auto auto; gap: .45rem; align-items: center; }
.optkey { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 800; font-size: .875rem; }
.correct { display: flex; gap: .35rem; align-items: center; margin: 0; font-weight: 600; white-space: nowrap; }
.iconbtn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.iconbtn:hover { border-color: var(--field); background: var(--panel-2); }
.iconbtn.danger { color: var(--rec-text); }
.iconbtn .icon { width: 18px; height: 18px; }
.qcard-foot { margin-top: 1rem; gap: 1.5rem; }
.inline-num { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 600; }
.inline-num input { width: 84px; }
@media (max-width: 640px) { .optrow { grid-template-columns: 28px minmax(0, 1fr) auto; } .optrow .iconbtn { display: none; } }

/* ---------- Control panel: what shows depends on the live state ---------- */
.runhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.runhead h1 { margin-bottom: .35rem; }
.runstate { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.0625rem; margin: 0; }
.run[data-status=open] .runstate { color: var(--rec-text); }
.runtimer { font-variant-numeric: tabular-nums; padding: .1rem .55rem; border-radius: 999px; border: 1px solid currentColor; }
.runtimer.soon { background: #fff4d6; color: var(--amber-text); }
.run.offline .runstate::after { content: "Reconnecting"; margin-left: .5rem; color: var(--muted); font-weight: 600; }
.run[data-status=open] .when-notopen, .run:not([data-status=open]) .when-open { display: none !important; }
.run[data-status=draft] .if-closed, .run[data-status=closed] .if-draft { display: none; }
.run .ph-open, .run .ph-locked, .run .ph-revealed, .run .ph-idle { display: none; }
.run[data-phase=open] .ph-open, .run[data-phase=locked] .ph-locked, .run[data-phase=revealed] .ph-revealed, .run[data-phase=idle] .ph-idle { display: block; }
.controls { display: grid; gap: 1.25rem; }
.opener { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.opener label { margin: 0; }
.btn.rec { background: var(--ink); color: #fff; border-color: var(--ink); padding-left: .85rem; }
.btn.rec:hover { background: #2d323b; }
.btn.rec .lamp { margin-right: .15rem; }
.phase-btns { margin-bottom: 1rem; }
.qlist { margin: 0; padding: 0; list-style: none; counter-reset: q; border: 1px solid var(--line); border-radius: var(--radius); }
.qlist li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .55rem .8rem; border-bottom: 1px solid var(--line); counter-increment: q; }
.qlist li:last-child { border-bottom: 0; }
.qlist li::before { content: counter(q); font-weight: 800; color: var(--muted); }
.qlist li.current { background: var(--rec-soft); }
.qlist li.current::before { color: var(--rec-text); }
.qlist form { margin: 0; }
.audience { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; padding-top: 1rem; border-top: 1px solid var(--line); }
.seg { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 0; }
.seg-label { font-weight: 700; }
.seg-opts { display: inline-flex; border: 1px solid var(--field); border-radius: var(--radius); overflow: hidden; }
.seg-opts label { margin: 0; font-weight: 600; }
.seg-opts input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opts span { display: block; padding: .55rem .9rem; cursor: pointer; border-right: 1px solid var(--line); }
.seg-opts label:last-child span { border-right: 0; }
.seg-opts input:checked + span { background: var(--ink); color: #fff; }
.seg-opts input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.switch { display: flex; gap: .55rem; align-items: center; margin: 0; font-weight: 700; cursor: pointer; }
.reveal { margin: 0; }
.share { display: grid; grid-template-columns: 132px 1fr; gap: 1.25rem; align-items: start; }
.qrsmall svg { width: 132px; height: 132px; display: block; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 640px) { .share { grid-template-columns: 1fr; } }

/* ---------- Staff results ---------- */
.staff-results { margin-bottom: 1.5rem; }
.rhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.25rem; margin-bottom: .75rem; }
.rhead h2 { margin: 0; }
.rhead p { margin: 0; }
.rhead .rcount { color: var(--ink); font-size: 1.25rem; }
.rlinks { display: flex; gap: 1rem; }
.sres { display: grid; gap: 1rem; }
.sq { margin: 0; }
.sq.current { border-color: var(--rec); box-shadow: inset 3px 0 0 var(--rec); }
.sq-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: .9rem; }
.sq-head h3 { margin: 0; }
.sbars { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.sbars li { display: grid; grid-template-columns: 1fr auto; row-gap: .3rem; column-gap: 1rem; align-items: baseline; }
.sb-label { font-weight: 600; overflow-wrap: anywhere; }
.sb-val { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: pre; }
.sb-track { grid-column: 1 / -1; height: 12px; background: var(--panel-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.sb-track i { display: block; height: 100%; width: 0; background: var(--ink-2); border-radius: 0 4px 4px 0; transition: width .4s ease-out; }
.sbars li.correct .sb-track i { background: var(--go); }
.sb-correct { display: inline-flex; gap: .2rem; align-items: center; color: var(--go); font-weight: 800; font-size: .875rem; margin-left: .3rem; }
.sb-correct .icon { width: 16px; height: 16px; }
.savg { margin-bottom: .75rem; }
.savg b { font-size: 1.75rem; font-weight: 800; margin-right: .15rem; }
.st-tools { margin-bottom: .75rem; }
.st-tools .check { display: inline-flex; gap: .4rem; align-items: center; font-weight: 600; margin: 0; }
.stexts { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.stexts li { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.stexts li.handled { background: var(--panel-2); }
.stexts li.handled .st-value { color: var(--muted); }
.stexts li.featured { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--ink); }
.st-value { font-size: 1.0625rem; margin: 0 0 .3rem; white-space: pre-line; overflow-wrap: anywhere; max-width: none; }
.st-meta { font-size: .875rem; margin: 0 0 .5rem; }
.st-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (prefers-reduced-motion: reduce) { .sb-track i { transition: none; } }

/* ---------- Responses table ---------- */
.resp td.cell { min-width: 140px; max-width: 360px; white-space: pre-line; overflow-wrap: anywhere; }
.resp th { white-space: nowrap; }

.formlist li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }

/* ---------- Leaderboard, words, duplicate ---------- */
.run[data-board=true] .if-noboard, .run:not([data-board=true]) .if-board { display: none !important; }
.boardctl { padding-block-start: 1rem; border-block-start: 1px solid var(--line); }
.boardctl form { margin: 0; }
.sboard ol { margin: 0; padding-inline-start: 1.4rem; display: grid; gap: .3rem; }
.sboard .who { font-weight: 700; }
.swords { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.swords li { display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); }
.swords .sw-word { font-weight: 700; text-align: left; }
.swords .sw-n { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.swords li.hidden-word .sw-word { text-decoration: line-through; color: var(--muted); }
.st-tools { gap: 1.25rem; }
.dupform { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1.25rem; }
.tight { margin-top: -.6rem; }

/* ---------- Phone remote: the controls you need on stage, big ---------- */
.remote { display: flex; flex-direction: column; gap: .9rem; }
.remote h1 { font-size: 1.5rem; margin: 0; }
.remote-back { margin: 0; }
.remote .rnow { font-weight: 700; margin: 0; padding: .7rem .9rem; border-radius: var(--radius); background: var(--rec-soft); }
.rcount-line { margin: 0; color: var(--ink-2); }
.rcount-line .rcount { font-size: 2rem; font-weight: 800; color: var(--ink); margin-right: .2rem; }
.rbtns { display: grid; gap: .7rem; }
.rbtns form { margin: 0; display: flex; gap: .5rem; align-items: stretch; }
.rbtns select { min-height: 64px; }
.btn.big { min-height: 64px; width: 100%; font-size: 1.15rem; }
.big-switch { min-height: 56px; padding: 0 .9rem; border: 1px solid var(--field); border-radius: var(--radius); width: 100%; }
.bare-main:has(.remote) { max-width: 520px; padding-top: 1.25rem; }

/* ---------- Report ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.figures dt { color: var(--muted); font-size: .9375rem; }
.figures dd { margin: 0; font-size: 1.75rem; font-weight: 800; }
.figures dd small { font-size: .9375rem; font-weight: 700; color: var(--ink-2); }
/* Arrivals: one column per 10 minutes, one color, the busiest slot labeled. */
.cols { display: flex; align-items: flex-end; gap: 2px; height: 180px; margin: 2rem 0 2.25rem; border-bottom: 1px solid var(--line); }
.col { position: relative; flex: 1 1 0; min-width: 2px; max-width: 24px; height: 100%; display: flex; align-items: flex-end; outline-offset: 2px; }
.col-bar { position: relative; display: block; width: 100%; min-height: 2px; background: var(--ink-2); border-radius: 4px 4px 0 0; }
.col-peak { position: absolute; bottom: 100%; left: 50%; translate: -50% -4px; font-size: .8125rem; font-weight: 800; color: var(--ink); }
.col-time { position: absolute; top: calc(100% + 6px); left: 0; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.col.end .col-time { left: auto; right: 0; }
.col:hover .col-bar, .col:focus-visible .col-bar { background: var(--ink); }
.col:hover .col-bar::after, .col:focus-visible .col-bar::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 1.5rem); left: 0;
  background: var(--ink); color: #fff; font-size: .8125rem; font-weight: 700; padding: .3rem .55rem; border-radius: 4px; white-space: nowrap; z-index: 2; }
.col.end:hover .col-bar::after, .col.end:focus-visible .col-bar::after { left: auto; right: 0; }
.narrowtable { max-width: 320px; }
.sectionhead { margin: 2rem 0 1rem; }
.rform .rq { margin-block-start: 1.1rem; }
.rq-prompt { font-weight: 700; margin-bottom: .5rem; }
.toplist { margin-top: .25rem; }

/* ---------- Door: scanning, taps waiting for the connection ---------- */
.door-find { display: flex; gap: .5rem; }
.door-find input { flex: 1; min-width: 0; }
.door-scan { min-height: 54px; white-space: nowrap; }
.tag.wait { background: var(--panel); border: 1px dashed var(--field); color: var(--ink-2); }
.door-foot { margin: 1.75rem 0 0; color: var(--ink-2); font-size: .9375rem; }
.toast { display: grid; gap: .5rem; }
.scan { padding: 1rem; }
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.scan-head h2, .scan-head form { margin: 0; }
.scan-view { position: relative; width: 100%; aspect-ratio: 1; max-height: 48vh; background: #111; border-radius: var(--radius); overflow: hidden; }
.scan-view video { display: block; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .3); }
.scan-result { display: grid; gap: .15rem; margin: .9rem 0; padding: .75rem 1rem; min-height: 4.4rem; border-radius: var(--radius);
  background: var(--panel-2); border-left: 6px solid var(--line); }
.scan-result b { font-size: 1.3rem; line-height: 1.2; overflow-wrap: anywhere; }
.scan-result.ok { background: var(--go-soft); border-color: var(--go); }
.scan-result.warn { background: #fff4d6; border-color: var(--amber); }
.scan-result.bad { background: var(--rec-soft); border-color: var(--rec); }
.scan-type label { display: block; font-weight: 700; margin-bottom: .35rem; }
.scan-type input { text-transform: uppercase; letter-spacing: .06em; }
