:root {
  --bg: #eef3f9;
  --card: #ffffff;
  --surface: #f6f8fc;
  --line: #dce4ef;
  --text: #172033;
  --muted: #6c7a90;
  --accent: #1976ed;
  --accent-2: #18b982;
  --warn: #ee941b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
  overflow-x: hidden;
}
.card {
  max-width: 460px; margin: auto; padding: 28px 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  width: calc(100% - 32px); min-width: 0; align-self: center;
  box-shadow: 0 24px 70px rgba(42, 63, 94, .14);
}
h1 { margin: 0 0 4px; font-size: 28px; }
h1::first-letter { color: var(--accent); }
h2, h3, p { margin-top: 0; }
.tag { color: var(--muted); margin: 0 0 20px; }
label { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
input {
  width: 100%; margin-top: 6px; padding: 12px 14px; font-size: 16px;
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
}
select {
  width: 100%; padding: 11px 36px 11px 12px; font: inherit;
  color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
}
.roles { display: grid; gap: 10px; margin-top: 18px; }
button {
  padding: 14px 16px; font-size: 16px; font-weight: 600; cursor: pointer;
  border-radius: 10px; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: #fff; }
button.ghost { background: #fff; color: var(--text); border-color: var(--line); }
button.talk { background: var(--accent-2); color: #04120c; }
button.talk.live { background: #ff5d5d; color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.hint, .status { color: var(--muted); font-size: 13px; }
.hint { margin-top: 16px; }
.join-error { min-height: 20px; margin: 10px 0 0; color: #ff8585; font-size: 13px; }
.meeting-hint { padding: 0 14px 14px; margin: 0; }
.notice {
  margin: 10px 12px 0; padding: 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; border: 1px solid var(--warn);
  border-radius: 12px; background: #fff7ea;
  box-shadow: 0 8px 24px rgba(51, 70, 98, .08);
}
.notice > div { min-width: 0; display: grid; }
.notice strong { color: #9d5700; }
.notice small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.notice button { flex: 0 0 auto; padding: 10px 12px; }
.mic-invite { border-color: var(--accent-2); background: #eafaf4; }
.mic-invite strong { color: #087652; }
.caption-overlay {
  position: absolute; z-index: 2; left: 5%; right: 5%; bottom: 18px;
  padding: 8px 12px; border-radius: 8px; background: rgba(0, 0, 0, .78);
  color: #fff; font-size: clamp(15px, 2.4vw, 24px); font-weight: 700;
  line-height: 1.3; text-align: center; text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* meeting layout */
.stage {
  flex: 1; display: flex; flex-direction: column; width: 100%; min-width: 0;
  max-width: 960px; margin: 0 auto; background: var(--card);
  box-shadow: 0 0 60px rgba(42, 63, 94, .12);
}
.videowrap {
  position: relative; background: #10151d; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: min(42vh, 520px); aspect-ratio: 16 / 9;
}
.videowrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.overlay { position: absolute; top: 10px; left: 10px; right: 10px; display: flex;
  justify-content: space-between; gap: 8px; pointer-events: none; }
.overlay-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.presentation-label {
  max-width: min(52vw, 420px); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; background: rgba(18, 68, 58, .86);
}
.pill { background: rgba(0,0,0,.55); padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.controls {
  display: flex; gap: 10px; padding: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); background: var(--card);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.controls button { flex: 1; min-width: 120px; }
.roster { padding: 14px; border-top: 1px solid var(--line); background: var(--surface); }
.roster h3 { margin: 6px 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.roster ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.roster li {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; min-width: min(100%, 250px);
}
.roster li.hand { border-color: var(--warn); color: #a65a00; background: #fff8ed; }
.roster li.speaking { border-color: var(--accent-2); color: #087652; background: #edfaf5; }
.person-details { display: grid; line-height: 1.25; }
.person-details small { color: var(--muted); font-size: 11px; }
.roster li button { padding: 7px 10px; font-size: 12px; flex: 0 0 auto; }
.allow-person { background: var(--accent-2); color: #04120c; }
.mute-person { background: transparent; color: #ff8585; border-color: #6e3038; }

.presenter {
  padding: 18px 14px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.presenter-heading, .queue-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.presenter-heading h2 { margin: 0; font-size: 20px; }
.eyebrow {
  margin: 0 0 2px; color: var(--accent-2); font-size: 11px;
  font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.mode-badge {
  flex: 0 0 auto; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); font-size: 12px;
}
.mode-badge.live { color: #087652; border-color: #8dd8bd; background: #e7f8f2; }
.presenter-actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin-top: 14px;
}
.action-tile {
  min-height: 68px; margin: 0; padding: 10px 12px; display: flex;
  align-items: center; gap: 10px; text-align: left; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 14px rgba(46, 72, 105, .05);
  cursor: pointer;
}
.action-tile:hover, .action-tile:focus-visible { border-color: var(--accent); }
.action-icon {
  width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center;
  border-radius: 8px; background: #e8f1ff; color: var(--accent); font-size: 18px;
}
.action-tile span:last-child { display: grid; min-width: 0; }
.action-tile strong { font-size: 13px; line-height: 1.25; }
.action-tile small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.25; }
.link-form {
  margin-top: 12px; padding: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
}
.link-form label { margin: 0 0 6px; }
.link-form > div { display: flex; align-items: stretch; gap: 8px; }
.link-form input { margin: 0; min-width: 0; }
.link-form button { flex: 0 0 auto; }
.link-form .join-error { margin-bottom: 0; }
.switcher-settings {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin-top: 12px;
}
.switcher-settings label {
  margin: 0; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff;
}
.switcher-settings label > span {
  display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.queue-heading { margin-top: 16px; }
.queue-heading h3 {
  margin: 0; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em;
}
.queue-heading h3 span {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  margin-left: 4px; border-radius: 999px; background: #e4ebf5; color: var(--text);
}
.text-button {
  padding: 4px; background: transparent; border: 0; color: #ff8585; font-size: 12px;
}
.presentation-queue {
  max-height: 180px; margin: 8px 0 0; padding: 0; overflow-y: auto;
  list-style: none; display: grid; gap: 6px;
}
.presentation-queue li {
  display: flex; align-items: center; gap: 10px; min-height: 50px;
  padding: 7px 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 9px;
}
.presentation-queue li.active { border-color: var(--accent); background: #edf5ff; }
.presentation-queue .queue-empty {
  display: block; padding: 12px; color: var(--muted); font-size: 12px; text-align: center;
}
.queue-thumb {
  width: 44px; height: 36px; flex: 0 0 44px; display: grid; place-items: center;
  overflow: hidden; border-radius: 6px; background: #e7edf6; color: var(--muted);
  font-size: 11px; text-transform: uppercase;
}
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-copy { min-width: 0; flex: 1; display: grid; }
.queue-copy strong, .queue-copy small {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue-copy strong { font-size: 13px; }
.queue-copy small { color: var(--muted); font-size: 11px; }
.queue-select, .queue-remove {
  flex: 0 0 auto; width: 34px; height: 34px; padding: 0; display: grid;
  place-items: center; background: transparent; border-color: var(--line);
}
.queue-remove { color: #ff8585; }
.presentation-controls {
  display: grid; grid-template-columns: 48px 1fr 48px 1fr 1fr;
  gap: 7px; margin-top: 10px;
}
.presentation-controls button { min-width: 0; padding: 10px 8px; font-size: 13px; }
.icon-command { font-size: 20px !important; }
.presenter-help { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.automation-controls {
  margin-top: 10px; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff;
}
.automation-controls > button { width: 100%; padding: 10px; }
.toggle-row {
  margin: 10px 0 0; display: flex; align-items: flex-start; gap: 9px;
  color: var(--text); font-size: 12px; cursor: pointer;
}
.toggle-row input { width: 18px; height: 18px; margin: 0; flex: 0 0 18px; }

.room-chat {
  padding: 16px 14px; border-top: 1px solid var(--line); background: var(--surface);
}
.room-chat-heading h3 { margin: 0; font-size: 17px; }
.chat-log {
  max-height: 220px; min-height: 68px; margin-top: 10px; padding: 8px;
  overflow-y: auto; border: 1px solid var(--line); border-radius: 10px;
  background: #fff;
}
.chat-empty { margin: 14px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.chat-message {
  margin: 0 0 8px; padding: 8px 10px; border-radius: 9px; background: #eef3fa;
  font-size: 13px; overflow-wrap: anywhere;
}
.chat-message:last-child { margin-bottom: 0; }
.chat-message.own { background: #e7f8f2; }
.chat-message.media { border: 1px solid #31537c; }
.chat-message strong { display: block; margin-bottom: 2px; color: #185eb6; font-size: 11px; }
.chat-message small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.chat-compose { display: flex; align-items: stretch; gap: 8px; margin-top: 8px; }
.chat-compose input { min-width: 0; margin: 0; }
.chat-compose button { flex: 0 0 auto; padding: 10px 14px; }
.share-photo {
  margin: 10px 0 0; padding: 11px; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  background: #fff; cursor: pointer;
}
.share-photo > span:first-child { font-size: 22px; }
.share-photo > span:last-child { display: grid; }
.share-photo small { color: var(--muted); font-size: 11px; }
.presentation-sources {
  position: fixed; left: -10000px; top: 0; width: 960px; height: 540px;
  overflow: hidden; pointer-events: none;
}
.presentation-sources video, .presentation-sources img,
.presentation-sources canvas { width: 960px; height: 540px; }

/* camera-first caster shell */
body.caster-page {
  display: block;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  background: #eaf0f7;
}
.caster-stage {
  min-height: calc(100dvh - 76px - env(safe-area-inset-bottom));
  max-width: 760px;
  overflow: visible;
}
.app-topbar {
  position: sticky;
  z-index: 35;
  top: 0;
  min-height: 58px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 18px;
  font-weight: 800;
}
.brand-lockup > span:last-child {
  min-width: 0;
  display: grid;
  line-height: 1.15;
}
.brand-lockup strong { font-size: 15px; }
.brand-lockup small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.top-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.top-status > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(24, 185, 130, .12);
}
.camera-dock {
  position: sticky;
  z-index: 30;
  top: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(42, 63, 94, .1);
}
.caster-stage .videowrap {
  min-height: 0;
  max-height: 48dvh;
  aspect-ratio: 16 / 9;
}
.camera-quick-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  gap: 8px;
}
.camera-action {
  width: 58px;
  height: 54px;
  padding: 6px;
  display: grid;
  place-items: center;
  gap: 1px;
  color: #fff;
  background: rgba(13, 20, 32, .78);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}
.camera-action svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.camera-action span { font-size: 10px; line-height: 1; }
.camera-action:active { transform: scale(.96); }
.caster-page .hand-notice {
  margin: 0;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}
.caster-home {
  flex: 1;
  min-height: 160px;
  background: #fff;
}
.session-summary {
  min-height: 74px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.session-summary > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.session-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.session-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.compact-command { padding: 10px 14px; font-size: 13px; }

.bottom-dock {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 0;
  width: min(760px, 100%);
  min-height: calc(68px + env(safe-area-inset-bottom));
  padding: 5px 8px max(6px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 32px rgba(42, 63, 94, .12);
  backdrop-filter: blur(14px);
}
.dock-button {
  min-width: 0;
  min-height: 56px;
  padding: 5px 2px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: #748095;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 10px;
}
.dock-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dock-button.active { color: var(--accent); }
.dock-plus {
  width: 58px;
  min-width: 58px;
  height: 58px;
  min-height: 58px;
  margin: -14px auto 5px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: 0 8px 22px rgba(25, 118, 237, .34);
  font-size: 31px;
  line-height: 1;
}
.dock-plus.active { color: #fff; background: #0f65d5; }

.sheet-backdrop {
  position: fixed;
  z-index: 70;
  top: var(--camera-floor, 320px);
  right: 0;
  bottom: calc(68px + env(safe-area-inset-bottom));
  left: 0;
  background: rgba(27, 41, 61, .2);
  backdrop-filter: blur(2px);
}
.app-sheet {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(68px + env(safe-area-inset-bottom));
  width: min(760px, 100%);
  max-height: calc(100dvh - var(--camera-floor, 320px) - 68px - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -16px 44px rgba(33, 49, 72, .18);
}
.sheet-header {
  position: sticky;
  z-index: 2;
  top: 0;
  min-height: 58px;
  padding: 8px 12px 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, .98);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.sheet-header > div {
  min-width: 0;
  flex: 1;
  display: grid;
  justify-items: start;
}
.sheet-header h2 {
  margin: 5px 0 0;
  font-size: 18px;
  line-height: 1.2;
}
.sheet-grabber {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #cfd8e6;
}
.sheet-close, .window-close {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 400;
}
.sheet-actions { display: grid; }
.sheet-action {
  width: 100%;
  min-height: 66px;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.sheet-action:active { background: #edf5ff; }
.sheet-action-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #e8f1ff;
  font-size: 19px;
}
.sheet-action > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.sheet-action strong { font-size: 14px; }
.sheet-action small { color: var(--muted); font-size: 11px; font-weight: 400; }
.sheet-action > span:last-child { color: #8995a8; font-size: 24px; }
.studio-sheet .presenter {
  padding-bottom: 24px;
  border-top: 0;
}
.presenter-heading h3 { margin: 0; font-size: 18px; }
.more-sheet { padding-bottom: 14px; }
.more-sheet .controls {
  border-top: 0;
  padding: 14px;
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.control-grid button {
  min-width: 0;
  width: 100%;
}
.danger-command {
  color: #ba2636;
  background: #fff1f3;
  border-color: #f2b8c0;
}
.more-sheet .automation-controls { margin: 0 14px; }

.floating-window {
  position: fixed;
  z-index: 65;
  width: min(400px, calc(100vw - 24px));
  max-height: 36dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #cfd9e6;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(29, 46, 70, .22);
}
.floating-window.dragging {
  box-shadow: 0 22px 60px rgba(25, 118, 237, .24);
}
.window-bar {
  min-height: 52px;
  padding: 7px 8px 7px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--text);
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.window-bar:active { cursor: grabbing; }
.window-bar > div { min-width: 0; display: grid; }
.window-bar strong { font-size: 14px; }
.window-bar small { color: var(--muted); font-size: 10px; }
.floating-window.roster ul {
  padding: 10px;
  overflow-y: auto;
}
.floating-window.room-chat {
  background: #fff;
  border-top: 1px solid #cfd9e6;
}
.floating-window .chat-log {
  min-height: 90px;
  margin: 8px;
  flex: 1;
}
.floating-window .chat-compose {
  margin: 0;
  padding: 0 8px 8px;
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  .card { padding: 24px 20px; }
  .presenter-actions { grid-template-columns: 1fr; }
  .action-tile { min-height: 58px; }
  .switcher-settings { grid-template-columns: 1fr; }
  .presentation-controls { grid-template-columns: 44px 1fr 44px; }
  .presentation-controls #return-camera,
  .presentation-controls #speaker-pip { grid-column: span 1; }
  .presentation-controls #return-camera { grid-column: 1 / span 2; }
  .presentation-controls #speaker-pip { grid-column: 3; }
  .notice { align-items: stretch; flex-direction: column; }
  .notice button { width: 100%; }
  .stage { box-shadow: none; }
  .videowrap { min-height: 34vh; aspect-ratio: auto; }
  .caster-stage .videowrap {
    height: min(34dvh, 300px);
    min-height: 210px;
    aspect-ratio: auto;
  }
  .session-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .session-summary .compact-command {
    grid-column: 1 / -1;
    width: 100%;
  }
  .sheet-action { min-height: 62px; }
}
