/* Layout: a projector board. QR card on the left, the live headcount on the right; stacks on phones. */
:root {
  --bg: #eef0ee;
  --surface: #ffffff;
  --ink: #14181d;
  --muted: #5a636c;
  --line: #d6dad6;
  --accent: #2847c4;
  --red: #cf3b2c;    --red-wash: #fae3df;
  --amber: #d98300;  --amber-wash: #fcefd6;
  --green: #1d9652;  --green-wash: #daf2e3;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1215; --surface: #181c20; --ink: #eef0f2; --muted: #9aa3ac; --line: #2a3036; --accent: #8fa3ff;
    --red: #ff6a5c; --red-wash: #3a1814; --amber: #ffb43d; --amber-wash: #382910; --green: #3cd17f; --green-wash: #0f2f1f;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-display);
  font-size: 16px;
  line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(20px, env(safe-area-inset-top, 0px)) max(40px, env(safe-area-inset-bottom, 0px));
}
main { max-width: 1240px; margin: 0 auto; }
h1, h2, p { margin: 0; }
h1 { text-wrap: balance; }
a { color: var(--accent); }
.mono { font-family: var(--f-mono); font-size: 0.85rem; }
.eyebrow {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}

/* State tokens: each view sets data-state and these follow */
[data-state] { --state: var(--red); --state-wash: var(--red-wash); }
[data-state="amber"] { --state: var(--amber); --state-wash: var(--amber-wash); }
[data-state="green"], [data-state="full"] { --state: var(--green); --state-wash: var(--green-wash); }

/* Buttons */
button, .btn {
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; display: inline-block;
  border-radius: 999px; padding: 10px 18px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
}
button:hover, .btn:hover { border-color: var(--ink); }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Create form */
.create { max-width: 560px; margin: 4vh auto 0; display: grid; gap: 24px; }
.create h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; font-stretch: 112%; line-height: 1.05; letter-spacing: -0.01em; }
.create .lede { color: var(--muted); max-width: 46ch; }
form.card, .recent {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display: grid; gap: 18px;
}
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field .hint { font-size: 0.82rem; color: var(--muted); }
input[type="text"], input[type="number"], input[type="email"] {
  font: inherit; font-size: 1.05rem; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
input#f-total { font-size: 2rem; font-weight: 800; font-stretch: 110%; font-variant-numeric: tabular-nums; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-error { color: var(--red); font-size: 0.9rem; }
.recent { gap: 10px; padding: 18px 24px; }
.recent h2 { font-size: 1rem; font-weight: 700; }
.recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recent li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.recent li a { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent li time { color: var(--muted); font-size: 0.82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Host board */
.bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.bar h1 { font-size: clamp(1.6rem, 3.4vw, 2.6rem); font-weight: 800; font-stretch: 110%; line-height: 1.05; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.board { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; }
.qr-card {
  margin: 0; background: #ffffff; color: #14181d; border-radius: var(--radius);
  padding: 24px; display: grid; gap: 16px; align-content: start; justify-items: center;
  border: 1px solid var(--line);
}
#qr { width: 100%; max-width: 380px; aspect-ratio: 1; }
#qr svg { width: 100%; height: 100%; display: block; }
.qr-card figcaption { display: grid; gap: 8px; justify-items: center; text-align: center; width: 100%; }
.qr-card strong { font-size: 1.5rem; font-weight: 800; font-stretch: 112%; }
.qr-card .mono { color: #5a636c; word-break: break-all; font-size: 1rem; }
.qr-card .copy-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.qr-card button { background: #fff; color: #14181d; border-color: #d6dad6; }
.qr-card button:hover { border-color: #14181d; }

.count-panel {
  background: var(--state-wash); border: 2px solid var(--state); border-radius: var(--radius);
  padding: clamp(20px, 3vw, 36px); display: grid; gap: 22px; align-content: center;
  transition: background .6s ease, border-color .6s ease; min-width: 0;
}
.chip {
  justify-self: start; display: inline-flex; align-items: center; gap: 10px;
  background: var(--state); color: #fff; font-weight: 700; font-size: 1rem;
  padding: 8px 16px; border-radius: 999px; transition: background .6s ease;
}
[data-state="amber"] .chip { color: #1d1400; }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .85; }
.count { display: flex; align-items: baseline; gap: 0.2em; flex-wrap: wrap; line-height: 0.9; font-variant-numeric: tabular-nums; }
.count .n { font-size: clamp(5rem, 15vw, 12rem); font-weight: 900; font-stretch: 118%; color: var(--state); letter-spacing: -0.03em; transition: color .6s ease; }
.count .of { font-size: clamp(1.8rem, 4.4vw, 3.6rem); font-weight: 700; font-stretch: 110%; color: var(--muted); }
.count .n.bump { animation: bump .5s ease; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.08); } 100% { transform: scale(1); } }

.meter { position: relative; height: 28px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--state); border-radius: 999px; transition: width .8s cubic-bezier(.2,.8,.2,1), background .6s ease; }
.meter .tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .35; }
.scale { position: relative; height: 1.2em; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.scale span:first-child { transform: none; }
.scale span:last-child { transform: translateX(-100%); }
.summary { font-size: clamp(1.05rem, 1.8vw, 1.35rem); font-weight: 600; }
.summary .sub { display: block; font-weight: 400; color: var(--muted); font-size: 0.85em; }
.live { font-size: 0.8rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.live.off::before { background: var(--muted); }

.arrivals { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 12px; }
.arrivals-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.arrivals h2 { font-size: 1.05rem; font-weight: 700; }
.arrivals ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.arrivals li {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-size: 0.9rem; max-width: 100%;
}
.arrivals li .av { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--line); font-weight: 700; font-size: .75rem; }
.arrivals li span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrivals li time { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 0.92rem; }

/* Participant view */
.guest { max-width: 460px; margin: 3vh auto 0; display: grid; gap: 18px; }
.guest-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 24px; display: grid; gap: 20px; text-align: center; justify-items: center;
}
.guest-card h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 800; font-stretch: 110%; line-height: 1.08; }
.guest-card .note { color: var(--muted); max-width: 34ch; }
.guest-card .field { width: 100%; text-align: left; }
button.big {
  width: 100%; padding: 22px; font-size: 1.4rem; font-weight: 800; font-stretch: 110%;
  background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 16px;
}
button.big:hover { filter: brightness(1.08); border-color: var(--accent); }
.done-mark {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-wash); color: var(--green); border: 3px solid var(--green);
}
.done-mark svg { width: 46px; height: 46px; }
.mini { width: 100%; display: grid; gap: 8px; }
.mini .meter { height: 14px; }
.mini p { font-weight: 600; font-variant-numeric: tabular-nums; }
.mini p b { color: var(--state); }

/* Messages */
.msg { max-width: 520px; margin: 8vh auto 0; display: grid; gap: 12px; text-align: center; justify-items: center; }
.msg h1 { font-size: 1.8rem; font-weight: 800; font-stretch: 110%; }
.msg p { color: var(--muted); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}
footer { max-width: 1240px; margin: 40px auto 0; color: var(--muted); font-size: .8rem; text-align: center; }

@media (max-width: 820px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  #qr { max-width: 300px; }
}
@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
