/* Shared by every page: design tokens, base elements, buttons, form controls, toasts, overlays. */

:root {
  --bg: #0b0d12;
  --card: #151924;
  --card-2: #1b2030;
  --line: #262c3b;
  --text: #e9ebf2;
  --muted: #8d95a9;
  --accent: #8b6cff;
  --accent-2: #22d3ee;
  --accent-ink: #ffffff;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #ff5d6c;
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
kbd {
  font: 12px var(--mono);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); letter-spacing: 0.06em; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.spacer, .grow { flex: 1; }

/* Timer colours: elements set data-tone="ok|warn|over" and read var(--tone). */
:root [data-tone='warn'] { --tone: var(--warn); }
:root [data-tone='over'] { --tone: var(--danger); }

select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
select:focus { border-color: var(--accent); }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
}
.btn:hover { border-color: #3a4256; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: #9a80ff; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--card-2); color: var(--danger); }

.field { display: grid; gap: 5px; margin-top: 12px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
input:not([type]), input[type='text'], .field input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  outline: none;
}
.field input:focus, .code-form input:focus { border-color: var(--accent); }

.form-error { color: var(--danger); }

/* A row of mutually exclusive options; the chosen button gets .active (see markActive). */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented button { height: 30px; border: 0; border-radius: 7px; background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset; }

.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }


.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15); }

.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.15s; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; letter-spacing: -0.02em; text-decoration: none; font-size: 17px; }
.brand-mark {
  width: 14px; height: 24px; border-radius: 5px;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  position: relative;
}
.brand-mark::after { content: ''; position: absolute; left: 4px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--bg); }
.brand.big { font-size: 20px; }

/* ---------- Top bar & cards (presenter and admin pages) ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: rgba(11, 13, 18, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}
.card > h2 + * { margin-top: 10px; }

/* ---------- Toasts & overlays ---------- */

.toasts {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 100;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: 11px;
  background: #222838;
  border: 1px solid #323a50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  text-align: center;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.error { border-color: rgba(255, 93, 108, 0.5); }
.toast.warn { border-color: rgba(251, 191, 36, 0.45); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.overlay {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(5, 6, 10, 0.8);
  backdrop-filter: blur(6px);
}
.overlay-card {
  width: min(400px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  display: grid; gap: 14px;
  text-align: center;
}
.overlay-card h2 { font-size: 20px; }
