/*
 * Era Watch Room 1407 — v0.7.5
 * Consolidated production stylesheet.
 * Desktop, tablet and approved phone layouts are kept in separate sections.
 */

:root {
  --ewr1407-safe-top: env(safe-area-inset-top, 0px);
  --ewr1407-safe-right: env(safe-area-inset-right, 0px);
  --ewr1407-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ewr1407-safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  margin: 0 !important;
  min-height: 100%;
}

#ewr1407-app,
#ewr1407-app * {
  box-sizing: border-box;
}

#ewr1407-app {
  --ewr1407-bg: #06090f;
  --ewr1407-panel: #0f1621;
  --ewr1407-panel-2: #141d2a;
  --ewr1407-panel-3: #192432;
  --ewr1407-border: rgba(139, 226, 255, 0.28);
  --ewr1407-border-strong: rgba(139, 226, 255, 0.58);
  --ewr1407-text: #f7fbff;
  --ewr1407-muted: #98a7bb;
  --ewr1407-soft: #6f7e91;
  --ewr1407-accent-a: #68dcff;
  --ewr1407-accent-b: #bd68ff;
  --ewr1407-danger: #ff4f66;
  --ewr1407-success: #2bd879;
  --ewr1407-control-bg: rgba(8, 12, 19, 0.84);
  --ewr1407-shadow: 0 18px 56px rgba(0, 0, 0, 0.32);
  --ewr1407-radius: 20px;
  --ewr1407-gap: clamp(8px, 0.8vw, 14px);

  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--ewr1407-gap);
  width: 100vw;
  height: var(--ewr1407-visual-height, 100dvh);
  min-height: 0;
  padding:
    max(10px, var(--ewr1407-safe-top))
    max(10px, var(--ewr1407-safe-right))
    max(10px, var(--ewr1407-safe-bottom))
    max(10px, var(--ewr1407-safe-left));
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 12% 0%, rgba(55, 217, 255, 0.10), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(174, 92, 255, 0.10), transparent 28%),
    var(--ewr1407-bg);
  color: var(--ewr1407-text);
  font-family: Montserrat, Inter, Arial, sans-serif;
}

#ewr1407-app[data-mode="call"] {
  --ewr1407-bg: #e8dfd2;
  --ewr1407-panel: #f5efe7;
  --ewr1407-panel-2: #ece3d8;
  --ewr1407-panel-3: #e3d7c8;
  --ewr1407-border: rgba(65, 55, 49, 0.20);
  --ewr1407-border-strong: rgba(65, 55, 49, 0.40);
  --ewr1407-text: #24201d;
  --ewr1407-muted: #6e625a;
  --ewr1407-soft: #8a7d72;
  --ewr1407-control-bg: rgba(245, 239, 231, 0.90);
  --ewr1407-shadow: 0 18px 44px rgba(74, 58, 45, 0.18);

  background:
    radial-gradient(circle at 12% 0%, rgba(104, 220, 255, 0.16), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(189, 104, 255, 0.12), transparent 28%),
    var(--ewr1407-bg);
}

#ewr1407-app button,
#ewr1407-app input,
#ewr1407-app select {
  font: inherit;
}

#ewr1407-app button {
  -webkit-tap-highlight-color: transparent;
}

#ewr1407-app [hidden] {
  display: none !important;
}

#ewr1407-app[data-room-active="false"] .ewr1407-topbar,
#ewr1407-app[data-room-active="false"] .ewr1407-workspace,
#ewr1407-app[data-room-active="false"] .ewr1407-mobile-tools,
#ewr1407-app[data-room-active="false"] .ewr1407-settings-overlay,
#ewr1407-app[data-room-active="false"] .ewr1407-camera-popout {
  visibility: hidden;
  pointer-events: none;
}

#ewr1407-app[data-room-active="true"] .ewr1407-lobby {
  display: none;
}

/* Lobby */
#ewr1407-app .ewr1407-lobby {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 10%, rgba(104, 220, 255, 0.12), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(189, 104, 255, 0.10), transparent 30%),
    #05080e;
}

#ewr1407-app .ewr1407-lobby-card {
  width: min(480px, 100%);
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 30px;
  background: rgba(15, 22, 33, 0.94);
  box-shadow: var(--ewr1407-shadow);
}

#ewr1407-app .ewr1407-kicker,
#ewr1407-app .ewr1407-card-kicker {
  margin: 0;
  color: var(--ewr1407-muted);
  font-family: Rajdhani, Montserrat, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#ewr1407-app .ewr1407-lobby-title {
  margin: 12px 0 12px;
  font-family: Rajdhani, Montserrat, sans-serif;
  font-size: clamp(40px, 6vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

#ewr1407-app .ewr1407-lobby-copy {
  margin: 0;
  color: var(--ewr1407-muted);
  font-size: 15px;
  line-height: 1.65;
}

#ewr1407-app .ewr1407-field {
  display: grid;
  gap: 7px;
  margin-top: 26px;
  color: var(--ewr1407-muted);
  font-size: 11px;
}

#ewr1407-app .ewr1407-input,
#ewr1407-app .ewr1407-select,
#ewr1407-app .ewr1407-youtube-input,
#ewr1407-app .ewr1407-chat-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--ewr1407-border);
  border-radius: 14px;
  outline: none;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-text);
}

#ewr1407-app .ewr1407-input,
#ewr1407-app .ewr1407-select {
  min-height: 48px;
  padding: 0 14px;
}

#ewr1407-app .ewr1407-name-select {
  color: var(--ewr1407-text) !important;
  font-weight: 700;
  opacity: 1;
}

#ewr1407-app .ewr1407-name-select option {
  background: #151e2a;
  color: #ffffff;
}

#ewr1407-app .ewr1407-create-room-button {
  position: relative;
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  background: #080b10;
  color: rgba(255, 255, 255, 0.82);
  cursor: default;
}

#ewr1407-app .ewr1407-create-progress {
  position: absolute;
  inset: 0;
  background: #080b10;
}

#ewr1407-app .ewr1407-create-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #292f38, #f4f7fb);
  transition: width 180ms ease;
}

#ewr1407-app .ewr1407-create-room-label {
  position: relative;
  z-index: 2;
  font-size: 16px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.36);
}

#ewr1407-app .ewr1407-create-room-button[data-ready="true"],
#ewr1407-app .ewr1407-create-room-button[data-load-state="ready"] {
  border-color: transparent;
  background: linear-gradient(100deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(104, 220, 255, 0.18);
}

#ewr1407-app .ewr1407-create-room-button[data-ready="true"] .ewr1407-create-progress,
#ewr1407-app .ewr1407-create-room-button[data-load-state="ready"] .ewr1407-create-progress {
  display: none;
}

#ewr1407-app .ewr1407-create-room-button[data-load-state="ready"] .ewr1407-create-room-label {
  color: #071019;
  text-shadow: none;
}

#ewr1407-app .ewr1407-lobby-status {
  margin: 16px 0 0;
  color: var(--ewr1407-muted);
  font-size: 13px;
  text-align: center;
}

/* Top row */
#ewr1407-app .ewr1407-topbar {
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr) minmax(180px, 230px) 112px;
  gap: var(--ewr1407-gap);
  min-height: 72px;
}

#ewr1407-app .ewr1407-topbar-actions,
#ewr1407-app .ewr1407-topbar-right {
  display: flex;
  gap: var(--ewr1407-gap);
  min-width: 0;
}

#ewr1407-app .ewr1407-topbar-right {
  display: contents;
}

#ewr1407-app .ewr1407-icon-button,
#ewr1407-app .ewr1407-search-button,
#ewr1407-app .ewr1407-card-icon-button,
#ewr1407-app .ewr1407-stage-control-button,
#ewr1407-app .ewr1407-chat-icon-button,
#ewr1407-app .ewr1407-send-button,
#ewr1407-app .ewr1407-settings-action,
#ewr1407-app .ewr1407-panic-button,
#ewr1407-app .ewr1407-chat-notification-button,
#ewr1407-app .ewr1407-round-control {
  border: 1px solid var(--ewr1407-border);
  background: var(--ewr1407-panel);
  color: var(--ewr1407-text);
  cursor: pointer;
}

#ewr1407-app .ewr1407-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  height: 100%;
  padding: 0 14px;
  border-radius: 16px;
  font-weight: 700;
}

#ewr1407-app .ewr1407-icon-button:hover,
#ewr1407-app .ewr1407-search-button:hover,
#ewr1407-app .ewr1407-settings-action:hover,
#ewr1407-app .ewr1407-card-icon-button:hover {
  border-color: var(--ewr1407-border-strong);
  background: var(--ewr1407-panel-3);
}

#ewr1407-app .ewr1407-room-link-button[data-copied="true"] {
  border-color: rgba(43, 216, 121, 0.8);
}

#ewr1407-app .ewr1407-youtube-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--ewr1407-border);
  border-radius: 16px;
  background: var(--ewr1407-panel);
}

#ewr1407-app .ewr1407-youtube-input {
  height: 100%;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#ewr1407-app .ewr1407-search-button {
  min-width: 86px;
  border: 0;
  border-left: 1px solid var(--ewr1407-border);
  border-radius: 0;
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
  font-weight: 800;
  text-transform: uppercase;
}

#ewr1407-app .ewr1407-mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: center;
  gap: 5px 10px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 16px;
  background: var(--ewr1407-panel);
  color: var(--ewr1407-muted);
  font-size: 11px;
}

#ewr1407-app .ewr1407-mini-stats span {
  white-space: nowrap;
}

#ewr1407-app .ewr1407-mini-stats b {
  color: var(--ewr1407-text);
}

#ewr1407-app .ewr1407-mini-stats small {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--ewr1407-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Local camera */
#ewr1407-app .ewr1407-local-camera-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  min-width: 0;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--ewr1407-border);
  border-radius: 16px;
  outline: none;
  background: #020407;
  cursor: pointer;
}

#ewr1407-app .ewr1407-local-camera-video,
#ewr1407-app .ewr1407-remote-camera-video,
#ewr1407-app .ewr1407-screen-video,
#ewr1407-app .ewr1407-popout-video {
  display: none;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: cover;
}

#ewr1407-app .ewr1407-local-camera-video {
  transform: scaleX(-1);
}

#ewr1407-app .ewr1407-local-camera-card.ewr1407-video-live .ewr1407-local-camera-video,
#ewr1407-app .ewr1407-remote-video-shell.ewr1407-video-live .ewr1407-remote-camera-video,
#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-screen-video {
  display: block;
}

#ewr1407-app .ewr1407-camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  color: var(--ewr1407-muted);
  font-size: 11px;
  text-align: center;
}

#ewr1407-app .ewr1407-video-live > .ewr1407-camera-placeholder,
#ewr1407-app .ewr1407-video-live .ewr1407-camera-placeholder,
#ewr1407-app .ewr1407-remote-video-shell.ewr1407-video-live .ewr1407-camera-placeholder {
  display: none;
}

#ewr1407-app .ewr1407-camera-quick-controls {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  grid-template-columns: repeat(2, 42px);
  place-content: center;
  gap: 10px;
  background: rgba(3, 7, 12, 0.72);
  backdrop-filter: blur(5px);
}

#ewr1407-app .ewr1407-local-camera-card.ewr1407-controls-visible .ewr1407-camera-quick-controls {
  display: grid;
}

#ewr1407-app .ewr1407-round-control {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-color: rgba(255, 86, 106, 0.85);
  border-radius: 50%;
  background: rgba(143, 23, 40, 0.92);
  color: #fff;
}

#ewr1407-app .ewr1407-round-control.ewr1407-control-active {
  border-color: rgba(43, 216, 121, 0.90);
  background: rgba(18, 128, 72, 0.94);
}

#ewr1407-app .ewr1407-round-control svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-local-media-indicator {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  max-width: calc(100% - 10px);
  overflow: hidden;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: rgba(255, 255, 255, 0.86);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ewr1407-app .ewr1407-local-camera-card.ewr1407-controls-visible .ewr1407-local-media-indicator {
  display: none;
}

/* Main desktop/iPad layout */
#ewr1407-app .ewr1407-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 22vw, 340px);
  gap: var(--ewr1407-gap);
  min-width: 0;
  min-height: 0;
}

#ewr1407-app .ewr1407-stage,
#ewr1407-app .ewr1407-remote-camera-card,
#ewr1407-app .ewr1407-chat-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--ewr1407-border);
  border-radius: var(--ewr1407-radius);
  background: var(--ewr1407-panel);
  box-shadow: var(--ewr1407-shadow);
}

#ewr1407-app .ewr1407-stage {
  position: relative;
  display: grid;
  place-items: center;
  background: #000307;
}

#ewr1407-app .ewr1407-side-column {
  display: grid;
  grid-template-rows: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: var(--ewr1407-gap);
  min-width: 0;
  min-height: 0;
}

/* Stage */
#ewr1407-app .ewr1407-screen-video,
#ewr1407-app .ewr1407-youtube-player-shell,
#ewr1407-app .ewr1407-call-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#ewr1407-app .ewr1407-screen-video {
  object-fit: contain;
}

#ewr1407-app .ewr1407-youtube-player-shell,
#ewr1407-app .ewr1407-call-background {
  display: none;
}

#ewr1407-app .ewr1407-youtube-player-shell iframe {
  width: 100% !important;
  height: 100% !important;
}

#ewr1407-app .ewr1407-call-background {
  background:
    linear-gradient(rgba(20, 14, 18, 0.24), rgba(20, 14, 18, 0.34)),
    url("https://images8.alphacoders.com/127/1272726.png") center / cover no-repeat;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-youtube-player-shell {
  display: block;
}

#ewr1407-app[data-mode="call"] .ewr1407-stage[data-source="empty"] .ewr1407-call-background {
  display: block;
}

#ewr1407-app .ewr1407-stage-placeholder {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 8px;
  max-width: 500px;
  padding: 26px;
  color: var(--ewr1407-muted);
  text-align: center;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-stage-placeholder,
#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-stage-placeholder,
#ewr1407-app[data-mode="call"] .ewr1407-stage[data-source="empty"] .ewr1407-stage-placeholder {
  display: none;
}

#ewr1407-app .ewr1407-stage-placeholder strong {
  color: #fff;
  font-size: clamp(18px, 2vw, 28px);
}

#ewr1407-app .ewr1407-stage-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 17px;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-accent-a);
  font-family: Rajdhani, Montserrat, sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#ewr1407-app .ewr1407-stage-source-label {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 7;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.80);
  font-size: 10px;
}

#ewr1407-app .ewr1407-stage-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(2, 5, 9, 0.78);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(10px);
}

#ewr1407-app .ewr1407-stage.ewr1407-controls-visible .ewr1407-stage-controls,
#ewr1407-app .ewr1407-stage:focus-within .ewr1407-stage-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-stage-controls,
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-stage-controls {
  display: none;
}

#ewr1407-app .ewr1407-stage-control-button,
#ewr1407-app .ewr1407-chat-icon-button,
#ewr1407-app .ewr1407-send-button,
#ewr1407-app .ewr1407-card-icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
}

#ewr1407-app .ewr1407-youtube-timeline {
  flex: 1 1 auto;
  min-width: 40px;
  accent-color: var(--ewr1407-accent-a);
}

#ewr1407-app .ewr1407-time-label {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

#ewr1407-app .ewr1407-volume-control {
  position: relative;
  flex: 0 0 auto;
}

#ewr1407-app .ewr1407-volume-palette {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(10, minmax(34px, 1fr));
  gap: 4px;
  width: min(520px, calc(100vw - 28px));
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 13px;
  background: rgba(2, 5, 9, 0.94);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

#ewr1407-app .ewr1407-volume-palette button {
  min-width: 0;
  min-height: 34px;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: #18212d;
  color: #fff;
  font-size: 9px;
  cursor: pointer;
}

#ewr1407-app .ewr1407-volume-palette button:hover,
#ewr1407-app .ewr1407-volume-palette button[data-selected="true"] {
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
}

#ewr1407-app .ewr1407-desktop-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 150px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
}

#ewr1407-app .ewr1407-desktop-volume input {
  width: 100%;
  accent-color: var(--ewr1407-accent-b);
}

/* Remote camera */
#ewr1407-app .ewr1407-remote-camera-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
}

#ewr1407-app .ewr1407-card-heading,
#ewr1407-app .ewr1407-chat-header,
#ewr1407-app .ewr1407-settings-header,
#ewr1407-app .ewr1407-quality-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#ewr1407-app .ewr1407-card-heading {
  position: absolute;
  top: 8px;
  right: 8px;
  left: 8px;
  z-index: 5;
  padding: 6px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.54);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

#ewr1407-app .ewr1407-remote-camera-card:hover .ewr1407-card-heading,
#ewr1407-app .ewr1407-remote-camera-card:focus-within .ewr1407-card-heading {
  opacity: 1;
  pointer-events: auto;
}

#ewr1407-app .ewr1407-card-actions {
  display: flex;
  gap: 6px;
}

#ewr1407-app .ewr1407-remote-video-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #000307;
}

#ewr1407-app .ewr1407-remote-camera-video {
  object-fit: cover;
}

#ewr1407-app .ewr1407-remote-status-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ewr1407-muted);
  font-size: 9px;
}

#ewr1407-app .ewr1407-mobile-local-slot {
  display: none;
}

#ewr1407-app .ewr1407-remote-camera-card.ewr1407-popout-active .ewr1407-remote-video-shell {
  opacity: 0.28;
}

/* Chat */
#ewr1407-app .ewr1407-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
}

#ewr1407-app .ewr1407-chat-header strong {
  display: block;
  margin-top: 3px;
}

#ewr1407-app .ewr1407-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ewr1407-border-strong) transparent;
}

#ewr1407-app .ewr1407-message-row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

#ewr1407-app .ewr1407-message-own {
  align-self: flex-end;
  align-items: flex-end;
}

#ewr1407-app .ewr1407-message-remote {
  align-self: flex-start;
  align-items: flex-start;
}

#ewr1407-app .ewr1407-message-system {
  align-self: center;
  max-width: 100%;
  color: var(--ewr1407-soft);
  font-size: 10px;
  text-align: center;
}

#ewr1407-app .ewr1407-message-meta {
  margin: 0 6px 3px;
  color: var(--ewr1407-soft);
  font-size: 8px;
}

#ewr1407-app .ewr1407-message-bubble {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--ewr1407-panel-3);
  color: var(--ewr1407-text);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#ewr1407-app .ewr1407-message-own .ewr1407-message-bubble {
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
}

#ewr1407-app .ewr1407-chat-form {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 7px;
}

#ewr1407-app .ewr1407-chat-input {
  min-height: 38px;
  padding: 0 11px;
}

#ewr1407-app .ewr1407-send-button {
  border-color: transparent;
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
}

#ewr1407-app .ewr1407-emoji-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 12px;
  background: var(--ewr1407-panel-2);
}

#ewr1407-app .ewr1407-emoji-palette button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

/* Mobile controls */
#ewr1407-app .ewr1407-mobile-tools {
  display: none;
}

#ewr1407-app .ewr1407-panic-button,
#ewr1407-app .ewr1407-chat-notification-button {
  border-radius: 16px;
  font-weight: 800;
}

#ewr1407-app .ewr1407-panic-button {
  border-color: rgba(255, 79, 102, 0.62);
  background: rgba(93, 17, 31, 0.92);
  color: #ffdfe4;
}

#ewr1407-app .ewr1407-chat-notification-button {
  border-color: rgba(43, 216, 121, 0.64);
  background: rgba(15, 97, 55, 0.94);
  color: #fff;
}

#ewr1407-app .ewr1407-chat-notification-button[data-unread="true"] {
  border-color: rgba(255, 79, 102, 0.82);
  background: rgba(151, 23, 43, 0.96);
}

/* Settings */
#ewr1407-app .ewr1407-settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(2, 5, 10, 0.70);
  backdrop-filter: blur(8px);
}

#ewr1407-app .ewr1407-settings-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(900px, 96vw);
  max-height: min(88dvh, 760px);
  overflow: hidden;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 24px;
  background: var(--ewr1407-panel);
  color: var(--ewr1407-text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

#ewr1407-app .ewr1407-settings-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ewr1407-border);
}

#ewr1407-app .ewr1407-settings-header h2,
#ewr1407-app .ewr1407-settings-section h3 {
  margin: 0;
}

#ewr1407-app .ewr1407-settings-scroll {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
}

#ewr1407-app .ewr1407-settings-section {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 16px;
  background: var(--ewr1407-panel-2);
}

#ewr1407-app .ewr1407-settings-quality,
#ewr1407-app .ewr1407-settings-stats {
  grid-column: 1 / -1;
}

#ewr1407-app .ewr1407-settings-section h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

#ewr1407-app .ewr1407-settings-button-grid,
#ewr1407-app .ewr1407-quality-grid,
#ewr1407-app .ewr1407-stats-grid,
#ewr1407-app .ewr1407-room-info-grid {
  display: grid;
  gap: 8px;
}

#ewr1407-app .ewr1407-settings-button-grid,
#ewr1407-app .ewr1407-quality-grid,
#ewr1407-app .ewr1407-stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#ewr1407-app .ewr1407-settings-action {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
}

#ewr1407-app .ewr1407-settings-action-active {
  border-color: transparent;
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  color: #071019;
}

#ewr1407-app .ewr1407-settings-danger {
  border-color: rgba(255, 79, 102, 0.58);
  color: var(--ewr1407-danger);
}

#ewr1407-app .ewr1407-quality-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 13px;
  background: var(--ewr1407-panel);
}

#ewr1407-app .ewr1407-quality-heading {
  grid-column: 1 / -1;
}

#ewr1407-app .ewr1407-quality-block label {
  display: grid;
  gap: 5px;
  color: var(--ewr1407-muted);
  font-size: 10px;
}

#ewr1407-app .ewr1407-stats-grid div,
#ewr1407-app .ewr1407-room-info-grid > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px;
  border-radius: 11px;
  background: var(--ewr1407-panel);
}

#ewr1407-app .ewr1407-stats-grid span,
#ewr1407-app .ewr1407-room-info-grid span {
  color: var(--ewr1407-muted);
  font-size: 9px;
}

#ewr1407-app .ewr1407-settings-note {
  margin: 8px 0 0;
  color: var(--ewr1407-muted);
  font-size: 10px;
  line-height: 1.45;
}

/* Full camera view */
#ewr1407-app .ewr1407-camera-popout {
  position: absolute;
  top: 8%;
  left: 8%;
  z-index: 35;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(720px, 72vw);
  height: min(520px, 72vh);
  min-width: 260px;
  min-height: 190px;
  overflow: hidden;
  resize: both;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 18px;
  background: #000;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.58);
}

#ewr1407-app .ewr1407-popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--ewr1407-panel);
  color: var(--ewr1407-text);
  cursor: move;
}

#ewr1407-app .ewr1407-popout-video {
  display: block;
  object-fit: contain;
}

#ewr1407-app .ewr1407-toast,
#ewr1407-app .ewr1407-peer-audio-container {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

#ewr1407-app.ewr1407-panic-active > :not(.ewr1407-lobby):not(.ewr1407-settings-overlay) {
  visibility: hidden !important;
}

/* Desktop and tablet tightening */
@media (max-width: 1180px) and (min-width: 851px) {
  #ewr1407-app .ewr1407-topbar {
    grid-template-columns: auto minmax(240px, 1fr) 170px 96px;
  }

  #ewr1407-app .ewr1407-icon-button {
    min-width: 84px;
    padding: 0 10px;
  }

  #ewr1407-app .ewr1407-button-label {
    font-size: 11px;
  }

  #ewr1407-app .ewr1407-local-camera-card {
    width: 96px;
  }

  #ewr1407-app .ewr1407-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(238px, 27vw, 300px);
  }

  #ewr1407-app .ewr1407-desktop-volume {
    display: none;
  }
}

/* Phone / small tablet portrait */
@media (max-width: 850px) and (orientation: portrait) {
  #ewr1407-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 48px minmax(0, 34fr) minmax(0, 22fr) minmax(0, 44fr);
    grid-template-areas:
      "top"
      "stage"
      "remote"
      "chat";
    gap: 7px;
    padding:
      max(7px, var(--ewr1407-safe-top))
      max(7px, var(--ewr1407-safe-right))
      max(7px, var(--ewr1407-safe-bottom))
      max(7px, var(--ewr1407-safe-left));
  }

  #ewr1407-app[data-mode="call"] {
    grid-template-rows: 48px minmax(0, 29fr) minmax(0, 47fr) minmax(0, 24fr);
    grid-template-areas:
      "top"
      "remote"
      "chat"
      "stage";
  }

  #ewr1407-app .ewr1407-topbar {
    grid-area: top;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px;
    min-height: 0;
  }

  #ewr1407-app .ewr1407-topbar-actions {
    gap: 7px;
  }

  #ewr1407-app .ewr1407-icon-button {
    min-width: 42px;
    height: 48px;
    padding: 0 10px;
    border-radius: 13px;
  }

  #ewr1407-app .ewr1407-icon-button .ewr1407-button-label {
    display: none;
  }

  #ewr1407-app .ewr1407-youtube-search {
    min-width: 0;
    height: 48px;
    border-radius: 13px;
  }

  #ewr1407-app .ewr1407-youtube-input {
    padding: 0 10px;
    font-size: 11px;
  }

  #ewr1407-app .ewr1407-search-button {
    min-width: 54px;
    font-size: 9px;
  }

  #ewr1407-app .ewr1407-topbar-right {
    display: none;
  }

  #ewr1407-app .ewr1407-workspace,
  #ewr1407-app .ewr1407-side-column {
    display: contents;
  }

  #ewr1407-app .ewr1407-stage {
    grid-area: stage;
    border-radius: 16px;
  }

  #ewr1407-app .ewr1407-remote-camera-card {
    grid-area: remote;
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
    padding: 7px;
    border-radius: 16px;
  }

  #ewr1407-app .ewr1407-remote-video-shell {
    grid-column: 1;
    grid-row: 1 / 3;
    border-radius: 12px;
  }

  #ewr1407-app .ewr1407-card-heading,
  #ewr1407-app .ewr1407-remote-status-row {
    display: none;
  }

  #ewr1407-app .ewr1407-mobile-local-slot {
    grid-column: 2;
    grid-row: 1;
    display: block;
    min-width: 0;
    min-height: 0;
  }

  #ewr1407-app .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100%;
    height: 100%;
    border-radius: 12px;
  }

  #ewr1407-app .ewr1407-mobile-tools {
    grid-area: remote;
    z-index: 7;
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
    padding: 7px;
    pointer-events: none;
  }

  #ewr1407-app .ewr1407-panic-button {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    height: 100%;
    pointer-events: auto;
  }

  #ewr1407-app .ewr1407-chat-notification-button {
    display: none;
  }

  #ewr1407-app .ewr1407-chat-panel {
    grid-area: chat;
    padding: 9px;
    border-radius: 16px;
  }

  #ewr1407-app .ewr1407-chat-header {
    min-height: 28px;
  }

  #ewr1407-app .ewr1407-card-kicker {
    display: none;
  }

  #ewr1407-app .ewr1407-message-bubble {
    font-size: 11px;
  }

  #ewr1407-app .ewr1407-stage-source-label {
    top: 7px;
    left: 7px;
    padding: 4px 7px;
    font-size: 8px;
  }

  #ewr1407-app .ewr1407-stage-controls {
    right: 7px;
    bottom: 7px;
    left: 7px;
    gap: 5px;
    padding: 6px;
  }

  #ewr1407-app .ewr1407-stage-control-button {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  #ewr1407-app .ewr1407-time-label {
    display: none;
  }

  #ewr1407-app .ewr1407-desktop-volume {
    display: none;
  }

  #ewr1407-app .ewr1407-volume-palette {
    left: -38px;
    grid-template-columns: repeat(10, minmax(28px, 1fr));
    width: min(370px, calc(100vw - 22px));
  }

  #ewr1407-app .ewr1407-volume-palette button {
    min-height: 30px;
    font-size: 8px;
  }

  #ewr1407-app .ewr1407-camera-quick-controls {
    grid-template-columns: repeat(2, 36px);
    gap: 8px;
  }

  #ewr1407-app .ewr1407-round-control {
    width: 36px;
    height: 36px;
  }

  #ewr1407-app[data-keyboard-context="chat"] {
    height: var(--ewr1407-visual-height, 100dvh);
  }

  #ewr1407-app[data-keyboard-context="search"] {
    height: 100dvh;
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: calc(100vw - 12px);
    max-height: calc(var(--ewr1407-visual-height, 100dvh) - 12px);
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: 1fr;
  }

  #ewr1407-app .ewr1407-settings-quality,
  #ewr1407-app .ewr1407-settings-stats {
    grid-column: auto;
  }

  #ewr1407-app .ewr1407-camera-popout {
    top: 7%;
    left: 5%;
    width: 90vw;
    height: 56vh;
    min-width: 0;
    min-height: 180px;
  }
}

/* iPhone landscape cinema */
@media (max-width: 850px) and (orientation: landscape) {
  #ewr1407-app {
    grid-template-columns: minmax(0, 68fr) minmax(0, 25fr) minmax(52px, 7fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding:
      max(6px, var(--ewr1407-safe-top))
      max(6px, var(--ewr1407-safe-right))
      max(6px, var(--ewr1407-safe-bottom))
      max(6px, var(--ewr1407-safe-left));
  }

  #ewr1407-app .ewr1407-topbar,
  #ewr1407-app .ewr1407-topbar-right,
  #ewr1407-app .ewr1407-workspace,
  #ewr1407-app .ewr1407-side-column,
  #ewr1407-app .ewr1407-mobile-tools {
    display: contents;
  }

  #ewr1407-app .ewr1407-topbar-actions,
  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-mini-stats,
  #ewr1407-app .ewr1407-chat-panel {
    display: none;
  }

  #ewr1407-app .ewr1407-stage {
    grid-column: 1;
    grid-row: 1 / 3;
    border-radius: 14px;
  }

  #ewr1407-app .ewr1407-remote-camera-card {
    grid-column: 2 / 4;
    grid-row: 2;
    padding: 6px;
    border-radius: 14px;
  }

  #ewr1407-app .ewr1407-remote-video-shell {
    border-radius: 10px;
  }

  #ewr1407-app .ewr1407-card-heading,
  #ewr1407-app .ewr1407-remote-status-row,
  #ewr1407-app .ewr1407-mobile-local-slot {
    display: none;
  }

  #ewr1407-app .ewr1407-local-camera-card {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    width: 100%;
    height: calc(50% - 3px);
    border-radius: 12px;
  }

  #ewr1407-app .ewr1407-panic-button {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    height: 100%;
  }

  #ewr1407-app .ewr1407-chat-notification-button {
    grid-column: 3;
    grid-row: 1;
    align-self: end;
    display: block;
    width: 100%;
    height: calc(50% - 3px);
    min-height: 0;
  }

  #ewr1407-app .ewr1407-stage-controls {
    right: 6px;
    bottom: 6px;
    left: 6px;
    gap: 5px;
    padding: 5px 7px;
  }

  #ewr1407-app .ewr1407-stage-control-button {
    width: 30px;
    height: 30px;
  }

  #ewr1407-app .ewr1407-time-label,
  #ewr1407-app .ewr1407-desktop-volume {
    display: none;
  }

  #ewr1407-app .ewr1407-volume-palette {
    left: -36px;
    grid-template-columns: repeat(10, minmax(26px, 1fr));
    width: min(360px, calc(100vw - 18px));
  }

  #ewr1407-app .ewr1407-volume-palette button {
    min-height: 28px;
    font-size: 7px;
  }

  #ewr1407-app .ewr1407-camera-quick-controls {
    grid-template-columns: repeat(2, 30px);
    gap: 5px;
  }

  #ewr1407-app .ewr1407-round-control {
    width: 30px;
    height: 30px;
  }

  #ewr1407-app .ewr1407-local-media-indicator {
    display: none;
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-camera-popout {
    top: 4%;
    left: 5%;
    width: 76vw;
    height: 88vh;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  #ewr1407-app {
    grid-template-rows: 46px minmax(0, 34fr) minmax(0, 22fr) minmax(0, 44fr);
  }

  #ewr1407-app[data-mode="call"] {
    grid-template-rows: 46px minmax(0, 29fr) minmax(0, 47fr) minmax(0, 24fr);
  }

  #ewr1407-app .ewr1407-topbar,
  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-icon-button {
    height: 46px;
  }

  #ewr1407-app .ewr1407-search-button {
    min-width: 48px;
  }

  #ewr1407-app .ewr1407-chat-panel {
    padding: 7px;
  }

  #ewr1407-app .ewr1407-chat-form {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
  }

  #ewr1407-app .ewr1407-chat-icon-button,
  #ewr1407-app .ewr1407-send-button {
    width: 34px;
    height: 34px;
  }

  #ewr1407-app .ewr1407-chat-input {
    min-height: 34px;
    font-size: 11px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    padding: 8px;
  }

  #ewr1407-app .ewr1407-quality-grid,
  #ewr1407-app .ewr1407-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ewr1407-app *,
  #ewr1407-app *::before,
  #ewr1407-app *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================
   Desktop layout and responsive shell
   ========================================================= */

#ewr1407-app .ewr1407-custom-name-input {
  margin-top: 8px;
}

#ewr1407-app .ewr1407-screen-share-button.ewr1407-screen-share-active {
  border-color: rgba(43, 216, 121, 0.82);
  background: rgba(17, 111, 64, 0.92);
  color: #ffffff;
}

#ewr1407-app .ewr1407-local-camera-card.ewr1407-microphone-active {
  border-color: #36d9ff;
  box-shadow:
    0 0 0 1px rgba(54, 217, 255, 0.95),
    0 0 18px rgba(54, 217, 255, 0.70),
    0 0 34px rgba(54, 217, 255, 0.24);
}

#ewr1407-app .ewr1407-local-media-overlay {
  position: absolute;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 4, 9, 0.76);
  backdrop-filter: blur(10px);
}

#ewr1407-app .ewr1407-local-media-dialog {
  display: grid;
  grid-template-columns: repeat(2, 112px);
  place-content: center;
  gap: 24px;
  width: min(420px, calc(100vw - 48px));
  min-height: 220px;
  padding: 32px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 28px;
  background: var(--ewr1407-panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

#ewr1407-app .ewr1407-media-control-button {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  padding: 0;
  border: 1px solid rgba(255, 91, 112, 0.95);
  border-radius: 28px;
  background: rgba(139, 25, 45, 0.96);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(94, 10, 25, 0.30);
}

#ewr1407-app .ewr1407-media-control-button.ewr1407-control-active {
  border-color: rgba(67, 235, 142, 0.96);
  background: rgba(20, 133, 75, 0.98);
  box-shadow: 0 16px 36px rgba(10, 92, 50, 0.30);
}

#ewr1407-app .ewr1407-media-control-button svg {
  width: 48px;
  height: 48px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-remote-camera-card {
  display: block;
  padding: 0;
}

#ewr1407-app .ewr1407-remote-video-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: inherit;
}

#ewr1407-app .ewr1407-remote-camera-video {
  object-fit: cover;
}

#ewr1407-app .ewr1407-remote-camera-card:hover .ewr1407-card-heading,
#ewr1407-app .ewr1407-remote-camera-card:focus-within .ewr1407-card-heading,
#ewr1407-app .ewr1407-remote-camera-card.ewr1407-remote-controls-visible .ewr1407-card-heading {
  opacity: 1;
  pointer-events: auto;
}

#ewr1407-app .ewr1407-camera-popout {
  max-width: calc(100vw - 32px);
  max-height: calc(var(--ewr1407-visual-height, 100dvh) - 32px);
}

#ewr1407-app .ewr1407-settings-mobile-only {
  display: none;
}

#ewr1407-app .ewr1407-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

#ewr1407-app .ewr1407-section-heading h3 {
  margin: 4px 0 0;
  font-family: Rajdhani, Montserrat, sans-serif;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;
}

#ewr1407-app .ewr1407-section-heading p {
  max-width: 390px;
  margin: 0;
  color: var(--ewr1407-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
}

#ewr1407-app .ewr1407-room-name-field {
  margin-top: 0;
}

@media (min-width: 1181px) {
  #ewr1407-app {
    grid-template-rows: 78px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  #ewr1407-app .ewr1407-topbar {
    grid-template-columns: minmax(330px, auto) minmax(360px, 1fr) minmax(210px, 240px) 112px;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(96px, 1fr));
    gap: 10px;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-icon-button {
    min-width: 0;
    padding: 0 12px;
    border-radius: 14px;
    white-space: nowrap;
  }

  #ewr1407-app .ewr1407-workspace {
    grid-template-columns: minmax(0, 4.55fr) minmax(290px, 1.15fr);
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-side-column {
    grid-template-rows: minmax(0, 0.92fr) minmax(0, 1.28fr);
    gap: 12px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-stage,
  #ewr1407-app .ewr1407-remote-camera-card,
  #ewr1407-app .ewr1407-chat-panel {
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: min(1180px, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    height: auto;
    max-height: calc(var(--ewr1407-visual-height, 100dvh) - 48px);
    border-radius: 26px;
  }

  #ewr1407-app .ewr1407-settings-header {
    padding: 18px 22px;
  }

  #ewr1407-app .ewr1407-settings-header h2 {
    margin-top: 3px;
    font-family: Rajdhani, Montserrat, sans-serif;
    font-size: 30px;
    line-height: 1;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
    grid-template-rows: auto auto;
    gap: 14px;
    padding: 16px;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-settings-section {
    min-width: 0;
    padding: 18px;
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-column: 2;
    grid-row: 1;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-column: 2;
    grid-row: 2;
  }

  #ewr1407-app .ewr1407-quality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #ewr1407-app .ewr1407-quality-block {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 10px;
    min-height: 230px;
    padding: 15px;
    border-radius: 15px;
  }

  #ewr1407-app .ewr1407-quality-heading {
    grid-column: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  #ewr1407-app .ewr1407-quality-heading span {
    color: var(--ewr1407-muted);
    font-size: 10px;
    line-height: 1.35;
  }

  #ewr1407-app .ewr1407-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #ewr1407-app .ewr1407-room-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #ewr1407-app .ewr1407-room-name-field,
  #ewr1407-app .ewr1407-room-info-grid .ewr1407-settings-danger {
    grid-column: 1 / -1;
  }

  #ewr1407-app .ewr1407-room-info-grid > div,
  #ewr1407-app .ewr1407-stats-grid > div {
    min-height: 62px;
    align-content: center;
  }
}

@media (max-width: 1180px) {
  #ewr1407-app .ewr1407-local-media-dialog {
    grid-template-columns: repeat(2, 92px);
    min-height: 190px;
  }

  #ewr1407-app .ewr1407-media-control-button {
    width: 92px;
    height: 92px;
    border-radius: 24px;
  }
}


@media (max-width: 600px), (max-width: 900px) and (max-height: 500px) {
  #ewr1407-app .ewr1407-settings-mobile-only {
    display: block;
  }
}

/* =========================================================
   Desktop player and media presentation
   ========================================================= */

#ewr1407-app .ewr1407-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Lobby */
#ewr1407-app .ewr1407-lobby-card {
  width: min(560px, 100%);
  padding: clamp(38px, 5vw, 58px);
  border-color: rgba(104, 220, 255, 0.54);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(16, 24, 36, 0.985), rgba(8, 13, 21, 0.985));
  box-shadow:
    0 36px 100px rgba(0, 0, 0, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#ewr1407-app .ewr1407-lobby-title {
  margin: 14px 0 32px;
  font-family: Montserrat, Inter, Arial, sans-serif;
  font-size: clamp(48px, 6vw, 72px);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

#ewr1407-app .ewr1407-lobby-card .ewr1407-field {
  margin-top: 0;
  font-size: 12px;
  font-weight: 600;
}

#ewr1407-app .ewr1407-lobby-card .ewr1407-input {
  min-height: 54px;
  padding: 0 17px;
  border-radius: 16px;
  font-size: 15px;
}

#ewr1407-app .ewr1407-create-room-button {
  min-height: 52px;
  margin-top: 16px;
  border-radius: 16px;
}

#ewr1407-app .ewr1407-create-room-label {
  font-size: 16px;
  letter-spacing: -0.01em;
}

#ewr1407-app .ewr1407-lobby-status {
  margin-top: 18px;
  font-size: 13px;
}

/* Integrated share button */
#ewr1407-app .ewr1407-youtube-search {
  grid-template-columns: 58px minmax(0, 1fr) auto;
}

#ewr1407-app .ewr1407-search-share-button {
  display: grid;
  place-items: center;
  width: 58px;
  min-width: 58px;
  height: 100%;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--ewr1407-border);
  background: transparent;
  color: var(--ewr1407-muted);
  cursor: pointer;
  transition:
    background 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

#ewr1407-app .ewr1407-search-share-button:hover {
  background: var(--ewr1407-panel-3);
  color: var(--ewr1407-text);
}

#ewr1407-app .ewr1407-search-share-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-search-share-button.ewr1407-screen-share-active {
  border-color: rgba(43, 216, 121, 0.72);
  background: rgba(43, 216, 121, 0.14);
  color: #55e69a;
  box-shadow: inset 0 0 0 1px rgba(43, 216, 121, 0.22);
}

/* Local camera */
#ewr1407-app .ewr1407-local-camera-card {
  aspect-ratio: 1 / 1;
  width: auto;
  height: 100%;
  min-width: 0;
  border-radius: 18px;
}

#ewr1407-app .ewr1407-local-camera-card.ewr1407-microphone-active {
  border-color: rgba(54, 217, 255, 0.88);
  box-shadow:
    0 0 0 1px rgba(54, 217, 255, 0.34),
    0 0 11px rgba(54, 217, 255, 0.34);
}

/* Remote camera */
#ewr1407-app .ewr1407-remote-camera-card {
  position: relative;
  overflow: hidden;
}

#ewr1407-app .ewr1407-card-heading {
  top: 12px;
  right: 12px;
  left: auto;
  width: auto;
  padding: 0;
  border-radius: 14px;
  background: rgba(3, 7, 12, 0.68);
  backdrop-filter: blur(12px);
}

#ewr1407-app .ewr1407-card-actions {
  padding: 6px;
}

#ewr1407-app .ewr1407-remote-name-banner {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 4;
  overflow: hidden;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(2, 5, 9, 0.84), rgba(2, 5, 9, 0.54));
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

#ewr1407-app .ewr1407-remote-camera-video {
  object-fit: cover;
}

/* Chat */
#ewr1407-app .ewr1407-chat-header strong {
  margin-top: 0;
  font-size: 17px;
}

#ewr1407-app .ewr1407-message-row {
  gap: 0;
}

#ewr1407-app .ewr1407-message-row + .ewr1407-message-grouped {
  margin-top: -5px;
}

#ewr1407-app .ewr1407-message-meta {
  margin: 0 7px 5px;
  font-size: 10px;
  font-weight: 600;
}

#ewr1407-app .ewr1407-message-bubble {
  padding: 9px 11px;
  font-size: 13px;
}

#ewr1407-app .ewr1407-emoji-palette {
  position: relative;
  z-index: 12;
  pointer-events: auto;
}

#ewr1407-app .ewr1407-emoji-palette button {
  display: grid;
  place-items: center;
  pointer-events: auto;
  user-select: none;
  font-size: 19px;
}

#ewr1407-app .ewr1407-emoji-palette button:hover,
#ewr1407-app .ewr1407-emoji-palette button:focus-visible {
  background: var(--ewr1407-panel-3);
  outline: none;
}

/* Settings typography */
#ewr1407-app .ewr1407-settings-dialog {
  width: min(1180px, calc(100vw - 48px));
  max-height: min(90dvh, 820px);
  border-radius: 30px;
}

#ewr1407-app .ewr1407-settings-header {
  padding: 22px 24px;
}

#ewr1407-app .ewr1407-settings-header h2 {
  margin-top: 5px;
  font-family: Montserrat, Inter, Arial, sans-serif;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.035em;
}

#ewr1407-app .ewr1407-settings-scroll {
  gap: 14px;
  padding: 16px;
}

#ewr1407-app .ewr1407-settings-section {
  padding: 18px;
  border-radius: 20px;
}

#ewr1407-app .ewr1407-section-heading h3 {
  font-family: Montserrat, Inter, Arial, sans-serif;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

#ewr1407-app .ewr1407-section-heading p {
  max-width: 430px;
  font-size: 13px;
  line-height: 1.55;
}

#ewr1407-app .ewr1407-card-kicker {
  font-size: 11px;
}

#ewr1407-app .ewr1407-quality-block {
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
}

#ewr1407-app .ewr1407-quality-heading strong {
  font-size: 17px;
}

#ewr1407-app .ewr1407-quality-heading span {
  font-size: 12px;
}

#ewr1407-app .ewr1407-quality-block label {
  gap: 7px;
  font-size: 12px;
}

#ewr1407-app .ewr1407-select,
#ewr1407-app .ewr1407-settings-room .ewr1407-input {
  min-height: 48px;
  font-size: 13px;
}

#ewr1407-app .ewr1407-stats-grid div,
#ewr1407-app .ewr1407-room-info-grid > div {
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
}

#ewr1407-app .ewr1407-stats-grid span,
#ewr1407-app .ewr1407-room-info-grid span {
  font-size: 11px;
}

#ewr1407-app .ewr1407-stats-grid strong,
#ewr1407-app .ewr1407-room-info-grid strong {
  font-size: 18px;
}

@media (min-width: 1181px) {
  #ewr1407-app {
    grid-template-rows: 88px minmax(0, 1fr);
  }

  #ewr1407-app .ewr1407-topbar {
    grid-template-columns: auto minmax(460px, 1fr) minmax(220px, 260px) 88px;
    min-height: 88px;
  }

  #ewr1407-app .ewr1407-topbar-actions,
  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-mini-stats,
  #ewr1407-app .ewr1407-local-camera-card {
    height: 88px;
  }

  #ewr1407-app .ewr1407-topbar-actions .ewr1407-icon-button {
    min-width: 154px;
    font-size: 14px;
  }

  #ewr1407-app .ewr1407-youtube-input {
    font-size: 14px;
  }

  #ewr1407-app .ewr1407-search-button {
    min-width: 112px;
    font-size: 13px;
    letter-spacing: 0.08em;
  }

  #ewr1407-app .ewr1407-mini-stats {
    padding: 14px 16px;
    font-size: 12px;
  }

  #ewr1407-app .ewr1407-mini-stats small {
    font-size: 10px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.85fr);
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-column: 2;
    grid-row: 1;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-column: 2;
    grid-row: 2;
  }

  #ewr1407-app .ewr1407-quality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  #ewr1407-app .ewr1407-local-camera-card {
    width: auto;
    height: 100%;
  }

  #ewr1407-app .ewr1407-remote-name-banner {
    right: 9px;
    bottom: 9px;
    left: 9px;
    padding: 7px 10px;
    font-size: 11px;
  }
}

/* =========================================================
   Themes, settings and desktop composition
   ========================================================= */

/* Palette system */
#ewr1407-app[data-palette="neon"] {
  --ewr1407-bg: #06090f;
  --ewr1407-panel: #0f1621;
  --ewr1407-panel-2: #141d2a;
  --ewr1407-panel-3: #192432;
  --ewr1407-border: rgba(139, 226, 255, 0.25);
  --ewr1407-border-strong: rgba(139, 226, 255, 0.56);
  --ewr1407-text: #f7fbff;
  --ewr1407-muted: #9aaabc;
  --ewr1407-soft: #6f7e91;
  --ewr1407-accent-a: #68dcff;
  --ewr1407-accent-b: #bd68ff;
  --ewr1407-control-bg: rgba(8, 12, 19, 0.88);
  background:
    radial-gradient(circle at 12% 0%, rgba(55, 217, 255, 0.10), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(174, 92, 255, 0.10), transparent 28%),
    var(--ewr1407-bg);
}

#ewr1407-app[data-palette="warm"] {
  --ewr1407-bg: #17130f;
  --ewr1407-panel: #241e18;
  --ewr1407-panel-2: #2d251d;
  --ewr1407-panel-3: #3a2f24;
  --ewr1407-border: rgba(238, 194, 138, 0.23);
  --ewr1407-border-strong: rgba(238, 194, 138, 0.54);
  --ewr1407-text: #fff8ed;
  --ewr1407-muted: #c7b7a3;
  --ewr1407-soft: #948372;
  --ewr1407-accent-a: #f2cc92;
  --ewr1407-accent-b: #c88954;
  --ewr1407-control-bg: rgba(30, 24, 18, 0.90);
  background:
    radial-gradient(circle at 10% 0%, rgba(242, 204, 146, 0.12), transparent 33%),
    radial-gradient(circle at 92% 2%, rgba(200, 137, 84, 0.11), transparent 30%),
    var(--ewr1407-bg);
}

#ewr1407-app[data-palette="velvet"] {
  --ewr1407-bg: #11080b;
  --ewr1407-panel: #211015;
  --ewr1407-panel-2: #2b141b;
  --ewr1407-panel-3: #3a1822;
  --ewr1407-border: rgba(255, 111, 139, 0.24);
  --ewr1407-border-strong: rgba(255, 111, 139, 0.56);
  --ewr1407-text: #fff6f8;
  --ewr1407-muted: #c9a7af;
  --ewr1407-soft: #8e6871;
  --ewr1407-accent-a: #ff6f8b;
  --ewr1407-accent-b: #b72d58;
  --ewr1407-control-bg: rgba(26, 10, 15, 0.91);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 91, 127, 0.12), transparent 31%),
    radial-gradient(circle at 88% 0%, rgba(121, 27, 67, 0.18), transparent 32%),
    var(--ewr1407-bg);
}

#ewr1407-app[data-palette="apple"] {
  --ewr1407-bg: #f5f5f7;
  --ewr1407-panel: rgba(255, 255, 255, 0.82);
  --ewr1407-panel-2: rgba(246, 246, 248, 0.92);
  --ewr1407-panel-3: rgba(231, 232, 235, 0.96);
  --ewr1407-border: rgba(29, 29, 31, 0.15);
  --ewr1407-border-strong: rgba(29, 29, 31, 0.30);
  --ewr1407-text: #1d1d1f;
  --ewr1407-muted: #5f6368;
  --ewr1407-soft: #85888d;
  --ewr1407-accent-a: #5ac8fa;
  --ewr1407-accent-b: #0071e3;
  --ewr1407-control-bg: rgba(255, 255, 255, 0.88);
  --ewr1407-shadow: 0 24px 72px rgba(50, 50, 60, 0.16);
  background:
    radial-gradient(circle at 12% 0%, rgba(90, 200, 250, 0.20), transparent 31%),
    radial-gradient(circle at 90% 0%, rgba(175, 82, 222, 0.10), transparent 30%),
    var(--ewr1407-bg);
}

#ewr1407-app[data-palette="apple"] .ewr1407-stage,
#ewr1407-app[data-palette="apple"] .ewr1407-remote-camera-card,
#ewr1407-app[data-palette="apple"] .ewr1407-local-camera-card {
  background: #000;
  color: #fff;
}

/* Lobby hierarchy — stronger, wider, more deliberate */
#ewr1407-app .ewr1407-lobby-card {
  width: min(650px, calc(100vw - 40px));
  padding: clamp(48px, 6vw, 72px);
}

#ewr1407-app .ewr1407-lobby-title {
  margin: 18px 0 48px;
  font-size: clamp(56px, 6vw, 82px);
  font-weight: 760;
  line-height: 0.94;
  letter-spacing: -0.058em;
  word-spacing: 0.06em;
}

#ewr1407-app .ewr1407-lobby-card .ewr1407-field {
  gap: 10px;
  font-size: 13px;
}

#ewr1407-app .ewr1407-lobby-card .ewr1407-input {
  min-height: 58px;
  font-size: 16px;
}

#ewr1407-app .ewr1407-create-room-button {
  min-height: 56px;
  margin-top: 18px;
}

/* Empty player uses the supplied artwork instead of placeholder copy */
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-stage-placeholder {
  display: block;
  background:
    linear-gradient(180deg, rgba(2, 4, 8, 0.10), rgba(2, 4, 8, 0.32)),
    url("https://images8.alphacoders.com/127/1272726.png") center center / cover no-repeat;
}

#ewr1407-app[data-mode="call"] .ewr1407-stage[data-source="empty"] .ewr1407-stage-placeholder {
  display: block;
}

/* Microphone state: a clean cyan outline, no outer glow */
#ewr1407-app .ewr1407-local-camera-card.ewr1407-microphone-active {
  border-color: #26d8ff;
  box-shadow: inset 0 0 0 1px rgba(38, 216, 255, 0.78);
}

/* Palette selector */
#ewr1407-app .ewr1407-palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#ewr1407-app .ewr1407-palette-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 15px;
  background: var(--ewr1407-panel);
  color: var(--ewr1407-text);
  text-align: left;
  cursor: pointer;
}

#ewr1407-app .ewr1407-palette-button:hover,
#ewr1407-app .ewr1407-palette-button-active {
  border-color: var(--ewr1407-border-strong);
  background: var(--ewr1407-panel-3);
}

#ewr1407-app .ewr1407-palette-button-active {
  box-shadow: inset 0 0 0 1px var(--ewr1407-accent-a);
}

#ewr1407-app .ewr1407-palette-button > span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

#ewr1407-app .ewr1407-palette-button strong {
  font-size: 14px;
}

#ewr1407-app .ewr1407-palette-button small {
  overflow: hidden;
  color: var(--ewr1407-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ewr1407-app .ewr1407-palette-preview {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 12px;
}

#ewr1407-app .ewr1407-palette-preview-neon {
  background: linear-gradient(135deg, #0d1724 48%, #68dcff 49%, #bd68ff);
}

#ewr1407-app .ewr1407-palette-preview-warm {
  background: linear-gradient(135deg, #2d251d 48%, #f2cc92 49%, #c88954);
}

#ewr1407-app .ewr1407-palette-preview-velvet {
  background: linear-gradient(135deg, #2b141b 48%, #ff6f8b 49%, #8c1e47);
}

#ewr1407-app .ewr1407-palette-preview-apple {
  border-color: rgba(29, 29, 31, 0.15);
  background: linear-gradient(135deg, #ffffff 48%, #5ac8fa 49%, #0071e3);
}

#ewr1407-app .ewr1407-toolbar-svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

@media (min-width: 1181px) {
  #ewr1407-app {
    grid-template-rows: 74px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px 12px;
  }

  #ewr1407-app .ewr1407-topbar {
    grid-template-columns: auto minmax(0, 1fr) minmax(250px, 280px) 74px;
    gap: 10px;
    min-height: 74px;
  }

  #ewr1407-app .ewr1407-topbar-actions,
  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-mini-stats,
  #ewr1407-app .ewr1407-local-camera-card {
    height: 74px;
  }

  #ewr1407-app .ewr1407-topbar-actions {
    gap: 10px;
  }

  #ewr1407-app .ewr1407-topbar-actions .ewr1407-icon-button {
    width: 74px;
    min-width: 74px;
    height: 74px;
    padding: 0;
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-topbar-actions .ewr1407-button-label {
    display: none;
  }

  #ewr1407-app .ewr1407-youtube-search {
    min-width: 0;
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-search-share-button {
    width: 62px;
    min-width: 62px;
  }

  #ewr1407-app .ewr1407-youtube-input {
    padding-inline: 18px;
    font-size: 15px;
  }

  #ewr1407-app .ewr1407-search-button {
    min-width: 114px;
    font-size: 13px;
  }

  #ewr1407-app .ewr1407-mini-stats {
    height: 74px;
    padding: 12px 14px;
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-local-camera-card {
    width: 74px;
    min-width: 74px;
    height: 74px;
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-camera-placeholder {
    font-size: 10px;
    line-height: 1.25;
  }

  #ewr1407-app .ewr1407-workspace {
    min-height: 0;
  }

  /* Settings consume the horizontal desktop space and fit the viewport */
  #ewr1407-app .ewr1407-settings-overlay {
    padding: 16px;
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: min(1460px, calc(100vw - 32px));
    height: min(790px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    border-radius: 28px;
  }

  #ewr1407-app .ewr1407-settings-header {
    padding: 20px 24px;
  }

  #ewr1407-app .ewr1407-settings-header h2 {
    font-size: 34px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.72fr) minmax(280px, 0.72fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "quality stats theme"
      "quality room room";
    gap: 14px;
    padding: 14px;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-area: quality;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-area: stats;
  }

  #ewr1407-app .ewr1407-settings-theme {
    grid-area: theme;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-area: room;
  }

  #ewr1407-app .ewr1407-settings-section {
    min-height: 0;
    padding: 18px;
    border-radius: 20px;
    overflow: hidden;
  }

  #ewr1407-app .ewr1407-settings-quality {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  #ewr1407-app .ewr1407-quality-grid {
    align-content: start;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #ewr1407-app .ewr1407-section-heading {
    gap: 16px;
    margin-bottom: 16px;
  }

  #ewr1407-app .ewr1407-section-heading h3 {
    font-size: 24px;
  }

  #ewr1407-app .ewr1407-section-heading p {
    font-size: 13px;
  }

  #ewr1407-app .ewr1407-quality-block {
    padding: 16px;
  }

  #ewr1407-app .ewr1407-stats-grid {
    gap: 8px;
  }

  #ewr1407-app .ewr1407-stats-grid div,
  #ewr1407-app .ewr1407-room-info-grid > div {
    padding: 12px;
  }

  #ewr1407-app .ewr1407-stats-grid strong,
  #ewr1407-app .ewr1407-room-info-grid strong {
    font-size: 17px;
  }

  #ewr1407-app .ewr1407-room-info-grid {
    grid-template-columns: minmax(220px, 1fr) 0.65fr 0.85fr;
    align-items: end;
  }

  #ewr1407-app .ewr1407-room-name-field {
    grid-column: 1;
    margin: 0;
  }

  #ewr1407-app .ewr1407-settings-danger {
    grid-column: 1 / -1;
  }
}

/* =========================================================
   Playback and broadcast controls
   ========================================================= */

/* Stronger broadcast-style type hierarchy */
#ewr1407-app {
  --ewr1407-gap: 12px;
  font-family: Montserrat, Inter, "Segoe UI", Arial, sans-serif;
}

#ewr1407-app .ewr1407-kicker,
#ewr1407-app .ewr1407-card-kicker,
#ewr1407-app .ewr1407-search-button,
#ewr1407-app .ewr1407-button-label,
#ewr1407-app .ewr1407-section-heading h3,
#ewr1407-app .ewr1407-quality-heading strong {
  font-family: "Bahnschrift SemiCondensed", "Arial Narrow", Montserrat, sans-serif;
}

#ewr1407-app .ewr1407-kicker,
#ewr1407-app .ewr1407-card-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

/* Supplied artwork must cover the complete empty stage. */
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-stage-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.16)),
    url("https://images8.alphacoders.com/127/1272726.png") center center / cover no-repeat;
}

#ewr1407-app[data-mode="call"] .ewr1407-stage[data-source="empty"] .ewr1407-call-background {
  display: none;
}

/* Named camera placeholders. */
#ewr1407-app .ewr1407-camera-placeholder[data-avatar="true"] {
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  color: transparent;
}

/* Microphone state is an illuminated inner cyan line, never an outer glow. */
#ewr1407-app .ewr1407-local-camera-card.ewr1407-microphone-active,
#ewr1407-app .ewr1407-remote-camera-card.ewr1407-microphone-active,
#ewr1407-app .ewr1407-camera-popout.ewr1407-microphone-active {
  border-color: #24d9ff;
  box-shadow: inset 0 0 0 2px rgba(36, 217, 255, 0.86);
}

/* Copy confirmation uses the same visual weight as the toolbar icons. */
#ewr1407-app .ewr1407-room-link-button .ewr1407-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

/* Remote camera overlay and voice gain (0–200%, centre = normal). */
#ewr1407-app .ewr1407-card-heading {
  display: grid;
  grid-template-columns: auto minmax(170px, 1fr);
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 6px;
}

#ewr1407-app .ewr1407-remote-audio-control {
  display: grid;
  grid-template-columns: auto auto minmax(70px, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 0 7px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-weight: 700;
}

#ewr1407-app .ewr1407-remote-audio-control input {
  min-width: 70px;
  accent-color: #24d9ff;
}

#ewr1407-app .ewr1407-remote-audio-control output {
  min-width: 38px;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#ewr1407-app .ewr1407-remote-audio-control:has(input:disabled) {
  opacity: 0.42;
}

/* Screen streams receive the same local volume controls as YouTube. */
#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-stage-controls {
  display: flex;
}

#ewr1407-app .ewr1407-stage[data-source="screen"][data-screen-local="true"] .ewr1407-stage-controls {
  display: none;
}

#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-youtube-only {
  display: none;
}

#ewr1407-app .ewr1407-stage-controls button:disabled,
#ewr1407-app .ewr1407-stage-controls input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* Fully styled select components; native selects remain as the data model. */
#ewr1407-app .ewr1407-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#ewr1407-app .ewr1407-custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
  z-index: 20;
}

#ewr1407-app .ewr1407-custom-select[data-open="true"] {
  z-index: 120;
}

#ewr1407-app .ewr1407-custom-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--ewr1407-panel-2);
  color: var(--ewr1407-text);
  font-size: 14px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

#ewr1407-app .ewr1407-custom-select-button:hover,
#ewr1407-app .ewr1407-custom-select[data-open="true"] .ewr1407-custom-select-button {
  border-color: var(--ewr1407-border-strong);
  background: var(--ewr1407-panel-3);
}

#ewr1407-app .ewr1407-custom-select-chevron {
  color: var(--ewr1407-accent-a);
  font-size: 20px;
  transform: translateY(-2px);
  transition: transform 150ms ease;
}

#ewr1407-app .ewr1407-custom-select[data-open="true"] .ewr1407-custom-select-chevron {
  transform: rotate(180deg) translateY(2px);
}

#ewr1407-app .ewr1407-custom-select-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  display: none;
  max-height: min(330px, 42dvh);
  overflow-y: auto;
  padding: 7px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ewr1407-panel) 96%, transparent);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(20px);
}

#ewr1407-app .ewr1407-custom-select[data-open="true"] .ewr1407-custom-select-menu {
  display: grid;
  gap: 4px;
}

#ewr1407-app .ewr1407-custom-select-menu button {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ewr1407-text);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

#ewr1407-app .ewr1407-custom-select-menu button:hover,
#ewr1407-app .ewr1407-custom-select-menu button[data-selected="true"] {
  background: linear-gradient(90deg, color-mix(in srgb, var(--ewr1407-accent-a) 18%, transparent), transparent);
  color: var(--ewr1407-text);
}

#ewr1407-app .ewr1407-custom-select-menu button[data-selected="true"]::before {
  content: "●";
  margin-right: 9px;
  color: var(--ewr1407-accent-a);
  font-size: 9px;
}

#ewr1407-app .ewr1407-settings-room .ewr1407-custom-select-menu {
  top: auto;
  bottom: calc(100% + 7px);
}

/* Bright warm palette works as an intentional on-screen light source. */
#ewr1407-app[data-palette="warm"] {
  --ewr1407-bg: #fff4dc;
  --ewr1407-panel: #fffaf0;
  --ewr1407-panel-2: #f6ead5;
  --ewr1407-panel-3: #ead7b8;
  --ewr1407-border: rgba(73, 52, 28, 0.20);
  --ewr1407-border-strong: rgba(73, 52, 28, 0.42);
  --ewr1407-text: #1f1810;
  --ewr1407-muted: #6f5c47;
  --ewr1407-soft: #927d64;
  --ewr1407-accent-a: #ffc85a;
  --ewr1407-accent-b: #ff8a3d;
  --ewr1407-control-bg: rgba(255, 250, 240, 0.94);
  --ewr1407-shadow: 0 20px 54px rgba(107, 74, 34, 0.15);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.98), transparent 48%),
    linear-gradient(135deg, #fffdf5, #ffe7b7 72%, #ffd18a);
}

#ewr1407-app[data-palette="warm"] .ewr1407-stage,
#ewr1407-app[data-palette="warm"] .ewr1407-remote-camera-card,
#ewr1407-app[data-palette="warm"] .ewr1407-local-camera-card {
  background: #000;
  color: #fff;
}

/* Realistic cyberpunk palette: urban black, acid yellow, cyan and restrained magenta. */
#ewr1407-app[data-palette="cyberpunk"] {
  --ewr1407-bg: #050507;
  --ewr1407-panel: #111116;
  --ewr1407-panel-2: #191920;
  --ewr1407-panel-3: #24242d;
  --ewr1407-border: rgba(235, 240, 40, 0.22);
  --ewr1407-border-strong: rgba(235, 240, 40, 0.68);
  --ewr1407-text: #f7f7ef;
  --ewr1407-muted: #a6a6a0;
  --ewr1407-soft: #77777f;
  --ewr1407-accent-a: #eef238;
  --ewr1407-accent-b: #00d9ff;
  --ewr1407-control-bg: rgba(8, 8, 12, 0.92);
  --ewr1407-shadow: 0 22px 64px rgba(0, 0, 0, 0.55);
  background:
    linear-gradient(118deg, transparent 0 67%, rgba(255, 37, 138, 0.055) 67% 68%, transparent 68%),
    radial-gradient(circle at 85% 0%, rgba(0, 217, 255, 0.10), transparent 30%),
    radial-gradient(circle at 10% 0%, rgba(238, 242, 56, 0.09), transparent 28%),
    #050507;
}

#ewr1407-app .ewr1407-palette-preview-cyberpunk {
  background: linear-gradient(135deg, #09090d 0 44%, #eef238 45% 62%, #00d9ff 63% 80%, #ff258a 81%);
}

#ewr1407-app .ewr1407-palette-preview-warm {
  border-color: rgba(73, 52, 28, 0.18);
  background: linear-gradient(135deg, #fffdf5 0 48%, #ffc85a 49%, #ff8a3d);
}

/* Desktop structure: top toolbar and workspace use the identical two-column grid. */
@media (min-width: 1181px) {
  #ewr1407-app {
    grid-template-rows: 78px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px 12px;
  }

  #ewr1407-app .ewr1407-topbar,
  #ewr1407-app .ewr1407-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 340px);
    gap: 12px;
  }

  #ewr1407-app .ewr1407-topbar {
    display: grid;
    min-height: 78px;
  }

  #ewr1407-app .ewr1407-topbar-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-topbar-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 12px;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-topbar-actions,
  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-mini-stats,
  #ewr1407-app .ewr1407-local-camera-card {
    height: 78px;
  }

  #ewr1407-app .ewr1407-topbar-actions {
    gap: 12px;
  }

  #ewr1407-app .ewr1407-topbar-actions .ewr1407-icon-button {
    width: 78px;
    min-width: 78px;
    height: 78px;
    border-radius: 14px;
  }

  #ewr1407-app .ewr1407-youtube-search,
  #ewr1407-app .ewr1407-mini-stats,
  #ewr1407-app .ewr1407-local-camera-card,
  #ewr1407-app .ewr1407-stage,
  #ewr1407-app .ewr1407-remote-camera-card,
  #ewr1407-app .ewr1407-chat-panel {
    border-radius: 14px;
  }

  #ewr1407-app .ewr1407-youtube-search {
    min-width: 0;
  }

  #ewr1407-app .ewr1407-mini-stats {
    width: auto;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-local-camera-card {
    width: 78px;
    min-width: 78px;
    aspect-ratio: 1 / 1;
  }

  /* Settings use the viewport efficiently without making the page scroll. */
  #ewr1407-app .ewr1407-settings-overlay {
    padding: 12px;
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: min(1500px, calc(100vw - 24px));
    height: min(860px, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  #ewr1407-app .ewr1407-settings-header {
    min-height: 86px;
    padding: 18px 24px;
  }

  #ewr1407-app .ewr1407-settings-header h2 {
    font-size: 38px;
    font-weight: 780;
    letter-spacing: -0.045em;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.78fr) minmax(300px, 0.78fr);
    grid-template-rows: minmax(300px, 1fr) auto;
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #ewr1407-app .ewr1407-settings-section {
    padding: 18px;
    border-radius: 14px;
  }

  #ewr1407-app .ewr1407-section-heading h3 {
    font-size: 26px;
    font-weight: 760;
    letter-spacing: -0.025em;
  }

  #ewr1407-app .ewr1407-section-heading p,
  #ewr1407-app .ewr1407-quality-heading span,
  #ewr1407-app .ewr1407-quality-block label,
  #ewr1407-app .ewr1407-stats-grid span,
  #ewr1407-app .ewr1407-room-info-grid span {
    font-size: 12px;
    line-height: 1.45;
  }

  #ewr1407-app .ewr1407-quality-heading strong {
    font-size: 19px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
  }

  #ewr1407-app .ewr1407-stats-grid strong,
  #ewr1407-app .ewr1407-room-info-grid strong {
    font-size: 19px;
  }

  #ewr1407-app .ewr1407-palette-button {
    min-height: 62px;
    border-radius: 11px;
  }
}

/* =========================================================
   Shared components and media switching
   ========================================================= */

/* The supplied artwork always fills the empty stage. */
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-stage-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(1, 2, 5, 0.06), rgba(1, 2, 5, 0.20)),
    url("https://images8.alphacoders.com/127/1272726.png") center center / cover no-repeat;
}

#ewr1407-app .ewr1407-stage-source-label {
  display: none !important;
}

/* Strong but clean microphone state on local, remote and pop-out cameras. */
#ewr1407-app .ewr1407-local-camera-card.ewr1407-microphone-active,
#ewr1407-app .ewr1407-remote-camera-card.ewr1407-microphone-active,
#ewr1407-app .ewr1407-camera-popout.ewr1407-microphone-active {
  border: 3px solid #20dfff;
  box-shadow: inset 0 0 0 1px rgba(32, 223, 255, 0.34);
}

/* Copy confirmation has the same scale as the regular toolbar icons. */
#ewr1407-app .ewr1407-copied-check {
  width: 30px;
  height: 30px;
  fill: #51efa8;
}

/* Custom dropdowns intentionally omit arrows and selected-item glyphs. */
#ewr1407-app .ewr1407-custom-select-button {
  grid-template-columns: minmax(0, 1fr);
  padding-inline: 16px;
}

#ewr1407-app .ewr1407-custom-select-chevron,
#ewr1407-app .ewr1407-custom-select-menu button[data-selected="true"]::before {
  display: none !important;
}

#ewr1407-app .ewr1407-custom-select-menu {
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.46);
}

#ewr1407-app .ewr1407-custom-select-menu button {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 720;
}

/* Reusable, professional speaker icon. */
#ewr1407-app .ewr1407-speaker-svg {
  width: 21px;
  height: 21px;
  overflow: visible;
  fill: currentColor;
}

#ewr1407-app .ewr1407-speaker-wave {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

#ewr1407-app .ewr1407-muted .ewr1407-speaker-wave {
  opacity: 0.18;
}

/* Remote voice controls: icon, gain slider and compact percentage only. */
#ewr1407-app .ewr1407-remote-audio-control {
  grid-template-columns: 26px minmax(90px, 1fr) 42px;
  gap: 8px;
  padding: 0 8px;
}

#ewr1407-app .ewr1407-remote-audio-control .ewr1407-speaker-svg {
  width: 22px;
  height: 22px;
}

#ewr1407-app .ewr1407-remote-audio-control input {
  width: 100%;
  min-width: 90px;
}

/* The common stage volume slider sits directly beside the mute button. */
#ewr1407-app .ewr1407-stage-volume-slider {
  flex: 0 1 150px;
  width: clamp(90px, 12vw, 170px);
  min-width: 90px;
  accent-color: var(--ewr1407-accent-b);
}

#ewr1407-app .ewr1407-desktop-volume {
  display: none !important;
}

/* YouTube quality helper: the public IFrame API cannot set resolution. */
#ewr1407-app .ewr1407-youtube-quality-control {
  position: relative;
  display: grid;
  place-items: center;
}

#ewr1407-app .ewr1407-gear-svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-youtube-quality-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(290px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 10px;
  background: rgba(7, 10, 15, 0.96);
  color: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.48);
  text-align: left;
}

#ewr1407-app .ewr1407-youtube-quality-panel[hidden] {
  display: none;
}

#ewr1407-app .ewr1407-youtube-quality-panel strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

#ewr1407-app .ewr1407-youtube-quality-panel p {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
}

#ewr1407-app .ewr1407-youtube-quality-panel button {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: #fff;
  color: #080b10;
  font-weight: 800;
  cursor: pointer;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-stage-controls {
  bottom: 54px;
}

#ewr1407-app .ewr1407-stage[data-youtube-native-controls="true"] .ewr1407-stage-controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Flashlight is a genuine bright mode: all interface text becomes dark. */
#ewr1407-app[data-palette="warm"] {
  color: #111318;
}

#ewr1407-app[data-palette="warm"] .ewr1407-topbar,
#ewr1407-app[data-palette="warm"] .ewr1407-settings-dialog,
#ewr1407-app[data-palette="warm"] .ewr1407-chat-panel,
#ewr1407-app[data-palette="warm"] .ewr1407-settings-section,
#ewr1407-app[data-palette="warm"] .ewr1407-mini-stats,
#ewr1407-app[data-palette="warm"] .ewr1407-youtube-search,
#ewr1407-app[data-palette="warm"] .ewr1407-icon-button,
#ewr1407-app[data-palette="warm"] .ewr1407-custom-select-button,
#ewr1407-app[data-palette="warm"] .ewr1407-custom-select-menu,
#ewr1407-app[data-palette="warm"] .ewr1407-palette-button,
#ewr1407-app[data-palette="warm"] .ewr1407-quality-block,
#ewr1407-app[data-palette="warm"] .ewr1407-stats-grid > div,
#ewr1407-app[data-palette="warm"] .ewr1407-room-info-grid > div {
  color: #111318;
}

#ewr1407-app[data-palette="warm"] .ewr1407-muted,
#ewr1407-app[data-palette="warm"] .ewr1407-soft,
#ewr1407-app[data-palette="warm"] .ewr1407-card-kicker,
#ewr1407-app[data-palette="warm"] .ewr1407-section-heading p,
#ewr1407-app[data-palette="warm"] .ewr1407-mini-stats,
#ewr1407-app[data-palette="warm"] .ewr1407-mini-stats small,
#ewr1407-app[data-palette="warm"] .ewr1407-youtube-input,
#ewr1407-app[data-palette="warm"] .ewr1407-stats-grid span,
#ewr1407-app[data-palette="warm"] .ewr1407-room-info-grid span {
  color: #3d3328;
}

#ewr1407-app[data-palette="warm"] .ewr1407-stage-controls,
#ewr1407-app[data-palette="warm"] .ewr1407-card-heading,
#ewr1407-app[data-palette="warm"] .ewr1407-remote-name-banner {
  border-color: rgba(20, 20, 20, 0.16);
  background: rgba(255, 250, 239, 0.93);
  color: #111318;
}

/* Desktop: one consistent 10px rhythm and no unused third action column. */
@media (min-width: 1181px) {
  #ewr1407-app {
    --ewr1407-gap: 10px;
    gap: 10px;
    padding: 10px;
  }

  #ewr1407-app .ewr1407-topbar,
  #ewr1407-app .ewr1407-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 340px);
    gap: 10px;
  }

  #ewr1407-app .ewr1407-topbar-main {
    display: grid;
    grid-template-columns: 166px minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, 78px);
    gap: 10px;
    width: 166px;
    min-width: 166px;
  }

  #ewr1407-app .ewr1407-topbar-right {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 10px;
  }

  #ewr1407-app .ewr1407-youtube-search {
    width: 100%;
    min-width: 0;
  }

  #ewr1407-app .ewr1407-side-column {
    gap: 10px;
  }

  #ewr1407-app .ewr1407-card-heading {
    grid-template-columns: auto minmax(140px, 1fr);
  }
}


/* ========================================================================== 
   Room state, audio gain and source switching
   ========================================================================== */

/* Keep the settings name dropdown above neighbouring cards and controls. */
#ewr1407-app .ewr1407-settings-section {
  position: relative;
}

#ewr1407-app .ewr1407-settings-room {
  z-index: 8;
  overflow: visible;
}

#ewr1407-app .ewr1407-settings-room:has(.ewr1407-custom-select[data-open="true"]) {
  z-index: 1000;
}

#ewr1407-app .ewr1407-settings-room .ewr1407-custom-select[data-open="true"] {
  z-index: 1100;
}

#ewr1407-app .ewr1407-settings-room .ewr1407-custom-select-menu {
  top: calc(100% + 7px);
  bottom: auto;
  z-index: 1200;
}

@media (min-width: 1181px) {
  #ewr1407-app .ewr1407-settings-dialog,
  #ewr1407-app .ewr1407-settings-scroll {
    overflow: visible;
  }
}

/* The remote voice slider must stay interactive while the camera overlay is visible. */
#ewr1407-app .ewr1407-card-heading,
#ewr1407-app .ewr1407-remote-audio-control,
#ewr1407-app .ewr1407-remote-audio-control input,
#ewr1407-app .ewr1407-remote-audio-control output {
  pointer-events: auto;
}

#ewr1407-app .ewr1407-remote-audio-control input[type="range"] {
  position: relative;
  z-index: 4;
  cursor: pointer;
  touch-action: none;
}

/* Explicit stacking keeps YouTube visible after leaving a screen share. */
#ewr1407-app .ewr1407-screen-video {
  z-index: 1;
}

#ewr1407-app .ewr1407-youtube-player-shell {
  z-index: 2;
  overflow: hidden;
  background: #000;
}

#ewr1407-app .ewr1407-youtube-player-shell iframe {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  border: 0 !important;
  visibility: visible !important;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-screen-video,
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-screen-video {
  display: none !important;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-youtube-player-shell {
  display: block !important;
}

#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-youtube-player-shell,
#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-youtube-player-shell {
  display: none !important;
}


/* ========================================================================== 
   YouTube embed and search-field behavior
   ========================================================================== */
#ewr1407-app .ewr1407-youtube-search {
  grid-template-columns: 58px minmax(0, 1fr) 46px auto;
}

#ewr1407-app .ewr1407-search-clear-button {
  display: grid;
  place-items: center;
  width: 46px;
  min-width: 46px;
  height: 100%;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--ewr1407-border);
  background: transparent;
  color: var(--ewr1407-muted);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

#ewr1407-app .ewr1407-search-clear-button:hover,
#ewr1407-app .ewr1407-search-clear-button:focus-visible {
  background: var(--ewr1407-panel-3);
  color: var(--ewr1407-text);
  outline: none;
}

#ewr1407-app .ewr1407-search-clear-button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Keep the YouTube iframe entirely below screen sharing when sources switch. */
#ewr1407-app .ewr1407-stage[data-source="screen"] .ewr1407-youtube-player-shell,
#ewr1407-app .ewr1407-stage[data-source="empty"] .ewr1407-youtube-player-shell {
  display: none !important;
  pointer-events: none !important;
}

#ewr1407-app .ewr1407-stage[data-source="youtube"] .ewr1407-youtube-player-shell {
  display: block !important;
  pointer-events: auto !important;
}


/* ==========================================================================
   Reconnect-safe settings controls
   ========================================================================== */

/* Open the settings display-name menu upward so it stays inside the viewport. */
#ewr1407-app .ewr1407-settings-room .ewr1407-custom-select-menu {
  top: auto !important;
  bottom: calc(100% + 8px) !important;
  max-height: min(260px, 34dvh);
  transform-origin: bottom center;
}

#ewr1407-app .ewr1407-settings-room:has(.ewr1407-custom-select[data-open="true"]) {
  z-index: 1400;
}

#ewr1407-app .ewr1407-settings-room .ewr1407-custom-select[data-open="true"] {
  z-index: 1500;
}


/* ========================================================================== 
   Tablet chat keyboard viewport
   ========================================================================== */

/* Share, reload, input, clear, search. */
#ewr1407-app .ewr1407-youtube-search {
  grid-template-columns: 58px 58px minmax(0, 1fr) 46px auto;
}

#ewr1407-app .ewr1407-search-reload-button {
  display: grid;
  place-items: center;
  width: 58px;
  min-width: 58px;
  height: 100%;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--ewr1407-border);
  background: transparent;
  color: var(--ewr1407-muted);
  cursor: pointer;
  transition:
    background 150ms ease,
    color 150ms ease,
    opacity 150ms ease;
}

#ewr1407-app .ewr1407-search-reload-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-search-reload-button:hover,
#ewr1407-app .ewr1407-search-reload-button:focus-visible {
  background: var(--ewr1407-panel-3);
  color: var(--ewr1407-text);
  outline: none;
}

#ewr1407-app .ewr1407-search-reload-button[aria-busy="true"] svg {
  animation: ewr1407-reconnect-spin 850ms linear infinite;
}

#ewr1407-app .ewr1407-search-reload-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

#ewr1407-app .ewr1407-search-reload-button[aria-busy="true"]:disabled {
  opacity: 0.78;
  cursor: wait;
}

@media (min-width: 1181px) {
  #ewr1407-app .ewr1407-youtube-search {
    grid-template-columns: 62px 62px minmax(0, 1fr) 46px auto;
  }

  #ewr1407-app .ewr1407-search-reload-button {
    width: 62px;
    min-width: 62px;
  }
}

@keyframes ewr1407-reconnect-spin {
  to { transform: rotate(360deg); }
}

/* Tablet chat keyboard layout
   Search remains behind the keyboard. During chat input, the chat expands to
   the full right column and the remote camera moves over the left player. */
#ewr1407-app[data-device-class="tablet"] {
  height: 100dvh;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="search"] {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  transform: none;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--ewr1407-visual-height, 100dvh);
  transform: none;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-workspace {
  position: relative;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 34vw, 370px);
  min-height: 0;
  overflow: hidden;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-side-column {
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: visible;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-chat-panel {
  grid-row: 1;
  min-height: 0;
  height: 100%;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-chat-log {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-chat-form {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-camera-card {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 18;
  width: clamp(190px, 27vw, 270px);
  height: min(calc(100% - 24px), 330px);
  min-height: 0;
  margin: 0;
  transform: translateY(-50%);
  border-width: 1px;
  border-radius: 16px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
  height: 100%;
  border-radius: 15px;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-camera-card .ewr1407-mobile-local-slot {
  display: none !important;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-stage {
  min-height: 0;
}



/* ========================================================================== 
   Tablet visual viewport and camera overlay
   ========================================================================== */

/*
 * Safari can move the visual viewport upward while the keyboard opens. The
 * app follows the actual visible viewport instead of only shortening itself
 * from the top of the layout viewport. This keeps the bottom edge aligned
 * with the keyboard instead of leaving the interface too high.
 */
#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] {
  inset: auto;
  top: 0;
  left: 0;
  width: var(--ewr1407-visual-width, 100vw);
  height: var(--ewr1407-visual-height, 100dvh);
  padding-bottom: max(0px, var(--ewr1407-safe-bottom));
  transform: translate3d(
    var(--ewr1407-visual-left, 0px),
    var(--ewr1407-visual-top, 0px),
    0
  );
}

/* The workspace remains the positioning surface for the floating camera. */
#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-workspace {
  position: relative;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 34vw, 370px);
  min-height: 0;
  overflow: hidden;
}

/* The right column is exclusively occupied by the expanded chat. */
#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-side-column {
  position: static;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: visible;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-chat-panel {
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/*
 * The remote camera is not part of the tablet grid while chat is active.
 * It floats on the z-axis above the player and sits at the very bottom-left
 * of the visible website. It therefore cannot push or resize the stage.
 */
#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-camera-card {
  position: absolute !important;
  top: auto !important;
  right: auto !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 40;
  width: clamp(210px, 28vw, 300px);
  height: clamp(138px, 22vh, 220px);
  min-width: 0;
  min-height: 0;
  margin: 0;
  transform: none !important;
  border-width: 1px;
  border-radius: 16px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.44);
  pointer-events: auto;
  transition: none;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 15px;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-camera-card .ewr1407-mobile-local-slot {
  display: none !important;
}

/* Reversion is automatic when data-keyboard-context is no longer "chat". */

/* ========================================================================== 
   Tablet expanded chat and lobby rejoin
   ========================================================================== */

/* Optional saved-room action on the lobby. */
#ewr1407-app .ewr1407-rejoin-room-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 16px;
  background: rgba(104, 220, 255, 0.07);
  color: var(--ewr1407-text);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease,
    opacity 150ms ease;
}

#ewr1407-app .ewr1407-rejoin-room-button:hover:not(:disabled) {
  border-color: var(--ewr1407-accent-a);
  background: rgba(104, 220, 255, 0.13);
  transform: translateY(-1px);
}

#ewr1407-app .ewr1407-rejoin-room-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

#ewr1407-app .ewr1407-rejoin-room-icon {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

#ewr1407-app .ewr1407-rejoin-room-button[aria-busy="true"] .ewr1407-rejoin-room-icon {
  animation: ewr1407-rejoin-spin 760ms linear infinite;
}

@keyframes ewr1407-rejoin-spin {
  to {
    transform: rotate(360deg);
  }
}

/*
 * iPad chat focus:
 * - chat becomes approximately twice as wide as its normal tablet column;
 * - remote camera remains outside the grid on a higher z-layer;
 * - camera is anchored immediately to the left of the expanded chat,
 *   at the bottom edge of the visible website.
 */
#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-workspace {
  --ewr1407-ipad-chat-width: clamp(480px, 56vw, 620px);
  grid-template-columns: minmax(0, 1fr) var(--ewr1407-ipad-chat-width);
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-side-column {
  width: var(--ewr1407-ipad-chat-width);
  min-width: var(--ewr1407-ipad-chat-width);
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-chat-panel {
  width: 100%;
  max-width: none;
}

#ewr1407-app[data-device-class="tablet"][data-keyboard-context="chat"] .ewr1407-remote-camera-card {
  right: calc(var(--ewr1407-ipad-chat-width) + 10px) !important;
  left: auto !important;
  bottom: 0 !important;
  width: clamp(210px, 25vw, 290px);
  height: clamp(138px, 22vh, 220px);
}


/* ========================================================================== */
/* Phone base layouts           */
/* Desktop and tablet rules above remain untouched.                            */
/* ========================================================================== */

@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding:
      max(7px, var(--ewr1407-safe-top))
      max(7px, var(--ewr1407-safe-right))
      max(7px, var(--ewr1407-safe-bottom))
      max(7px, var(--ewr1407-safe-left));
    gap: 7px;
    overflow: hidden;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-main,
  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-actions,
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search,
  #ewr1407-app[data-device-class="phone"] .ewr1407-workspace,
  #ewr1407-app[data-device-class="phone"] .ewr1407-side-column,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card,
  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-tools {
    min-width: 0;
    min-height: 0;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-workspace,
  #ewr1407-app[data-device-class="phone"] .ewr1407-side-column,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card,
  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-tools {
    display: contents !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar {
    grid-area: top;
    display: block !important;
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
    width: 100%;
    height: 48px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, 48px);
    gap: 7px;
    height: 48px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-icon-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 13px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-icon-button .ewr1407-button-label {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-toolbar-svg {
    width: 22px;
    height: 22px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search {
    display: grid;
    grid-template-columns: 36px 36px minmax(0, 1fr) 30px 54px;
    align-items: stretch;
    width: 100%;
    height: 48px;
    overflow: hidden;
    border-radius: 13px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-share-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-reload-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button {
    width: 100%;
    min-width: 0;
    height: 48px;
    min-height: 48px;
    padding: 0;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-share-button svg,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-reload-button svg {
    width: 18px;
    height: 18px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-input {
    min-width: 0;
    height: 48px;
    padding: 0 8px;
    font-size: 10px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-clear-button {
    font-size: 13px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button {
    font-size: 8px;
    letter-spacing: .08em;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-right,
  #ewr1407-app[data-device-class="phone"] .ewr1407-mini-stats {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-video-shell,
  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-panel,
  #ewr1407-app[data-device-class="phone"] .ewr1407-local-camera-card,
  #ewr1407-app[data-device-class="phone"] .ewr1407-panic-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-notification-button {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 15px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage {
    grid-area: stage;
    width: 100%;
    height: 100%;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-video-shell {
    grid-area: remote;
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 1px solid var(--ewr1407-border);
    background: var(--ewr1407-panel);
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-local-slot {
    grid-area: local;
    display: block !important;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    z-index: 6;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1 / 1;
    border-radius: 15px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-panel {
    grid-area: chat;
    width: 100%;
    height: 100%;
    padding: 8px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-header {
    min-height: 26px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-header strong {
    font-size: 15px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-log {
    min-height: 0;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-form {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 5px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-icon-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-send-button {
    width: 34px;
    height: 34px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-input {
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-panic-button {
    grid-area: panic;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 8px;
    pointer-events: auto;
    font-size: clamp(11px, 3.2vw, 15px);
    letter-spacing: .1em;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-notification-button {
    grid-area: notification;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    pointer-events: auto;
    font-size: 18px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-card-heading {
    opacity: 0;
    pointer-events: none;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card.ewr1407-remote-controls-visible .ewr1407-card-heading {
    opacity: 1;
    pointer-events: auto;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage-controls {
    right: 6px;
    bottom: 6px;
    left: 6px;
    gap: 4px;
    padding: 5px;
    border-radius: 12px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage-control-button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border-radius: 9px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage-volume-slider {
    width: 72px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-time-label {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-timeline {
    min-width: 38px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-dialog {
    width: calc(100vw - 12px);
    max-width: none;
    height: calc(var(--ewr1407-visual-height, 100dvh) - 12px);
    max-height: calc(var(--ewr1407-visual-height, 100dvh) - 12px);
    border-radius: 18px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-scroll {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-camera-popout {
    top: max(8px, var(--ewr1407-safe-top));
    left: max(8px, var(--ewr1407-safe-left));
    width: calc(100vw - 16px - var(--ewr1407-safe-left) - var(--ewr1407-safe-right));
    height: min(64vh, calc(100dvh - 16px - var(--ewr1407-safe-top) - var(--ewr1407-safe-bottom)));
    min-width: 0;
    min-height: 180px;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
}

/* -------------------------------------------------------------------------- */
/* iPhone portrait — Cinema wireframe                                          */
/* -------------------------------------------------------------------------- */
@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"] {
    grid-template-columns: minmax(0, 1fr) minmax(116px, 42vw);
    grid-template-rows:
      48px
      minmax(0, 2.75fr)
      minmax(0, 1.35fr)
      minmax(0, 3fr);
    grid-template-areas:
      "top top"
      "stage stage"
      "remote panic"
      "chat chat";
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-remote-video-shell {
    grid-area: remote;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-panic-button {
    grid-area: panic;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-mobile-local-slot {
    grid-area: panic;
    align-self: start;
    justify-self: start;
    width: 58%;
    height: 52%;
    padding: 6px 0 0 6px;
    pointer-events: none;
    z-index: 8;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    pointer-events: auto;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-chat-notification-button {
    display: none !important;
  }
}

/* -------------------------------------------------------------------------- */
/* iPhone portrait — Call wireframe                                            */
/* -------------------------------------------------------------------------- */
@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"] {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 27vw);
    grid-template-rows:
      48px
      minmax(0, .95fr)
      minmax(0, 1.15fr)
      minmax(0, 3.15fr)
      minmax(0, 1.35fr);
    grid-template-areas:
      "top top"
      "remote local"
      "remote panic"
      "chat chat"
      "stage stage";
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-stage {
    grid-area: stage;
    justify-self: center;
    width: min(76%, 340px);
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-remote-video-shell {
    grid-area: remote;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-mobile-local-slot {
    grid-area: local;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-panic-button {
    grid-area: panic;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-chat-notification-button {
    display: none !important;
  }
}

/* -------------------------------------------------------------------------- */
/* iPhone landscape — Horizontal Cinema wireframe                             */
/* -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] {
    grid-template-columns: minmax(0, 67fr) minmax(0, 24fr) minmax(54px, 9fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: none;
    gap: 6px;
    padding:
      max(6px, var(--ewr1407-safe-top))
      max(6px, var(--ewr1407-safe-right))
      max(6px, var(--ewr1407-safe-bottom))
      max(6px, var(--ewr1407-safe-left));
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-main,
  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-actions,
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search,
  #ewr1407-app[data-device-class="phone"] .ewr1407-mini-stats,
  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-panel {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-topbar-right,
  #ewr1407-app[data-device-class="phone"] .ewr1407-workspace,
  #ewr1407-app[data-device-class="phone"] .ewr1407-side-column,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card,
  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-tools {
    display: contents !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 100%;
    height: 100%;
    border-radius: 14px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-video-shell {
    grid-column: 2 / 4;
    grid-row: 2;
    width: 100%;
    height: 100%;
    border-radius: 14px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-mobile-local-slot {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-local-camera-card {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    justify-self: stretch;
    width: 100%;
    height: calc(50% - 3px);
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 12px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-panic-button {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    height: 100%;
    border-radius: 14px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-notification-button {
    grid-column: 3;
    grid-row: 1;
    align-self: end;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: calc(50% - 3px);
    border-radius: 12px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage-controls {
    right: 5px;
    bottom: 5px;
    left: 5px;
    padding: 4px 5px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-stage-volume-slider {
    width: 64px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-quality-control {
    display: none;
  }
}

/* -------------------------------------------------------------------------- */
/* Phone keyboard geometry                                                     */
/* Search keeps the full layout behind the keyboard; chat follows the visual   */
/* viewport so its bottom edge meets the top edge of the keyboard.              */
/* -------------------------------------------------------------------------- */
@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-keyboard-context="search"] {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
  }

  #ewr1407-app[data-device-class="phone"][data-keyboard-context="chat"] {
    position: fixed;
    top: var(--ewr1407-visual-top, 0px);
    left: var(--ewr1407-visual-left, 0px);
    right: auto;
    bottom: auto;
    width: var(--ewr1407-visual-width, 100vw);
    height: var(--ewr1407-visual-height, 100dvh);
  }

  #ewr1407-app[data-device-class="phone"][data-keyboard-context="chat"] .ewr1407-chat-log {
    scroll-behavior: auto;
  }
}

/* ========================================================================== */
/* Vertical Call foundation                              */
/* Only the vertical Call layout is changed. Desktop, iPad, portrait Cinema   */
/* and landscape Cinema keep their previous geometry.                         */
/* ========================================================================== */

@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"] {
    --ewr1407-phone-gap: 7px;
    --ewr1407-phone-half-gap: 3.5px;
    --ewr1407-phone-pad-top: max(7px, var(--ewr1407-safe-top));
    --ewr1407-phone-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-phone-pad-bottom: max(7px, var(--ewr1407-safe-bottom));
    --ewr1407-phone-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-phone-side: clamp(96px, 28vw, 116px);
    --ewr1407-phone-main: calc(
      100vw -
      var(--ewr1407-phone-pad-left) -
      var(--ewr1407-phone-pad-right) -
      var(--ewr1407-phone-gap) -
      var(--ewr1407-phone-side)
    );
    --ewr1407-phone-panic-height: max(
      92px,
      calc(
        var(--ewr1407-phone-main) -
        var(--ewr1407-phone-side) -
        var(--ewr1407-phone-gap)
      )
    );
    --ewr1407-phone-bottom-height: clamp(108px, 17vh, 136px);
    --ewr1407-phone-bottom-split: 43%;

    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--ewr1407-phone-layout-height, 100dvh);
    padding:
      var(--ewr1407-phone-pad-top)
      var(--ewr1407-phone-pad-right)
      var(--ewr1407-phone-pad-bottom)
      var(--ewr1407-phone-pad-left);
    gap: var(--ewr1407-phone-gap);
    grid-template-columns: minmax(0, 1fr) var(--ewr1407-phone-side);
    grid-template-rows:
      var(--ewr1407-phone-side)
      var(--ewr1407-phone-panic-height)
      minmax(0, 1fr)
      var(--ewr1407-phone-bottom-height);
    grid-template-areas:
      "remote local"
      "remote panic"
      "chat chat"
      ". .";
    overflow: hidden;
  }

  /* Both camera tiles stay square. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-remote-video-shell {
    grid-area: remote;
    align-self: start;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-mobile-local-slot {
    grid-area: local;
    width: var(--ewr1407-phone-side);
    height: var(--ewr1407-phone-side);
    aspect-ratio: 1 / 1;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
  }

  /* The panic area fills the remaining height beside the large camera. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-panic-button {
    grid-area: panic;
    min-height: 92px;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-chat-panel {
    grid-area: chat;
    min-height: 0;
    z-index: 8;
  }

  /* Bottom area: player on the left, room/settings/search tools on the right. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-stage {
    position: absolute;
    z-index: 3;
    left: var(--ewr1407-phone-pad-left);
    bottom: var(--ewr1407-phone-pad-bottom);
    width: calc(
      var(--ewr1407-phone-bottom-split) -
      var(--ewr1407-phone-pad-left) -
      var(--ewr1407-phone-half-gap)
    );
    height: var(--ewr1407-phone-bottom-height);
    min-width: 0;
    min-height: 0;
    border-radius: 15px;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar {
    position: absolute;
    z-index: 4;
    top: auto;
    right: var(--ewr1407-phone-pad-right);
    bottom: var(--ewr1407-phone-pad-bottom);
    left: calc(
      var(--ewr1407-phone-bottom-split) +
      var(--ewr1407-phone-half-gap)
    );
    display: block !important;
    width: auto;
    height: var(--ewr1407-phone-bottom-height);
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-main {
    display: grid !important;
    grid-template-columns: 44px 44px minmax(0, 1fr);
    grid-template-rows: 44px minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    height: 100%;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions {
    display: contents !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions .ewr1407-icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 12px;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions .ewr1407-icon-button:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions .ewr1407-icon-button:last-child {
    grid-column: 2;
    grid-row: 1;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-youtube-search {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid !important;
    grid-template-columns: 34px 34px minmax(0, 1fr) 28px 48px;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 13px;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-search-share-button,
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-search-reload-button,
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-search-button,
  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-youtube-input {
    height: 100%;
    min-height: 0;
  }

  /* iOS does not zoom focused fields at 16px or above. */
  #ewr1407-app[data-device-class="phone"] input,
  #ewr1407-app[data-device-class="phone"] select,
  #ewr1407-app[data-device-class="phone"] textarea,
  #ewr1407-app[data-device-class="phone"] .ewr1407-chat-input,
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-input {
    font-size: 16px !important;
  }

  /* Chat keyboard: keep the complete page fixed. Only the chat panel grows
     above the keyboard; the keyboard covers the player and bottom tool area. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--ewr1407-phone-layout-height, 100dvh);
    transform: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    position: absolute;
    z-index: 40;
    top: calc(
      var(--ewr1407-phone-pad-top) +
      var(--ewr1407-phone-main) +
      var(--ewr1407-phone-gap)
    );
    right: var(--ewr1407-phone-pad-right);
    bottom: max(
      0px,
      calc(
        var(--ewr1407-phone-layout-height, 100dvh) -
        var(--ewr1407-visual-top, 0px) -
        var(--ewr1407-visual-height, 100dvh)
      )
    );
    left: var(--ewr1407-phone-pad-left);
    width: auto;
    height: auto;
    min-height: 118px;
    transition: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-log {
    min-height: 0;
    scroll-behavior: auto;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar {
    z-index: 2;
  }
}

/* ========================================================================== */
/* Touch audio and phone chat stability */
/* ========================================================================== */

/* Desktop keeps the continuous range control. Touch layouts use a compact
   native dropdown that cannot extend beyond the camera tile. */
#ewr1407-app .ewr1407-remote-volume-select {
  display: none;
  width: 100%;
  min-width: 78px;
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 10px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) calc(100% - 15px) 15px / 5px 5px no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) calc(100% - 10px) 15px / 5px 5px no-repeat,
    rgba(8, 12, 19, 0.84);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

#ewr1407-app .ewr1407-remote-volume-select option {
  background: #111722;
  color: #ffffff;
}

#ewr1407-app[data-device-class="tablet"] .ewr1407-remote-audio-control,
#ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control {
  grid-template-columns: 24px minmax(78px, 1fr);
  width: min(160px, 100%);
  gap: 8px;
  padding: 0 4px;
}

#ewr1407-app[data-device-class="tablet"] .ewr1407-remote-volume-range,
#ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-range,
#ewr1407-app[data-device-class="tablet"] .ewr1407-remote-audio-control output,
#ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control output {
  display: none;
}

#ewr1407-app[data-device-class="tablet"] .ewr1407-remote-volume-select,
#ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-select {
  display: block;
}

#ewr1407-app[data-device-class="tablet"] .ewr1407-remote-audio-control:has(select:disabled),
#ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control:has(select:disabled) {
  opacity: 0.42;
}

/* The phone opens in Call mode through JavaScript. While the chat keyboard is
   open, preserve every tile at its normal size and move the complete interface
   upward only far enough for the chat panel to meet the keyboard edge. */
@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--ewr1407-phone-layout-height, 100dvh);
    transform: translate3d(
      0,
      calc(-1 * var(--ewr1407-phone-chat-shift, 0px)),
      0
    ) !important;
    transition: none !important;
    will-change: transform;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    z-index: 8;
    transition: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-video-shell,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button {
    transform: none !important;
    transition: none !important;
  }
}

/* ========================================================================== */
/* Vertical Call focused-input layout                                  */
/* Chat and YouTube focus share one stable layout inside the visual viewport. */
/* ========================================================================== */

@media (max-width: 700px) and (orientation: portrait) {
  /* Phone camera controls remain compact: cycle + voice level only. */
  #ewr1407-app[data-device-class="phone"] #ewr1407-remote-popout-button {
    display: none !important;
  }

  /* Keep the native iOS volume selector above the camera-card click layer. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-card-heading,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-select {
    position: relative;
    pointer-events: auto !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-card-heading {
    z-index: 90;
    overflow: visible;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control {
    z-index: 91;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-select {
    z-index: 92;
    min-width: 84px;
    min-height: 40px;
    font-size: 16px !important;
    touch-action: manipulation;
  }

  /* Both focused fields use the same temporary Call layout. The app occupies
     exactly the visible viewport above the iOS keyboard, so the keyboard does
     not push or translate the page. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"],
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] {
    --ewr1407-focus-gap: 7px;
    --ewr1407-focus-pad-top: max(7px, var(--ewr1407-safe-top));
    --ewr1407-focus-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-focus-pad-bottom: 7px;
    --ewr1407-focus-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-focus-media-height: clamp(
      86px,
      calc(var(--ewr1407-visual-height, 100dvh) * 0.22),
      112px
    );
    --ewr1407-focus-chat-height: clamp(
      132px,
      calc(var(--ewr1407-visual-height, 100dvh) * 0.37),
      210px
    );
    --ewr1407-focus-camera-size: max(
      96px,
      min(
        136px,
        calc(
          var(--ewr1407-visual-height, 100dvh) -
          var(--ewr1407-focus-pad-top) -
          var(--ewr1407-focus-pad-bottom) -
          var(--ewr1407-focus-media-height) -
          var(--ewr1407-focus-chat-height) -
          (var(--ewr1407-focus-gap) * 3)
        )
      )
    );
    --ewr1407-focus-local-size: min(
      98px,
      var(--ewr1407-focus-camera-size)
    );

    position: fixed !important;
    top: var(--ewr1407-visual-top, 0px) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-visual-left, 0px) !important;
    display: block !important;
    width: var(--ewr1407-visual-width, 100vw) !important;
    height: var(--ewr1407-visual-height, 100dvh) !important;
    padding: 0 !important;
    overflow: hidden !important;
    transform: none !important;
    transition: none !important;
  }

  /* The original bottom pair moves unchanged to the top. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-stage {
    position: absolute !important;
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-focus-pad-left) !important;
    width: calc(
      var(--ewr1407-phone-bottom-split, 43%) -
      var(--ewr1407-focus-pad-left) -
      3.5px
    ) !important;
    height: var(--ewr1407-focus-media-height) !important;
    min-height: 0 !important;
    transform: none !important;
    z-index: 20;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar {
    position: absolute !important;
    top: var(--ewr1407-focus-pad-top) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: auto !important;
    left: calc(var(--ewr1407-phone-bottom-split, 43%) + 3.5px) !important;
    display: block !important;
    width: auto !important;
    height: var(--ewr1407-focus-media-height) !important;
    min-height: 0 !important;
    transform: none !important;
    z-index: 21;
  }

  /* Both cameras move one visual row down and remain square. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-video-shell,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-remote-video-shell {
    position: absolute !important;
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-focus-media-height) +
      var(--ewr1407-focus-gap)
    ) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-focus-pad-left) !important;
    width: var(--ewr1407-focus-camera-size) !important;
    height: var(--ewr1407-focus-camera-size) !important;
    aspect-ratio: 1 / 1 !important;
    transform: none !important;
    z-index: 22;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-mobile-local-slot {
    position: absolute !important;
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-focus-media-height) +
      var(--ewr1407-focus-gap)
    ) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: auto !important;
    left: auto !important;
    display: block !important;
    width: var(--ewr1407-focus-local-size) !important;
    height: var(--ewr1407-focus-local-size) !important;
    aspect-ratio: 1 / 1 !important;
    transform: none !important;
    z-index: 23;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-panic-button {
    position: absolute !important;
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-focus-media-height) +
      var(--ewr1407-focus-gap) +
      var(--ewr1407-focus-local-size) +
      var(--ewr1407-focus-gap)
    ) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: auto !important;
    left: auto !important;
    width: var(--ewr1407-focus-local-size) !important;
    height: max(
      34px,
      calc(
        var(--ewr1407-focus-camera-size) -
        var(--ewr1407-focus-local-size) -
        var(--ewr1407-focus-gap)
      )
    ) !important;
    min-height: 34px !important;
    transform: none !important;
    z-index: 23;
  }

  /* Chat occupies the bottom of the visible viewport and therefore rests
     directly on the top edge of the keyboard. */
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-chat-panel {
    position: absolute !important;
    top: auto !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: var(--ewr1407-focus-pad-bottom) !important;
    left: var(--ewr1407-focus-pad-left) !important;
    width: auto !important;
    height: var(--ewr1407-focus-chat-height) !important;
    min-height: 0 !important;
    transform: none !important;
    transition: none !important;
    z-index: 30;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-log,
  #ewr1407-app[data-device-class="phone"][data-mode="call"][data-keyboard-context="search"] .ewr1407-chat-log {
    min-height: 0 !important;
    scroll-behavior: auto;
  }
}

/* Phone Chat and Search focus separation */
@media (max-width: 767px) and (orientation: portrait) {
  /* Chat focus: the video player and the complete media toolbar are removed
     from the visible keyboard layout. The cameras move to the top and the
     chat uses all remaining height down to the keyboard edge. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
    top: var(--ewr1407-focus-pad-top) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot {
    top: var(--ewr1407-focus-pad-top) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button {
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-focus-local-size) +
      var(--ewr1407-focus-gap)
    ) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-focus-camera-size) +
      var(--ewr1407-focus-gap)
    ) !important;
    bottom: var(--ewr1407-focus-pad-bottom) !important;
    height: auto !important;
  }

  /* Search focus intentionally keeps the player plus Share, Reload,
     Settings and the YouTube search bar visible at the top. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}


/* ========================================================================== */
/* Vertical Call touch controls            */
/* ========================================================================== */

@media (max-width: 767px) and (orientation: portrait) {
  /* Remote camera controls: one compact, centered control row. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-card-heading {
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: max-content !important;
    max-width: calc(100% - 18px) !important;
    padding: 8px 9px !important;
    gap: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 16px !important;
    background: rgba(4, 8, 14, 0.84) !important;
    opacity: 0;
    pointer-events: none !important;
    transform: translate(-50%, -50%) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card.ewr1407-remote-controls-visible .ewr1407-card-heading,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card:focus-within .ewr1407-card-heading {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-card-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto;
    padding: 0 !important;
    gap: 7px !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control {
    position: relative !important;
    z-index: 1000 !important;
    display: grid !important;
    grid-template-columns: 24px minmax(96px, 118px) !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    gap: 7px !important;
    pointer-events: auto !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-select {
    position: relative !important;
    z-index: 1001 !important;
    display: block !important;
    width: 112px !important;
    min-width: 112px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 30px 0 11px !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    border-radius: 12px !important;
    background-color: rgba(16, 23, 34, 0.98) !important;
    color: #ffffff !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    pointer-events: auto !important;
    touch-action: auto !important;
    appearance: menulist-button !important;
    -webkit-appearance: menulist-button !important;
  }

  /* Chat focus: no player or toolbar, centered camera row, Panic to the right. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] {
    --ewr1407-chat-focus-gap: 8px;
    --ewr1407-chat-focus-camera: clamp(92px, 27vw, 112px);
    --ewr1407-chat-focus-panic: clamp(58px, 17vw, 72px);
    --ewr1407-chat-focus-row-width: calc(
      (var(--ewr1407-chat-focus-camera) * 2) +
      var(--ewr1407-chat-focus-panic) +
      (var(--ewr1407-chat-focus-gap) * 2)
    );
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-stage,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-topbar-right {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: calc(50% - (var(--ewr1407-chat-focus-row-width) / 2)) !important;
    width: var(--ewr1407-chat-focus-camera) !important;
    height: var(--ewr1407-chat-focus-camera) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot {
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: calc(
      50% - (var(--ewr1407-chat-focus-row-width) / 2) +
      var(--ewr1407-chat-focus-camera) +
      var(--ewr1407-chat-focus-gap)
    ) !important;
    width: var(--ewr1407-chat-focus-camera) !important;
    height: var(--ewr1407-chat-focus-camera) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button {
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: calc(
      50% - (var(--ewr1407-chat-focus-row-width) / 2) +
      (var(--ewr1407-chat-focus-camera) * 2) +
      (var(--ewr1407-chat-focus-gap) * 2)
    ) !important;
    width: var(--ewr1407-chat-focus-panic) !important;
    height: var(--ewr1407-chat-focus-camera) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-name-banner {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-chat-focus-camera) +
      var(--ewr1407-chat-focus-gap)
    ) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: var(--ewr1407-focus-pad-bottom) !important;
    left: var(--ewr1407-focus-pad-left) !important;
    width: auto !important;
    height: auto !important;
  }

  /* Search focus: Settings + Share at the left, search consumes the width,
     player below. Cameras and chat are not part of this focused layout. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-remote-video-shell,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-mobile-local-slot,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-panic-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-chat-panel,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-right {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar {
    position: absolute !important;
    top: var(--ewr1407-focus-pad-top) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: auto !important;
    left: var(--ewr1407-focus-pad-left) !important;
    display: block !important;
    width: auto !important;
    height: 52px !important;
    min-height: 52px !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 30 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-main {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) !important;
    align-items: stretch !important;
    width: 100% !important;
    height: 52px !important;
    gap: 7px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-actions {
    display: block !important;
    width: 48px !important;
    height: 52px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] #ewr1407-room-link-button {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] #ewr1407-settings-open-button {
    display: grid !important;
    place-items: center !important;
    width: 48px !important;
    height: 52px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-search {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) 40px 64px !important;
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    gap: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-reload-button {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-share-button {
    display: grid !important;
    place-items: center !important;
    width: 48px !important;
    height: 52px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-input {
    display: block !important;
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 11px !important;
    font-size: 16px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-button {
    display: grid !important;
    place-items: center !important;
    height: 52px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-stage {
    position: absolute !important;
    top: calc(var(--ewr1407-focus-pad-top) + 52px + var(--ewr1407-focus-gap)) !important;
    right: var(--ewr1407-focus-pad-right) !important;
    bottom: var(--ewr1407-focus-pad-bottom) !important;
    left: var(--ewr1407-focus-pad-left) !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 20 !important;
  }
}


/* ========================================================================== */
/* Vertical Call control details                           */
/* ========================================================================== */

@media (max-width: 767px) and (orientation: portrait) {
  /* The phone never acts as a screen-share sender. Removing this control also
     gives the focused YouTube toolbar a cleaner mobile hierarchy. */
  #ewr1407-app[data-device-class="phone"] #ewr1407-screen-share-button {
    display: none !important;
  }

  /* Keep the native receiver-volume menu on top of every camera click layer.
     It remains selectable even while the remote microphone is currently off;
     the chosen level is applied as soon as audio becomes available. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-camera-card,
  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-video-shell {
    overflow: visible !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-card-heading {
    z-index: 300 !important;
    isolation: isolate;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-audio-control {
    z-index: 301 !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-remote-volume-select {
    z-index: 302 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: auto !important;
    user-select: auto !important;
  }

  /* Chat focus: the Panic surface begins beside the own-camera tile and then
     stretches all the way to the right safe-area edge. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button {
    right: var(--ewr1407-focus-pad-right) !important;
    left: calc(
      50% - (var(--ewr1407-chat-focus-row-width) / 2) +
      (var(--ewr1407-chat-focus-camera) * 2) +
      (var(--ewr1407-chat-focus-gap) * 2)
    ) !important;
    width: auto !important;
    max-width: none !important;
  }

  /* Search focus: Settings occupies the former screen-share position. Reload
     is the first integrated control inside the YouTube search bar, exactly as
     on desktop. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-main {
    grid-template-columns: 48px minmax(0, 1fr) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-search {
    grid-template-columns: 48px minmax(0, 1fr) 40px 64px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-reload-button {
    display: grid !important;
    place-items: center !important;
    width: 48px !important;
    height: 52px !important;
  }
}

/* ========================================================================== */
/* Vertical Call search geometry                              */
/* ========================================================================== */

@media (max-width: 767px) and (orientation: portrait) {
  /* Normal Vertical Call mode: the removed Screen Share control must not
     leave an empty grid column. Settings stays beside Room Link, while Reload
     is the first real control inside the compact YouTube bar. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search {
    grid-template-columns: 36px minmax(0, 1fr) 30px 54px !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-share-button {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-reload-button {
    display: grid !important;
    grid-column: 1 !important;
    place-items: center !important;
  }

  /* Search focus: JavaScript moves Settings into the form. It becomes the
     first integrated segment, immediately followed by Reload. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-main {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-actions {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-search {
    grid-template-columns: 48px 48px minmax(0, 1fr) 40px 64px !important;
    gap: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > #ewr1407-settings-open-button.ewr1407-settings-in-search {
    display: grid !important;
    grid-column: 1 !important;
    place-items: center !important;
    width: 48px !important;
    min-width: 48px !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 !important;
    border: 0 !important;
    border-right: 1px solid var(--ewr1407-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--ewr1407-text) !important;
    box-shadow: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > #ewr1407-settings-open-button.ewr1407-settings-in-search .ewr1407-toolbar-svg {
    width: 20px !important;
    height: 20px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-reload-button {
    grid-column: 2 !important;
    width: 48px !important;
    min-width: 48px !important;
    height: 52px !important;
    min-height: 52px !important;
    border-right: 1px solid var(--ewr1407-border) !important;
  }
}

/* ========================================================================== */
/* Vertical Call search styling                     */
/* Functionality is unchanged. These rules only correct mobile proportions.   */
/* ========================================================================== */

@media (max-width: 767px) and (orientation: portrait) {
  /* One consistent segmented-control appearance for both mobile states. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search {
    box-sizing: border-box !important;
    align-items: stretch !important;
    gap: 0 !important;
    overflow: hidden !important;
    border: 1px solid var(--ewr1407-border) !important;
    border-radius: 15px !important;
    background: color-mix(in srgb, var(--ewr1407-panel) 94%, transparent) !important;
    box-shadow: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > * {
    box-sizing: border-box !important;
    min-width: 0 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > *:not(:last-child) {
    border-right: 1px solid var(--ewr1407-border) !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-input {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 12px !important;
    background: transparent !important;
    color: var(--ewr1407-text) !important;
    font-size: 16px !important;
    line-height: 1 !important;
    text-overflow: ellipsis !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-input::placeholder {
    color: var(--ewr1407-muted) !important;
    opacity: .78 !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-reload-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button,
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > #ewr1407-settings-open-button.ewr1407-settings-in-search {
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    background: transparent !important;
    color: var(--ewr1407-text) !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-reload-button svg,
  #ewr1407-app[data-device-class="phone"] .ewr1407-youtube-search > #ewr1407-settings-open-button.ewr1407-settings-in-search .ewr1407-toolbar-svg {
    width: 22px !important;
    height: 22px !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-clear-button {
    font-size: 20px !important;
    font-weight: 400 !important;
    opacity: .72 !important;
  }

  /* The phone uses a compact icon instead of the word SEARCH. This prevents
     the label from wrapping in the narrow normal Call layout. */
  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button {
    position: relative !important;
    background: var(--ewr1407-accent-gradient) !important;
    color: #071018 !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button span {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 50%;
    transform: translate(-2px, -2px);
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-search-button::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform: translate(7px, 7px) rotate(45deg);
    transform-origin: center;
  }

  /* Normal Vertical Call: the compact bar has enough room for a useful input
     while remaining inside the right-hand bottom column. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="search"]) .ewr1407-youtube-search {
    grid-template-columns: 40px minmax(0, 1fr) 34px 42px !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="search"]) .ewr1407-search-reload-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="search"]) .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="search"]) .ewr1407-search-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="search"]) .ewr1407-youtube-input {
    height: 100% !important;
    min-height: 0 !important;
  }

  /* Focused Search: Settings and Reload become the first two integrated
     segments. The input receives all remaining width. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar {
    right: max(10px, var(--ewr1407-safe-right)) !important;
    left: max(10px, var(--ewr1407-safe-left)) !important;
    width: auto !important;
    height: 58px !important;
    min-height: 58px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-topbar-main {
    display: block !important;
    width: 100% !important;
    height: 58px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-search {
    grid-template-columns: 54px 54px minmax(0, 1fr) 44px 52px !important;
    width: 100% !important;
    height: 58px !important;
    min-height: 58px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-search > #ewr1407-settings-open-button.ewr1407-settings-in-search,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-reload-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-clear-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-search-button,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-youtube-input {
    width: 100% !important;
    height: 58px !important;
    min-height: 58px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="search"] .ewr1407-stage {
    top: calc(var(--ewr1407-focus-pad-top) + 58px + var(--ewr1407-focus-gap)) !important;
  }
}

/* ========================================================================== */
/* Horizontal Cinema camera rail                             */
/* The local camera sits above the chat-notification button. The remote       */
/* camera name banner is hidden in this compact landscape layout.              */
/* ========================================================================== */

@media (orientation: landscape) and (max-height: 540px) {
  /* Keep the toolbar wrapper transparent to the layout instead of hiding it.
     The local camera is stored inside .ewr1407-topbar-right in landscape. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-topbar-right {
    display: contents !important;
  }

  /* Only the local camera is needed from the top toolbar in landscape. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-topbar-main,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-mini-stats {
    display: none !important;
  }

  /* Right-hand rail: own camera on top, chat notification directly below. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-local-camera-card {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: start !important;
    justify-self: stretch !important;
    display: block !important;
    width: 100% !important;
    height: calc(50% - 3px) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    z-index: 8 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-chat-notification-button {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: end !important;
    justify-self: stretch !important;
    display: flex !important;
    width: 100% !important;
    height: calc(50% - 3px) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 12px !important;
    z-index: 8 !important;
  }

  /* Horizontal Cinema has no room for the remote username banner. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-remote-name-banner {
    display: none !important;
  }
}

/* ========================================================================== */
/* Horizontal Cinema base geometry              */
/* The lower remote-camera tile is sized from the available row height.       */
/* Panic and notification controls use a narrower right-side rail.             */
/* ========================================================================== */

@media (orientation: landscape) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] {
    --ewr1407-hc-gap: 6px;
    --ewr1407-hc-pad-top: max(6px, var(--ewr1407-safe-top));
    --ewr1407-hc-pad-right: max(6px, var(--ewr1407-safe-right));
    --ewr1407-hc-pad-bottom: max(6px, var(--ewr1407-safe-bottom));
    --ewr1407-hc-pad-left: max(6px, var(--ewr1407-safe-left));
    --ewr1407-hc-row-size: calc(
      (
        100dvh -
        var(--ewr1407-hc-pad-top) -
        var(--ewr1407-hc-pad-bottom) -
        var(--ewr1407-hc-gap)
      ) / 2
    );
    --ewr1407-hc-control-rail: clamp(44px, 6.2vw, 54px);
    --ewr1407-hc-panic-width: max(
      92px,
      calc(
        var(--ewr1407-hc-row-size) -
        var(--ewr1407-hc-control-rail) -
        var(--ewr1407-hc-gap)
      )
    );

    grid-template-columns:
      minmax(0, 1fr)
      var(--ewr1407-hc-panic-width)
      var(--ewr1407-hc-control-rail) !important;
    grid-template-rows:
      var(--ewr1407-hc-row-size)
      var(--ewr1407-hc-row-size) !important;
    gap: var(--ewr1407-hc-gap) !important;
    padding:
      var(--ewr1407-hc-pad-top)
      var(--ewr1407-hc-pad-right)
      var(--ewr1407-hc-pad-bottom)
      var(--ewr1407-hc-pad-left) !important;
  }

  /* Colums 2 + 3 plus their gap equal one row height, so this tile is square. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-remote-video-shell {
    grid-column: 2 / 4 !important;
    grid-row: 2 !important;
    justify-self: end !important;
    align-self: stretch !important;
    width: var(--ewr1407-hc-row-size) !important;
    max-width: 100% !important;
    height: var(--ewr1407-hc-row-size) !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-remote-camera-video,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-remote-placeholder-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-panic-button {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
  }

  /* Own camera remains square; the notification fills the remaining rail. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-local-camera-card {
    width: var(--ewr1407-hc-control-rail) !important;
    height: var(--ewr1407-hc-control-rail) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-chat-notification-button {
    width: var(--ewr1407-hc-control-rail) !important;
    height: calc(
      var(--ewr1407-hc-row-size) -
      var(--ewr1407-hc-control-rail) -
      var(--ewr1407-hc-gap)
    ) !important;
    min-height: 40px !important;
  }
}

/* ========================================================================== */
/* Phone Call chat focus and mode state */
/* ========================================================================== */

/* The active layout button has an explicit state selector. This avoids a
   transient colourless state in mobile Safari while the layout is repainted. */
#ewr1407-app .ewr1407-settings-action[aria-pressed="true"],
#ewr1407-app .ewr1407-settings-action[data-selected="true"] {
  border-color: transparent !important;
  background: linear-gradient(120deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b)) !important;
  color: #071019 !important;
  opacity: 1 !important;
}

#ewr1407-app .ewr1407-settings-action[aria-pressed="false"],
#ewr1407-app .ewr1407-settings-action[data-selected="false"] {
  background: var(--ewr1407-panel-2) !important;
  color: var(--ewr1407-text) !important;
  opacity: 1 !important;
}

@media (max-width: 700px) and (orientation: portrait) {
  /* Call + chat focus:
     remote camera on the left, own camera directly beside it, Panic fills the
     remaining width on the right. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] {
    --ewr1407-call-chat-gap: 8px;
    --ewr1407-call-chat-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-call-chat-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-call-chat-camera: clamp(88px, 25vw, 108px);
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-call-chat-pad-left) !important;
    width: var(--ewr1407-call-chat-camera) !important;
    height: var(--ewr1407-call-chat-camera) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot {
    top: var(--ewr1407-focus-pad-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: calc(
      var(--ewr1407-call-chat-pad-left) +
      var(--ewr1407-call-chat-camera) +
      var(--ewr1407-call-chat-gap)
    ) !important;
    width: var(--ewr1407-call-chat-camera) !important;
    height: var(--ewr1407-call-chat-camera) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-panic-button {
    top: var(--ewr1407-focus-pad-top) !important;
    right: var(--ewr1407-call-chat-pad-right) !important;
    bottom: auto !important;
    left: calc(
      var(--ewr1407-call-chat-pad-left) +
      (2 * var(--ewr1407-call-chat-camera)) +
      (2 * var(--ewr1407-call-chat-gap))
    ) !important;
    width: auto !important;
    height: var(--ewr1407-call-chat-camera) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    top: calc(
      var(--ewr1407-focus-pad-top) +
      var(--ewr1407-call-chat-camera) +
      var(--ewr1407-call-chat-gap)
    ) !important;
  }

  /* Restore the normal Vertical Cinema geometry from v0.6.13. The v0.6.14
     experimental overlay arrangement is intentionally cancelled here. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) {
    --ewr1407-vc-gap: 7px;
    --ewr1407-vc-pad-top: max(7px, var(--ewr1407-safe-top));
    --ewr1407-vc-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-vc-pad-bottom: max(7px, var(--ewr1407-safe-bottom));
    --ewr1407-vc-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-vc-side: clamp(94px, 27vw, 110px);
    --ewr1407-vc-panic-height: clamp(42px, 12vw, 50px);
    --ewr1407-vc-stage-height: calc(
      (
        100vw -
        var(--ewr1407-vc-pad-left) -
        var(--ewr1407-vc-pad-right)
      ) / 1.7777778
    );

    grid-template-columns: minmax(0, 1fr) var(--ewr1407-vc-side) !important;
    grid-template-rows:
      48px
      var(--ewr1407-vc-stage-height)
      var(--ewr1407-vc-side)
      var(--ewr1407-vc-panic-height)
      minmax(0, 1fr) !important;
    grid-template-areas:
      "top top"
      "stage stage"
      "remote local"
      "remote panic"
      "chat chat" !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) .ewr1407-remote-video-shell {
    grid-area: remote !important;
    position: relative !important;
    inset: auto !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    z-index: 5 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) .ewr1407-mobile-local-slot {
    grid-area: local !important;
    position: relative !important;
    inset: auto !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: var(--ewr1407-vc-side) !important;
    height: var(--ewr1407-vc-side) !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
    z-index: 7 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) .ewr1407-panic-button {
    grid-area: panic !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    z-index: 5 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) .ewr1407-chat-panel {
    grid-area: chat !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding-top: initial !important;
    z-index: 4 !important;
  }
}


/* ========================================================================== */
/* Phone mode controls and responsive layouts          */
/* ========================================================================== */

#ewr1407-app .ewr1407-mode-toggle-button {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 12px;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-text);
  font-weight: 800;
  cursor: pointer;
}

#ewr1407-app .ewr1407-mode-toggle-button .ewr1407-toolbar-svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

@media (max-width: 767px) and (orientation: portrait) {
  /* Vertical Call: Room link, Settings and the wide mode-switch button share
     the first row. The switch button consumes every remaining pixel. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"] .ewr1407-topbar-main {
    grid-template-columns: 44px 44px minmax(0, 1fr) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions > #ewr1407-room-link-button {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions > #ewr1407-settings-open-button {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"] .ewr1407-topbar-actions > #ewr1407-mode-toggle-button {
    display: flex !important;
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: 44px !important;
  }

  /* Vertical Cinema: the switch button lives inside the search bar and shares
     the right-hand end with the Search button. */
  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-youtube-search {
    grid-template-columns: 38px minmax(0, 1fr) 32px 46px 46px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-youtube-search > #ewr1407-mode-toggle-button.ewr1407-mode-toggle-in-search {
    display: grid !important;
    grid-column: 4 !important;
    place-items: center !important;
    width: 46px !important;
    min-width: 46px !important;
    height: 100% !important;
    padding: 0 !important;
    border: 0 !important;
    border-right: 1px solid var(--ewr1407-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-youtube-search > #ewr1407-mode-toggle-button.ewr1407-mode-toggle-in-search span {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-youtube-search > #ewr1407-mode-toggle-button.ewr1407-mode-toggle-in-search .ewr1407-toolbar-svg {
    width: 21px !important;
    height: 21px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"] .ewr1407-search-button {
    grid-column: 5 !important;
  }

  /* Normal Vertical Cinema: preserve the established geometry but transfer
     substantially more height to Chat by reducing only the remote-camera and
     Panic rows. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]) {
    --ewr1407-vc-side: clamp(78px, 22vw, 90px) !important;
    --ewr1407-vc-panic-height: clamp(28px, 8vw, 34px) !important;
  }

  /* Vertical Cinema + chat keyboard:
     top one third = 16:9 stream, stacked remote/local camera column and a
     full-height Panic column; bottom two thirds = Chat. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] {
    --ewr1407-vcc-gap: 6px;
    --ewr1407-vcc-pad-top: max(6px, var(--ewr1407-safe-top));
    --ewr1407-vcc-pad-right: max(6px, var(--ewr1407-safe-right));
    --ewr1407-vcc-pad-left: max(6px, var(--ewr1407-safe-left));
    --ewr1407-vcc-top-height: calc(
      (
        var(--ewr1407-visual-height, 100dvh) -
        var(--ewr1407-vcc-pad-top) -
        5px -
        var(--ewr1407-vcc-gap)
      ) / 3
    );
    --ewr1407-vcc-camera-side: calc(
      (var(--ewr1407-vcc-top-height) - var(--ewr1407-vcc-gap)) / 2
    );
    --ewr1407-vcc-stage-width: calc(var(--ewr1407-vcc-top-height) * 1.7777778);

    position: fixed !important;
    top: var(--ewr1407-visual-top, 0px) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-visual-left, 0px) !important;
    display: grid !important;
    width: var(--ewr1407-visual-width, 100vw) !important;
    height: var(--ewr1407-visual-height, 100dvh) !important;
    padding:
      var(--ewr1407-vcc-pad-top)
      var(--ewr1407-vcc-pad-right)
      5px
      var(--ewr1407-vcc-pad-left) !important;
    gap: var(--ewr1407-vcc-gap) !important;
    grid-template-columns:
      minmax(0, var(--ewr1407-vcc-stage-width))
      var(--ewr1407-vcc-camera-side)
      minmax(48px, 1fr) !important;
    grid-template-rows:
      var(--ewr1407-vcc-camera-side)
      var(--ewr1407-vcc-camera-side)
      minmax(0, 1fr) !important;
    grid-template-areas:
      "stage remote panic"
      "stage local panic"
      "chat chat chat" !important;
    overflow: hidden !important;
    transform: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-topbar-right,
  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-notification-button {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-stage {
    grid-area: stage !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: var(--ewr1407-vcc-top-height) !important;
    aspect-ratio: 16 / 9 !important;
    align-self: start !important;
    justify-self: start !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
    grid-area: remote !important;
    position: relative !important;
    inset: auto !important;
    width: var(--ewr1407-vcc-camera-side) !important;
    height: var(--ewr1407-vcc-camera-side) !important;
    aspect-ratio: 1 / 1 !important;
    align-self: start !important;
    justify-self: stretch !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot {
    grid-area: local !important;
    position: relative !important;
    inset: auto !important;
    width: var(--ewr1407-vcc-camera-side) !important;
    height: var(--ewr1407-vcc-camera-side) !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
    align-self: start !important;
    justify-self: stretch !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-panic-button {
    grid-area: panic !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: calc(
      (2 * var(--ewr1407-vcc-camera-side)) + var(--ewr1407-vcc-gap)
    ) !important;
    min-height: 0 !important;
    align-self: stretch !important;
    justify-self: stretch !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    grid-area: chat !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding-top: initial !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-remote-name-banner {
    display: none !important;
  }
}

/* Horizontal Cinema: lock the stream to a true 16:9 box at the left edge.
   Remaining width goes first to the camera rail, then to Panic and chat alert. */
@media (orientation: landscape) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"] {
    --ewr1407-h16-gap: 6px;
    --ewr1407-h16-pad-top: max(6px, var(--ewr1407-safe-top));
    --ewr1407-h16-pad-right: max(6px, var(--ewr1407-safe-right));
    --ewr1407-h16-pad-bottom: max(6px, var(--ewr1407-safe-bottom));
    --ewr1407-h16-pad-left: max(6px, var(--ewr1407-safe-left));
    --ewr1407-h16-height: calc(
      100dvh -
      var(--ewr1407-h16-pad-top) -
      var(--ewr1407-h16-pad-bottom)
    );
    --ewr1407-h16-stage-width: min(
      calc(var(--ewr1407-h16-height) * 1.7777778),
      calc(
        100vw -
        var(--ewr1407-h16-pad-left) -
        var(--ewr1407-h16-pad-right) -
        156px -
        (2 * var(--ewr1407-h16-gap))
      )
    );
    --ewr1407-h16-row: calc(
      (var(--ewr1407-h16-height) - var(--ewr1407-h16-gap)) / 2
    );
    --ewr1407-h16-control: clamp(50px, 8vw, 70px);

    grid-template-columns:
      var(--ewr1407-h16-stage-width)
      minmax(0, 1fr)
      var(--ewr1407-h16-control) !important;
    grid-template-rows:
      var(--ewr1407-h16-row)
      var(--ewr1407-h16-row) !important;
    gap: var(--ewr1407-h16-gap) !important;
    padding:
      var(--ewr1407-h16-pad-top)
      var(--ewr1407-h16-pad-right)
      var(--ewr1407-h16-pad-bottom)
      var(--ewr1407-h16-pad-left) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-stage {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    align-self: start !important;
    justify-self: start !important;
    width: var(--ewr1407-h16-stage-width) !important;
    height: var(--ewr1407-h16-height) !important;
    aspect-ratio: 16 / 9 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-remote-video-shell {
    grid-column: 2 / 4 !important;
    grid-row: 2 !important;
    align-self: stretch !important;
    justify-self: end !important;
    width: min(100%, var(--ewr1407-h16-row)) !important;
    height: var(--ewr1407-h16-row) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-local-camera-card {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: start !important;
    justify-self: stretch !important;
    width: var(--ewr1407-h16-control) !important;
    height: var(--ewr1407-h16-control) !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-chat-notification-button {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: end !important;
    justify-self: stretch !important;
    width: var(--ewr1407-h16-control) !important;
    height: calc(
      var(--ewr1407-h16-row) -
      var(--ewr1407-h16-control) -
      var(--ewr1407-h16-gap)
    ) !important;
    min-height: 36px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"] .ewr1407-panic-button {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"] #ewr1407-mode-toggle-button {
    display: none !important;
  }
}

/* ========================================================================== */
/* Approved Vertical Call layout      */
/* Cinema and keyboard-focus layouts remain unchanged.                         */
/* ========================================================================== */
@media (max-width: 700px) and (orientation: portrait) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) {
    --ewr1407-phone-gap: 7px;
    --ewr1407-phone-half-gap: 3.5px;
    --ewr1407-phone-pad-top: max(7px, var(--ewr1407-safe-top));
    --ewr1407-phone-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-phone-pad-bottom: max(7px, var(--ewr1407-safe-bottom));
    --ewr1407-phone-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-phone-side: clamp(96px, 28vw, 116px);
    --ewr1407-phone-main: calc(
      100vw -
      var(--ewr1407-phone-pad-left) -
      var(--ewr1407-phone-pad-right) -
      var(--ewr1407-phone-gap) -
      var(--ewr1407-phone-side)
    );
    --ewr1407-phone-panic-height: max(
      92px,
      calc(
        var(--ewr1407-phone-main) -
        var(--ewr1407-phone-side) -
        var(--ewr1407-phone-gap)
      )
    );
    --ewr1407-phone-bottom-height: clamp(108px, 17vh, 136px);
    --ewr1407-phone-bottom-split: 43%;

    position: fixed !important;
    inset: 0 !important;
    display: grid !important;
    width: 100vw !important;
    height: var(--ewr1407-phone-layout-height, 100dvh) !important;
    padding:
      var(--ewr1407-phone-pad-top)
      var(--ewr1407-phone-pad-right)
      var(--ewr1407-phone-pad-bottom)
      var(--ewr1407-phone-pad-left) !important;
    gap: var(--ewr1407-phone-gap) !important;
    grid-template-columns: minmax(0, 1fr) var(--ewr1407-phone-side) !important;
    grid-template-rows:
      var(--ewr1407-phone-side)
      var(--ewr1407-phone-panic-height)
      minmax(0, 1fr)
      var(--ewr1407-phone-bottom-height) !important;
    grid-template-areas:
      "remote local"
      "remote panic"
      "chat chat"
      ". ." !important;
    overflow: hidden !important;
    transform: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-remote-video-shell {
    grid-area: remote !important;
    position: relative !important;
    inset: auto !important;
    align-self: start !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-mobile-local-slot {
    grid-area: local !important;
    position: relative !important;
    inset: auto !important;
    width: var(--ewr1407-phone-side) !important;
    height: var(--ewr1407-phone-side) !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-panic-button {
    grid-area: panic !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 92px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-chat-panel {
    grid-area: chat !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    padding-top: initial !important;
    margin: 0 !important;
    z-index: 8 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-stage {
    position: absolute !important;
    z-index: 3 !important;
    top: auto !important;
    right: auto !important;
    left: var(--ewr1407-phone-pad-left) !important;
    bottom: var(--ewr1407-phone-pad-bottom) !important;
    width: calc(
      var(--ewr1407-phone-bottom-split) -
      var(--ewr1407-phone-pad-left) -
      var(--ewr1407-phone-half-gap)
    ) !important;
    height: var(--ewr1407-phone-bottom-height) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 15px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-topbar {
    position: absolute !important;
    z-index: 4 !important;
    top: auto !important;
    right: var(--ewr1407-phone-pad-right) !important;
    bottom: var(--ewr1407-phone-pad-bottom) !important;
    left: calc(
      var(--ewr1407-phone-bottom-split) +
      var(--ewr1407-phone-half-gap)
    ) !important;
    display: block !important;
    width: auto !important;
    height: var(--ewr1407-phone-bottom-height) !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-topbar-main {
    display: grid !important;
    grid-template-columns: 44px 44px minmax(0, 1fr) !important;
    grid-template-rows: 44px minmax(0, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
    height: 100% !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-topbar-actions {
    display: contents !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) #ewr1407-room-link-button {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) #ewr1407-settings-open-button {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) #ewr1407-mode-toggle-button {
    display: flex !important;
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: 44px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-mode="call"]:not([data-keyboard-context="chat"]):not([data-keyboard-context="search"]) .ewr1407-youtube-search {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    display: grid !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border-radius: 13px !important;
  }
}

/* ========================================================================== */
/* Approved Vertical Cinema layout                    */
/* ========================================================================== */
@media (max-width: 700px) and (orientation: portrait) {
  /*
   * Root cause fixed here:
   * Earlier normal-Cinema overrides excluded data-keyboard-context="search".
   * On iOS an input can remain focused after the keyboard is dismissed, so
   * the app can remain in the "search" context and silently fall back to an
   * older camera/chat grid. This rule intentionally applies to every normal
   * Cinema state except the dedicated chat-keyboard layout.
   *
   * The camera band is now one explicit value: 75% of the former square
   * remote-camera height. Its saved 25% is therefore guaranteed to become
   * part of the flexible chat row. Panic and remote camera share the exact
   * same lower edge.
   */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) {
    --ewr1407-cinema22-gap: 7px;
    --ewr1407-cinema22-pad-top: max(7px, var(--ewr1407-safe-top));
    --ewr1407-cinema22-pad-right: max(7px, var(--ewr1407-safe-right));
    --ewr1407-cinema22-pad-bottom: max(7px, var(--ewr1407-safe-bottom));
    --ewr1407-cinema22-pad-left: max(7px, var(--ewr1407-safe-left));
    --ewr1407-cinema22-side: clamp(94px, 27vw, 110px);
    --ewr1407-cinema22-remote-width: calc(
      100vw -
      var(--ewr1407-cinema22-pad-left) -
      var(--ewr1407-cinema22-pad-right) -
      var(--ewr1407-cinema22-gap) -
      var(--ewr1407-cinema22-side)
    );
    --ewr1407-cinema22-camera-band: max(
      calc(var(--ewr1407-cinema22-side) + var(--ewr1407-cinema22-gap) + 24px),
      calc(var(--ewr1407-cinema22-remote-width) * 0.75)
    );
    --ewr1407-cinema22-panic-height: calc(
      var(--ewr1407-cinema22-camera-band) -
      var(--ewr1407-cinema22-side) -
      var(--ewr1407-cinema22-gap)
    );
    --ewr1407-cinema22-stage-height: calc(
      (
        100vw -
        var(--ewr1407-cinema22-pad-left) -
        var(--ewr1407-cinema22-pad-right)
      ) / 1.7777778
    );

    position: fixed !important;
    inset: 0 !important;
    display: grid !important;
    width: 100vw !important;
    height: var(--ewr1407-phone-layout-height, 100dvh) !important;
    padding:
      var(--ewr1407-cinema22-pad-top)
      var(--ewr1407-cinema22-pad-right)
      var(--ewr1407-cinema22-pad-bottom)
      var(--ewr1407-cinema22-pad-left) !important;
    gap: var(--ewr1407-cinema22-gap) !important;
    grid-template-columns:
      minmax(0, 1fr)
      var(--ewr1407-cinema22-side) !important;
    grid-template-rows:
      48px
      var(--ewr1407-cinema22-stage-height)
      var(--ewr1407-cinema22-side)
      var(--ewr1407-cinema22-panic-height)
      minmax(0, 1fr) !important;
    grid-template-areas:
      "top top"
      "stage stage"
      "remote local"
      "remote panic"
      "chat chat" !important;
    overflow: hidden !important;
    transform: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-topbar {
    grid-area: top !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-stage {
    grid-area: stage !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 9 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-remote-video-shell {
    grid-area: remote !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    overflow: hidden !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-mobile-local-slot {
    grid-area: local !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: var(--ewr1407-cinema22-side) !important;
    height: var(--ewr1407-cinema22-side) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
    overflow: hidden !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    aspect-ratio: 1 / 1 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-panic-button {
    grid-area: panic !important;
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 4px !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-chat-panel {
    grid-area: chat !important;
    position: relative !important;
    inset: auto !important;
    display: grid !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow: hidden !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"]:not([data-keyboard-context="chat"]):not([data-mode="call"]) .ewr1407-chat-log {
    min-height: 0 !important;
  }

  /* Search focus must preserve the same geometry; only the keyboard overlays. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="search"] .ewr1407-remote-name-banner {
    display: none !important;
  }
}

/* ========================================================================== */
/* Vertical Cinema search and chat-focus layout  */
/* Normal Vertical Cinema geometry is intentionally isolated here.                       */
/* ========================================================================== */
@media (max-width: 700px) and (orientation: portrait) {
  /* iOS can temporarily drop the visual clipping layer while the YouTube
     input owns focus. Force the complete local-camera stack to use the same
     rounded clipping mask during the search-keyboard state. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="search"] .ewr1407-mobile-local-slot,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="search"] .ewr1407-local-camera-card {
    border-radius: 16px !important;
    overflow: hidden !important;
    isolation: isolate !important;
    clip-path: inset(0 round 16px) !important;
    -webkit-clip-path: inset(0 round 16px) !important;
    transform: translateZ(0) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="search"] .ewr1407-local-camera-video,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="search"] #ewr1407-local-camera-placeholder {
    inset: 1px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    object-fit: cover !important;
    background-clip: padding-box !important;
  }

  /* Dedicated chat-keyboard layout.
     The visible viewport is split into one top third and one chat area that is
     exactly twice as tall. The stage stays 16:9 at the upper left. Remote and
     local cameras are stacked in square cells. Panic occupies every remaining
     pixel on the right and is exactly as high as both cameras plus their gap. */
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] {
    --ewr1407-vcc24-gap: 6px;
    --ewr1407-vcc24-pad-top: max(6px, var(--ewr1407-safe-top));
    --ewr1407-vcc24-pad-right: max(6px, var(--ewr1407-safe-right));
    --ewr1407-vcc24-pad-left: max(6px, var(--ewr1407-safe-left));
    --ewr1407-vcc24-content-height: calc(
      var(--ewr1407-visual-height, 100dvh) -
      var(--ewr1407-vcc24-pad-top)
    );
    --ewr1407-vcc24-top-height: calc(
      (var(--ewr1407-vcc24-content-height) - var(--ewr1407-vcc24-gap)) / 3
    );
    --ewr1407-vcc24-camera-side: calc(
      (var(--ewr1407-vcc24-top-height) - var(--ewr1407-vcc24-gap)) / 2
    );
    --ewr1407-vcc24-content-width: calc(
      var(--ewr1407-visual-width, 100vw) -
      var(--ewr1407-vcc24-pad-left) -
      var(--ewr1407-vcc24-pad-right)
    );
    --ewr1407-vcc24-panic-min: clamp(46px, 13vw, 56px);
    --ewr1407-vcc24-stage-ideal: calc(var(--ewr1407-vcc24-top-height) * 1.7777778);
    --ewr1407-vcc24-stage-width: min(
      var(--ewr1407-vcc24-stage-ideal),
      calc(
        var(--ewr1407-vcc24-content-width) -
        var(--ewr1407-vcc24-camera-side) -
        var(--ewr1407-vcc24-panic-min) -
        (2 * var(--ewr1407-vcc24-gap))
      )
    );

    position: fixed !important;
    top: var(--ewr1407-visual-top, 0px) !important;
    right: auto !important;
    bottom: auto !important;
    left: var(--ewr1407-visual-left, 0px) !important;
    display: grid !important;
    width: var(--ewr1407-visual-width, 100vw) !important;
    height: var(--ewr1407-visual-height, 100dvh) !important;
    padding:
      var(--ewr1407-vcc24-pad-top)
      var(--ewr1407-vcc24-pad-right)
      0
      var(--ewr1407-vcc24-pad-left) !important;
    gap: var(--ewr1407-vcc24-gap) !important;
    grid-template-columns:
      minmax(0, var(--ewr1407-vcc24-stage-width))
      var(--ewr1407-vcc24-camera-side)
      minmax(var(--ewr1407-vcc24-panic-min), 1fr) !important;
    grid-template-rows:
      var(--ewr1407-vcc24-camera-side)
      var(--ewr1407-vcc24-camera-side)
      minmax(0, 1fr) !important;
    grid-template-areas:
      "stage remote panic"
      "stage local panic"
      "chat chat chat" !important;
    overflow: hidden !important;
    transform: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-topbar,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-topbar-right,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-notification-button {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-stage {
    grid-area: stage !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    align-self: start !important;
    justify-self: start !important;
    width: var(--ewr1407-vcc24-stage-width) !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 9 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    visibility: visible !important;
    z-index: 5 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-remote-video-shell {
    grid-area: remote !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: var(--ewr1407-vcc24-camera-side) !important;
    height: var(--ewr1407-vcc24-camera-side) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    clip-path: inset(0 round 14px) !important;
    -webkit-clip-path: inset(0 round 14px) !important;
    visibility: visible !important;
    z-index: 6 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-remote-video-shell .ewr1407-card-heading,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-remote-name-banner {
    display: none !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot {
    grid-area: local !important;
    position: relative !important;
    inset: auto !important;
    display: block !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: var(--ewr1407-vcc24-camera-side) !important;
    height: var(--ewr1407-vcc24-camera-side) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    isolation: isolate !important;
    clip-path: inset(0 round 14px) !important;
    -webkit-clip-path: inset(0 round 14px) !important;
    visibility: visible !important;
    z-index: 6 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-mobile-local-slot .ewr1407-local-camera-card {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    clip-path: inset(0 round 14px) !important;
    -webkit-clip-path: inset(0 round 14px) !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-local-camera-video,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] #ewr1407-local-camera-placeholder {
    inset: 1px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    object-fit: cover !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-panic-button {
    grid-area: panic !important;
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: var(--ewr1407-vcc24-top-height) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: var(--ewr1407-vcc24-top-height) !important;
    margin: 0 !important;
    padding: 0 5px !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    visibility: visible !important;
    z-index: 6 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-panel {
    grid-area: chat !important;
    position: relative !important;
    inset: auto !important;
    display: grid !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 0 -1px 0 !important;
    padding: 8px 8px 0 !important;
    border-radius: 14px 14px 0 0 !important;
    overflow: hidden !important;
    visibility: visible !important;
    z-index: 5 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-log {
    min-height: 0 !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"][data-keyboard-context="chat"] .ewr1407-chat-form {
    margin-bottom: 0 !important;
    padding-bottom: max(4px, var(--ewr1407-safe-bottom)) !important;
  }
}

/* ========================================================================== */
/* Horizontal Cinema remote-camera width       */
/* ========================================================================== */
@media (orientation: landscape) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"] .ewr1407-remote-video-shell {
    grid-column: 2 / 4 !important;
    grid-row: 2 !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    border-radius: 14px !important;
    overflow: hidden !important;
  }

  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"] .ewr1407-remote-camera-video,
  #ewr1407-app[data-device-class="phone"][data-room-active="true"][data-mode="cinema"] .ewr1407-remote-placeholder-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
}

/* ========================================================================== */
/* YouTube search results                                                     */
/* ========================================================================== */
#ewr1407-app .ewr1407-youtube-results {
  position: fixed;
  z-index: 100140;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 240px;
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 46%),
    color-mix(in srgb, var(--ewr1407-panel) 96%, transparent);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  color: var(--ewr1407-text);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#ewr1407-app .ewr1407-youtube-results[hidden] {
  display: none !important;
}

#ewr1407-app .ewr1407-youtube-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#ewr1407-app .ewr1407-youtube-results-header > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#ewr1407-app .ewr1407-youtube-results-header strong {
  overflow: hidden;
  font-family: Rajdhani, Montserrat, sans-serif;
  font-size: 20px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ewr1407-app .ewr1407-youtube-results-status {
  min-height: 18px;
  margin: 0;
  color: var(--ewr1407-muted);
  font-size: 12px;
  line-height: 1.45;
}

#ewr1407-app .ewr1407-youtube-results-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

#ewr1407-app .ewr1407-youtube-result {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  width: 100%;
  min-width: 0;
  min-height: 78px;
  padding: 7px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 13px;
  outline: none;
  overflow: hidden;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 130ms ease,
    background 130ms ease,
    transform 130ms ease;
}

#ewr1407-app .ewr1407-youtube-result:hover,
#ewr1407-app .ewr1407-youtube-result:focus-visible {
  border-color: var(--ewr1407-border-strong);
  background: var(--ewr1407-panel-3);
  transform: translateY(-1px);
}

#ewr1407-app .ewr1407-youtube-result-thumbnail {
  display: block;
  width: 126px;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  object-fit: cover;
  background: #020305;
}

#ewr1407-app .ewr1407-youtube-result-copy {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
}

#ewr1407-app .ewr1407-youtube-result-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#ewr1407-app .ewr1407-youtube-result-copy small {
  overflow: hidden;
  color: var(--ewr1407-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ewr1407-app .ewr1407-youtube-results-more {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--ewr1407-border-strong);
  border-radius: 11px;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

#ewr1407-app .ewr1407-youtube-results-more:disabled {
  cursor: wait;
  opacity: 0.55;
}

@media (max-width: 700px) {
  #ewr1407-app .ewr1407-youtube-results {
    gap: 8px;
    padding: 9px;
    border-radius: 15px;
  }

  #ewr1407-app .ewr1407-youtube-results-header strong {
    font-size: 18px;
  }

  #ewr1407-app .ewr1407-youtube-result {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 9px;
    min-height: 68px;
    padding: 6px;
    border-radius: 11px;
  }

  #ewr1407-app .ewr1407-youtube-result-thumbnail {
    width: 104px;
    border-radius: 8px;
  }

  #ewr1407-app .ewr1407-youtube-result-copy {
    gap: 5px;
  }

  #ewr1407-app .ewr1407-youtube-result-copy strong {
    font-size: 12px;
  }
}


/* ========================================================================== */
/* Cloudflare TURN monthly usage guard                                        */
/* ========================================================================== */
#ewr1407-app .ewr1407-turn-status {
  align-self: center;
  padding: 7px 10px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 999px;
  background: var(--ewr1407-panel-2);
  color: var(--ewr1407-muted);
  font-size: 11px;
  white-space: nowrap;
}

#ewr1407-app .ewr1407-turn-status[data-status="active"] {
  border-color: rgba(43, 216, 121, 0.62);
  color: var(--ewr1407-success);
}

#ewr1407-app .ewr1407-turn-status[data-status="blocked"],
#ewr1407-app .ewr1407-turn-status[data-status="error"] {
  border-color: rgba(255, 79, 102, 0.7);
  color: var(--ewr1407-danger);
}

#ewr1407-app .ewr1407-turn-copy {
  margin: 0 0 12px;
  color: var(--ewr1407-muted);
  font-size: 12px;
  line-height: 1.55;
}

#ewr1407-app .ewr1407-turn-progress-shell {
  width: 100%;
  height: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--ewr1407-border);
  border-radius: 999px;
  background: var(--ewr1407-panel-2);
}

#ewr1407-app .ewr1407-turn-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ewr1407-accent-a), var(--ewr1407-accent-b));
  transition: width 220ms ease;
}

#ewr1407-app .ewr1407-settings-turn-usage[data-blocked="true"] .ewr1407-turn-progress-bar {
  background: var(--ewr1407-danger);
}

#ewr1407-app .ewr1407-turn-history {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

#ewr1407-app .ewr1407-turn-history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

#ewr1407-app .ewr1407-turn-history-heading strong {
  font-size: 12px;
}

#ewr1407-app .ewr1407-turn-history-heading small {
  color: var(--ewr1407-muted);
  font-size: 10px;
  text-align: right;
}

#ewr1407-app .ewr1407-turn-history-list {
  display: grid;
  gap: 6px;
}

#ewr1407-app .ewr1407-turn-history-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.7fr) minmax(100px, 1fr) minmax(88px, 0.8fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--ewr1407-border);
  border-radius: 11px;
  background: var(--ewr1407-panel-2);
  font-size: 10px;
}

#ewr1407-app .ewr1407-turn-history-row strong:last-child {
  text-align: right;
}

@media (max-width: 700px) {
  #ewr1407-app .ewr1407-turn-history-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  #ewr1407-app .ewr1407-turn-history-heading small {
    text-align: left;
  }

  #ewr1407-app .ewr1407-turn-history-row {
    grid-template-columns: 1fr auto;
  }

  #ewr1407-app .ewr1407-turn-history-row span:nth-child(2) {
    display: none;
  }
}

/* ========================================================================== */
/* v0.7.5 — Dedicated Cloudflare column on desktop and iPad                    */
/* ========================================================================== */

/* The settings body is the only scrolling surface. The header remains fixed
 * and every card stays inside the dialog on all supported devices. */
#ewr1407-app .ewr1407-settings-overlay {
  overflow: hidden;
}

#ewr1407-app .ewr1407-settings-dialog {
  min-width: 0;
  min-height: 0;
}

#ewr1407-app .ewr1407-settings-scroll {
  min-width: 0;
  min-height: 0;
  align-items: start;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

#ewr1407-app .ewr1407-settings-section,
#ewr1407-app .ewr1407-settings-quality,
#ewr1407-app .ewr1407-settings-stats,
#ewr1407-app .ewr1407-settings-turn-usage,
#ewr1407-app .ewr1407-settings-theme,
#ewr1407-app .ewr1407-settings-room,
#ewr1407-app .ewr1407-settings-layout {
  min-width: 0;
  min-height: 0;
  align-self: start;
  overflow: visible;
}

#ewr1407-app .ewr1407-settings-turn-usage .ewr1407-stats-grid,
#ewr1407-app .ewr1407-settings-room .ewr1407-room-info-grid {
  min-width: 0;
}

#ewr1407-app .ewr1407-turn-stats-grid > div,
#ewr1407-app .ewr1407-turn-stats-grid strong,
#ewr1407-app .ewr1407-turn-history-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

#ewr1407-app .ewr1407-settings-scroll::-webkit-scrollbar {
  width: 10px;
}

#ewr1407-app .ewr1407-settings-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#ewr1407-app .ewr1407-settings-scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(150, 160, 175, 0.34);
  background-clip: padding-box;
}

/* Desktop:
 * Left side: Receive quality, WebRTC statistics, Color palette and Room.
 * Right side: Cloudflare TURN usage by itself. */
@media (min-width: 1181px) {
  #ewr1407-app .ewr1407-settings-dialog {
    width: min(1460px, calc(100vw - 32px));
    height: min(860px, calc(var(--ewr1407-visual-height, 100dvh) - 32px));
    max-height: calc(var(--ewr1407-visual-height, 100dvh) - 32px);
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns:
      minmax(280px, 1fr)
      minmax(280px, 1fr)
      minmax(390px, 1.08fr);
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "quality quality turn"
      "stats theme turn"
      "room room turn";
    gap: 12px;
    padding: 12px;
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-area: quality;
    display: block;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-area: stats;
  }

  #ewr1407-app .ewr1407-settings-turn-usage {
    grid-area: turn;
  }

  #ewr1407-app .ewr1407-settings-theme {
    grid-area: theme;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-area: room;
  }

  #ewr1407-app .ewr1407-quality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-quality-block {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    min-height: 0;
  }

  #ewr1407-app .ewr1407-quality-heading {
    grid-column: 1 / -1;
  }

  #ewr1407-app .ewr1407-turn-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-room-info-grid {
    grid-template-columns: minmax(220px, 1fr) minmax(120px, 0.55fr) minmax(150px, 0.75fr);
  }

  #ewr1407-app .ewr1407-settings-room .ewr1407-settings-danger {
    grid-column: 1 / -1;
  }
}

/* Short desktop displays use the same composition and scroll internally. */
@media (min-width: 1181px) and (max-height: 760px) {
  #ewr1407-app .ewr1407-settings-dialog {
    height: calc(var(--ewr1407-visual-height, 100dvh) - 20px);
    max-height: calc(var(--ewr1407-visual-height, 100dvh) - 20px);
  }

  #ewr1407-app .ewr1407-settings-header {
    min-height: 68px;
    padding: 12px 18px;
  }

  #ewr1407-app .ewr1407-settings-header h2 {
    font-size: 30px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    gap: 10px;
    padding: 10px;
  }

  #ewr1407-app .ewr1407-settings-section {
    padding: 13px;
  }

  #ewr1407-app .ewr1407-section-heading {
    margin-bottom: 10px;
  }

  #ewr1407-app .ewr1407-turn-copy {
    margin-bottom: 8px;
  }
}

/* iPad portrait and landscape:
 * The normal settings are stacked in the left column. Cloudflare TURN remains
 * alone in the right column. Both columns move together inside one scroller. */
@media (min-width: 701px) and (max-width: 1180px) {
  #ewr1407-app .ewr1407-settings-overlay {
    padding:
      max(10px, var(--ewr1407-safe-top))
      max(10px, var(--ewr1407-safe-right))
      max(10px, var(--ewr1407-safe-bottom))
      max(10px, var(--ewr1407-safe-left));
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 22px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1.16fr) minmax(280px, 0.84fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "quality turn"
      "stats turn"
      "theme turn"
      "room turn";
    gap: 12px;
    padding: 12px;
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-area: quality;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-area: stats;
  }

  #ewr1407-app .ewr1407-settings-turn-usage {
    grid-area: turn;
  }

  #ewr1407-app .ewr1407-settings-theme {
    grid-area: theme;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-area: room;
  }

  #ewr1407-app .ewr1407-quality-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #ewr1407-app .ewr1407-quality-block {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
  }

  #ewr1407-app .ewr1407-quality-heading {
    grid-column: 1 / -1;
  }

  #ewr1407-app .ewr1407-stats-grid,
  #ewr1407-app .ewr1407-turn-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-palette-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-room-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-room-name-field,
  #ewr1407-app .ewr1407-settings-room .ewr1407-settings-danger {
    grid-column: 1 / -1;
  }
}

/* iPhone portrait: every section is shown one below another in the established
 * order. */
@media (max-width: 700px) {
  #ewr1407-app .ewr1407-settings-overlay {
    place-items: stretch;
    padding:
      var(--ewr1407-safe-top)
      var(--ewr1407-safe-right)
      var(--ewr1407-safe-bottom)
      var(--ewr1407-safe-left);
  }

  #ewr1407-app .ewr1407-settings-dialog {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  #ewr1407-app .ewr1407-settings-header {
    min-height: 72px;
    padding: 12px 14px;
  }

  #ewr1407-app .ewr1407-settings-header h2 {
    font-size: 30px;
  }

  #ewr1407-app .ewr1407-settings-header .ewr1407-card-icon-button {
    width: 44px;
    height: 44px;
  }

  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "quality"
      "stats"
      "turn"
      "theme"
      "room"
      "layout";
    gap: 10px;
    padding: 10px 10px calc(18px + var(--ewr1407-safe-bottom));
  }

  #ewr1407-app .ewr1407-settings-quality {
    grid-area: quality;
  }

  #ewr1407-app .ewr1407-settings-stats {
    grid-area: stats;
  }

  #ewr1407-app .ewr1407-settings-turn-usage {
    grid-area: turn;
  }

  #ewr1407-app .ewr1407-settings-theme {
    grid-area: theme;
  }

  #ewr1407-app .ewr1407-settings-room {
    grid-area: room;
  }

  #ewr1407-app .ewr1407-settings-layout {
    grid-area: layout;
  }

  #ewr1407-app .ewr1407-settings-section {
    padding: 14px;
    border-radius: 16px;
  }

  #ewr1407-app .ewr1407-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  #ewr1407-app .ewr1407-section-heading p {
    max-width: none;
    text-align: left;
  }

  #ewr1407-app .ewr1407-settings-turn-usage .ewr1407-section-heading {
    gap: 10px;
  }

  #ewr1407-app .ewr1407-turn-status {
    align-self: flex-start;
  }

  #ewr1407-app .ewr1407-quality-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #ewr1407-app .ewr1407-quality-block {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
    padding: 13px;
  }

  #ewr1407-app .ewr1407-quality-heading {
    grid-column: 1 / -1;
  }

  #ewr1407-app .ewr1407-stats-grid,
  #ewr1407-app .ewr1407-turn-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-room-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #ewr1407-app .ewr1407-room-name-field,
  #ewr1407-app .ewr1407-settings-room .ewr1407-settings-danger {
    grid-column: 1 / -1;
  }

  #ewr1407-app .ewr1407-turn-history-row {
    min-width: 0;
  }
}

/* iPhone landscape can be wider than 700 px. Device detection therefore
 * explicitly forces the same single-column settings flow. */
@media (min-width: 701px) and (max-width: 900px) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-overlay {
    place-items: stretch;
    padding:
      var(--ewr1407-safe-top)
      var(--ewr1407-safe-right)
      var(--ewr1407-safe-bottom)
      var(--ewr1407-safe-left);
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-dialog {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-header {
    min-height: 58px;
    padding: 8px 12px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-header h2 {
    font-size: 25px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-scroll {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "quality"
      "stats"
      "turn"
      "theme"
      "room"
      "layout";
    gap: 9px;
    padding: 9px 9px calc(14px + var(--ewr1407-safe-bottom));
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-quality {
    grid-area: quality;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-stats {
    grid-area: stats;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-turn-usage {
    grid-area: turn;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-theme {
    grid-area: theme;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-room {
    grid-area: room;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-layout {
    grid-area: layout;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-section {
    padding: 12px;
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-quality-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #ewr1407-app[data-device-class="phone"] .ewr1407-turn-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* ========================================================================== */
/* v0.7.5 — Reliable scrollable settings layout                              */
/* ========================================================================== */

/*
 * The dialog itself never scrolls. Its header remains visible while the
 * complete settings body forms one real vertical scrolling surface.
 * max-content rows prevent the cards from being compressed into the viewport
 * and visually overlapping each other on short desktop and tablet screens.
 */
#ewr1407-app .ewr1407-settings-dialog {
  min-height: 0;
  overflow: hidden;
}

#ewr1407-app .ewr1407-settings-scroll {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  align-items: start;
  align-content: start;
  grid-auto-rows: max-content;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

#ewr1407-app .ewr1407-settings-section,
#ewr1407-app .ewr1407-settings-quality,
#ewr1407-app .ewr1407-settings-stats,
#ewr1407-app .ewr1407-settings-turn-usage,
#ewr1407-app .ewr1407-settings-theme,
#ewr1407-app .ewr1407-settings-room,
#ewr1407-app .ewr1407-settings-layout {
  width: auto;
  height: auto !important;
  max-height: none !important;
  min-height: max-content;
  align-self: start;
  overflow: visible !important;
}

/* Desktop: three genuine content rows in the left area. */
@media (min-width: 1181px) {
  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-rows: repeat(3, max-content) !important;
    padding-bottom: 24px;
  }

  #ewr1407-app .ewr1407-settings-turn-usage {
    align-self: start;
  }
}

/* iPad portrait and landscape: four genuine content rows on the left. */
@media (min-width: 701px) and (max-width: 1180px) {
  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-rows: repeat(4, max-content) !important;
    padding-bottom: calc(24px + var(--ewr1407-safe-bottom));
  }

  #ewr1407-app .ewr1407-settings-turn-usage {
    align-self: start;
  }
}

/* Phone: every card keeps its natural height and the full list scrolls. */
@media (max-width: 700px) {
  #ewr1407-app .ewr1407-settings-scroll {
    grid-template-rows: repeat(6, max-content) !important;
    grid-auto-rows: max-content !important;
    padding-bottom: calc(28px + var(--ewr1407-safe-bottom));
  }
}

/* Landscape phones can exceed 700px in width, so device detection wins. */
@media (min-width: 701px) and (max-width: 900px) and (max-height: 540px) {
  #ewr1407-app[data-device-class="phone"] .ewr1407-settings-scroll {
    grid-template-rows: repeat(6, max-content) !important;
    grid-auto-rows: max-content !important;
    padding-bottom: calc(24px + var(--ewr1407-safe-bottom));
  }
}


/* ========================================================================== */
/* v0.7.5 — Low-jank settings scrolling                                       */
/* ========================================================================== */

/*
 * Full-screen backdrop blur is expensive on Safari/iPadOS while an inner
 * element is scrolling. A dense translucent backdrop preserves readability
 * without continuously recompositing the page behind the dialog.
 */
#ewr1407-app .ewr1407-settings-overlay {
  overflow: hidden !important;
  background: rgba(2, 5, 10, 0.92) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#ewr1407-app .ewr1407-settings-dialog {
  contain: layout paint;
  isolation: isolate;
  transform: translateZ(0);
  backface-visibility: hidden;
}

#ewr1407-app .ewr1407-settings-scroll {
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  scroll-behavior: auto !important;
  scroll-snap-type: none !important;
  scroll-padding: 0 !important;
  overflow-anchor: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  transform: translateZ(0);
  backface-visibility: hidden;
}

#ewr1407-app .ewr1407-settings-section {
  contain: layout style;
}

@media (pointer: coarse) {
  #ewr1407-app .ewr1407-settings-scroll {
    scrollbar-width: none;
  }

  #ewr1407-app .ewr1407-settings-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}
