:root {
  color-scheme: dark;
  --night: #1c1b3a;
  --night-2: #26254d;
  --night-3: #312f60;
  --ink: #f3f0fa;
  --muted: #aaa7cc;
  --lantern: #f4c542;
  --lantern-deep: #b98e1a;
  --flag: #ee4b7e;
  --mint: #58c9a2;
  --line: rgba(243, 240, 250, 0.13);
  --display: 'Bricolage Grotesque', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-sm: 8px;
  --r-lg: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lantern); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 96px; }
.loading { color: var(--muted); }

h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 32px 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* header */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top .who { text-align: right; font-size: 0.875rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.top .who .btn-plain { display: block; margin-left: auto; }
.top .who strong { color: var(--ink); display: block; font-size: 1rem; }
.online { display: inline-flex; align-items: center; gap: 6px; }
.online::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }

/* sale strip */
.sale { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 20px; }
.sale .label { color: var(--muted); }
.sale .count { font-family: var(--display); font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.sale.live { border-color: var(--lantern); }
.sale.live .count { color: var(--lantern); }

/* the big button */
.through {
  display: block; width: 100%; border: 0; cursor: pointer;
  padding: 22px 20px 20px; margin: 16px 0 8px;
  background: var(--lantern); color: var(--night);
  border-radius: var(--r-lg);
  font-family: var(--display); font-weight: 800; font-size: 1.75rem; line-height: 1.05; text-align: left;
  box-shadow: 0 7px 0 var(--lantern-deep);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.through small { display: block; font-family: var(--body); font-weight: 700; font-size: 0.95rem; margin-top: 6px; opacity: 0.8; }
.through:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--lantern-deep); }
.through:disabled { opacity: 0.55; cursor: progress; }

/* my status */
.me { padding: 18px 16px; background: var(--night-2); border-radius: var(--r-lg); }
.me .state { font-family: var(--display); font-weight: 600; font-size: 1.25rem; margin-bottom: 4px; }
.me.alert { background: var(--flag); color: #fff; animation: pulse 1.2s ease-in-out 3; }
.me.alert .muted { color: rgba(255, 255, 255, 0.85); }
.me.done { box-shadow: inset 4px 0 0 var(--mint); }
@keyframes pulse { 50% { transform: scale(1.015); } }

.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn {
  border: 1.5px solid var(--line); background: transparent; border-radius: var(--r-sm);
  padding: 10px 14px; cursor: pointer; font-weight: 700; min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
.btn.on { border-color: var(--mint); color: var(--mint); }
.btn-mint { background: var(--mint); border-color: var(--mint); color: var(--night); }
.btn-flag { border-color: var(--flag); color: var(--flag); }
.btn-plain { border: 0; padding: 6px 4px; min-height: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
.btn-sm { padding: 6px 10px; min-height: 36px; font-size: 0.875rem; }

/* booking panel */
.booking { border: 2px solid var(--lantern); border-radius: var(--r-lg); padding: 18px 16px; margin-bottom: 8px; }
.booking-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.booking-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; }
.timer { font-family: var(--display); font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--lantern); }
.timer.late { color: var(--flag); }
.person { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.person:first-of-type { border-top: 0; }
.person input[type=checkbox] { width: 22px; height: 22px; margin: 4px 0 0; accent-color: var(--mint); grid-row: span 3; }
.person .pname { font-weight: 700; }
.person .lead { color: var(--lantern); font-weight: 400; font-size: 0.875rem; margin-left: 6px; }
.field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field .k { color: var(--muted); font-size: 0.875rem; width: 72px; }
.field .v { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; word-break: break-all; }
.copy { border: 1px solid var(--line); background: var(--night-3); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 0.8125rem; font-weight: 700; }
.copy.done { border-color: var(--mint); color: var(--mint); }

/* tally */
.tally { margin: 24px 0 8px; }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--night-3); }
.bar span { display: block; height: 100%; transition: width 300ms ease; }
.bar .b { background: var(--mint); }
.bar .p { background: var(--flag); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 0.9375rem; }
.legend b { font-family: var(--display); font-size: 1.25rem; }
.dot[data-dot=mint] { background: var(--mint); }
.dot[data-dot=flag] { background: var(--flag); }
.admin-hint { margin-top: 28px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px 11px 14px;
  border-bottom: 1px solid var(--line); box-shadow: inset 3px 0 0 transparent; }
.list li.you { background: var(--night-2); }
.list li.s-booked { box-shadow: inset 3px 0 0 var(--mint); }
.list li.s-booking { box-shadow: inset 3px 0 0 var(--flag); }
.list li.s-queue { box-shadow: inset 3px 0 0 var(--lantern); }
.list .n { font-weight: 700; }
.list .sub { color: var(--muted); font-size: 0.875rem; }
.status { font-size: 0.875rem; white-space: nowrap; }
.s-booked .status { color: var(--mint); }
.s-booking .status { color: var(--flag); }
.s-queue .status { color: var(--lantern); }
.s-idle .status { color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.live-booking { padding: 12px 14px; border-left: 3px solid var(--flag); background: var(--night-2); margin-bottom: 8px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.live-booking .t { font-variant-numeric: tabular-nums; }

.log { list-style: none; padding: 0; margin: 0; font-size: 0.9375rem; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }

details { border-top: 1px solid var(--line); padding: 14px 0; }
details summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 1.125rem; }
details ol { padding-left: 1.25rem; margin: 12px 0 0; }
details li { margin-bottom: 8px; }

/* forms */
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
label .hint { font-weight: 400; color: var(--muted); font-size: 0.875rem; }
input[type=text], input[type=password], input[type=datetime-local] {
  width: 100%; padding: 12px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--night); font-size: 1.0625rem;
}
input:focus { border-color: var(--lantern); outline: none; }
.err { color: var(--flag); font-weight: 700; min-height: 1.5em; margin: 0; }

.gate { max-width: 420px; margin: 12vh auto 0; }
.gate h1 { font-size: 2.25rem; margin-bottom: 8px; }
.pick { display: grid; gap: 8px; margin: 16px 0; }
.pick button { text-align: left; padding: 14px 16px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--night-2); cursor: pointer; font-weight: 700; }
.pick button:hover { border-color: var(--lantern); }

dialog { border: 0; border-radius: var(--r-lg); background: var(--night-2); color: var(--ink); padding: 20px; width: min(460px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 9, 30, 0.7); }
dialog h2 { margin: 0 0 16px; }

.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); display: grid; gap: 8px; width: min(520px, calc(100vw - 24px)); z-index: 10; }
.toast { background: var(--ink); color: var(--night); padding: 12px 14px; border-radius: var(--r-sm); font-weight: 700; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
.toast.hot { background: var(--flag); color: #fff; }
.toast.good { background: var(--mint); }

.conn { position: fixed; top: env(safe-area-inset-top, 0); left: 0; right: 0; text-align: center; background: var(--flag); color: #fff; font-weight: 700; padding: 6px; z-index: 20; }

@media (min-width: 560px) {
  h1 { font-size: 2rem; }
  .through { font-size: 2.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
