:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --app-bg: #0d1320;
  --surface: #121a28;
  --surface-soft: #182032;
  --surface-muted: #151d2b;
  --sidebar-bg: #050b13;
  --text: #eef3ff;
  --text-soft: rgba(223, 232, 245, .82);
  --text-muted: rgba(178, 191, 208, .72);
  --line: rgba(148, 163, 184, .18);
  --line-soft: rgba(148, 163, 184, .14);
  --line-strong: #2b3a50;
  --accent: #7b96ff;
  --accent-strong: #8ea6ff;
  --accent-soft: rgba(76, 143, 234, .14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, .16);
  --shadow-card: 0 10px 28px rgba(0, 0, 0, .28);
  --shadow-raised: 0 18px 48px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--app-bg); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--app-bg);
}
button, input { font: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

body.in-call .topbar { display: none; }

.topbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 4px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-icon,
.lobby-icon,
.call-brand-icon {
  display: block;
  object-fit: cover;
  border-radius: 50%;
  flex: 0 0 auto;
}
.brand-icon { width: 30px; height: 30px; }
.brand-copy,
.call-brand-copy { display: grid; min-width: 0; line-height: 1.05; }
.brand-copy strong,
.call-brand-copy strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 860;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.brand-copy span,
.call-brand-copy span { margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.status { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #667386; }
.dot.live { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.card,
.stats {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}
.lobby {
  width: min(520px, 100%);
  margin: max(48px, 9vh) auto;
  padding: 24px;
}
.lobby-heading { display: flex; align-items: center; gap: 14px; }
.lobby-icon {
  width: 58px;
  height: 58px;
  box-shadow: 0 0 28px rgba(56, 189, 248, .2);
}
.section-kicker {
  color: #dce8ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lobby h1 { margin: 4px 0 0; color: #fff; font-size: 28px; line-height: 1.08; font-weight: 900; }
.lobby-copy { margin: 18px 0 0; color: var(--text-soft); font-size: 14px; line-height: 1.45; }
.form-grid { display: grid; gap: 12px; margin-top: 20px; }
.lobby label { display: grid; gap: 7px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.lobby input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(5, 12, 23, .72);
  color: var(--text);
  outline: none;
}
.lobby input::placeholder { color: rgba(178, 191, 208, .45); }
.lobby input:focus { border-color: color-mix(in srgb, var(--accent) 62%, var(--line)); box-shadow: 0 0 0 3px rgba(123, 150, 255, .14); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.actions button,
.small {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 13px;
  font-weight: 780;
  cursor: pointer;
}
.actions button:hover,
.small:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft)); }
.actions .primary {
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
  background: color-mix(in srgb, var(--accent) 26%, var(--surface-soft));
  color: #f7f9ff;
}
.actions .secondary { color: var(--text-soft); }
.hint { margin: 14px 0 0; color: var(--text-muted) !important; font-size: 11px; line-height: 1.4; }
.hidden { display: none !important; }

.call {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.roomline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 5px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
}
.call-brand { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.call-brand-icon { width: 28px; height: 28px; }
.call-brand-copy strong { font-size: 10px; }
.call-brand-copy span { font-size: 9px; }
.room-info { min-width: 0; flex: 1 1 auto; }
.room-title { display: flex; align-items: baseline; gap: 6px; font-size: 11px; }
.room-title strong { font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.room-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.meta-separator { opacity: .5; }
.muted { color: var(--text-muted); }
.small { min-height: 34px; padding: 6px 10px; font-size: 10px; }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.copy-icon { font-size: 13px; line-height: 1; transform: translateY(-1px); }

.grid {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}
.grid[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
.grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
.grid[data-count="3"] { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.grid[data-count="3"] .tile:nth-child(2) { grid-column: 1; grid-row: 1 / span 2; }
.grid[data-count="3"] .tile.local { grid-column: 2; grid-row: 1; }
.grid[data-count="3"] .tile:nth-child(3) { grid-column: 2; grid-row: 2; }
.grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.grid[data-count="5"], .grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(210px, 1fr); }
.grid[data-count="7"], .grid[data-count="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(190px, 1fr); }
.grid[data-count="9"], .grid[data-count="10"], .grid[data-count="11"], .grid[data-count="12"], .grid[data-count="13"], .grid[data-count="14"], .grid[data-count="15"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(170px, 1fr);
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--sidebar-bg);
  isolation: isolate;
  box-shadow: var(--shadow-card);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.tile.speaking {
  border-color: color-mix(in srgb, var(--success) 72%, var(--line));
  box-shadow: 0 0 0 2px var(--success-soft), var(--shadow-card);
}
.tile-placeholder {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface-muted);
  color: var(--text-muted);
}
.avatar-circle {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 27px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.camera-note { font-size: 11px; }
.tile video {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  background: transparent;
  opacity: 0;
  transition: opacity .18s ease;
}
.tile.has-video:not(.camera-off) video { opacity: 1; }
.tile.local video { transform: scaleX(-1); }
.tile-meta {
  position: absolute;
  z-index: 3;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(5, 11, 19, .78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 12px;
}
.participant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-status { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.pin-mark {
  display: none;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 9px;
  white-space: nowrap;
}
.tile.pinned .pin-mark { display: inline-flex; }
.badge { color: var(--text-muted); white-space: nowrap; font-size: 11px; }
.tile.speaking .badge { color: var(--success); }
.tile[role="button"] { cursor: pointer; }
.tile[role="button"]::after {
  content: '↗';
  position: absolute;
  z-index: 4;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(5, 11, 19, .7);
  color: var(--text-soft);
  font-size: 13px;
  opacity: .72;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.tile.pinned::after { content: '×'; background: color-mix(in srgb, var(--accent) 68%, transparent); color: #fff; }
.tile[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.grid.focus-mode {
  grid-template-columns: minmax(0, 2.35fr) minmax(220px, .85fr) !important;
  grid-template-rows: repeat(4, minmax(110px, 1fr)) !important;
  grid-auto-rows: minmax(110px, 1fr) !important;
  align-items: stretch;
}
.grid.focus-mode .tile {
  grid-column: 2 !important;
  grid-row: auto !important;
  min-height: 110px;
  order: 1;
}
.grid.focus-mode .tile.focused {
  grid-column: 1 !important;
  grid-row: 1 / span 4 !important;
  min-height: 0;
  order: -1;
  border-color: color-mix(in srgb, var(--accent) 66%, var(--line));
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-raised);
}

.controls {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 5;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: color-mix(in srgb, var(--sidebar-bg) 90%, transparent);
  box-shadow: 0 10px 24px rgba(2, 6, 23, .24);
}
.control-btn {
  min-width: 122px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, border-color .18s ease;
}
.control-btn:active { transform: scale(.98); }
.control-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--text-muted);
}
.mic-icon::before {
  content: '';
  width: 7px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 6px;
}
.mic-icon::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 1px;
  height: 7px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}
.camera-icon::before {
  content: '';
  width: 11px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 3px;
}
.camera-icon::after {
  content: '';
  position: absolute;
  right: 1px;
  width: 5px;
  height: 6px;
  background: currentColor;
  clip-path: polygon(0 25%,100% 0,100% 100%,0 75%);
}
.network-icon::before,
.network-icon::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: currentColor;
}
.network-icon::before { left: 3px; height: 6px; box-shadow: 5px -3px 0 currentColor, 10px -7px 0 currentColor; }
.leave-icon { font-size: 22px; line-height: 1; }
.control-label { white-space: nowrap; }
.control-btn:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface-soft)); }
.control-btn.off { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 38%, transparent); color: #ffe7ec; }
.control-btn.off .control-icon { color: var(--danger); }
.control-btn.subtle { color: var(--text-soft); }
.control-btn.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 38%, transparent); color: #ffe7ec; }
.control-btn.danger .control-icon { color: var(--danger); font-size: 21px; }

.stats {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: 78px;
  width: min(560px, calc(100vw - 36px));
  max-height: min(62vh, 620px);
  padding: 15px;
  overflow: auto;
}
.stats-head { display: flex; justify-content: space-between; gap: 12px; color: var(--text-soft); }
.stats-head > div { display: flex; flex-direction: column; gap: 3px; }
.stats-head strong { color: var(--text); font-size: 13px; }
.stats-head span { color: var(--text-muted); font-size: 11px; }
.stats-close { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-soft); color: var(--text-soft); cursor: pointer; }
.stats pre { margin: 12px 0 0; color: var(--text-soft); font-size: 11px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 900px) {
  .control-btn { min-width: 108px; }
  .grid[data-count="7"], .grid[data-count="8"],
  .grid[data-count="9"], .grid[data-count="10"], .grid[data-count="11"], .grid[data-count="12"], .grid[data-count="13"], .grid[data-count="14"], .grid[data-count="15"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body.in-call { overflow: hidden; }
  .shell {
    width: 100%;
    padding: max(8px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
  }
  body.in-call .shell { height: 100dvh; min-height: 100dvh; }
  body.in-call .topbar { display: none; }
  .lobby { margin: 3vh auto; padding: 18px; }
  .lobby-icon { width: 52px; height: 52px; }
  .lobby h1 { font-size: 25px; }
  .actions { grid-template-columns: 1fr; }

  .call { height: 100%; gap: 6px; }
  .roomline { min-height: 50px; padding: 6px 7px; gap: 8px; border-radius: 10px; }
  .call-brand-icon { width: 32px; height: 32px; }
  .call-brand-copy strong { font-size: 9px; }
  .call-brand-copy span { font-size: 8px; }
  .room-title { font-size: 11px; }
  .room-title strong { font-size: 12px; }
  .room-meta { font-size: 9px; }
  .copy-btn { min-height: 34px; padding: 7px 9px; font-size: 10px; }

  .grid {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    gap: 6px;
    overflow-y: auto;
  }
  .tile { border-radius: 12px; }
  .tile-meta { left: 7px; right: 7px; bottom: 7px; padding: 6px 8px; border-radius: 8px; font-size: 10px; }
  .badge { font-size: 9px; }
  .avatar-circle { width: 58px; height: 58px; font-size: 22px; }
  .camera-note { font-size: 10px; }

  .grid[data-count="1"] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  .grid[data-count="2"] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  .grid[data-count="2"] .tile:not(.local) {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 100%;
  }
  .grid[data-count="2"] .tile.local {
    position: absolute;
    z-index: 4;
    top: 8px;
    right: 8px;
    width: clamp(96px, 28vw, 140px);
    height: clamp(128px, 22vh, 182px);
    border-radius: 12px;
    border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
    box-shadow: var(--shadow-raised);
  }
  .grid[data-count="2"] .tile.local .tile-meta { left: 5px; right: 5px; bottom: 5px; padding: 5px 7px; }
  .grid[data-count="2"] .tile.local .badge { display: none; }
  .grid[data-count="2"] .tile.local .camera-note { display: none; }
  .grid[data-count="2"] .tile.local .avatar-circle { width: 44px; height: 44px; font-size: 18px; }

  .grid[data-count="3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1.55fr) minmax(0, 1fr);
    overflow: hidden;
  }
  .grid[data-count="3"] .tile:nth-child(2) { grid-column: 1 / span 2; grid-row: 1; }
  .grid[data-count="3"] .tile.local { grid-column: 1; grid-row: 2; }
  .grid[data-count="3"] .tile:nth-child(3) { grid-column: 2; grid-row: 2; }

  .grid[data-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    overflow: hidden;
  }
  .grid[data-count="5"], .grid[data-count="6"],
  .grid[data-count="7"], .grid[data-count="8"],
  .grid[data-count="9"], .grid[data-count="10"], .grid[data-count="11"], .grid[data-count="12"], .grid[data-count="13"], .grid[data-count="14"], .grid[data-count="15"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(150px, 29vh);
    overflow-y: auto;
  }

  .grid.focus-mode {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: none !important;
    grid-auto-rows: minmax(132px, 26vh) !important;
    overflow-y: auto !important;
    align-items: stretch;
  }
  .grid.focus-mode .tile {
    grid-column: auto !important;
    grid-row: auto !important;
    min-height: 132px;
    order: 1;
  }
  .grid.focus-mode .tile.focused {
    grid-column: 1 / span 2 !important;
    grid-row: auto !important;
    min-height: 44vh;
    order: -1;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
  .control-btn {
    min-width: 0;
    height: 54px;
    flex-direction: column;
    gap: 3px;
    padding: 5px 3px;
    border-radius: 17px;
    font-size: 10px;
  }
  .control-icon { width: 20px; height: 20px; flex-basis: 20px; }
  .control-btn.danger .control-icon { font-size: 20px; }

  .stats {
    left: 8px;
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 52dvh;
    padding: 13px;
  }
}

@media (max-width: 430px) {
  .roomline { min-height: 48px; gap: 6px; }
  .call-brand-copy { display: none; }
  .room-title .muted { display: none; }
  .room-title strong { font-size: 11px; }
  .room-meta { font-size: 9px; }
  .room-meta .meta-separator { display: none; }
  #connectionLabel { display: none; }
  .copy-icon { display: none; }
  .copy-btn { padding-inline: 8px; }
  .control-btn { font-size: 9px; }
  .control-label { max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 360px) {
  .control-label { font-size: 9px; }
  .copy-btn { padding-inline: 8px; }
}


/* Product prejoin + device controls */
.single-action { grid-template-columns: 1fr; }
.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, transparent);
  border-radius: 8px;
  background: var(--danger-soft);
  color: #ffe7ec;
  font-size: 12px;
  line-height: 1.4;
}

.prejoin {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, .75fr);
  gap: 12px;
  align-items: stretch;
}
.prejoin-main { min-height: 0; }
.prejoin-preview-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sidebar-bg);
  box-shadow: var(--shadow-card);
}
.prejoin-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: var(--surface-muted);
}
.prejoin-preview-wrap.camera-off .prejoin-video { opacity: 0; }
.prejoin-camera-off {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  background: var(--surface-muted);
}
.prejoin-room-chip {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 11, 19, .78);
  color: var(--text-soft);
  font-size: 11px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.prejoin-room-chip strong { margin-left: 5px; color: var(--text); letter-spacing: .08em; }
.prejoin-panel {
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.prejoin-head h2 { margin: 5px 0 7px; font-size: 24px; line-height: 1.15; }
.prejoin-head p { margin: 0 0 18px; color: var(--text-muted); font-size: 12px; }
.field-label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 760;
}
.field-label input,
.field-label select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 23, .72);
  color: var(--text);
  outline: none;
}
.field-label input:focus,
.field-label select:focus { border-color: color-mix(in srgb, var(--accent) 62%, var(--line)); box-shadow: 0 0 0 3px rgba(123, 150, 255, .12); }
.device-fields { display: grid; gap: 10px; margin-top: 12px; }
.prejoin-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.device-toggle {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}
.device-toggle.off { border-color: color-mix(in srgb, var(--danger) 38%, transparent); background: var(--danger-soft); color: #ffe7ec; }
.wide-action {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 28%, var(--surface-soft));
  color: #f7f9ff;
  font-weight: 820;
  cursor: pointer;
}
.wide-action:disabled { opacity: .5; cursor: default; }
.text-button {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
}

.share-icon::before {
  content: '';
  width: 12px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 2px;
}
.share-icon::after {
  content: '↗';
  position: absolute;
  right: -1px;
  top: -5px;
  font-size: 11px;
  font-weight: 800;
}
.devices-icon::before {
  content: '';
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.devices-icon::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 -8px 0 -1px currentColor, 0 8px 0 -1px currentColor, 8px 0 0 -1px currentColor, -8px 0 0 -1px currentColor;
}
.control-btn.active { border-color: color-mix(in srgb, var(--accent) 52%, transparent); background: var(--accent-soft); color: #e9efff; }
.control-btn.unsupported { opacity: .45; }

.floating-panel {
  position: fixed;
  z-index: 28;
  right: 18px;
  bottom: 84px;
  width: min(390px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}
.panel-head { display: flex; justify-content: space-between; gap: 12px; }
.panel-head > div { display: grid; gap: 3px; }
.panel-head strong { font-size: 13px; }
.panel-head span { color: var(--text-muted); font-size: 10px; line-height: 1.35; }
.panel-action {
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-soft);
  cursor: pointer;
}
.tile.screen-sharing video { object-fit: contain; background: #05080d; }
.tile.local.screen-sharing video { transform: none; }
.tile.screen-sharing .camera-note { display: none; }

@media (max-width: 900px) {
  .prejoin { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .8fr); }
}

@media (max-width: 720px) {
  body.prejoin-mode { overflow: auto; }
  body.prejoin-mode .shell { min-height: 100dvh; }
  .prejoin {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: auto;
  }
  .prejoin-preview-wrap { height: min(48dvh, 430px); min-height: 300px; border-radius: 12px; }
  .prejoin-panel { padding: 16px; justify-content: flex-start; }
  .prejoin-head h2 { font-size: 21px; }
  .device-fields { grid-template-columns: 1fr; }
  .controls {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding-inline: 5px;
  }
  .control-btn { height: 56px; border-radius: 15px; font-size: 9px; }
  .control-label { max-width: 64px; }
  .floating-panel { left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); width: auto; }
}

@media (max-width: 430px) {
  .lobby-copy { font-size: 13px; }
  .prejoin-preview-wrap { height: 42dvh; min-height: 270px; }
  .prejoin-panel { border-radius: 10px; }
  .prejoin-toggles { gap: 6px; }
  .device-toggle { font-size: 10px; }
  .controls .control-icon { width: 18px; height: 18px; flex-basis: 18px; transform: scale(.9); }
  .control-label { font-size: 8px; }
}


/* Entry cleanup: one brand, no technical chrome */
.compact-heading { display: block; }
.compact-heading h1 { margin: 0; }
#entry .lobby-copy { margin-top: 10px; }
#entry .hint { text-align: center; }
#entry { margin-top: clamp(36px, 8vh, 84px); }
@media (max-width: 720px) {
  .topbar { margin-bottom: 4px; }
  #entry { margin-top: 18px; }
  #entry .lobby-copy { margin-top: 8px; }
}
