:root {
  --bg: #f6f6f4; --surface: #fff; --text: #1d1d1b; --muted: #6b6b66; --border: #e3e3de;
  --accent: #3b5bdb; --accent-text: #fff; --ok: #2b8a3e; --ok-bg: #e6f4ea;
  --warn: #a15c00; --warn-bg: #fff3d6; --err: #c92a2a; --err-bg: #fdecec;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --surface: #1f1f1d; --text: #ececea; --muted: #9a9a94; --border: #33332f;
    --accent: #748ffc; --accent-text: #0d0d0c; --ok: #69db7c; --ok-bg: #1c3322;
    --warn: #ffc94d; --warn-bg: #3a2f14; --err: #ff8787; --err-bg: #3b1d1d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text);
  overflow-x: clip; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; overflow-wrap: anywhere; }
h1 { font-size: 1.6rem; }
.container { max-width: 600px; margin: 0 auto; padding: 1rem max(16px, env(safe-area-inset-right)) calc(4rem + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: calc(.75rem + env(safe-area-inset-top)) 16px .75rem; display: flex; justify-content: space-between; align-items: center; }
.login { max-width: 380px; margin: 3rem auto; }
.error { color: var(--err); margin: 0; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1rem; color: var(--muted); text-decoration: none; }
.brand img { display: block; height: 32px; width: auto; max-width: 150px; object-fit: contain; }
.invite-logo { display: block; height: 48px; width: auto; max-width: 80%; object-fit: contain; margin: 0 auto 1.25rem; }
.invite-page .eyebrow { color: #d61332; }

/* Install screen: the admin app only runs from the home screen */
body.gate .topbar { display: none; }
.gate-box { min-height: calc(100vh - 2rem); min-height: calc(100dvh - 2rem); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: .5rem; max-width: 360px; margin: 0 auto; }
.gate-icon { border-radius: 22px; border: 1px solid var(--border); box-shadow: 0 8px 24px rgb(0 0 0 / .08); margin-bottom: .5rem; }
.gate-box h1 { margin: 0; }
.gate-btn { margin-top: 1rem; min-height: 52px; font-size: 1.05rem; }
.gate-help { margin-top: 1rem; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1rem; }
.gate-help ol { margin: 0; padding-left: 1.25rem; display: grid; gap: .5rem; }
.gate-help p { margin: .75rem 0 0; }
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.2em; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.event-card { display: block; color: inherit; text-decoration: none; }
.event-card:hover { border-color: var(--accent); }
.event-card.closed { opacity: .75; }
.event-card.live { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.logo-preview { display: grid; place-items: center; min-height: 110px; padding: 1rem; margin-bottom: .5rem;
  background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); }
.logo-preview img { max-width: 100%; max-height: 90px; height: auto; }
.file-btn { cursor: pointer; }
.phrase-preview { display: grid; gap: .2rem; padding: .75rem; background: var(--bg); border-radius: var(--radius); }
.door-shortcut { margin: .25rem 0 1rem; text-align: center; }
.door-shortcut .muted { margin-top: .35rem; }
.section-title { font-size: 1rem; margin: 1.5rem 0 .6rem; }
.badge.soon { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.done-events { margin-top: 1.5rem; }
.done-events > summary { padding: .5rem 0; cursor: pointer; }
.closed-banner { margin-top: .75rem; padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-size: .9rem; }

form.stack { display: grid; gap: .75rem; }
form.grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
label { display: grid; gap: .25rem; font-size: .875rem; color: var(--muted); }
/* 16px font on inputs stops iOS Safari from zooming in on focus. */
input, textarea, select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .7rem; width: 100%; min-width: 0; max-width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .55rem .9rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; white-space: nowrap;
  min-height: 44px; touch-action: manipulation;
}
button:disabled, [aria-disabled="true"] { opacity: .45; cursor: default; }
.block { display: flex; width: 100%; }
button:hover, .btn:hover { border-color: var(--muted); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { color: var(--err); }
.wa { color: #128c4b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa { color: #4cd38a; } }
.ghost { background: transparent; border-color: transparent; }
.sm { padding: .3rem .7rem; font-size: .875rem; min-height: 36px; }

.quick-add { display: grid; gap: .75rem; }
.quick-row { display: flex; align-items: center; gap: .5rem; }
.quick-row .grow { flex: 1 1 0; }
.stepper { display: flex; flex: none; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); }
.stepper button { border: 0; border-radius: 0; background: transparent; width: 40px; padding: 0; font-size: 1.25rem; }
.stepper input { width: 2.75rem; border: 0; border-radius: 0; text-align: center; padding: .6rem 0; background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.page-head { margin-bottom: .5rem; }
.back { margin: .25rem 0 1rem; padding-left: .6rem; gap: .25rem; color: var(--text); font-size: .95rem; }
.back:hover { border-color: var(--muted); }
.page-head h1 { margin: 0; }
.suggest-wrap { position: relative; }
.suggest { list-style: none; margin: .25rem 0 0; padding: .25rem; position: absolute; left: 0; right: 0; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.suggest button { width: 100%; justify-content: flex-start; text-align: left; border: 0; background: transparent;
  font-weight: 400; padding: .5rem .6rem; white-space: normal; gap: .5rem; }
.suggest button:hover, .suggest button:focus-visible { background: var(--bg); }
.suggest button:disabled { opacity: .55; }
.list-tools { display: grid; gap: .5rem; margin-bottom: .75rem; }
/* Calendar */
.field { display: grid; gap: .25rem; font-size: .875rem; color: var(--muted); min-width: 0; }
.date-btn { justify-content: flex-start; font-weight: 400; font-size: 16px; background: var(--bg); min-height: 2.75rem;
  overflow: hidden; text-overflow: ellipsis; padding: .6rem .7rem; }
.date-btn.placeholder { color: var(--muted); }
.cal { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; background: var(--surface); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .25rem; }
.cal-head button { border: 0; background: transparent; font-size: 1.4rem; min-width: 44px; padding: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.cal-grid .wd { font-size: .75rem; color: var(--muted); padding: .25rem 0; }
.cal-grid button { min-height: 40px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-weight: 500; font-variant-numeric: tabular-nums; }
.cal-grid button:disabled { opacity: .3; text-decoration: line-through; }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.cal-grid button.sel { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.time-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ends-hint { margin: -.4rem 0 0; text-align: right; }
select { -webkit-appearance: none; appearance: none; min-height: 2.75rem; padding-right: 1.75rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .3s; }

.tabs { display: flex; gap: .25rem; }
.tabs button { flex: 1; }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.guest-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.guest { display: flex; gap: .75rem; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.guest:last-child { border-bottom: 0; }
.guest .name { font-weight: 600; overflow-wrap: anywhere; }
.guest .meta { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.guest.in .name { color: var(--ok); }
.guest.partial .name { color: var(--warn); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: var(--border); color: var(--text); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.25rem; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.entry-code { display: grid; gap: .1rem; justify-items: center; margin: -.25rem 0 .75rem; }
.entry-code b { font: 700 2rem/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.qr { display: block; margin: 1rem auto; width: 260px; max-width: 100%; height: auto; background: #fff; border-radius: 8px; }

/* Top of the screen, so the on-screen keyboard never covers it. */
#toast { position: fixed; left: 16px; right: 16px; top: calc(.75rem + env(safe-area-inset-top)); margin: 0 auto; width: fit-content;
  max-width: calc(100vw - 32px); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; overflow-wrap: anywhere; text-align: center; }
#toast.show { opacity: 1; }

/* Scanner */
#reader { width: 100%; max-width: 420px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; }
#reader video { display: block; }
.scan-result { border-radius: var(--radius); padding: 1rem; margin: 1rem 0; text-align: center; font-weight: 600; }
.scan-result .big { font-size: 1.4rem; display: block; }
.scan-result.ok { background: var(--ok-bg); color: var(--ok); }
.scan-result.warn { background: var(--warn-bg); color: var(--warn); }
.scan-result.err { background: var(--err-bg); color: var(--err); }

/* Invite page */
.invite-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.invite-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem 1.5rem; text-align: center; width: min(420px, 100%); }
.invite-card p { margin: .25rem 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--accent); font-weight: 700; }
.guest-name { font-size: 1.25rem; font-weight: 700; }

@media (max-width: 520px) {
  .guest { flex-wrap: wrap; }
  .guest .actions { width: 100%; justify-content: space-between; flex-wrap: nowrap; gap: .25rem; }
  .guest .actions .sm { padding: .3rem .55rem; }
}
