:root {
  /* The theme (S6). Dark only. Every colour a page uses is here or a group colour from /e/{slug}/groups.css.
     Contrast on --bg and --surface: text, muted, accent, danger, ok >= 4.5:1 (tests/test_ui_css.py). */
  --bg: #0b0e14;
  --surface: #161b26;
  --surface-2: #1e2534;
  --line: #2e3648;
  --text: #f2f4f8;
  --muted: #a9b3c4;
  --accent: #ffd23f;
  --accent-ink: #0b0e14;
  --danger: #ff8080;
  --ok: #4fe0a5;
  --shade: rgba(0, 0, 0, 0.45);
  --qr-bg: #ffffff;
  --panel: var(--surface); /* older name, still used by host pages */
  --tap: 48px;
  --nav-h: 64px;
  --radius: 14px;
  --gc: var(--accent);
  --gink: #0b0e14;
  --gclip: circle(50% at 50% 50%);
  color-scheme: dark;
}

/* ---- the page ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
img, svg, video { max-width: 100%; }
img { height: auto; }
.page { max-width: 36rem; margin: 0 auto; padding: 1rem 1rem 2rem; }
.player .page { padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
h1 { font-size: 1.75rem; line-height: 1.15; margin: 0.5rem 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; line-height: 1.2; margin: 1.5rem 0 0.75rem; }
p { margin: 0 0 1rem; }
.lead { font-size: 1.15rem; color: var(--text); }
.muted { color: var(--muted); }
.kicker { margin: 0 0 0.25rem; color: var(--muted); font-size: 1.125rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; }
a { color: var(--accent); text-underline-offset: 0.15em; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
strong { font-weight: 800; }

/* ---- focus: always visible ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible, .button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}

/* ---- controls: at least 48px high ---- */
button, .button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--tap); min-width: var(--tap); padding: 0 1.25rem;
  border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; text-align: center;
  touch-action: manipulation;
}
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: transparent; color: var(--text); border: 2px solid var(--line); }
button.danger, .button.danger { background: var(--danger); color: var(--accent-ink); }
button[disabled] { opacity: 0.55; cursor: not-allowed; }
.button.wide, button.wide { width: 100%; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 0.6rem 0.85rem;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="file"] { padding: 0.55rem; }
input::placeholder { color: var(--muted); }
label { display: block; font-weight: 700; margin: 1rem 0 0.4rem; }
.side-link { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; }
.hint { color: var(--muted); font-size: 1.125rem; margin: 0.4rem 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  margin: 0 0 1rem; }
.card > :last-child { margin-bottom: 0; }

/* the primary action of a screen sits low, in thumb reach, above the bottom navigation */
.primary-action {
  position: sticky; bottom: calc(var(--nav-h) + 0.75rem + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; width: 100%; min-height: 56px; font-size: 1.15rem; margin: 1rem 0;
  box-shadow: 0 6px 20px var(--shade);
}
body:not(.player) .primary-action { bottom: calc(0.75rem + env(safe-area-inset-bottom)); }

/* ---- flash messages and the event banner ---- */
.flashes { max-width: 36rem; margin: 0 auto; padding: 0.75rem 1rem 0; }
.flash { padding: 0.8rem 1rem; border-radius: var(--radius); background: var(--surface);
  border-left: 6px solid var(--accent); font-weight: 600; }
.flash-ok { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); }
.banner { padding: 0.7rem 1rem; text-align: center; font-weight: 800; background: var(--accent);
  color: var(--accent-ink); }
.banner-closed { background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--line); }

/* ---- bottom navigation: five places, always there ---- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-weight: 700; font-size: 1.125rem;
  line-height: 1.1; min-width: 0; letter-spacing: -0.01em;
}
.bottom-nav .icon { width: 26px; height: 26px; }
.bottom-nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 3px 0 var(--gc); }
.bottom-nav a[aria-current="page"] .icon { color: var(--gc); }

/* ---- icons and group shapes (sprite: /static/img/shapes.svg) ---- */
.icon { display: inline-block; width: 1.25em; height: 1.25em; flex: none; color: inherit; }
.shape { display: inline-block; width: 1em; height: 1em; flex: none; fill: var(--gc); vertical-align: -0.12em; }
.gfill { background: var(--gc); color: var(--gink); }
.gfill .shape { fill: var(--gink); }
.gname { display: inline-flex; align-items: center; gap: 0.35em; font-weight: 700; white-space: nowrap; }
/* older marker, kept for host pages */
.gmark { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; background: var(--gc);
  clip-path: var(--gclip); }

/* ---- QR codes are inline SVG on white ---- */
svg.qr, img.qr { display: block; width: 100%; max-width: 280px; height: auto; background: var(--qr-bg);
  border-radius: 10px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- plain pages (join, recover, errors) ---- */
.plain-head { display: flex; align-items: center; gap: 0.6rem; margin: 0.5rem 0 1.5rem; }
.plain-head .brand { color: var(--muted); font-weight: 800; font-size: 1.125rem; letter-spacing: 0.14em;
  text-transform: uppercase; }
.plain-head .icon { color: var(--accent); width: 28px; height: 28px; }
.stamp { display: inline-block; padding: 0.2rem 0.6rem; border: 2px solid var(--accent); border-radius: 6px;
  color: var(--accent); font-weight: 800; font-size: 1.125rem; letter-spacing: 0.12em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
