/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright (c) 2026 SVUI Inc. - MiraCall Web Client */

/* --------------------------------------------------------------------------
   Material Design 3 (Material You) Design Tokens & Foundations
   -------------------------------------------------------------------------- */
:root {
  /* Typography */
  --md-sys-typescale-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --md-sys-typescale-mono: 'JetBrains Mono', 'Roboto Mono', Menlo, Consolas, monospace;

  /* Shapes & Corner Radii */
  --md-sys-shape-none: 0px;
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* Motion & Transitions */
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.3, 0, 0, 1.25);
  --md-sys-motion-duration-short: 150ms;
  --md-sys-motion-duration-medium: 250ms;
  --md-sys-motion-duration-long: 400ms;

  /* Elevations */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.14);
  --md-sys-elevation-2: 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
  --md-sys-elevation-3: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
  --md-sys-elevation-4: 0 14px 28px rgba(0, 0, 0, 0.18), 0 10px 10px rgba(0, 0, 0, 0.12);
  --md-sys-elevation-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* In-call dock — fixed regardless of theme (light/dark/OLED all share the same black video
     backdrop, so the dock stays a consistent dark glass over it rather than following theme
     tokens that differ per theme). Ported 1:1 from the Android app's DarkCallColors
     (ui/theme/Color.kt) — its own OLED palette is just a .copy() of the dark one for the same
     reason, and its mic/camera/hangup buttons use this dedicated call palette (Danger/Glass/
     OnGlass), not the app's generic Material error/primary colors. */
  --dock-glass-bg: rgba(28, 28, 30, 0.25); /* Glass: 0x401C1C1E */
  --dock-glass-strong: rgba(28, 28, 30, 0.8); /* GlassStrong: 0xCC1C1C1E */
  --dock-glass-border: rgba(255, 255, 255, 0.141); /* GlassBorder: 0x24FFFFFF */
  --dock-on-surface: #FFFFFF; /* OnGlass */
  --dock-primary: #4C8DFF; /* Accent / BrandBlue */
  --dock-on-primary: #FFFFFF;
  --dock-error: #FF453A; /* Danger / DeclineRed */
  --dock-on-error: #FFFFFF; /* muted-mic/camera-off icon tint is Color.White, not a dark-on-error text color */
}

/* --------------------------------------------------------------------------
   Color Schemes: Light, Dark, and OLED True-Black
   -------------------------------------------------------------------------- */
[data-theme="light"] {
  --md-sys-color-primary: #0B61D6;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D8E4FF;
  --md-sys-color-on-primary-container: #001A44;

  --md-sys-color-secondary: #4C8DFF;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #E0EAFF;
  --md-sys-color-on-secondary-container: #001D4D;

  --md-sys-color-surface: #F8F9FD;
  --md-sys-color-on-surface: #191C20;
  --md-sys-color-surface-dim: #D9DAE0;
  --md-sys-color-surface-bright: #F8F9FD;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #F2F3F9;
  --md-sys-color-surface-container: #EBECF4;
  --md-sys-color-surface-container-high: #E4E6EF;
  --md-sys-color-surface-container-highest: #DEE0EA;
  --md-sys-color-surface-variant: #E1E2EC;
  --md-sys-color-on-surface-variant: #44474F;

  --md-sys-color-outline: #74777F;
  --md-sys-color-outline-variant: #C4C6D0;

  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #410002;

  --md-sys-color-success: #1E8E3E;
  --md-sys-color-caution: #F59E0B;

  /* Glassmorphism */
  --call-glass-bg: rgba(255, 255, 255, 0.85);
  --call-glass-strong: rgba(240, 243, 250, 0.94);
  --call-glass-border: rgba(0, 0, 0, 0.08);
  --call-video-backdrop: #000000;
  --call-scrim-top: linear-gradient(180deg, rgba(235, 238, 245, 0.9) 0%, rgba(235, 238, 245, 0) 100%);
}

[data-theme="dark"] {
  --md-sys-color-primary: #4C8DFF;
  --md-sys-color-on-primary: #002B6F;
  --md-sys-color-primary-container: #00409A;
  --md-sys-color-on-primary-container: #D8E4FF;

  --md-sys-color-secondary: #ADC6FF;
  --md-sys-color-on-secondary: #103060;
  --md-sys-color-secondary-container: #2A4677;
  --md-sys-color-on-secondary-container: #D8E4FF;

  --md-sys-color-surface: #0E1015;
  --md-sys-color-on-surface: #E2E2E9;
  --md-sys-color-surface-dim: #0E1015;
  --md-sys-color-surface-bright: #353840;
  --md-sys-color-surface-container-lowest: #090A0D;
  --md-sys-color-surface-container-low: #16181F;
  --md-sys-color-surface-container: #1C1E26;
  --md-sys-color-surface-container-high: #262933;
  --md-sys-color-surface-container-highest: #313440;
  --md-sys-color-surface-variant: #2A2D38;
  --md-sys-color-on-surface-variant: #C4C6D0;

  --md-sys-color-outline: #8E9099;
  --md-sys-color-outline-variant: #393C46;

  --md-sys-color-error: #FFB4AB;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000A;
  --md-sys-color-on-error-container: #FFDAD6;

  --md-sys-color-success: #30D158;
  --md-sys-color-caution: #F59E0B;

  /* Glassmorphism */
  --call-glass-bg: rgba(28, 30, 38, 0.72);
  --call-glass-strong: rgba(22, 24, 32, 0.88);
  --call-glass-border: rgba(255, 255, 255, 0.12);
  --call-video-backdrop: #000000;
  --call-scrim-top: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
}

[data-theme="oled"] {
  --md-sys-color-primary: #4C8DFF;
  --md-sys-color-on-primary: #000000;
  --md-sys-color-primary-container: #003685;
  --md-sys-color-on-primary-container: #D8E4FF;

  --md-sys-color-secondary: #90B4FF;
  --md-sys-color-on-secondary: #000000;
  --md-sys-color-secondary-container: #1D3B6A;
  --md-sys-color-on-secondary-container: #D8E4FF;

  --md-sys-color-surface: #000000;
  --md-sys-color-on-surface: #F0F0F5;
  --md-sys-color-surface-dim: #000000;
  --md-sys-color-surface-bright: #202024;
  --md-sys-color-surface-container-lowest: #000000;
  --md-sys-color-surface-container-low: #08080A;
  --md-sys-color-surface-container: #0D0D10;
  --md-sys-color-surface-container-high: #141418;
  --md-sys-color-surface-container-highest: #1B1B20;
  --md-sys-color-surface-variant: #141418;
  --md-sys-color-on-surface-variant: #B0B3BE;

  --md-sys-color-outline: #5B6270;
  --md-sys-color-outline-variant: #2A2D35;

  --md-sys-color-error: #FF8577;
  --md-sys-color-on-error: #000000;
  --md-sys-color-error-container: #600004;
  --md-sys-color-on-error-container: #FFDAD6;

  --md-sys-color-success: #30D158;
  --md-sys-color-caution: #FBBF24;

  /* Glassmorphism */
  --call-glass-bg: rgba(0, 0, 0, 0.85);
  --call-glass-strong: rgba(8, 8, 10, 0.95);
  --call-glass-border: rgba(255, 255, 255, 0.16);
  --call-video-backdrop: #000000;
  --call-scrim-top: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
}

/* --------------------------------------------------------------------------
   Base Styles & Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--md-sys-typescale-font);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */
.app-viewport {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top App Bar (Material 3 Center-Aligned Top App Bar) */
.m3-top-app-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 24px;
  height: 68px;
  background-color: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  z-index: 100;
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.app-bar-side {
  display: flex;
  align-items: center;
}

.app-bar-start {
  justify-self: start;
}

.app-bar-end {
  justify-self: end;
}

.brand-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, #2563EB 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-1);
  cursor: pointer;
  transition: filter var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.brand-icon-box:hover {
  filter: brightness(1.1);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.brand-title-center {
  grid-column: 2;
  text-align: center;
  white-space: nowrap;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status Chip */
.m3-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 12px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

.m3-status-chip .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--md-sys-color-outline);
  transition: background-color var(--md-sys-motion-duration-short);
}

.m3-status-chip.connected .status-dot {
  background-color: var(--md-sys-color-success);
  box-shadow: 0 0 8px var(--md-sys-color-success);
}

.m3-status-chip.reconnecting .status-dot {
  background-color: var(--md-sys-color-caution);
  animation: pulse-dot 1.2s infinite;
}

.m3-status-chip.disconnected .status-dot {
  background-color: var(--md-sys-color-error);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Icon Buttons */
.m3-icon-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background-color var(--md-sys-motion-duration-short),
              transform var(--md-sys-motion-duration-short);
}

.m3-icon-button:hover {
  background-color: rgba(125, 125, 125, 0.12);
  color: var(--md-sys-color-on-surface);
}

.m3-icon-button:active {
  transform: scale(0.92);
}

.m3-icon-button.filled-tonal {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}

/* --------------------------------------------------------------------------
   Screen Containers: Lobby & In-Call Stage
   -------------------------------------------------------------------------- */
.screens-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 68px);
  overflow: hidden;
}

.m3-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
  overflow: hidden;
}

.m3-screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* --------------------------------------------------------------------------
   Lobby Screen (Pre-Call Room & Self-Preview)
   -------------------------------------------------------------------------- */
#lobbyScreen {
  overflow-y: auto;
  padding: 24px 20px 48px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: radial-gradient(circle at 50% 0%, var(--md-sys-color-surface-container) 0%, var(--md-sys-color-surface) 70%);
}

.lobby-container {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 32px;
  margin-top: 12px;
}

@media (max-width: 860px) {
  .lobby-container {
    grid-template-columns: 1fr;
    max-width: 540px;
    gap: 24px;
  }
}

/* Self-Preview Column (Camera Tile + Mic Activity Meter) */
.self-preview-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Mic Activity Meter */
.mic-meter-track {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.mic-meter-icon {
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}

.mic-meter-bar {
  flex: 1;
  height: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-highest);
  overflow: hidden;
}

.mic-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--md-sys-color-primary), var(--md-sys-color-secondary));
  transition: width 90ms linear;
}

/* Self-Preview Card */
.self-preview-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 280px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background-color: var(--md-sys-color-surface-container-highest);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-2);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.self-preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror self-view */
}

/* Procedural Avatar Placeholder */
.avatar-cover {
  position: absolute;
  inset: 0;
  background-color: var(--md-sys-color-surface-container-highest);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short);
}

.avatar-cover.visible {
  opacity: 1;
  pointer-events: auto;
}

.procedural-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  background-size: cover;
  background-position: center;
  color: var(--md-sys-color-on-primary);
  font-size: 38px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-3);
}

.avatar-caption {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

/* Floating Controls inside Preview */
.preview-scrim {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

.preview-controls-row {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.preview-ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.preview-ctrl-btn:hover {
  transform: scale(1.06);
}

.preview-ctrl-btn:active {
  transform: scale(0.92);
}

.preview-ctrl-btn.off {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

/* Lobby Form Card */
.lobby-form-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px 28px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background-color: var(--md-sys-color-surface-container-high);
  box-shadow: var(--md-sys-elevation-1);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.lobby-form-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--md-sys-color-on-surface);
}

.lobby-form-header p {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

/* "Entering As" Notice (replaces the inline display-name field) */
.entering-as-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.entering-as-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--md-sys-color-on-surface-variant);
}

.entering-as-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}

.entering-as-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface-variant);
}

.entering-as-hint .material-symbols-rounded {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Material 3 Outlined Text Field */
.m3-text-field {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: 6px;
}

.m3-text-field input {
  width: 100%;
  height: 54px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1.5px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short),
              box-shadow var(--md-sys-motion-duration-short);
}

.m3-text-field input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.m3-text-field label {
  position: absolute;
  left: 14px;
  top: -9px;
  z-index: 1;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-primary);
  border-radius: 4px;
}

.input-action-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-action-wrapper input {
  padding-right: 56px;
}

.input-trailing-btn {
  position: absolute;
  top: 50%;
  right: 3px;
  width: 48px;
  height: 48px;
  transform: translateY(-50%);
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--md-sys-motion-duration-short);
}

.input-trailing-btn:hover {
  color: var(--md-sys-color-primary);
  transform: translateY(-50%) rotate(30deg);
}

/* Recent Rooms Chips */
.recent-chips-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
}

.recent-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recent-chips-scroll::-webkit-scrollbar {
  height: 4px;
}
.recent-chips-scroll::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: 4px;
}

.m3-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--md-sys-motion-duration-short);
}

.m3-filter-chip:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
}

.m3-filter-chip.selected {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: var(--md-sys-color-primary);
}

/* Codec Segmented Choice Chips */
.choice-chips-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.choice-chip {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-surface);
  border: 1.5px solid var(--md-sys-color-outline-variant);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short);
}

.choice-chip:hover {
  border-color: var(--md-sys-color-outline);
}

.choice-chip.active {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
}

/* Join Button */
.m3-filled-button {
  width: 100%;
  height: 54px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-2);
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  margin-top: 6px;
}

.m3-filled-button:hover {
  box-shadow: var(--md-sys-elevation-3);
  filter: brightness(1.08);
}

.m3-filled-button:active {
  transform: scale(0.98);
}

/* --------------------------------------------------------------------------
   In-Call Screen (Full-Bleed Stage & Floating Chrome)
   -------------------------------------------------------------------------- */
#callScreen {
  background-color: var(--call-video-backdrop);
}

.call-stage-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--call-video-backdrop);
  overflow: hidden;
}

/* Full-Bleed Remote Video */
.remote-video-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--call-video-backdrop);
}

.remote-video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--md-sys-motion-duration-short);
}

.remote-video-element.fit-content {
  object-fit: contain; /* Letterbox for screen shares / mobile feeds */
}

/* Waiting / Connecting State Placeholder */
.call-waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background-color: var(--md-sys-color-surface);
  z-index: 10;
  transition: opacity var(--md-sys-motion-duration-medium);
}

.waiting-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--md-sys-color-surface-container-highest);
  border-top-color: var(--md-sys-color-primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.waiting-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.waiting-room-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-high);
  font-size: 14px;
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

/* Draggable Picture-in-Picture Local Self-View */
.local-pip-tile {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 160px;
  height: 220px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1.5px solid var(--call-glass-border);
  box-shadow: var(--md-sys-elevation-glass);
  overflow: hidden;
  cursor: grab;
  z-index: 50;
  transition: box-shadow var(--md-sys-motion-duration-short);
}

.local-pip-tile:active {
  cursor: grabbing;
}

.local-pip-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.local-pip-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: var(--md-sys-shape-corner-small);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.local-pip-mic-icon {
  font-size: 13px;
  color: var(--md-sys-color-error);
}

.local-pip-waveform {
  width: 20px;
  height: 11px;
  display: block;
}

/* Local Self-View: Camera-Off Cover — the app's PipAvatar, at pip-tile scale */
.pip-avatar-cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-surface-container-highest);
}

.pip-avatar-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  background-size: cover;
  background-position: center;
  color: var(--md-sys-color-on-primary);
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Remote Peer: Camera-Off Cover — full-bleed, matching the app's PipAvatar in the main stage */
.remote-avatar-cover {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background-color: var(--md-sys-color-surface);
}

.remote-avatar-badge {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  background-size: cover;
  background-position: center;
  color: var(--md-sys-color-on-primary);
  font-size: 44px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-3);
}

/* Remote Peer: Name + Live Mic State Chip */
.remote-peer-chip {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--call-glass-strong);
  border: 1px solid var(--call-glass-border);
  backdrop-filter: blur(20px);
  box-shadow: var(--md-sys-elevation-2);
}

.remote-peer-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remote-peer-mic-icon {
  font-size: 16px;
  color: var(--md-sys-color-error);
}

.remote-peer-waveform {
  width: 26px;
  height: 16px;
  display: block;
}

/* In-Call Top Chrome Bar */
.call-top-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--call-scrim-top);
  z-index: 40;
  pointer-events: none;
}

.call-top-chrome > * {
  pointer-events: auto;
}

.call-status-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--call-glass-strong);
  border: 1px solid var(--call-glass-border);
  backdrop-filter: blur(20px);
  box-shadow: var(--md-sys-elevation-2);
}

.call-status-pill .room-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.call-status-pill .time-counter {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--md-sys-typescale-mono);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-status-pill .recording-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--md-sys-color-success);
}

/* FaceTime-Style Floating Control Tray */
.call-floating-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background-color: var(--dock-glass-strong);
  border: 1px solid var(--dock-glass-border);
  backdrop-filter: blur(24px);
  box-shadow: var(--md-sys-elevation-glass);
  z-index: 45;
}

.dock-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--dock-glass-border);
  background-color: var(--dock-glass-bg);
  color: var(--dock-on-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.dock-btn:hover {
  transform: scale(1.08);
  background-color: rgba(125, 125, 125, 0.25);
}

.dock-btn:active {
  transform: scale(0.92);
}

.dock-btn.active {
  background-color: var(--dock-primary);
  color: var(--dock-on-primary);
  border-color: transparent;
}

.dock-btn.off {
  background-color: var(--dock-error);
  color: var(--dock-on-error);
  border-color: transparent;
}

.dock-btn.btn-hangup {
  background-color: var(--dock-error);
  color: var(--dock-on-error);
  border-color: transparent;
  width: 58px;
  height: 58px;
}

.dock-btn.btn-hangup:hover {
  filter: brightness(1.15);
}

/* Badge on Chat */
.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  padding: 2px 7px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--md-sys-color-surface);
}

.unread-badge.hidden {
  display: none;
}

/* --------------------------------------------------------------------------
   In-Call Chat Drawer (Material 3 Modal Sheet)
   -------------------------------------------------------------------------- */
.m3-chat-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  background-color: var(--md-sys-color-surface-container);
  border-left: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-4);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(100%);
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.m3-chat-drawer.open {
  transform: translateX(0);
}

.chat-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.chat-drawer-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.chat-messages-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-bubble.self {
  align-self: flex-end;
}

.chat-bubble.remote {
  align-self: flex-start;
}

.chat-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

.chat-bubble-content {
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-corner-large);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-bubble.self .chat-bubble-content {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-bottom-right-radius: var(--md-sys-shape-corner-extra-small);
}

.chat-bubble.remote .chat-bubble-content {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border-bottom-left-radius: var(--md-sys-shape-corner-extra-small);
}

.chat-bubble.system {
  align-self: center;
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-corner-full);
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface);
}

.chat-input-row input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--md-sys-color-primary);
}

.chat-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--md-sys-motion-duration-short);
}

.chat-send-btn:active {
  transform: scale(0.92);
}

/* --------------------------------------------------------------------------
   Diagnostics HUD (Technical WebRTC Stats)
   -------------------------------------------------------------------------- */
.m3-stats-panel {
  position: absolute;
  top: 74px;
  left: 24px;
  padding: 14px 18px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--call-glass-strong);
  border: 1px solid var(--call-glass-border);
  backdrop-filter: blur(20px);
  box-shadow: var(--md-sys-elevation-glass);
  font-family: var(--md-sys-typescale-mono);
  font-size: 11px;
  color: var(--md-sys-color-on-surface);
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 280px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.m3-stats-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.stats-section-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--md-sys-color-primary);
  margin-top: 4px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.stats-row .label {
  color: var(--md-sys-color-on-surface-variant);
}

.stats-row .value {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Settings Modal Dialog
   -------------------------------------------------------------------------- */
.m3-dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-medium);
}

.m3-dialog-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.m3-dialog-card {
  width: 100%;
  max-width: 820px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-4);
  /* Extra bottom clearance: overflow-y:auto + border-radius clip content to the rounded
     corners, so a full-width pill button sitting flush against the padding edge gets its
     rounded ends visually cut by the card's own bottom corner curvature. */
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(0.95);
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

.m3-dialog-backdrop.open .m3-dialog-card {
  transform: scale(1);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

.settings-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.m3-select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1.5px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.m3-select:focus {
  border-color: var(--md-sys-color-primary);
}

/* Display-name character limit: yellow pulse approaching the cap, steady red at it. */
.m3-select.name-warning {
  border-color: var(--md-sys-color-caution);
  animation: name-limit-pulse 1s ease-in-out infinite;
}

.m3-select.name-limit {
  border-color: var(--md-sys-color-error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-error) 30%, transparent);
}

@keyframes name-limit-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-caution) 45%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-caution) 10%, transparent); }
}

.name-limit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
}

.name-limit-warning {
  color: var(--md-sys-color-caution);
  font-weight: 600;
}

.name-limit-counter {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  white-space: nowrap;
}

.name-limit-row.limit .name-limit-warning,
.name-limit-row.limit .name-limit-counter {
  color: var(--md-sys-color-error);
}

.m3-outlined-button {
  width: 100%;
  height: 54px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1.5px solid var(--md-sys-color-outline);
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short);
}

.m3-outlined-button:hover {
  background-color: rgba(125, 125, 125, 0.12);
}

.m3-outlined-button:active {
  transform: scale(0.98);
}

/* --------------------------------------------------------------------------
   Light / Dark Toggle (Header)
   -------------------------------------------------------------------------- */
.theme-toggle {
  position: relative;
  display: inline-flex;
  width: 96px;
  height: 48px;
  padding: 4px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.theme-toggle-thumb {
  position: absolute;
  z-index: 0;
  top: 50%;
  /* Exact centre of the sun button's content box: track is 96px wide with a 1px
     border + 4px padding each side, so the two flex:1 buttons split the
     remaining 86px content area into 43px halves — centres at 26.5 / 69.5. */
  left: 26.5px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
  transform: translate(-50%, -50%);
  transition: left var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.theme-toggle[data-active="dark"] .theme-toggle-thumb {
  left: 69.5px;
}

.theme-toggle-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  transition: color var(--md-sys-motion-duration-short);
}

.theme-toggle[data-active="light"] .theme-toggle-btn.sun,
.theme-toggle[data-active="dark"] .theme-toggle-btn.moon {
  color: var(--md-sys-color-on-primary);
}

/* --------------------------------------------------------------------------
   Settings: Profile Tile (Display Name + Avatar Picker)
   -------------------------------------------------------------------------- */
.settings-profile-tile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.settings-tile-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--md-sys-color-on-surface);
}

/* Identity/connection settings while a call is live — matches the Android app's dimmed,
   unresponsive Profile/Server SettingCards during a call. */
.settings-locked {
  opacity: 0.45;
  pointer-events: none;
}

/* Sits in normal flow above the group's own label/content instead of floating over it —
   an absolutely-positioned badge here used to land on top of the input or an avatar swatch
   depending on the group's height. */
.settings-locked::before {
  content: 'Locked during call';
  display: block;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--md-sys-color-on-surface);
  opacity: 0.8;
  margin-bottom: 2px;
}

.settings-switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 2px;
}

.settings-switch-text {
  flex: 1;
}

.settings-switch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.settings-switch-desc {
  font-size: 12px;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

/* Material 3 Switch */
.m3-switch {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 32px;
  padding: 0;
  border-radius: var(--md-sys-shape-corner-full);
  border: 2px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface-container-highest);
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color var(--md-sys-motion-duration-short),
              border-color var(--md-sys-motion-duration-short),
              border-width var(--md-sys-motion-duration-short);
}

.m3-switch-thumb {
  position: absolute;
  top: 50%;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--md-sys-color-outline);
  transform: translateY(-50%);
  transition: left var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              right var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              width var(--md-sys-motion-duration-short), height var(--md-sys-motion-duration-short),
              background-color var(--md-sys-motion-duration-short);
}

.m3-switch.on {
  /* Real M3 switches drop the outline entirely once selected — the reclaimed 2px on each
     side (border-box) is exactly what keeps the larger "on" thumb from looking cramped
     against the track edges. */
  border-width: 0;
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.m3-switch.on .m3-switch-thumb {
  left: auto;
  right: 6px;
  width: 24px;
  height: 24px;
  background-color: var(--md-sys-color-on-primary);
}

.mic-gain-readout {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mic-gain-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  min-width: 38px;
  text-align: right;
}

.mic-gain-value.over-ceiling {
  color: var(--md-sys-color-caution);
}

.mic-gain-reset-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mic-gain-reset-btn .material-symbols-rounded {
  font-size: 17px;
}

.mic-gain-reset-btn:hover {
  background-color: rgba(125, 125, 125, 0.12);
  color: var(--md-sys-color-primary);
}

.m3-range {
  width: 100%;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.settings-warning-icon {
  font-size: 18px;
  color: var(--md-sys-color-caution);
  cursor: help;
}

/* --------------------------------------------------------------------------
   Custom Animated Dropdown (Camera Input / Resolution)
   -------------------------------------------------------------------------- */
.m3-dropdown {
  position: relative;
}

.m3-dropdown-trigger {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1.5px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--md-sys-motion-duration-short), transform var(--md-sys-motion-duration-short);
}

.m3-dropdown-trigger span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m3-dropdown-trigger:active {
  transform: scale(0.99);
}

.m3-dropdown-trigger.open {
  border-color: var(--md-sys-color-primary);
}

.m3-dropdown-chevron {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.m3-dropdown-trigger.open .m3-dropdown-chevron {
  transform: rotate(180deg);
}

.m3-dropdown-trigger:disabled,
.m3-dropdown-trigger.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  border-color: var(--md-sys-color-outline-variant);
}

.m3-dropdown-menu {
  /* Portalled into <body> with position:fixed once opened (see camera-settings.js) so it
     always escapes the settings dialog's own overflow:auto scroll clipping; left/top/width
     are then set inline from the trigger's live bounding rect. */
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 260;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-3);
  transform-origin: top center;
  opacity: 0;
  transform: scaleY(0.85) translateY(-6px);
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.m3-dropdown-menu.open {
  opacity: 1;
  transform: scaleY(1) translateY(0);
  pointer-events: auto;
}

.m3-dropdown-option {
  padding: 10px 12px;
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background-color 100ms;
}

.m3-dropdown-option:hover {
  background-color: rgba(125, 125, 125, 0.12);
}

.m3-dropdown-option.selected {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
}

.m3-dropdown-option.picked {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 8px;
}

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  border-radius: var(--md-sys-shape-corner-medium);
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
}

.avatar-swatch {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 20px;
  font-weight: 700;
  border: 2.5px solid transparent;
  box-sizing: content-box;
  transition: border-color var(--md-sys-motion-duration-short), transform var(--md-sys-motion-duration-short);
}

.avatar-option.active .avatar-swatch {
  border-color: var(--md-sys-color-primary);
  transform: scale(1.05);
}

.avatar-option-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.avatar-option.active .avatar-option-label {
  color: var(--md-sys-color-primary);
}

.avatar-swatch-photo {
  background-color: var(--md-sys-color-surface-container-high);
  border: 1.5px dashed var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-variant);
}

.avatar-swatch-photo.has-photo {
  border-style: solid;
  border-color: transparent;
}

.avatar-photo-edit-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--md-sys-color-surface-container-highest);
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.avatar-photo-edit-btn .material-symbols-rounded {
  font-size: 12px;
}

.avatar-remove-photo-btn {
  align-self: center;
  border: none;
  background: transparent;
  color: var(--md-sys-color-error);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}

/* --------------------------------------------------------------------------
   Custom Photo Cropper
   -------------------------------------------------------------------------- */
.cropper-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background-color: #0B0B0D;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-medium);
}

.cropper-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cropper-header {
  text-align: center;
  padding-top: 24px;
}

.cropper-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #FFFFFF;
}

.cropper-header p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
}

.cropper-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 0;
}

.cropper-stage canvas {
  max-width: min(70vw, 420px);
  max-height: min(50vh, 420px);
  width: 320px;
  height: 320px;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
}

.cropper-stage canvas:active {
  cursor: grabbing;
}

.cropper-zoom-row {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  color: rgba(255, 255, 255, 0.7);
}

.cropper-zoom-row input[type="range"] {
  flex: 1;
  accent-color: var(--md-sys-color-primary);
}

.cropper-actions {
  width: 100%;
  max-width: 420px;
  display: flex;
  gap: 12px;
  padding: 20px 24px;
}

/* --------------------------------------------------------------------------
   Reduce Transparency (Settings toggle) — flattens the in-call glassmorphism
   (blurred, translucent surfaces) to solid theme colors.
   -------------------------------------------------------------------------- */
html[data-reduce-transparency="true"] .local-pip-label {
  background-color: #000000;
  backdrop-filter: none;
}

html[data-reduce-transparency="true"] .local-pip-tile {
  border-color: var(--md-sys-color-outline-variant);
}

html[data-reduce-transparency="true"] .call-status-pill,
html[data-reduce-transparency="true"] .call-floating-dock,
html[data-reduce-transparency="true"] .m3-stats-panel,
html[data-reduce-transparency="true"] .remote-peer-chip {
  background-color: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-outline-variant);
  backdrop-filter: none;
}

/* Only the resting (unmuted/on) state gets the solid fallback — .off/.active/.btn-hangup
   already have their own solid Danger/Accent backgrounds and shouldn't be flattened to the
   generic surface color just because transparency is reduced. */
html[data-reduce-transparency="true"] .dock-btn:not(.off):not(.active):not(.btn-hangup) {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline-variant);
}

/* --------------------------------------------------------------------------
   Reduced Motion (WCAG 2.3.3 / Material motion accessibility guidance)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .preview-ctrl-btn:hover,
  .dock-btn:hover,
  .m3-filled-button:active,
  .preview-ctrl-btn:active,
  .dock-btn:active,
  .chat-send-btn:active,
  .m3-icon-button:active {
    transform: none !important;
  }
}
