:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f2f2ee;
  --border: #e4e3dc;
  --text: #1c1c1a;
  --muted: #6a6963;
  --accent: #2563c9;
  --accent-soft: #dde9fb;
  --accent-text: #123e86;
  --on-accent: #ffffff;
  --border-strong: #85847d;
  --ok: #1a6f40;
  --ok-soft: #d8f0e1;
  --warn: #8a5a00;
  --warn-soft: #fbecc8;
  --bad: #a3322a;
  --bad-soft: #f8dcd8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 10, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514;
    --surface: #1e1e1c;
    --surface-2: #272725;
    --border: #353532;
    --text: #efefea;
    --muted: #a3a29a;
    --accent: #6ea2ff;
    --accent-soft: #1e3050;
    --accent-text: #bcd3ff;
    --on-accent: #0b1f44;
    --border-strong: #74746d;
    --ok: #6fd69a;
    --ok-soft: #173826;
    --warn: #f0c25a;
    --warn-soft: #3a2f12;
    --bad: #ff9d93;
    --bad-soft: #43201c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 8px 14px;
  min-height: 36px;
  transition: background-color 0.12s, border-color 0.12s, transform 0.08s;
}
button:hover { background: var(--surface-2); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.switch-btn[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.moment-options button.missed { border-style: dashed; color: var(--muted); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); }
button.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 10px;
  min-height: 38px;
}
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; margin: 0; }
label.check input { width: auto; min-height: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card > h2 + * { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.banner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.focus { background: var(--text); color: var(--bg); }
.banner.focus button { background: var(--bg); color: var(--text); border-color: var(--bg); }

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
}
.brand-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

/* ---------- landing ---------- */
.landing { max-width: 960px; margin: 0 auto; padding: 56px 24px; display: grid; gap: 32px; }
.landing-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
.hero p { font-size: 17px; max-width: 46ch; margin-top: 12px; color: var(--muted); }
.bullets { margin: 16px 0 0; padding-left: 18px; color: var(--muted); display: grid; gap: 4px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar .title { font-weight: 600; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- host ---------- */
.host-wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 64px; display: grid; gap: 16px; }
.host-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 650; line-height: 1.15; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }
.code {
  font: 600 24px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
}
.link-box {
  background: var(--surface-2); border-radius: 9px; padding: 8px 10px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere;
}
.chart { width: 100%; height: 190px; display: block; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); opacity: 0.5; }
.chart .dip { fill: var(--warn-soft); }
.chart .seg-band { fill: var(--surface-2); }
.chart .seg-label { font-weight: 600; fill: var(--text); }
.chart .marker { stroke: var(--accent-text); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button {
  border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted);
  border-bottom: 2px solid transparent; padding: 8px 12px;
}
.tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

.bar-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr 36px; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.25s; }
.bar-row.right .bar > span { background: var(--ok); }
.bar-row.miss .bar > span { background: var(--muted); }
.words { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; }

.q-list { display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.q { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.q.answered { opacity: 0.6; }
.q .votes { min-width: 44px; text-align: center; }
.q .meta { font-size: 12px; color: var(--muted); }
.vote-btn { display: grid; justify-items: center; padding: 4px 8px; min-height: 0; line-height: 1.15; }
.vote-btn .n { font-weight: 600; }

.reaction-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.reaction-tile { text-align: center; padding: 10px 4px; background: var(--surface-2); border-radius: 10px; font-size: 12px; color: var(--muted); }
.reaction-tile b { display: block; font-size: 22px; color: var(--text); }

.suggestion { display: grid; gap: 10px; }
.suggestion .row { gap: 6px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* ---------- attendee ---------- */
.att-wrap { max-width: 1100px; margin: 0 auto; padding: 16px 20px 64px; display: grid; gap: 14px; }
.att-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.att-tabs { display: none; }
.react-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.react-bar button { display: grid; gap: 2px; justify-items: center; padding: 10px 4px; font-size: 12px; }
.react-bar button .emoji { font-size: 20px; line-height: 1; }
.moment-options { display: grid; gap: 8px; }
.moment-options button { text-align: left; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { font-size: 18px; font-weight: 600; }
.bingo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bingo button { min-height: 58px; font-size: 13px; line-height: 1.2; padding: 6px; }
.bingo button.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.score { display: flex; justify-content: space-between; align-items: baseline; background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.score b { font-size: 24px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.checklist { display: grid; gap: 6px; }
.disclosure { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; font-size: 14px; }
.disclosure ul { margin: 0; padding-left: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20;
  max-width: calc(100vw - 32px);
}
.center-card { max-width: 440px; margin: 10vh auto 0; padding: 0 16px; display: grid; gap: 14px; }

@media (max-width: 1000px) {
  .host-grid, .landing-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .att-grid { grid-template-columns: 1fr; }
  .att-tabs { display: flex; position: sticky; top: 49px; z-index: 4; background: var(--bg); padding-top: 4px; margin: 0; }
  .att-grid > .col[data-panel] { display: none; }
  .att-grid[data-active="live"] > .col[data-panel="live"],
  .att-grid[data-active="play"] > .col[data-panel="play"] { display: grid; }
}

@media (max-width: 560px) {
  .topbar, .host-wrap, .att-wrap { padding-left: 14px; padding-right: 14px; }
  .tiles { grid-template-columns: 1fr; }
  .invite { grid-template-columns: 1fr; }
  .invite-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- mini window (floating or pop-up) ---------- */
body.mini { padding: 0; background: var(--bg); overflow: hidden; }
.mini-pill { display: flex; align-items: center; gap: 8px; height: 100vh; min-height: 56px; padding: 0 10px 0 14px; background: var(--surface); }
.mini-open { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; min-height: 40px; padding: 0; }
.mini-status { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.mini-status.attn { color: var(--accent-text); }
.mini-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.mini-pill .dot.new { animation: ping 1.6s ease-out 2; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.icon-btn { width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mini-card { height: 100vh; display: flex; flex-direction: column; position: relative; }
.mini-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.mini-head .t { flex: 1; min-width: 0; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-head .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.mini-tabs { display: flex; gap: 2px; padding: 6px 10px 0; }
.mini-tabs button { border: 0; background: transparent; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; min-height: 30px; padding: 4px 10px; font-size: 13px; }
.mini-tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.mini-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; display: grid; gap: 10px; align-content: start; }
.mini-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; display: grid; gap: 8px; }
.mini-auto { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.mini-note { position: absolute; inset: 0; z-index: 2; background: color-mix(in srgb, var(--bg) 94%, transparent); display: grid; align-content: center; gap: 10px; padding: 18px; }
.mini .react-bar button { padding: 6px 2px; font-size: 10.5px; min-height: 0; }
.mini .bingo button { min-height: 44px; font-size: 11.5px; }

/* ---------- topics, pinned questions, join screen ---------- */
.q.pinned { border-color: var(--accent); background: var(--accent-soft); }
.prepared { padding: 4px 0 4px 12px; border-left: 2px solid var(--border-strong); }
.prepared.used { opacity: 0.65; }
.join-dialog { border: 1px solid var(--border); border-radius: 16px; padding: 28px; text-align: center; background: var(--surface); color: var(--text); max-width: 420px; }
.join-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.join-dialog img { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 10px; }
.join-dialog { width: min(420px, calc(100vw - 32px)); overflow-wrap: anywhere; }
.join-dialog p, .join-dialog code, .join-dialog a { overflow-wrap: anywhere; word-break: break-word; }
.join-dialog img { max-width: 100%; height: auto; }
button.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
.join-short { font-size: 30px; font-weight: 700; letter-spacing: 0.04em; margin: 6px 0; }

/* ---------- polish: links, invite bar, folds, landing, attendee ---------- */
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.topbar a, .landing header a { font-size: 14px; }
.brand { text-decoration: none; color: var(--text); }

.invite { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 14px 18px; }
.invite-id { display: grid; gap: 2px; }
.invite-link { display: grid; gap: 4px; min-width: 0; }
.invite-actions { justify-content: flex-end; flex-wrap: wrap; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.button-like {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 14px;
}
.button-like:hover { background: var(--surface-2); }
.menu[open] > .button-like { background: var(--surface-2); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; min-width: 230px;
  display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(20, 20, 10, 0.16);
}
.menu-pop button { text-align: left; justify-content: flex-start; border: 0; width: 100%; }
.danger-text { color: var(--bad); }

.fold > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2::after { content: "  ▾"; color: var(--muted); font-size: 13px; font-weight: 500; }
.fold[open] > summary h2::after { content: "  ▴"; }
.fold[open] > summary { margin-bottom: 12px; }
.fold > .stack { gap: 16px; }

.steps { margin: 22px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); max-width: 46ch; }
.steps b { color: var(--text); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

#games-card.idle #bingo, #games-card.idle #pred-question, #games-card.idle #pred-buttons, #games-card.idle #pred-note { display: none; }
#games-card.idle h3 { display: none; }
#games-card.idle .score { margin-top: 10px !important; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; position: static; }
  .topbar > .row { flex-wrap: wrap; gap: 8px; }
  .topbar .title { max-width: 60vw; }
  .att-tabs { top: 0; }
  .react-bar button { font-size: 11px; }
}

/* ---------- people ---------- */
.people { display: grid; gap: 4px; margin-top: 8px; max-height: 320px; overflow: auto; }
.person-row {
  display: grid; grid-template-columns: minmax(120px, 1.2fr) auto 1fr; gap: 12px; align-items: center;
  text-align: left; border: 1px solid transparent; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; min-height: 44px;
}
.person-row:hover { border-color: var(--border-strong); }
.person-row .muted { text-align: right; }
.person-dialog { border: 1px solid var(--border); border-radius: 16px; padding: 22px; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 24px)); max-height: 88vh; overflow: auto; }
.person-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 8px; }
.bar-col { flex: 1; min-width: 14px; max-width: 44px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.bar-col span { display: block; width: 100%; min-height: 3px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col small { font-size: 10px; color: var(--muted); }
@media (max-width: 700px) { .person-row { grid-template-columns: 1fr; gap: 4px; } .person-row .muted { text-align: left; } }

/* ---------- embedded (Google Meet side panel) ---------- */
.panel { max-width: 480px; margin: 0 auto; padding: 12px; display: grid; gap: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel .tile .value { font-size: 24px; }
.panel .banner { flex-wrap: wrap; }
body.embed .topbar { padding: 8px 12px; gap: 8px; position: static; }
body.embed .topbar .title { max-width: 55vw; font-size: 14px; }
body.embed .att-wrap { padding: 10px 12px 40px; }
body.embed .att-tabs { top: 0; }
body.embed .card { padding: 14px; }

/* ---------- host tools inside the Meet side panel ---------- */
[data-feature][data-off] { display: none !important; }
body:not(.embed) [data-feature="export"] { display: none; }
.feature-bar { display: none; gap: 6px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0; }
body.embed .feature-bar { display: grid; }
.feature-bar label { margin: 0; font-size: 12px; color: var(--muted); }
.feature-bar select { font-weight: 600; }
body.embed .host-wrap { padding: 10px 12px 40px; gap: 12px; }
body.embed .host-grid { grid-template-columns: 1fr; }
body.embed .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
body.embed .tile { padding: 10px; }
body.embed .tile .value { font-size: 20px; }
body.embed .tile .sub { display: none; }
body.embed .invite { grid-template-columns: 1fr; }
body.embed .invite-actions { justify-content: flex-start; }
body.embed .topbar > .row:first-child .title { max-width: 40vw; }
body.embed #account, body.embed #role-chip, body.embed #clock-reset { display: none; }
.confirm-dialog { width: min(360px, calc(100vw - 24px)); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

/* participant: one prompt at a time, then back to the meeting */
body.prompting .att-tabs, body.prompting .att-grid > .col > .card:not(.moment-card), body.prompting #banners { display: none; }
body.prompting .moment-card { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.done-note { text-align: center; padding: 18px 12px; }
.done-note b { display: block; font-size: 18px; margin-bottom: 4px; }
body.embed #moment-card { order: -1; }

#link { user-select: all; overflow-wrap: anywhere; }

/* the Meet panel is a thin shell: the host or participant view lives in a frame inside it */
body.app-open .panel-head { display: none; }
body.app-open .panel { max-width: none; padding: 0; gap: 0; height: 100vh; }
#state-app { height: 100vh; }
#app-frame { display: block; width: 100%; height: 100%; border: 0; }
