/**
 * Hussam2 Guest App Styles
 * Matching host app design tokens and aesthetic
 */

:root {
  /* Color palette — values mirror the host theme, names stay the guest's own */
  --color-primary: #0aa86b;
  --color-primary-hover: #099b62;
  /* Green as TEXT on a light surface (5.6:1 on white); the primary is a fill. */
  --color-primary-text: #047857;
  --color-text: #434343;
  --color-text-secondary: #6b7280;
  --color-background: #f0f2f5;
  --color-surface: #ffffff;
  --color-surface-hover: #f9fafb;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-error: var(--color-danger);
  --color-success: #0aa86b;
  --color-warning: #f59e0b;
  --color-border: #e5e7eb;
  --color-shadow: rgba(0, 0, 0, 0.08);

  /* Dark surfaces behind video — the same value in both schemes */
  --color-background-dark: #1a1a2e;

  /* Component-level colours that need a dark counterpart */
  --chat-role-guest-bg: #f0f0f0;
  --landing-overlay-from: rgba(223, 240, 234, 0.6);
  --landing-overlay-to: rgba(200, 223, 224, 0.6);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Typography */
  --font-family-ar: 'IBM Plex Sans Arabic', 'SF Arabic', 'Segoe UI', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-family-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-family: var(--font-family-en);
  --font-family-mono: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* The page is dir="rtl" by default and toggles to ltr at runtime. Bare
   [dir="rtl"] ties with :root on specificity, so qualify it. */
:root[dir="rtl"] {
  --font-family: var(--font-family-ar);
}

/* ── Dark scheme ──────────────────────────────────────────────────────────
   A guest opening the link on a dark phone used to get a full-white page.
   Only the tokens change here; every component reads them. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #10b981;
    --color-primary-hover: #0aa86b;
    --color-primary-text: #34d399;
    --color-text: #e5e7eb;
    --color-text-secondary: #9ca3af;
    --color-background: #111827;
    --color-surface: #1f2937;
    --color-surface-hover: #374151;
    --color-border: #374151;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-error: #ef4444;
    --color-success: #10b981;
    --color-warning: #fbbf24;
    --color-shadow: rgba(0, 0, 0, 0.3);

    --chat-role-guest-bg: rgba(255, 255, 255, 0.12);
    /* Alpha stops, never the opaque surface tokens: they sit over the
       photographic bkg.png and an opaque value would brighten dark mode. */
    --landing-overlay-from: rgba(17, 24, 39, 0.82);
    --landing-overlay-to: rgba(10, 30, 30, 0.82);

    /* rgba(0,0,0,0.1) is invisible on #111827 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  }
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  overflow: hidden;
  /* Tells the UA to render form controls, scrollbars and the canvas dark */
  color-scheme: light dark;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow: hidden;
}

/* Support for RTL and LTR */
[dir='rtl'] {
  text-align: right;
}

[dir='ltr'] {
  text-align: left;
}

/* App container */
#app {
  height: var(--app-height, 100vh);
  overflow: hidden;
  position: relative;
}

/* Card container - matching host app cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--color-shadow), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Header section */
.header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.logo {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.logo-ar {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-family-ar);
}

.logo-en {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.subtitle,
.subtitle-en {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

.subtitle {
  font-weight: 500;
}

.subtitle-en {
  font-weight: 400;
  margin-top: var(--spacing-xs);
}

/* Status indicator */
.status-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-lg);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-background);
  border-radius: var(--radius-md);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.status-connecting {
  background-color: var(--color-warning);
}

.status-dot.status-connected {
  background-color: var(--color-success);
  animation: none;
}

.status-dot.status-error {
  background-color: var(--color-error);
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text);
}

/* Meeting code display */
.meeting-code-container {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.meeting-code-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.meeting-code {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.1em;
  padding: var(--spacing-md);
  background: var(--color-background);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-primary);
}

/* Status messages */
.status-message {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--color-background);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.status-message p {
  margin: var(--spacing-xs) 0;
  color: var(--color-text);
}

.status-message-en {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Retry container */
.retry-container {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--color-background);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

#retry-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

/* Error screen */
.error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height, 100vh);
  overflow: hidden;
  padding: var(--spacing-md);
}

.error-card {
  text-align: center;
}

.error-icon {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-lg);
  color: var(--color-error);
}

.error-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-md);
}

.error-message,
.error-message-en {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
}

.error-message {
  font-size: var(--font-size-base);
  margin-bottom: var(--spacing-md);
}

.error-message-en {
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-xl);
}

/* Retry button */
.retry-button {
  display: inline-block;
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  font-family: var(--font-family);
}

.retry-button:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.retry-button:active {
  transform: translateY(0);
}

.retry-button:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .card {
    padding: var(--spacing-lg);
  }

  .logo-ar {
    font-size: var(--font-size-xl);
  }

  .meeting-code {
    font-size: var(--font-size-lg);
  }

  .status-indicator {
    padding: var(--spacing-sm) var(--spacing-md);
  }
}

/* Join Input Screen */
.join-input-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height, 100vh);
  overflow: hidden;
  padding: var(--spacing-md);
}

.join-form {
  width: 100%;
}

.join-input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  text-align: center;
  direction: ltr;
  margin-bottom: var(--spacing-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.join-input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(10, 168, 107, 0.15);
}

.join-input-field::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.join-button {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  font-family: var(--font-family);
}

.join-button:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.join-button:active {
  transform: translateY(0);
}

.join-button:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.join-error {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  text-align: center;
  padding: var(--spacing-sm);
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
}

.join-hint {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  text-align: center;
  margin-bottom: var(--spacing-md);
  line-height: 1.5;
}

.join-hint-en {
  font-size: 0.8125rem;
  opacity: 0.8;
}

/* Connecting Screen */
.connecting-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height, 100vh);
  overflow: hidden;
  padding: var(--spacing-md);
}

/* In-Meeting Screen */
.in-meeting-screen {
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100vh);
  overflow: hidden;
  position: relative;
}

.meeting-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
}

.meeting-name-display {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}

.meeting-code-badge {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.1em;
  padding: 4px 12px;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-primary);
}

.meeting-stats {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-lg);
  justify-content: center;
  margin-top: var(--spacing-sm);
  flex-wrap: wrap;
}

.meeting-stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.meeting-stat svg {
  opacity: 0.7;
}

.session-timer-display {
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* Video Grid — dynamic multi-participant layout */
.video-grid {
  position: relative;
  width: 100%;
  flex-grow: 1;
  background: var(--color-background-dark);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: grid;
  gap: 4px;
  padding: 4px;
  /* Columns set dynamically by JS via --grid-cols */
  grid-template-columns: repeat(var(--grid-cols, 1), 1fr);
  grid-auto-rows: 1fr;
}

.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.video-tile {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--color-background-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-background-dark);
}

.video-tile .tile-label {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 2;
}

.video-tile .tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: rgba(255, 255, 255, 0.3);
}

.placeholder-initials {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.05em;
}

.video-tile--speaking {
  box-shadow: 0 0 0 3px var(--color-primary, #0aa86b);
  transition: box-shadow 0.15s ease;
}

/* Local tile — in-grid, mirrored */
.video-tile--local {
  position: relative;
  /* Self-view sorts last, the way the host grid orders it */
  order: 999;
}

.video-tile--local .video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-background-dark);
}

.video-mirrored {
  transform: scaleX(-1);
}

.tile-name-label {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  padding: 3px 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Muted indicator on a tile. inline-START, alongside the labels, which are
   pushed clear of it below. */
.tile-mute-badge {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  backdrop-filter: blur(4px);
}

.tile-mute-badge svg {
  width: 14px;
  height: 14px;
}

.video-tile:has(.tile-mute-badge) .tile-name-label,
.video-tile:has(.tile-mute-badge) .tile-label {
  inset-inline-start: 40px;
}

/* Video Placeholders */
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  color: rgba(255, 255, 255, 0.7);
  gap: var(--spacing-sm);
}

.placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-icon svg {
  stroke: currentColor;
}

.placeholder-text-ar,
.placeholder-text-en {
  font-size: var(--font-size-sm);
  text-align: center;
}

.placeholder-text-en {
  opacity: 0.7;
}

/* Media Controls Bar */
.media-controls {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  margin-top: var(--spacing-md);
  align-items: center;
}

.controls-center {
  display: flex;
  flex: 1;
  gap: var(--spacing-lg);
  align-items: center;
  justify-content: center;
}

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn.active {
  background: var(--color-error);
}

/* Mic and camera enabled = primary, matching the host. The :hover twin is
   mandatory: ID specificity would otherwise let .control-btn:hover win. */
#mute-btn:not(.active):not(.force-muted),
#camera-btn:not(.active):not(.camera-forced-off) {
  background: var(--color-primary);
}

#mute-btn:not(.active):not(.force-muted):hover,
#camera-btn:not(.active):not(.camera-forced-off):hover {
  background: #089a60;
}

.control-btn-danger {
  background: var(--color-error);
}

.control-btn-danger:hover {
  background: var(--color-danger-hover);
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.1);
}

.control-btn.force-muted,
.control-btn.camera-forced-off {
  background: var(--color-error);
  opacity: 0.7;
  cursor: not-allowed;
}

/* Secondary controls (chat, participants, screen share) sit a tier below the
   56px mic/camera pair. Must stay compound to outrank .control-btn. */
.control-btn.extra-control-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
}

.control-btn.extra-control-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: none;
}

.btn-icon {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Control button group (btn + chevron) */
.control-btn-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Chevron button */
.control-btn-chevron {
  width: 24px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.control-btn-chevron:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.control-btn-chevron.active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Device popup menu */
.device-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 320px;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 6px 0;
  z-index: 100;
  animation: popup-fade-in 0.12s ease-out;
}

.device-popup[hidden] {
  display: none;
}

@keyframes popup-fade-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.device-popup-section {
  padding: 4px 0;
}

.device-popup-label {
  display: block;
  padding: 6px 14px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.45);
  user-select: none;
}

.device-popup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.825rem;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background 0.1s;
  text-align: start;
}

.device-popup-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.device-popup-item.active {
  color: var(--color-primary);
}

.device-popup-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.device-popup-divider {
  height: 1px;
  margin: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
}

/* Session Ended Overlay */
.session-ended-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.session-ended-message {
  background: var(--color-surface);
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  margin: var(--spacing-md);
}

/* Error Screen - Meeting Full Variant */
.error-full .error-icon {
  color: var(--color-warning);
}

/* Smooth transitions for state changes */
.join-input-screen,
.connecting-screen,
.in-meeting-screen,
.error-screen {
  transition: opacity 0.3s ease;
}

[hidden] {
  display: none !important;
}

/* Visually hidden, still announced. clip-path, not the deprecated clip. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .meeting-header {
    padding: var(--spacing-md);
  }

  .meeting-stats {
    gap: var(--spacing-md);
  }

  .media-controls {
    padding: var(--spacing-md);
  }

  .controls-center {
    gap: var(--spacing-md);
  }

  .control-btn {
    width: 44px;
    height: 44px;
  }
}

/* Waiting Screen */
.waiting-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 100%;
  text-align: center;
  margin: 0 var(--spacing-md);
}

.waiting-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-lg);
}

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

.waiting-container h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.waiting-container p {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-xs);
}

.waiting-subtext {
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.waiting-cancel-btn {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-xl);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.waiting-cancel-btn:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

/* Rejected Screen */
.rejected-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 100%;
  text-align: center;
  margin: 0 var(--spacing-md);
}

.rejected-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-error);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto var(--spacing-lg);
}

.rejected-container h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.rejected-container p {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-xs);
}

/* Overlays (removed-by-host and session-ended) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
}

.removed-container,
.session-ended-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.removed-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-warning);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  margin: 0 auto var(--spacing-lg);
}

.session-ended-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  /* Not literal white: --color-text-secondary lightens to #9ca3af in dark,
     where a white glyph drops to ~2:1. The surface token inverts with it. */
  color: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto var(--spacing-lg);
}

.removed-container h2,
.session-ended-container h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.removed-container p,
.session-ended-container p {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-xs);
}

.removed-reason,
.session-ended-reason {
  font-size: var(--font-size-sm);
  font-style: italic;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height, 100vh);
  overflow: hidden;
  padding: var(--spacing-md);
}

/* Notification toasts — the STACK owns the positioning, so two toasts no
   longer land on top of each other. 96px clears both the header pill and the
   connection banner at top:56px. */
#toast-stack {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 90%;
  /* The stack is a click-through overlay; only the toasts take events */
  pointer-events: none;
}

.notification-toast {
  position: static;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 100%;
  text-align: center;
}

/* No translateX(-50%) here — the toast is no longer self-centring, and
   keeping it would yank every toast sideways as it dismisses. */
.notification-toast.notification-fade {
  opacity: 0;
  transform: translateY(-20px);
}

/* Language toggle button */
.lang-toggle-btn {
  position: fixed;
  top: 16px;
  right: max(20px, env(safe-area-inset-right));
  z-index: 100;
  padding: 8px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  transition: background-color 0.2s ease;
}

[dir="rtl"] .lang-toggle-btn {
  right: auto;
  left: max(20px, env(safe-area-inset-left));
}

.lang-toggle-btn:hover {
  background: var(--color-border);
}

/* ===== REDESIGNED LANDING (Phase 6) ===== */

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    linear-gradient(135deg, var(--landing-overlay-from) 0%, var(--landing-overlay-to) 100%),
    url('/assets/images/bkg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.7;
  pointer-events: none;
  z-index: -1;
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 520px;
}

.landing-logo {
  display: flex;
  justify-content: center;
}

/* Carries its own surface: the `card` class is gone from the markup, which
   was doubling the padding. */
.landing-card {
  width: 100%;
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Replaces the single-tab .tab-switcher/.tab-btn pair, which pretended to be
   a tab strip with nothing to switch to. */
.card-header {
  padding: 16px 24px;
  border-block-end: 1px solid var(--color-border);
}

.card-header-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-primary);
  text-align: center;
  margin: 0;
}

.tab-content {
  padding: 24px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--spacing-md);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-family);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(10, 168, 107, 0.15);
}

.form-input-mono {
  font-family: var(--font-family-mono);
  letter-spacing: 2px;
  text-align: center;
}

.cta-btn {
  width: 100%;
  padding: 14px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  font-family: var(--font-family);
}

.cta-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10, 168, 107, 0.3);
}

.cta-btn:active:not(:disabled) {
  transform: translateY(0);
}

.cta-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== CAMERA TEST SCREEN (Pre-Join) ===== */

.camera-test-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: var(--app-height, 100vh);
  /* Keep the definite height — min-height/auto forms no scrollport and stays
     clipped by #app — and let the content scroll inside it so the Join button
     stays reachable on short viewports. */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
}

.prejoin-header {
  display: flex;
  justify-content: center;
  padding: 16px 0 24px;
}

.prejoin-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 640px;
}

.prejoin-name-field {
  margin-bottom: 0;
}

.prejoin-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1a1a2e;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.prejoin-camera-off {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
}

.prejoin-camera-off-icon {
  font-size: 3rem;
  /* The preview behind it is #1a1a2e — an unset colour renders near-black */
  color: rgba(255, 255, 255, 0.6);
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Media acquisition in flight — reuses @keyframes spin */
#prejoin-media-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  background: var(--color-background-dark);
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--font-size-sm);
}

#prejoin-media-loading::before {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Permission denied / no device — replaces the preview inside the container.
   The container is aspect-ratio 16/9 (4/3 on phones) with overflow:hidden, and
   this panel is absolutely positioned inside it, so on a 320px phone the Retry
   button fell outside the box and was neither visible nor tappable. It scrolls
   instead — and flex-start is load-bearing, not cosmetic: with `center` the
   TOP overflow of a flex scroll container cannot be scrolled to, so the icon
   and the first line of the message would stay permanently out of reach. */
.prejoin-error-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  padding: 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-background-dark);
  color: #fff;
  text-align: center;
}

.prejoin-error-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.prejoin-error-msg {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin: 0 0 8px;
}

#prejoin-error-hint {
  font-size: var(--font-size-sm);
  opacity: 0.7;
  margin: 0 0 16px;
}

.prejoin-retry-btn {
  min-height: 44px;
  padding: 8px 20px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.prejoin-retry-btn:hover {
  background: var(--color-primary-hover);
}

.prejoin-retry-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.prejoin-name-overlay {
  position: absolute;
  bottom: 12px;
  inset-inline-end: 12px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.prejoin-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.prejoin-create-btn {
  flex: none;
  width: auto;
  padding: 12px 28px;
}

.prejoin-cancel-btn {
  padding: 12px 20px;
  background: var(--color-error);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family);
  transition: background-color 0.2s ease;
}

.prejoin-cancel-btn:hover {
  background: var(--color-danger-hover);
}

.prejoin-media-toggles {
  display: flex;
  gap: 8px;
  margin-inline-start: auto;
}

.prejoin-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.prejoin-toggle-btn:hover { transform: scale(1.08); }
.toggle-on { background: var(--color-primary); color: white; }
.toggle-off { background: var(--color-error); color: white; }
.toggle-neutral { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); }

/* The meeting the guest is about to enter */
.prejoin-meeting-code {
  align-self: center;
  margin-bottom: var(--spacing-sm);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  direction: ltr;
}

/* End-to-end-encryption reassurance, shown before the guest commits */
.prejoin-e2ee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(10, 168, 107, 0.1);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-align: center;
}

.prejoin-e2ee svg {
  flex-shrink: 0;
}

.prejoin-level-meter {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.prejoin-level-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 80ms ease-out;
  width: 0;
}

/* "Speak to test your mic" under the level meter */
#prejoin-level-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  text-align: center;
}

.prejoin-device-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.prejoin-device-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prejoin-device-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.prejoin-device-row-inner {
  display: flex;
  gap: 8px;
}

.prejoin-device-select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.prejoin-test-btn {
  padding: 8px 14px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  cursor: pointer;
  color: var(--color-text);
  font-family: var(--font-family);
  white-space: nowrap;
}

.prejoin-test-btn:hover {
  background: var(--color-border);
}

/* ===== REDESIGNED IN-MEETING (Phase 7) ===== */

.in-meeting-screen {
  flex-direction: column;
  padding: 0;
}

/* Video area — fills full width, relative for overlay panel */
.meeting-video-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Floating header bar ── */
.session-header-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  color: white;
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error, #ef4444);
  flex-shrink: 0;
  display: none;
}

.recording-dot.recording-active {
  display: block;
  animation: pulse 1.5s ease-in-out infinite;
}

.header-bar-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.header-bar-code {
  font-family: var(--font-family-mono);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.header-bar-title {
  font-weight: 600;
  font-size: 0.75rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Direction toggle, in-meeting. A chip inside the pill rather than a floating
   button: the pill spans nearly the full width in the same top band at ≤640, so
   a fixed-position toggle was painted over by it and every tap opened the
   encryption popover instead. Wrapping with the rest of the pill makes that
   overlap structurally impossible at every width, in both directions. */
.header-bar-lang {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.header-bar-lang:hover {
  background: rgba(255, 255, 255, 0.25);
}

.header-bar-lang:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Only surfaces on small phones, where the bottom-bar button is hidden. The
   ≤480 block below turns it on; this base rule MUST stay above it. */
.header-participant-btn {
  display: none;
}

/* Connection quality — signal bars ported from the host QualityIndicator */
#connection-quality {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  /* Bars read weakest-to-strongest left-to-right in both directions */
  direction: ltr;
  flex-shrink: 0;
  cursor: help;
}

#connection-quality[hidden] {
  display: none;
}

.quality-bar {
  width: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}

.quality-bar.active {
  opacity: 1;
}

.quality-bar:nth-child(1) {
  height: 6px;
}

.quality-bar:nth-child(2) {
  height: 10px;
}

.quality-bar:nth-child(3) {
  height: 14px;
}

.quality-excellent .quality-bar.active,
.quality-good .quality-bar.active {
  background: var(--color-success);
}

.quality-good .quality-bar:nth-child(3).active {
  opacity: 0.8;
}

.quality-fair .quality-bar:nth-child(1).active,
.quality-fair .quality-bar:nth-child(2).active {
  background: var(--color-warning);
}

.quality-poor .quality-bar:nth-child(1).active {
  background: var(--color-error);
}

/* ── Encryption badge ── */

/* Positioned ancestor for .safety-code-popup, which is a SIBLING of the badge:
   inside the button its text was folded into the button's accessible name and
   every click on the code closed the popover. inline-flex so the pair still
   behaves as one chip in the header pill's flex row. */
.encryption-badge-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.encryption-badge {
  /* Not an anchor any more — kept for the touch hit-area expansion below */
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.3s ease;
  /* UA reset for when the badge becomes a <button> (safety-code trigger).
     Deliberately folded into the base rule: a `button.encryption-badge`
     selector would outrank the metrics above and the state colours below. */
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.encryption-badge-icon {
  flex-shrink: 0;
}

.encryption-badge-inactive {
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.08);
}

.encryption-badge-active {
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
}

/* Key rotation dropped to an unauthenticated transport */
.encryption-badge-downgraded {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
}

/* Encryption is off when it should not be — this has to shout */
.encryption-badge-warning {
  color: #fff;
  background: rgba(239, 68, 68, 0.85);
  font-weight: 700;
}

.encryption-badge-epoch {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  min-width: 16px;
  text-align: center;
}

/* Host certificate fingerprint, shown before the guest commits to joining */
.prejoin-host-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.prejoin-host-identity-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.prejoin-cert-fingerprint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  /* Wrap at the colons, don't split a byte pair down the middle */
  overflow-wrap: anywhere;
  user-select: all;
}

.prejoin-host-identity-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Safety code — compared with the host out of band to detect a MITM */
.encryption-safety-code {
  position: relative;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  color: inherit;
}

/* Safety-code popover. Anchored DOWNWARD from the header pill — it must not
   reuse .device-popup, which opens upward from the control bar. */
.safety-code-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  min-width: 200px;
  max-width: min(280px, 80vw);
  padding: 10px 12px;
  background: rgba(20, 20, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  white-space: normal;
  animation: safety-code-fade-in 0.12s ease-out;
}

.safety-code-popup[hidden] {
  display: none;
}

@keyframes safety-code-fade-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.safety-code-popup-value {
  display: block;
  margin-block: 6px;
  direction: ltr;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-base);
  font-weight: 700;
  letter-spacing: 0.08em;
  user-select: all;
}

.safety-code-popup-hint {
  display: block;
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.7);
}

/* Flash animation on key rotation */
.encryption-badge-flash {
  animation: badge-flash 1.5s ease-out;
}

@keyframes badge-flash {
  0% {
    background: rgba(52, 211, 153, 0.45);
    color: #fff;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
  }
  50% {
    background: rgba(52, 211, 153, 0.25);
    color: #fff;
  }
  100% {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    box-shadow: none;
  }
}

/* ── Slide-out side panel ── */
.session-side-panel {
  position: absolute;
  inset-inline-end: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  background: var(--color-surface);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  z-index: 15;
  display: flex;
  flex-direction: column;
  animation: panel-slide-in 0.25s ease-out;
}

@keyframes panel-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

[dir="rtl"] .session-side-panel {
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  animation-name: panel-slide-in-rtl;
}

@keyframes panel-slide-in-rtl {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.side-panel-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.side-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.side-panel-close:hover {
  background: var(--color-background);
  color: var(--color-text);
}

.side-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-content-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.participant-list {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.participant-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.participant-list-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.participant-count-badge {
  background: var(--color-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.participant-items {
  display: flex;
  flex-direction: column;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
}

.participant-item:last-child {
  border-bottom: none;
}

.participant-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  /* Present, not muted. Without a background the dot was invisible on every
     ordinary row and only the .is-muted override below painted one — inverting
     what the dot means. That override is more specific, so it still wins. */
  background: var(--color-success);
}

/* Bottom bar for in-meeting */
.meeting-bottom-bar {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
}

.meeting-level-meter {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.meeting-level-fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 80ms ease-out;
  width: 0;
}

.meeting-controls-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  /* Physical, not logical: dir="rtl" would mirror these onto the wrong edge */
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  gap: 12px;
}

.screen-sharing-active {
  background: var(--color-primary) !important;
  color: #fff !important;
}

.meeting-leave-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color-error);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family);
  transition: background-color 0.2s ease;
  margin-inline-start: auto;
}

.meeting-leave-btn:hover {
  background: var(--color-danger-hover);
}

/* Participants toggle button */
.participants-control-btn {
  position: relative;
}

.participants-count-badge {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.55rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-weight: 700;
}

.participants-toggle-active {
  background: var(--color-primary) !important;
  color: white !important;
}

/* Responsive for meeting */
@media (max-width: 768px) {
  .session-side-panel {
    width: 100%;
  }
  .session-header-bar {
    max-width: calc(100% - 24px);
  }
}

/* Meeting title in sidebar */
.meeting-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  padding: 2px 0;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ──── Chat Styles ──── */

/* (sidebar tab styles removed — now using slide-out panel) */

/* Chat panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 4px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  text-align: center;
  padding: 20px 8px;
}

.chat-empty-icon {
  font-size: 2rem;
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-hint {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* Bubbles */
.chat-bubble {
  max-width: 90%;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  word-break: break-word;
}

.chat-bubble-own {
  align-self: flex-end;
  background: var(--color-primary);
  color: white;
}

.chat-bubble-own .chat-role-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.chat-bubble-own .chat-timestamp {
  color: rgba(255, 255, 255, 0.7);
}

.chat-bubble-own .chat-file-link {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.chat-bubble-own .chat-file-download {
  color: rgba(255, 255, 255, 0.8);
}

.chat-bubble-other {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.chat-bubble-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.chat-sender-name {
  font-weight: 600;
  font-size: 0.75rem;
}

.chat-role-badge {
  flex-shrink: 0;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.chat-role-host {
  background: rgba(10, 168, 107, 0.15);
  color: var(--color-primary);
}

.chat-role-guest {
  background: var(--chat-role-guest-bg);
  color: var(--color-text-secondary);
}

.chat-timestamp {
  font-size: 0.65rem;
  color: var(--color-text-secondary);
  margin-inline-start: auto;
}

.chat-bubble-text {
  white-space: pre-wrap;
  line-height: 1.4;
}

/* Image preview */
.chat-bubble-image {
  margin-top: 4px;
}

.chat-image-preview {
  display: block;
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

/* The thumbnail is a button: it opens the image view below. */
.chat-image-open {
  display: block;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  cursor: zoom-in;
}

.chat-image-open:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Full-size image view, in place of the new tab that used to open. Above the
   side panel and the control bar; below nothing a meeting can raise but the
   session-ended surface, which closes it on the way in. */
.chat-lightbox {
  position: fixed;
  inset: 0;
  /* Over everything in the meeting, and under the overlays that end it —
     "the meeting has ended" and "you were removed" (1000) — so that an open
     picture can never be what hides them. */
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  /* Room for the close button, and for a phone's notch and home indicator. */
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.9);
  cursor: zoom-out;
}

.chat-lightbox[hidden] {
  display: none;
}

.chat-lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  inset-inline-end: 12px;
  /* 44px: the smallest target a thumb reliably hits. */
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
}

.chat-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.chat-lightbox-image {
  max-width: 100%;
  /* Leaves the footer its line. min-height lets the flex item shrink at all. */
  min-height: 0;
  flex: 0 1 auto;
  max-height: calc(100% - 48px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: default;
}

.chat-lightbox-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 100%;
  cursor: default;
}

.chat-lightbox-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
}

.chat-lightbox-download {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.8rem;
  text-decoration: none;
}

.chat-lightbox-download:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* File link */
.chat-file-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-background);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.75rem;
  transition: opacity 0.15s ease;
}

.chat-file-link:hover {
  opacity: 0.8;
}

.chat-file-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.chat-file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-size {
  font-size: 0.65rem;
  color: var(--color-text-secondary);
}

.chat-file-download {
  font-size: 0.65rem;
  color: var(--color-primary);
  white-space: nowrap;
}

/* Upload progress */
.chat-uploads {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-upload-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

.chat-upload-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.chat-upload-bar {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.chat-upload-fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 150ms ease-out;
}

.chat-upload-error {
  padding: 4px 8px;
  font-size: 0.7rem;
  color: var(--color-error);
  text-align: center;
}

/* Chat input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid var(--color-border);
}

.chat-textarea {
  flex: 1;
  min-height: 32px;
  max-height: 100px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  resize: none;
  line-height: 1.4;
}

.chat-textarea:focus {
  border-color: var(--color-primary);
}

.chat-attach-btn,
.chat-send-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.chat-attach-btn:hover {
  background: var(--color-background);
}

.chat-send-btn {
  background: var(--color-primary);
  color: #fff;
}

.chat-send-btn:disabled {
  background: transparent;
  color: var(--color-text-secondary);
  opacity: 0.3;
  cursor: default;
}

/* A 10%-alpha wash would blank a filled button on hover */
.chat-send-btn:not(:disabled):hover {
  background: var(--color-primary-hover, #099b62);
}

/* The send glyph points at the writing direction */
[dir="rtl"] .chat-send-btn > svg {
  transform: scaleX(-1);
}

.chat-file-input-hidden {
  display: none;
}

/* Chat toggle button in bottom bar */
.chat-control-btn {
  position: relative;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8) !important;
}

.chat-control-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

.chat-toggle-active {
  background: var(--color-primary) !important;
  color: white !important;
}

.chat-unread-badge {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  background: var(--color-error);
  color: white;
  font-size: 0.55rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-weight: 700;
}

/* ── Screen share tiles ──
   A screen is a .video-tile inside #video-grid like every other stage item.
   The separate spotlight container these rules used to style is gone, and with
   it the second layout that had to be kept in step with the grid. */

.video-tile--screen {
  background: #000;
  /* Screens sort ahead of every camera. Remote cameras sit at the default
     order 0 and the self camera pins itself to 999, so the whole negative
     range belongs to screens; upsertScreenShare() writes an inline
     `order: -1000 - seq`, which puts the NEWEST share first. */
  order: -1000;
  /* The share's own frame, in the brand green rather than the blue the host
     used, so a screen is identifiable before its label is read. */
  border: 2px solid var(--color-primary);
}

.video-tile--screen .screen-tile-video {
  width: 100%;
  height: 100%;
  /* A screen is never cropped — contain, on the tile's own black. This is the
     one place .video-tile video's `cover` would lose content rather than
     framing. */
  object-fit: contain;
  background: #000;
}

/* LIVE pill — the "who is sharing" signal, identical in the grid, in the strip
   and on the focused stage. */
.tile-live-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  /* Decorative and non-interactive: it must never eat a tap meant for the
     tile's own focus button underneath it. */
  pointer-events: none;
}

.tile-live-badge svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* In the strip a tile is 100–180px wide. The pill keeps its colour and icon
   and shrinks rather than wrapping over the picture. */
.video-grid-thumbnails-mode .tile-live-badge {
  top: 4px;
  inset-inline-start: 4px;
  padding: 2px 5px;
  gap: 2px;
  font-size: 0.55rem;
}

.video-grid-thumbnails-mode .tile-live-badge svg {
  width: 10px;
  height: 10px;
}

/* Stop sharing, on our own screen tile only. Revealed by hover or by keyboard
   focus landing anywhere inside the tile; see the (hover: none) block below
   for touch, where there is no hover to reveal it with. */
.screen-tile-stop-btn {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.video-tile--screen:hover .screen-tile-stop-btn,
.video-tile--screen:focus-within .screen-tile-stop-btn {
  opacity: 1;
}

.screen-tile-stop-btn:hover {
  background: var(--color-danger-hover);
}

.screen-tile-stop-btn:focus-visible {
  opacity: 1;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* No hover to reveal it with, so it is simply always there. */
@media (hover: none) {
  .screen-tile-stop-btn {
    opacity: 1;
  }
}

.screen-tile-stop-btn > svg {
  flex-shrink: 0;
}

/* In the strip a 100px thumbnail cannot carry the words; the glyph and the
   aria-label do. */
.video-grid-thumbnails-mode .screen-tile-stop-btn {
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.video-grid-thumbnails-mode .screen-tile-stop-text {
  display: none;
}

/* Sharing marker on the SHARER'S CAMERA tile — the answer to "which of these
   faces is the one presenting". Positioned like the mute badge, with the name
   label pushed clear of whichever markers are actually present. */
.tile-sharing-badge {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
}

.tile-sharing-badge svg {
  width: 14px;
  height: 14px;
}

.video-tile:has(.tile-mute-badge) .tile-sharing-badge {
  inset-inline-start: 40px;
}

.video-tile:has(.tile-sharing-badge) .tile-name-label {
  inset-inline-start: 40px;
}

.video-tile:has(.tile-mute-badge):has(.tile-sharing-badge) .tile-name-label {
  inset-inline-start: 72px;
}

/* Roster marker, in the same words as the tile badge's accessible name.
   Outlined, so it never reads as a second host badge beside the filled one. */
.chat-role-sharing {
  background: transparent;
  border: 1px solid currentColor;
  color: var(--color-primary-text);
}

/* Thumbnail mode — video grid shrinks to a horizontal strip at bottom */
.video-grid-thumbnails-mode {
  flex: none !important;
  flex-grow: 0 !important;
  height: 130px !important;
  display: flex !important;
  grid-template-columns: unset !important;
  grid-auto-rows: unset !important;
  gap: 6px;
  padding: 6px !important;
  overflow-x: auto;
  overflow-y: hidden;
  /* The grid's own surface. A translucent black read as dark only over a dark
     page: in the light theme the strip turned into a pale grey band under the
     stage, with the tiles huddled at one end of it. */
  background: var(--color-background-dark);
  border-radius: var(--radius-md);
}

.video-grid-thumbnails-mode .placeholder-initials {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.video-grid-thumbnails-mode .video-tile,
.video-grid-thumbnails-mode .video-container {
  width: 180px !important;
  min-width: 180px;
  height: 100% !important;
  flex-shrink: 0;
}

/* The item on the stage must not also be in the strip: it would render the
   same stream twice, side by side with itself. refreshTileFocusState() owns
   the class. Scoped to the strip so grid mode is never affected. */
.video-grid-thumbnails-mode .video-tile--is-focused {
  display: none !important;
}

/* ── Focus view mode ── */

.focus-view-container {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}

.focus-view-container video.focus-camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.focus-view-container video.focus-screenshare {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Action buttons — hidden until hover */
/* Always shown, and at the bottom, across from the name. Revealed only on
   hover, the stage's one way back to the grid was invisible to anyone who did
   not think to point at it; at the top, a phone's meeting header — pinned over
   the top of the stage — covered it entirely. */
.focus-view-actions {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

[dir="rtl"] .focus-view-actions {
  right: auto;
  left: 12px;
}


/* The stage carries the same pill the tile does, one size up. */
.focus-view-container .tile-live-badge {
  top: 12px;
  inset-inline-start: 12px;
  padding: 4px 10px;
  font-size: 0.72rem;
}

.focus-view-container .tile-live-badge svg {
  width: 14px;
  height: 14px;
}

/* Action button style */
.focus-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease;
}

.focus-action-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Stop sharing, in the same cluster as fullscreen and exit. Red, because it
   ends something for everyone in the meeting rather than only for the viewer. */
.focus-action-btn--danger {
  background: var(--color-danger);
}

.focus-action-btn--danger:hover {
  background: var(--color-danger-hover);
}

.focus-action-btn svg {
  width: 18px;
  height: 18px;
}

/* "Show everyone": a labelled pill rather than another bare icon. */
.focus-action-btn--grid {
  width: auto;
  border-radius: 18px;
  padding-inline: 12px 14px;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* Name label in focus view. It shares the bottom edge with the actions, so a
   long name stops short of them instead of running underneath. */
.focus-view-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  max-width: calc(100% - 280px);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 2;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

[dir="rtl"] .focus-view-label {
  left: auto;
  right: 12px;
}

/* Placeholder for camera-off in focus */
.focus-view-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.focus-view-placeholder .placeholder-initials {
  width: 96px;
  height: 96px;
  font-size: 2.5rem;
}

/* Clickable tiles in grid mode */
.video-tile--clickable {
  cursor: pointer;
}

.video-tile--clickable:hover {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* Fullscreen overrides */
.focus-view-container:fullscreen {
  border-radius: 0;
  background: black;
}

.focus-view-container:-webkit-full-screen {
  border-radius: 0;
  background: black;
}

/* ===== MOBILE RESPONSIVE ===== */

/* ── Mobile viewport height fix ── */
/* iOS Safari: 100vh includes area behind browser chrome.
   JS sets --app-height to window.innerHeight for pixel-perfect fit. */

/* Prevent overscroll bounce on the meeting screen */
.in-meeting-screen {
  overscroll-behavior: none;
}

/* Safe area insets for devices with home indicator / notch */
.meeting-bottom-bar {
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

/* ── 768px: Side panel & header touch targets ── */
@media (max-width: 768px) {
  .side-panel-close {
    width: 44px;
    height: 44px;
  }
}

/* ── 640px: Large phone / small tablet ── */
@media (max-width: 640px) {
  /* Meeting layout — use JS-set --app-height (= window.innerHeight) for
     pixel-perfect viewport fit on iOS Safari. Falls back to 100vh. */
  .in-meeting-screen {
    height: var(--app-height, 100vh);
    overflow: hidden;
    touch-action: manipulation;
  }
  .meeting-video-area {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .focus-view-container {
    min-height: 0;
    margin-bottom: 4px;
  }
  .meeting-bottom-bar {
    flex-shrink: 0;
    overflow: hidden;
    max-height: 120px;
  }
  /* The floating header pill is absolute at top:12px over the grid and wraps
     to two rows on a phone, straight across a top-start LIVE pill on the first
     tile. In GRID mode the pill moves to the opposite corner; in the strip —
     which sits at the bottom of the video area, nowhere near the header — it
     stays exactly where every other layout has it. */
  .video-grid:not(.video-grid-thumbnails-mode) .video-tile--screen .tile-live-badge {
    top: auto;
    bottom: 4px;
    inset-inline-start: auto;
    inset-inline-end: 4px;
  }

  /* …above our own tile's Stop button, which claims that same corner and
     grows to a 44px target on touch. */
  .video-grid:not(.video-grid-thumbnails-mode) .video-tile--screen:has(.screen-tile-stop-btn) .tile-live-badge {
    bottom: 58px;
  }

  /* The STAGE is where a share spends most of its life, and on a phone its
     bottom edge cannot hold everything that sits there on a desktop: the
     actions alone ("Show everyone", in two languages) take most of the width.
     Sharing a line with them, the name was cut down to its last few letters;
     and the LIVE pill, sent to the bottom-end corner to get out from under the
     header, ended up underneath the actions when they moved there too. So the
     bottom edge is two rows here: actions below, name and pill above. */
  .focus-view-label {
    bottom: 64px;
    max-width: calc(100% - 140px);
  }
  .focus-view-container .tile-live-badge {
    top: auto;
    bottom: 66px;
    inset-inline-start: auto;
    inset-inline-end: 12px;
  }
  /* A camera on the stage has no pill, so its name can run the full width. */
  .focus-view-container:not(:has(.tile-live-badge)) .focus-view-label {
    max-width: calc(100% - 24px);
  }

  /* Shrink thumbnail strip */
  .video-grid-thumbnails-mode {
    height: 90px !important;
  }
  .video-grid-thumbnails-mode .video-tile,
  .video-grid-thumbnails-mode .video-container {
    width: 120px !important;
    min-width: 120px;
  }

  /* Join Input */
  .landing-content {
    max-width: 100%;
    padding: 0 8px;
  }
  .tab-content {
    padding: 16px;
  }
  .card-header {
    padding: 12px 16px;
  }
  .card-header-title {
    font-size: var(--font-size-sm);
  }

  /* Camera Test (Pre-Join) */
  .camera-test-screen {
    padding: 16px;
  }
  .prejoin-content {
    gap: 12px;
  }
  .prejoin-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .prejoin-create-btn,
  .prejoin-cancel-btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }
  .prejoin-media-toggles {
    margin-inline-start: 0;
    justify-content: center;
  }
  .prejoin-device-select {
    font-size: 16px; /* iOS auto-zoom fix */
  }
  /* Compact enough that the panel usually needs no scrolling at all inside the
     4:3 preview box; .prejoin-error-state's overflow is the safety net for long
     copy and large-font users. */
  .prejoin-error-state {
    padding: 16px;
  }
  .prejoin-error-icon {
    font-size: 1.75rem;
    margin-bottom: 8px;
  }

  /* Header Bar — wrap rather than scroll; the left/right/transform/
     margin-inline set has to land together or left:50% halves the width. */
  .session-header-bar {
    left: 12px;
    right: 12px;
    transform: none;
    margin-inline: auto;
    width: fit-content;
    max-width: none;
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
    border-radius: 14px;
    padding: 4px 10px;
    gap: 6px;
    /* Room for the ±8px block hit-area expansion the touch block gives the
       chips, so two wrapped rows cannot fight over the same taps. */
    row-gap: 16px;
  }
  .header-bar-title {
    max-width: 120px;
  }
  .header-bar-code {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  /* Camera + mic chevrons — touch-friendly size */
  #camera-btn-group .control-btn-chevron,
  #mic-btn-group .control-btn-chevron {
    width: 32px;
    height: 40px;
    border-radius: 8px;
  }

  /* Video Grid */
  .video-grid {
    gap: 2px;
    padding: 2px;
  }
  /* The row floor belongs on the track, not the tile: a per-tile min-height
     silently clips the last row once the grid runs out of height. Scoped off
     the screen-share thumbnail strip, whose overflow is horizontal. */
  .video-grid:not(.video-grid-thumbnails-mode) {
    grid-auto-rows: minmax(100px, 1fr);
    overflow-y: auto;
    overscroll-behavior: contain;
    align-content: start;
  }
  .video-grid:not(.video-grid-thumbnails-mode) .video-tile {
    min-height: 0;
  }
  .tile-name-label {
    font-size: 0.65rem;
    padding: 2px 6px;
    bottom: 4px;
    inset-inline-start: 4px;
  }

  /* Bottom Bar */
  .meeting-controls-row {
    padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: center;
  }
  .controls-center {
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: center;
  }
  .control-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    font-size: 1.1rem;
  }
  .meeting-leave-btn {
    padding: 8px 14px;
    font-size: 0.75rem;
    gap: 4px;
    margin-inline-start: auto;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Device Popup — bottom sheet */
  .device-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    max-width: none;
    min-width: 0;
    max-height: 50vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 200;
    animation: sheet-slide-up 0.25s ease-out;
  }
  .device-popup-item {
    min-height: 44px;
    padding: 10px 14px;
  }
  @keyframes sheet-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  /* Backdrop overlay for bottom sheet */
  .device-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
  }

  /* Chat */
  .chat-textarea {
    font-size: 16px; /* iOS auto-zoom fix */
  }
  .chat-bubble {
    max-width: 85%;
  }
  .chat-input-area {
    padding: 6px;
    gap: 4px;
  }
  .chat-attach-btn,
  .chat-send-btn {
    width: 36px;
    height: 36px;
  }
}

/* ── 480px: Small phone ── */
@media (max-width: 480px) {
  /* Smaller thumbnail strip */
  .video-grid-thumbnails-mode {
    height: 72px !important;
    gap: 4px;
    padding: 4px !important;
  }
  .video-grid-thumbnails-mode .video-tile,
  .video-grid-thumbnails-mode .video-container {
    width: 100px !important;
    min-width: 100px;
  }

  /* Overlay cards (waiting, rejected, status) */
  .card {
    max-width: calc(100vw - 32px);
    padding: var(--spacing-md);
  }
  .waiting-container,
  .rejected-container {
    max-width: calc(100vw - 32px);
    padding: var(--spacing-lg);
  }
  .waiting-container h2,
  .rejected-container h2 {
    font-size: var(--font-size-lg);
  }
  .retry-button {
    min-height: 44px;
    width: 100%;
  }

  /* Join Input */
  .join-input-screen {
    align-items: flex-start;
    padding-top: 24px;
  }
  .landing-card {
    border-radius: var(--radius-md);
  }
  .form-input,
  .form-input-mono {
    font-size: 16px; /* iOS auto-zoom fix */
  }
  .cta-btn {
    min-height: 48px;
    font-size: var(--font-size-base);
  }

  /* Camera Test */
  .prejoin-video-container {
    aspect-ratio: 4 / 3;
  }
  .prejoin-toggle-btn {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }

  /* Header Bar — hide title to save space */
  .header-bar-title {
    display: none;
  }
  .header-bar-divider {
    display: none;
  }

  /* Header participants button (replaces hidden bottom-bar button) */
  .header-participant-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
  }
  .header-participant-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Video Grid */
  .video-grid:not(.video-grid-thumbnails-mode) {
    grid-auto-rows: minmax(80px, 1fr);
  }
  .placeholder-initials {
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
  }
  .placeholder-icon {
    font-size: 2rem;
  }
  /* Bottom Bar — compact single row, icon-only leave */
  .meeting-controls-row {
    flex-wrap: nowrap;
    justify-content: center;
    padding: 6px 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    gap: 4px;
  }
  .controls-center {
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: center;
  }
  .control-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    font-size: 1rem;
  }
  .control-btn svg {
    width: 20px;
    height: 20px;
  }
  /* Hide participants — moved to header bar */
  #participants-toggle-btn {
    display: none;
  }
  /* Hide screen share — unreliable on mobile browsers */
  #screen-share-btn {
    display: none;
  }
  /* Leave button — 44×44 circle, icon only */
  .meeting-leave-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    align-items: center;
    margin-inline-start: auto;
  }
  .meeting-leave-btn > span:first-child {
    display: none;
  }
  .meeting-leave-btn > span:last-child {
    display: flex;
  }

  /* Side Panel */
  .session-side-panel {
    z-index: 25;
  }
  .side-panel-header {
    padding: 10px 12px;
  }
  .participant-item {
    padding: 8px 12px;
  }

  /* Chat */
  .chat-bubble {
    max-width: 98%;
  }
  .chat-sender-name {
    font-size: 0.65rem;
  }
  .chat-timestamp {
    font-size: 0.55rem;
  }
}

/* ── Phone held sideways ──
   Every phone rule above keys on WIDTH, and a phone on its side is wider than
   all of them. It was given the desktop layout — floating header, 130px strip,
   84px control bar — inside some 350px of height, which left a shared screen
   about 170px tall with the header lying across the top of it. Height is what
   is scarce here, so this block keys on height.

   The min-width keeps it away from a portrait phone whose on-screen keyboard
   has shortened the viewport into a landscape shape, and from the ≤480 rules,
   which move the participants button into the header. */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 481px) {
  /* Control bar: one compact row. */
  .meeting-controls-row {
    padding: 4px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    gap: 8px;
    flex-wrap: nowrap;
  }
  .controls-center {
    gap: 6px;
    flex-wrap: nowrap;
  }
  .control-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    font-size: 1.1rem;
  }
  .control-btn svg {
    width: 20px;
    height: 20px;
  }
  .meeting-leave-btn {
    padding: 8px 14px;
    font-size: 0.75rem;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  /* Opens upward from the bar, and 320px of menu does not fit above it. */
  .device-popup {
    max-height: calc(var(--app-height, 100vh) - 76px);
  }
  /* The stage comes right down to the bar here, with no strip in between, so
     a menu opening upward lands on the stage's own buttons — and those would
     otherwise paint over it. */
  .meeting-bottom-bar {
    position: relative;
    z-index: 30;
  }

  /* With something on the stage: the stage takes the full height on one side,
     and the header and the other tiles stack in a column beside it. A shared
     screen is limited by height on a sideways phone, so the column costs it
     nothing — that width was letterbox either way — and the header no longer
     covers it.

     Every rule of this layout hangs off the same :has() test, deliberately: a
     browser without :has() drops all of them together and keeps the stacked
     layout, rather than applying half. */
  .meeting-video-area:has(> .focus-view-container) {
    /* As wide as the letterbox a 16:9 share would leave beside itself anyway
       (64px: the control bar and this area's padding), held between what the
       header chips need and what a tile is worth. */
    --side-column: clamp(140px, calc(100vw - (var(--app-height, 100vh) - 64px) * 16 / 9 - 14px), 172px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-column);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px 6px;
    padding: 4px;
    /* Physical, as on the control bar: the notch does not follow dir. */
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  .meeting-video-area:has(> .focus-view-container) > .focus-view-container {
    grid-column: 1;
    grid-row: 1 / -1;
    min-width: 0;
    margin-bottom: 0;
  }
  .meeting-video-area:has(> .focus-view-container) > .session-header-bar {
    position: static;
    transform: none;
    grid-column: 2;
    grid-row: 1;
    width: auto;
    max-width: none;
    margin: 0;
    flex-wrap: wrap;
    justify-content: center;
    padding: 4px 6px;
    gap: 4px 6px;
    row-gap: 6px;
    border-radius: 12px;
    /* It floated over video before; here it sits on the page, and its
       translucent black turns grey on a light one. */
    background: var(--color-background-dark);
  }
  /* The lock, the epoch and the safety code say it; the words are what make
     the pill too wide for the column. Still read out to a screen reader. */
  .meeting-video-area:has(> .focus-view-container) #encryption-badge-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .meeting-video-area:has(> .focus-view-container) .header-bar-divider,
  .meeting-video-area:has(> .focus-view-container) .header-bar-title {
    display: none;
  }
  /* Centred on its badge it would run off the edge of the screen, the column
     being at that edge; and its entrance animation would put the centring
     transform straight back. */
  .meeting-video-area:has(> .focus-view-container) .safety-code-popup {
    left: auto;
    right: auto;
    inset-inline-end: 0;
    transform: none;
    animation: none;
  }
  .meeting-video-area:has(> .focus-view-container) > .video-grid-thumbnails-mode {
    grid-column: 2;
    grid-row: 2;
    width: auto !important;
    height: auto !important;
    min-height: 0;
    flex-direction: column;
    gap: 4px;
    padding: 4px !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .meeting-video-area:has(> .focus-view-container) > .video-grid-thumbnails-mode .video-tile,
  .meeting-video-area:has(> .focus-view-container) > .video-grid-thumbnails-mode .video-container {
    width: 100% !important;
    min-width: 0;
    /* 16:9, less the strip's own padding. */
    height: calc((var(--side-column) - 8px) * 9 / 16) !important;
  }
  /* The panel opens over that column, and must cover the header in it. */
  .meeting-video-area:has(> .focus-view-container) > .session-side-panel {
    z-index: 25;
  }

  /* The stage's own overlays. The header has left the top of the stage, so
     the name and the LIVE pill take that edge and the actions keep the bottom
     to themselves: on a sideways phone the picture reaches both edges, and
     three things along one of them hid a good part of it — or, on a small
     phone, cut the name short again. */
  .meeting-video-area:has(> .focus-view-container) .focus-view-label {
    top: 8px;
    bottom: auto;
    left: 8px;
    max-width: calc(100% - 134px);
  }
  [dir="rtl"] .meeting-video-area:has(> .focus-view-container) .focus-view-label {
    left: auto;
    right: 8px;
  }
  .meeting-video-area:has(> .focus-view-container) .focus-view-container .tile-live-badge {
    top: 12px;
    bottom: auto;
    inset-inline-start: auto;
    inset-inline-end: 8px;
  }
  .meeting-video-area:has(> .focus-view-container) .focus-view-actions {
    bottom: 8px;
    right: 8px;
  }
  [dir="rtl"] .meeting-video-area:has(> .focus-view-container) .focus-view-actions {
    right: auto;
    left: 8px;
  }
}

/* ── In-meeting connection banner ──
   Shown over the video area while the socket is down or retrying. The
   connecting-screen status nodes are hidden once the meeting is visible, so
   without this a disconnect produced no user-visible signal whatsoever. */
.connection-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 460px);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(20, 20, 22, 0.92);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
}

.connection-banner[hidden] {
  display: none;
}

.connection-banner-spinner {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: connection-banner-spin 0.9s linear infinite;
}

/* A terminal state has nothing left to wait for, so the spinner would lie. */
.connection-banner--error .connection-banner-spinner {
  display: none;
}

.connection-banner--error {
  background: rgba(153, 27, 27, 0.94);
}

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

@media (prefers-reduced-motion: reduce) {
  .connection-banner-spinner { animation: none; }
}

/* ════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY — focus rings and touch targets
   Appended last so these win against the ≤640/≤480 blocks above on equal
   specificity. Keep this section at the end of the file.
   ════════════════════════════════════════════════════════════════════════ */

/* Focus rings, split by surface: one blanket colour is worse than none,
   because it disappears on either the light cards or the dark video chrome. */
.cta-btn:focus-visible,
.prejoin-toggle-btn:focus-visible,
.waiting-cancel-btn:focus-visible,
.side-panel-close:focus-visible,
.chat-attach-btn:focus-visible,
.chat-send-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.control-btn:focus-visible,
.control-btn-chevron:focus-visible,
.meeting-leave-btn:focus-visible,
.focus-action-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Its parent's overflow clips a positive offset, so ring inwards. */
.device-popup-item:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* iOS/iPadOS zooms the page for any field under 16px. The ≤640 rules already
   cover phones; this extends the fix to tablets and hybrid devices. */
@media (pointer: coarse) {
  .chat-textarea,
  .prejoin-device-select {
    font-size: 16px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .chat-attach-btn,
  .chat-send-btn,
  .side-panel-close,
  .focus-action-btn,
  .screen-tile-stop-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .lang-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }

  /* 32x40, NOT 44: with the mic chevron restored, four 44px chevrons
     overflow a 320px nowrap control bar. The hit area is expanded below. */
  .control-btn-chevron {
    width: 32px;
    height: 40px;
    border-radius: 8px;
  }

  .header-participant-btn,
  .control-btn-chevron,
  .header-bar-code,
  .header-bar-lang,
  .encryption-badge {
    position: relative;
  }

  /* Inert hit-area expansion — no paint, no layout, just a bigger target. */
  .header-participant-btn::after,
  .control-btn-chevron::after {
    content: '';
    position: absolute;
    inset: -12px;
  }

  /* Header-pill chips: block only. The pill's 6px inline gap means an inline
     expansion would overlap the neighbour, and the later element wins the hit
     test — turning a small target into a mis-target. All three are already
     wide enough; only their height fell short of a legal touch target, and a
     min-height instead would balloon the floating pill over the video. */
  .header-bar-code::after,
  .header-bar-lang::after,
  .encryption-badge::after {
    content: '';
    position: absolute;
    inset-block: -8px;
    inset-inline: 0;
  }
}

/* Programmatic focus targets only. showScreen() focuses the pre-meeting screen
   it just revealed so a screen reader announces the new context; these
   containers carry tabindex="-1" and are never keyboard-reachable, so a ring
   drawn around the entire viewport would be noise rather than affordance.
   :focus, not :focus-visible — the ring must be suppressed for the scripted
   focus specifically, and no user gesture can produce this one. */
.join-input-screen:focus,
.camera-test-screen:focus,
.connecting-screen:focus,
.error-screen:focus,
.screen:focus {
  outline: none;
}

/* Roster row for a participant whose microphone is off. The row also carries a
   bilingual "مكتوم | Muted" badge, so this is reinforcement, not the only
   signal — a colour-only mute marker would be no better than none. */
.participant-item.is-muted .participant-status-dot {
  background: var(--color-text-secondary);
}

.participant-name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* UA reset for the meeting-code chip now that it is a <button> (copy-to-
   clipboard trigger). Folded in as a separate rule rather than a
   `button.header-bar-code` selector, which would outrank the metrics in the
   base rule above. The stylesheet already does exactly this for
   .encryption-badge; the code chip became a button in the same pass. */
.header-bar-code {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  color: inherit;
  line-height: inherit;
  cursor: pointer;
}

.header-bar-code:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
