/* Session Pulse — shared styles for the audience board, the presenter console and the /join pages. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #fafbfc;
  --text: #15171c;
  --text-2: #3b414c;
  --muted: #5a6170;
  --faint: #8a909c;
  --border: #e2e5ea;
  --border-strong: #c9ced6;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-text: #ffffff;
  --accent-soft: #eef0ff;
  --accent-soft-text: #3730a3;
  --accent-ring: #a5adf5;
  --green: #0f7a4a;
  --green-soft: #e3f4ea;
  --green-dot: #12a15a;
  --red: #b42318;
  --red-soft: #fdecea;
  --red-border: #ebc8c3;
  --amber: #a15c07;
  --amber-strong: #7a4405;
  --amber-soft: #fef2df;
  --amber-border: #f3c98b;
  --track: #eef0f3;
  --count-bg: #e6e8ec;
  --toast-bg: #15171c;
  --toast-text: #ffffff;
  --toast-action: #c7cbff;
  --shadow: 0 1px 2px rgb(21 23 28 / 0.04), 0 12px 32px rgb(21 23 28 / 0.06);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --surface: #171a21;
    --surface-muted: #14171d;
    --text: #eceef2;
    --text-2: #c9ced8;
    --muted: #a0a7b4;
    --faint: #737a87;
    --border: #2a2f3a;
    --border-strong: #3b414e;
    --accent: #8b93ff;
    --accent-hover: #a5abff;
    --accent-text: #0b0d12;
    --accent-soft: #232750;
    --accent-soft-text: #c7cbff;
    --accent-ring: #5d64c9;
    --green: #4ade80;
    --green-soft: #12301f;
    --green-dot: #34d27b;
    --red: #f87171;
    --red-soft: #3a1513;
    --red-border: #5c2321;
    --amber: #fbbf63;
    --amber-strong: #fcd28d;
    --amber-soft: #3a2a10;
    --amber-border: #6b4a14;
    --track: #22262f;
    --count-bg: #2a2f3a;
    --toast-bg: #eceef2;
    --toast-text: #15171c;
    --toast-action: #3730a3;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.35);
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, p { margin: 0; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---------- Layout ---------- */

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 32px; }
.container.narrow { max-width: 480px; padding: 0 16px; }
@media (max-width: 640px) { .container { padding: 0 16px; } }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
}
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 700; }
.brand-title { font-size: 19px; font-weight: 700; line-height: 1.25; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 600 15px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { color: var(--red); border-color: var(--red-border); }
.btn-danger:hover { color: var(--red); border-color: var(--red); }
.btn-lg { min-height: 52px; border-radius: 12px; font-size: 17px; font-weight: 700; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 700; }
.label .optional { font-weight: 400; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.input, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1.5px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font: 16px var(--font);
}
.textarea { min-height: 88px; padding: 12px 14px; line-height: 1.45; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.input.code { min-height: 52px; font: 700 20px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.input.code.warn { border-color: var(--amber-border); }

.password-field { display: flex; align-items: center; border: 1.5px solid var(--border-strong); border-radius: 12px; background: var(--surface); padding-right: 4px; }
.password-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.password-field .input { border: 0; box-shadow: none; min-height: 50px; font: 600 20px var(--mono); letter-spacing: 0.14em; }
.icon-btn { flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--track); color: var(--text); }

.form-error { font-size: 14px; color: var(--red); }
.form-error:empty { display: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.badge-mine { background: var(--accent-soft); color: var(--accent-soft-text); }
.badge-answered { background: var(--green-soft); color: var(--green); }

.live { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 700; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--green-dot); }
.live.offline { background: var(--amber-soft); color: var(--amber); }
.live.offline::before { background: var(--amber); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 0; right: 0; bottom: 28px; z-index: 10; width: max-content; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 18px; min-height: 52px; border-radius: 12px;
  background: var(--toast-bg); color: var(--toast-text); font-size: 15px;
  box-shadow: 0 12px 32px rgb(21 23 28 / 0.25);
  animation: toast-in 160ms ease-out;
}
.toast:not(:has(.toast-action)) { padding-right: 18px; }
.toast-icon { display: inline-flex; color: var(--green-dot); }
.toast-action { min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--toast-action); font: 700 15px var(--font); cursor: pointer; }
.toast-action:hover { background: color-mix(in srgb, var(--toast-action) 15%, transparent); }
.toast.error { background: var(--red); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Audience board ---------- */

.aud-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 0; }
.aud-header .container { display: flex; flex-direction: column; gap: 6px; }
.aud-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.aud-title { font-size: 21px; line-height: 1.25; font-weight: 800; }

.aud-main { padding: 16px 0 96px; }
.aud-main .container { display: flex; flex-direction: column; gap: 18px; }

.composer { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-send { display: flex; gap: 10px; }
.composer-send .input { flex: 1; min-width: 0; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--red); font-weight: 700; }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.list-head h2 { font-size: 17px; font-weight: 700; }

.a-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.a-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.a-card.mine { border: 1.5px solid var(--accent-ring); }
.a-card.answered { background: var(--surface-muted); }
.a-card.answered .a-text { color: var(--text-2); }
.a-text { font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.a-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); }

/* Join form and the /join pages */
.join-page { padding: 28px 0 48px; }
.join-page .container { display: flex; flex-direction: column; gap: 28px; }
.join-hero { display: flex; flex-direction: column; gap: 8px; }
.join-hero h1 { font-size: 30px; line-height: 1.15; font-weight: 800; }
.join-card { display: flex; flex-direction: column; gap: 14px; padding: 22px 20px; border-radius: 16px; }
.join-card > div { display: flex; flex-direction: column; gap: 4px; }
.join-card h2 { font-size: 19px; font-weight: 700; }
.join-card p { font-size: 15px; color: var(--muted); }
.notice-icon { width: 48px; height: 48px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; }
.notice-icon.warn { background: var(--amber-soft); color: var(--amber); }
.notice-icon.locked { background: var(--red-soft); color: var(--red); }
.notice-icon.wait { background: var(--accent-soft); color: var(--accent-soft-text); }
.notice-title { font-size: 23px; font-weight: 800; }
.reassure { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.reassure li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.reassure svg { flex-shrink: 0; margin-top: 2px; color: var(--green); }

/* ---------- Presenter ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.login-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.login-card { display: flex; flex-direction: column; gap: 18px; padding: 32px 28px; border-radius: 18px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-foot { text-align: center; font-size: 14px; color: var(--muted); }

.console { padding: 28px 0 112px; }
.console .container { display: flex; flex-direction: column; gap: 28px; }

.doors { display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; padding: 20px 24px; }
.doors-info { display: flex; align-items: center; gap: 20px 28px; flex-wrap: wrap; min-width: 0; }
.doors-status { display: flex; align-items: center; gap: 14px; }
.doors-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.doors-title { font-size: 17px; font-weight: 700; }
.doors-sub { font-size: 14px; color: var(--muted); }
.doors[data-state="open"] .doors-icon { background: var(--green-soft); color: var(--green); }
.doors[data-state="open"] .doors-title { color: var(--green); }
.doors[data-state="locked"] .doors-icon { background: var(--red-soft); color: var(--red); }
.doors[data-state="locked"] .doors-title { color: var(--red); }
.doors .lock-open, .doors .lock-closed { display: none; }
.doors[data-state="open"] .lock-open, .doors[data-state="locked"] .lock-closed { display: block; }
.doors-code { display: flex; flex-direction: column; gap: 2px; padding-left: 28px; border-left: 1px solid var(--border); }
.doors-code strong { font: 700 18px var(--mono); letter-spacing: 0.04em; }
.doors-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--track); border-radius: 12px; }
.segmented button { min-height: 40px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 15px var(--font); cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); font-weight: 700; box-shadow: 0 1px 3px rgb(21 23 28 / 0.14); }
.segmented button[data-doors="open"][aria-pressed="true"] { color: var(--green); }
.segmented button[data-doors="locked"][aria-pressed="true"] { color: var(--red); }

.tabs-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; margin-bottom: -1px;
  border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted);
  font: 600 16px var(--font); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.tab-count { min-width: 24px; padding: 2px 8px; border-radius: 999px; background: var(--count-bg); color: var(--text-2); font-size: 13px; font-weight: 700; text-align: center; }
.tab[aria-selected="true"] .tab-count { background: var(--accent); color: var(--accent-text); }
.tabs-meta { display: inline-flex; align-items: center; gap: 8px; padding-bottom: 14px; font-size: 14px; color: var(--muted); }
.tabs-meta::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--green-dot); }

.q-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.q-card { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 18px 20px; }
.q-body { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.q-text { font-size: 17px; line-height: 1.45; overflow-wrap: anywhere; }
.q-meta { font-size: 14px; color: var(--muted); }
.q-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 24px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty svg { color: var(--faint); }
.empty p { max-width: 420px; font-size: 15px; color: var(--muted); }
.q-section { display: flex; flex-direction: column; gap: 16px; }
