:root {
  /* Dark theme — speeqr.com neutral grayscale (hue 0, 0% saturation). */
  --bg: #171717; --bg2: #1f1f1f; --panel: #262626; --line: #333333;
  --fg: #fafafa; --muted: #a3a3a3; --accent: #5b6bff; --accent2: #7d8bff;
  --good: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  /* Near-black "bar" surface for toolbar + topbar status badges (both themes). */
  --bar: #18181b; --bar-fg: #fafafa; --bar-line: #3a3a3a; --bar-muted: #a3a3a3;
  --radius: 16px; --font: 'Baloo 2', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
[data-theme="light"] {
  /* Light theme — speeqr.com neutral light: white cards, near-black ink. */
  --bg: #f5f5f5; --bg2: #ffffff; --panel: #ffffff; --line: #e3e3e3;
  --fg: #171717; --muted: #737373;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--font);
}
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
button { cursor: pointer; font-family: inherit; }

/* ───── Join ───── */
.join { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.join-card { width: 100%; max-width: 520px; }
.logo {
  text-align: center; margin: 0; font-size: 58px; font-weight: 800;
  letter-spacing: .5px; font-family: var(--font);
}
.tagline { text-align: center; color: var(--muted); margin: 6px 0 40px; font-size: 18px; }
.field { display: block; margin-bottom: 26px; font-weight: 700; font-size: 16px; }
.field input {
  display: block; width: 100%; margin-top: 12px; padding: 18px 20px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  color: var(--fg); font-size: 16px; font-weight: 400;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { outline: none; border-color: var(--accent2); }
.synthetic {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  margin: -8px 0 24px; font-size: 13px;
}
.synthetic input[type=number] { width: 76px; padding: 6px 8px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--fg); margin-left: auto; }
/* ───── DSP settings panel (join screen) ───── */
.dsp-panel {
  border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 26px; overflow: hidden;
}
.dsp-header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--bg2); border: 0; color: var(--fg);
  font-size: 14px; font-weight: 700; cursor: pointer; text-align: left;
}
.dsp-header:hover { background: var(--line); }
.dsp-caret { font-size: 11px; color: var(--muted); }
.dsp-settings { border-top: 1px solid var(--line); }
.dsp-settings.dsp-collapsed { display: none; }
.dsp-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.dsp-row:last-child { border-bottom: 0; }
.dsp-row-disabled { opacity: 0.45; }
.dsp-info { flex: 1; min-width: 0; }
.dsp-name { display: block; font-size: 13px; font-weight: 700; }
.dsp-desc { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
/* Pill toggle switch */
.toggle { position: relative; display: inline-flex; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  width: 42px; height: 24px; border-radius: 12px; background: var(--line);
  transition: background .2s; cursor: pointer; display: block;
}
.slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(18px); }
.toggle input:disabled + .slider { cursor: not-allowed; }

.primary {
  width: 100%; padding: 18px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
}
.primary:hover { background: var(--accent2); }
.primary.sm { width: auto; padding: 10px 16px; font-size: 14px; }
.err { color: var(--bad); text-align: center; min-height: 18px; margin-top: 12px; font-weight: 600; }
.status { color: var(--muted); text-align: center; min-height: 18px; margin-top: 12px; font-weight: 600; }

/* ───── App shell ───── */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.tb-center { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.tb-right { display: flex; align-items: center; gap: 8px; min-width: 180px; justify-content: flex-end; }
.meeting-name { font-size: 19px; font-weight: 700; }
.avatar {
  display: grid; place-items: center; border-radius: 50%; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
}
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
/* Uniform compact dark badges for the topbar status cluster (both themes). */
.badge {
  display: flex; align-items: center; gap: 7px; padding: 5px 12px;
  background: var(--bar); color: var(--bar-fg);
  border: 1px solid var(--bar-line); border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; flex: 0 0 auto;
}
.badge .lbl {
  color: var(--bar-muted); font-weight: 700; font-size: 10px; letter-spacing: .4px;
}
/* .pill keeps its name for the timer; visual comes from .badge. */
.pill { gap: 6px; }
.sync-pill .clock { color: var(--bar-muted); transition: color .3s; flex: 0 0 auto; }
.sync-pill.ready .clock { color: var(--good); }
.sync-pill .rtt { font-size: 12px; }
.gauge { gap: 8px; }
.bars { width: 24px; height: 16px; }
.bar { width: 64px; height: 7px; background: rgba(255,255,255,.14); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; transition: width .25s; }
.bar.cpu i { background: var(--warn); }
.aec-gauge { gap: 5px; }
.aec-chip {
  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .3px; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--bar-line); color: var(--bar-muted); white-space: nowrap;
}
.aec-chip.on  { color: #fff; background: var(--good); border-color: transparent; }
.aec-chip.off { color: var(--bar-muted); background: transparent; }
.icon {
  height: 38px; min-width: 38px; padding: 0 10px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--fg);
  font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.icon span { font-size: 12px; font-weight: 700; }
.icon:hover { border-color: var(--accent2); }

/* ───── Stage / rooms ───── */
.stage { flex: 1; overflow: auto; padding: 26px; }
.rooms { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.roomBox {
  display: flex; gap: 14px; padding: 18px 16px 16px; border-radius: 24px;
  border: 1px solid rgba(255,255,255,.06); position: relative;
}
.roomBox .room-label {
  position: absolute; top: -10px; left: 16px; font-size: 11px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line);
  color: var(--muted);
}
.roomBox .chirp-badge {
  position: absolute; top: -10px; right: 16px; font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line);
  color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.roomBox .chirp-badge.ready { color: var(--good); border-color: rgba(82,196,26,.4); }
.roomBox .chirp-badge:empty { display: none; }
.device { width: 120px; text-align: center; }
.device .ava-wrap { position: relative; width: 100px; height: 100px; margin: 0 auto; }
.device .ava {
  width: 100px; height: 100px; border-radius: 50%; display: grid; place-items: center;
  font-size: 46px; background: #2a3140; border: 3px solid transparent;
  transition: background .15s, box-shadow .15s;
}
.device.self .ava { background: #cfd6e4; }
/* Speaking: the avatar circle itself fills green (declared last so it wins
   over .self). The GCC alignment ring is a separate outer ring below. */
.device.speaking .ava {
  background: var(--good); box-shadow: 0 0 18px rgba(46,204,113,.45);
}
/* GCC synchronized: steady green ring OUTSIDE the avatar. */
.device.aligned .ava-wrap::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 3px solid var(--good); pointer-events: none;
}
.mic-badge {
  position: absolute; right: 4px; bottom: 4px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--good); display: grid; place-items: center; font-size: 13px;
  border: 3px solid var(--bg); color: #06210f;
}
.mic-badge.muted { background: var(--bad); color: #fff; }
.device .nm { margin-top: 8px; font-size: 14px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.device .nm small { color: var(--muted); font-weight: 400; }

/* ───── QR ───── */
.qr-card {
  position: fixed; left: 22px; bottom: 26px; background: #fff; color: #111;
  padding: 12px; border-radius: 14px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.qr-card img { width: 120px; height: 120px; display: block; }
.qr-card span { font-size: 12px; color: #333; display: block; margin-top: 6px; }

/* ───── Panels ───── */
.panel {
  position: fixed; top: 70px; right: 16px; bottom: 110px; width: 320px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 14px 50px rgba(0,0,0,.35);
}
.panel-head { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.panel-head .x { background: none; border: 0; color: var(--muted); font-size: 16px; }
.chat-log { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg .who { font-size: 11px; color: var(--muted); }
.chat-msg .body { background: var(--panel); padding: 8px 10px; border-radius: 10px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; color: var(--fg); }
.people-list { overflow: auto; padding: 8px; }
.people-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; }
.people-row:hover { background: var(--panel); }
.people-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.people-row .dot.on { background: var(--good); }
.people-row .rm { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ───── Toolbar ───── */
.toolbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--bar); border: 1px solid var(--bar-line); border-radius: 18px;
  box-shadow: 0 14px 50px rgba(0,0,0,.4);
}
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 62px; min-height: 52px;
  padding: 6px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--bar-fg);
}
.tool .ico { font-size: 18px; line-height: 1; }
.tool label { font-size: 11px; line-height: 1; pointer-events: none; }
.tool:hover { background: rgba(255,255,255,.08); }
.tool.off { color: var(--bar-fg); }
.tool.off .ico { background: var(--bad); border-radius: 8px; padding: 2px 6px; }
.tool.active { background: var(--accent); color: #fff; }
.tool.exit {
  background: var(--bad); color: #fff; min-width: 76px; min-height: 52px;
  padding: 0 20px; font-weight: 700;
}
.tool.exit:hover { background: #dc2626; }
.divider { width: 1px; height: 32px; background: var(--bar-line); margin: 0 6px; }
.help {
  position: fixed; right: 18px; bottom: 22px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: #000c; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  max-width: calc(100vw - 32px); text-align: center;
}

/* ───── Mobile / tablet ───── */
@media (max-width: 760px) {
  /* Join screen: tighter card, smaller logo */
  .join { padding: 16px; }
  .logo { font-size: 46px; }
  .tagline { margin: 4px 0 28px; font-size: 16px; }
  .field { margin-bottom: 18px; }
  .field input { padding: 14px 16px; }
  .primary { padding: 16px; }

  /* Topbar: let the three zones shrink and the stats overflow-scroll */
  .topbar { gap: 8px; padding: 8px 12px; }
  .tb-left { min-width: 0; flex: 0 1 auto; gap: 8px; }
  .tb-right { min-width: 0; gap: 6px; }
  .tb-center {
    min-width: 0; gap: 10px; margin: 0; flex: 1 1 auto;
    overflow-x: auto; justify-content: flex-end;
    scrollbar-width: none;
  }
  .tb-center::-webkit-scrollbar { display: none; }
  .meeting-name {
    font-size: 16px; max-width: 28vw; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .gauge .lbl { display: none; }            /* drop "CPU" label to save room */
  .badge { padding: 5px 10px; gap: 6px; }
  .bar { width: 48px; }
  .icon { height: 36px; min-width: 36px; padding: 0 8px; }

  /* Stage: less padding so tiles use the width */
  .stage { padding: 16px 12px 96px; }       /* bottom space for the toolbar */
  .rooms { gap: 14px; justify-content: center; }
  .roomBox { padding: 12px; gap: 6px; flex-wrap: wrap; justify-content: center; }
  .device { width: 92px; }
  .device .ava-wrap, .device .ava { width: 76px; height: 76px; }
  .device .ava { font-size: 34px; }

  /* Help button gets out of the way; QR stays visible (shrunk, lifted above
     the toolbar). */
  .help { display: none; }
  .qr-card { left: 12px; bottom: 84px; padding: 8px; }
  .qr-card img { width: 72px; height: 72px; }
  .qr-card span { font-size: 10px; margin-top: 4px; }

  /* Panels become near-fullscreen sheets */
  .panel {
    top: 62px; right: 12px; left: 12px; bottom: 84px; width: auto;
  }

  /* Toolbar: full-width, horizontally scrollable, compact tools */
  .toolbar {
    left: 12px; right: 12px; transform: none; bottom: 12px;
    justify-content: flex-start; gap: 4px; padding: 8px;
    overflow-x: auto; scrollbar-width: none; border-radius: 16px;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool { min-width: 56px; padding: 6px 6px; flex: 0 0 auto; }
  .tool .ico { font-size: 17px; }
  .tool.exit { min-width: 60px; padding: 10px 12px; }
  .divider { display: none; }
}

@media (max-width: 420px) {
  .tb-left .avatar.sm { display: none; }     /* reclaim space for the name */
  .gauge:has(.bar.cpu) { display: none; }    /* hide CPU bar on the narrowest phones */
  .meeting-name { max-width: 40vw; }
}
