/* ============================================================
   Main Settings — Google Meet style module
   ------------------------------------------------------------
   .ms-* namespace. The "main" entry-point settings panel.
   Hosts microphone, speaker, and future sections. Cyan accent
   matches the host's primary --widget-accent.
   ============================================================ */

/* (Gear FAB removed — mic icon is the sole entry point.) */

.ms-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2147483646;
}
.ms-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
[data-theme="light"] .ms-backdrop {
  background: rgba(15, 23, 42, 0.18);
}

.ms-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  width: min(720px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 80px));
  background: #1f2125;
  border-radius: 14px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  color: #e3e5e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    opacity 0.22s ease,
    transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2147483647;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}
.ms-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
[data-theme="light"] .ms-panel {
  background: #ffffff;
  color: #202124;
  box-shadow:
    0 20px 60px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(15, 23, 42, 0.06);
}

.ms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.ms-header.dragging {
  cursor: grabbing;
}
/* Once the user has dragged the panel, kill the centering transform so
   the explicit top/left wins. The open/close fades via opacity only. */
.ms-panel.dragged,
.ms-panel.dragged.open {
  transform: none !important;
}
[data-theme="light"] .ms-header {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
.ms-header-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.ms-header-close {
  background: transparent;
  border: none;
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.ms-header-close:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .ms-header-close:hover {
  background: rgba(15, 23, 42, 0.08);
}
.ms-header-close svg {
  width: 18px;
  height: 18px;
}

.ms-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  flex: 1;
  min-height: 0;
}

.ms-sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
[data-theme="light"] .ms-sidebar {
  border-right-color: rgba(15, 23, 42, 0.08);
}
.ms-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.ms-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .ms-tab:hover {
  background: rgba(15, 23, 42, 0.06);
}
.ms-tab.active {
  /* Selected tab = the accent color, but heavily transparent. */
  background: color-mix(in srgb, var(--widget-accent) 16%, transparent);
  color: var(--widget-accent);
}
[data-theme="light"] .ms-tab.active {
  background: color-mix(in srgb, var(--widget-accent) 14%, transparent);
}
.ms-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ms-main {
  padding: 20px 24px 24px;
  overflow-y: auto;
}
.ms-pane {
  display: none;
}
.ms-pane.active {
  display: block;
  animation: ms-fade-in 0.2s ease;
}
@keyframes ms-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ms-sub-header {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 4px 0 14px;
  /* Animatable so Appearance → Section labels can collapse it smoothly. */
  overflow: hidden;
  max-height: 3em;
  transition:
    max-height 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.24s ease,
    margin 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Appearance → Section labels = Hide: collapse every section header. */
#msPanel.ms-hide-headers .ms-sub-header {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
}
/* ...and collapse the left sidebar to icons only (animated). */
.ms-body { transition: grid-template-columns 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
.ms-tab span {
  max-width: 140px;
  overflow: hidden;
  white-space: nowrap;
  transition:
    max-width 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.2s ease;
}
#msPanel.ms-hide-headers .ms-body { grid-template-columns: 58px 1fr; }
#msPanel.ms-hide-headers .ms-tab {
  gap: 0;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
#msPanel.ms-hide-headers .ms-tab span { max-width: 0; opacity: 0; }

.ms-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .ms-row {
  border-bottom-color: rgba(15, 23, 42, 0.05);
}
.ms-row:last-child {
  border-bottom: none;
}
/* Hide rows whose backend isn't implemented yet. Drop the modifier
   class on the markup to bring them back. Used today to mask the
   non-functional Stereo/mono + Spatial audio rows in the Audio
   output pane (see web/index.html around the spk.ch.t / spk.sp.t
   labels). !important so it survives any per-row inline display
   overrides Main Settings might set during pane switching. */
.ms-row.ms-row--hidden {
  display: none !important;
}
/* Locked control — e.g. the Mute toggle while the translation player is
   hidden (forced muted, not user-changeable until the player is shown). */
.ms-row--locked .ms-switch {
  opacity: 0.5;
  pointer-events: none;
}

/* Private profile fields (name / email / room / about) — hidden by default;
   toggled with Ctrl+Alt+P or by clicking the hint. */
#msPaneSes.ms-ses-hide-private .ms-ses-private {
  display: none !important;
}
.ms-ses-private-hint {
  display: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--widget-ink-dim, rgba(255, 255, 255, 0.55));
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px dashed var(--widget-border, rgba(255, 255, 255, 0.14));
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.ms-ses-private-hint:hover {
  color: var(--widget-ink, #e3e5e8);
  border-color: var(--widget-accent, #fbbf24);
}
#msPaneSes.ms-ses-hide-private .ms-ses-private-hint {
  display: block;
}
.ms-ses-private-hint kbd {
  font-family: var(--widget-font-mono);
  font-size: 0.66rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--widget-surface, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--widget-border, rgba(255, 255, 255, 0.14));
}
/* Same shape for action buttons (the big primary buttons in the
   Session pane's ms-action-row). Used today to mask the redundant
   Mic toggle — Host Start/Stop already manages mic capture, so a
   separate button is unnecessary. Drop the modifier class on the
   markup to bring it back. */
.ms-action-btn.ms-action-btn--hidden {
  display: none !important;
}
.ms-row-title {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.ms-row-desc {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
[data-theme="light"] .ms-row-desc {
  color: rgba(15, 23, 42, 0.55);
}
/* Info pane — metrics legend. Two-column rows: abbrev key + description. */
.ms-legend { margin: 2px 0 6px; }
/* Group card: one bordered box per metrics section. */
.ms-leg-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 8px 12px 5px;
  margin: 8px 0 12px;
  background: rgba(255, 255, 255, 0.02);
}
.ms-leg-card .ms-leg-title {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--widget-accent, #4fd6c0); margin-bottom: 5px;
}
.ms-leg-card .ms-leg-row:last-child { border-bottom: none; }
/* Expandable rows: summary (abbrev + short desc) → verbose + example on click. */
details.ms-leg-row { display: block; padding: 0; }
details.ms-leg-row > summary {
  display: flex; gap: 10px; align-items: baseline; padding: 4px 0;
  cursor: pointer; list-style: none; outline: none;
}
details.ms-leg-row > summary::-webkit-details-marker { display: none; }
details.ms-leg-row > summary::marker { content: ''; }
details.ms-leg-row > summary::after {
  content: '＋'; margin-left: auto; color: rgba(255, 255, 255, 0.3);
  font-size: 0.7rem; flex: 0 0 auto;
}
details.ms-leg-row[open] > summary::after { content: '−'; }
.ms-leg-more {
  font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); line-height: 1.5;
  padding: 0 0 8px 78px;
}
.ms-leg-more code {
  font-family: var(--widget-mono, ui-monospace, monospace); font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08); padding: 0 4px; border-radius: 3px;
  color: var(--widget-accent, #4fd6c0);
}
[data-theme="light"] .ms-leg-more { color: rgba(15, 23, 42, 0.6); }
[data-theme="light"] .ms-leg-more code { background: rgba(15, 23, 42, 0.06); }
[data-theme="light"] .ms-leg-card { border-color: rgba(15, 23, 42, 0.1); background: rgba(15, 23, 42, 0.02); }
.ms-leg-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.ms-leg-k {
  flex: 0 0 68px; font-family: var(--widget-mono, ui-monospace, monospace);
  font-size: 0.72rem; font-weight: 700; color: var(--widget-accent, #4fd6c0);
}
.ms-leg-d { font-size: 0.74rem; color: rgba(255, 255, 255, 0.62); line-height: 1.35; }
.ms-leg-v {
  font-family: var(--widget-mono, ui-monospace, monospace);
  font-size: 0.68rem; color: rgba(255, 255, 255, 0.4); margin-left: 4px; white-space: nowrap;
}
[data-theme="light"] .ms-leg-row { border-bottom-color: rgba(15, 23, 42, 0.06); }
[data-theme="light"] .ms-leg-d { color: rgba(15, 23, 42, 0.62); }
[data-theme="light"] .ms-leg-v { color: rgba(15, 23, 42, 0.4); }
/* Appearance → Descriptions = None: hide helper text, drop the row
   separator lines, and tighten rows for a clean, dense panel. */
#msPanel.ms-desc-none .ms-row-desc { display: none; }
#msPanel.ms-desc-none .ms-row {
  border-bottom: none;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Dropdown */
.ms-select {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.06)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa0a6' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: inherit;
  font-family: inherit;
  font-size: 0.86rem;
  padding: 8px 32px 8px 12px;
  min-width: 220px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.ms-select:hover {
  border-color: rgba(255, 255, 255, 0.25);
}
.ms-select:focus {
  outline: none;
  border-color: var(--widget-accent, #67e8f9);
}
[data-theme="light"] .ms-select {
  background-color: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
}
.ms-select option {
  background: #2a2d31;
  color: #e3e5e8;
}
[data-theme="light"] .ms-select option {
  background: #fff;
  color: #202124;
}

/* Material switch */
.ms-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-block;
}
.ms-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ms-switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  transition: background 0.2s ease;
}
[data-theme="light"] .ms-switch-track {
  background: rgba(15, 23, 42, 0.18);
}
.ms-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.ms-switch input:checked ~ .ms-switch-track {
  background: var(--widget-accent, #67e8f9);
}
.ms-switch input:checked ~ .ms-switch-thumb {
  transform: translateX(18px);
}

/* Full-width row variant (used by Mic test) */
.ms-row.full {
  grid-template-columns: 1fr;
}

/* Test button (pill, outlined) */
.ms-test-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: inherit;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
[data-theme="light"] .ms-test-btn {
  border-color: rgba(15, 23, 42, 0.2);
}
.ms-test-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--widget-accent, #67e8f9);
  color: var(--widget-accent, #67e8f9);
}
[data-theme="light"] .ms-test-btn:hover {
  background: rgba(15, 23, 42, 0.04);
}
.ms-test-btn.active {
  background: var(--widget-accent, #67e8f9);
  border-color: var(--widget-accent, #67e8f9);
  color: #0a0a0b;
}
[data-theme="light"] .ms-test-btn.active {
  color: #fff;
}
.ms-test-btn svg {
  width: 14px;
  height: 14px;
}

.ms-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Hide helper — used for elements that are toggled by JS instead of inline style */
.ms-hidden {
  display: none !important;
}

/* VU meter (mic test) */
.ms-vu-wrap {
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  display: none;
}
.ms-vu-wrap.active {
  display: flex;
}
[data-theme="light"] .ms-vu-wrap {
  background: rgba(15, 23, 42, 0.04);
}
.ms-vu-bars {
  display: flex;
  gap: 3px;
  height: 28px;
  align-items: center;
}
.ms-vu-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  transition:
    height 0.06s ease,
    background 0.06s ease;
}
[data-theme="light"] .ms-vu-bar {
  background: rgba(15, 23, 42, 0.1);
}
.ms-vu-bar.lit {
  background: var(--widget-accent, #67e8f9);
  height: 18px;
}
.ms-vu-bar.lit.mid {
  background: #fbbf24;
}
.ms-vu-bar.lit.hot {
  background: #f87171;
}
.ms-vu-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
}
[data-theme="light"] .ms-vu-status {
  color: rgba(15, 23, 42, 0.6);
}

/* Chipset (Stereo / Mono) */
.ms-segment {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 2px;
}
[data-theme="light"] .ms-segment {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}
.ms-segment button {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.7;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ms-segment button:hover {
  opacity: 1;
}
.ms-segment button.active {
  background: var(--widget-accent, #67e8f9);
  color: #0a0a0b;
  opacity: 1;
}
[data-theme="light"] .ms-segment button.active {
  color: #fff;
}

/* Slider */
.ms-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.ms-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  height: 3px;
  border-radius: 2px;
  outline: none;
}
[data-theme="light"] .ms-slider {
  background: rgba(15, 23, 42, 0.12);
}
.ms-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--widget-accent, #67e8f9);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.ms-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.ms-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--widget-accent, #67e8f9);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.ms-slider-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  color: var(--widget-accent, #67e8f9);
  min-width: 48px;
  text-align: right;
}

/* Smart-TTS equalizer — a stacked set of weight faders shown only while
   TTS = Smart (feature/smart-tts). Reuses .ms-slider / .ms-slider-value. */
.ms-eq {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ms-eq-head {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.65;
}
.ms-eq-slider {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 12px;
}
.ms-eq-label {
  font-size: 0.76rem;
  font-weight: 500;
  opacity: 0.85;
}
.ms-eq .ms-slider-wrap {
  min-width: 0;
}

/* Hint */
.ms-hint {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  font-family: "JetBrains Mono", monospace;
  font-style: italic;
  margin-top: 4px;
}
[data-theme="light"] .ms-hint {
  color: rgba(15, 23, 42, 0.5);
}

/* Accent-color picker — round colored chips */
.ms-accent-row {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ms-accent-row button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.ms-accent-row button:hover {
  transform: scale(1.1);
}
.ms-accent-row button.active {
  border-color: var(--widget-ink, #f5f5f5);
  /* Selected swatch gets a soft halo in its own (accent) color, transparent. */
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ac, var(--widget-accent)) 22%, transparent);
}
[data-theme="light"] .ms-accent-row button.active {
  border-color: rgba(15, 23, 42, 0.6);
}
.ms-accent-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ac, var(--widget-accent, #67e8f9));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
/* Per-color utility classes — keep inline styles out of the HTML. */
.ms-accent-cyan {
  --ac: #67e8f9;
}
.ms-accent-violet {
  --ac: #a78bfa;
}
.ms-accent-green {
  --ac: #86efac;
}
.ms-accent-amber {
  --ac: #fbbf24;
}
.ms-accent-pink {
  --ac: #f9a8d4;
}

/* Reduced-motion class — applied to <html> when the user enables the
   Appearance switch. Mirrors the @media (prefers-reduced-motion) rules
   so the toggle works on systems where the OS pref isn't set. */
html.ms-reduced-motion *,
html.ms-reduced-motion *::before,
html.ms-reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ============ SESSION SECTION ============
   Identity card · room info · live status · big action buttons ·
   role pills · device-info rows with copy buttons. */

/* Identity wraps in a subtle card so the user feels they're looking at
   their profile, not just a row of inputs. */
.ms-ses-identity {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  margin-bottom: 4px;
}
[data-theme="light"] .ms-ses-identity {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.06);
}

/* Avatar — gradient fill + presence dot in the bottom-right. */
.ms-avatar {
  position: relative;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--widget-accent, #67e8f9) 0%,
    color-mix(in srgb, var(--widget-accent, #67e8f9) 65%, #a78bfa) 100%
  );
  color: #0a0a0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  -webkit-user-select: none;
  user-select: none;
}
[data-theme="light"] .ms-avatar {
  color: #f8fafc;
}
.ms-avatar::after {
  /* Presence dot — turns green when the host shows 'connected'. */
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2.5px solid #1f2125;
  transition: background 0.2s ease;
}
[data-theme="light"] .ms-avatar::after {
  border-color: #ffffff;
}
.ms-avatar.online::after {
  background: #86efac;
  box-shadow: 0 0 6px rgba(134, 239, 172, 0.6);
}
.ms-ses-id-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.ms-ses-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-ses-inline {
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  padding: 3px 6px;
  border-radius: 5px;
  outline: none;
  min-width: 120px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.ms-ses-inline:hover {
  background: rgba(255, 255, 255, 0.04);
}
.ms-ses-inline:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--widget-accent, #67e8f9);
}
[data-theme="light"] .ms-ses-inline:hover {
  background: rgba(15, 23, 42, 0.04);
}
[data-theme="light"] .ms-ses-inline:focus {
  background: rgba(15, 23, 42, 0.06);
}
.ms-ses-email {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}
[data-theme="light"] .ms-ses-email {
  color: rgba(15, 23, 42, 0.55);
}

/* Role pill — color reflects the chosen role */
.ms-role-pill {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(103, 232, 249, 0.16);
  color: var(--widget-accent, #67e8f9);
  white-space: nowrap;
}
.ms-role-pill.role-speaker {
  background: rgba(103, 232, 249, 0.16);
  color: #67e8f9;
}
.ms-role-pill.role-admin {
  background: rgba(248, 113, 113, 0.16);
  color: #f87171;
}
.ms-role-pill.role-participant {
  background: rgba(134, 239, 172, 0.16);
  color: #86efac;
}

/* Room info compact rows */
.ms-ses-field {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.ms-ses-field-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] .ms-ses-field-label {
  color: rgba(15, 23, 42, 0.5);
}
.ms-ses-field-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: inherit;
  font-family: inherit;
  font-size: 0.84rem;
  padding: 7px 10px;
}
[data-theme="light"] .ms-ses-field-input {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}
.ms-ses-field-input:focus {
  outline: none;
  border-color: var(--widget-accent, #67e8f9);
}

/* Live status — full-width banner with a soft tint and an animated dot. */
.ms-ses-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 14px;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}
[data-theme="light"] .ms-ses-status {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.08);
}
.ms-ses-status.connected {
  background: rgba(134, 239, 172, 0.08);
  border-color: rgba(134, 239, 172, 0.25);
}
.ms-ses-status.connecting {
  background: rgba(251, 191, 36, 0.07);
  border-color: rgba(251, 191, 36, 0.22);
}
.ms-ses-status.error {
  background: rgba(248, 113, 113, 0.07);
  border-color: rgba(248, 113, 113, 0.25);
}
.ms-ses-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.ms-ses-status.connected .ms-ses-status-dot {
  background: #86efac;
  box-shadow: 0 0 8px #86efac;
  animation: ms-status-pulse 1.6s ease-in-out infinite;
}
.ms-ses-status.connecting .ms-ses-status-dot {
  background: #fbbf24;
  animation: ms-status-pulse 1s ease-in-out infinite;
}
.ms-ses-status.error .ms-ses-status-dot {
  background: #f87171;
}
@keyframes ms-status-pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}
.ms-ses-status-text {
  color: inherit;
  font-weight: 500;
}
.ms-ses-status-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 4px;
}
[data-theme="light"] .ms-ses-status-meta {
  color: rgba(15, 23, 42, 0.5);
}

/* Big action buttons — slightly taller, gradient primary, comfortable hover. */
.ms-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.ms-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--widget-accent-grad);
  color: #0a0a0b;
  border: none;
  border-radius: 11px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow:
    0 6px 18px color-mix(in srgb, var(--widget-accent) 30%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.ms-action-btn:hover {
  filter: brightness(1.06);
}
.ms-action-btn:hover {
  transform: translateY(-1px);
}
.ms-action-btn:active {
  transform: translateY(0);
}
.ms-action-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  box-shadow: none;
}
[data-theme="light"] .ms-action-btn:disabled {
  background: rgba(15, 23, 42, 0.05);
  color: rgba(15, 23, 42, 0.3);
}
.ms-action-btn.danger {
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  color: #fff;
  box-shadow:
    0 6px 18px rgba(248, 113, 113, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
/* Start + Stop always keep a white label + icon, in every theme. The
   id selectors out-specify the .ms-action-btn base color (#0a0a0b). */
#msSesConnect,
#msSesStop {
  color: #fff;
}
/* Start keeps its accent (yellow) gradient even when disabled — the id
   out-specifies the :disabled grey; the dim below conveys the state. */
#msSesConnect {
  background: var(--widget-accent-grad);
  box-shadow:
    0 6px 18px color-mix(in srgb, var(--widget-accent) 30%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
/* Stop button stays red in every state — the id out-specifies the
   :disabled grey, so it never washes out when inactive. */
#msSesStop {
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  box-shadow:
    0 6px 18px rgba(248, 113, 113, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
/* Clicking Start (connect) or Stop (disconnect) disables that button —
   show it as deactivated by dimming it. The id+pseudo selectors out-
   specify the colour/background id rules above so the dim is visible. */
#msSesConnect:disabled,
#msSesStop:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: not-allowed;
}
.ms-action-btn.muted {
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: none;
}
[data-theme="light"] .ms-action-btn.muted {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.16);
}
.ms-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Device info — compact card wrapping the three info rows. */
.ms-device-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 4px 14px;
  margin-top: 4px;
}
[data-theme="light"] .ms-device-card {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.06);
}
.ms-device-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.78rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ms-device-card .ms-device-row:last-child {
  border-bottom: none;
}
[data-theme="light"] .ms-device-row {
  border-bottom-color: rgba(15, 23, 42, 0.04);
}
.ms-device-row-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] .ms-device-row-label {
  color: rgba(15, 23, 42, 0.5);
}
.ms-device-row-value {
  font-family: "JetBrains Mono", monospace;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-copy-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ms-copy-btn:hover {
  color: var(--widget-accent, #67e8f9);
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .ms-copy-btn {
  color: rgba(15, 23, 42, 0.5);
}
[data-theme="light"] .ms-copy-btn:hover {
  background: rgba(15, 23, 42, 0.06);
}
.ms-copy-btn.copied {
  color: #86efac;
}
.ms-copy-btn svg {
  width: 13px;
  height: 13px;
}

/* Spacing utilities used in the Session pane */
.ms-mt-14 {
  margin-top: 14px;
}
.ms-mt-22 {
  margin-top: 22px;
}

/* Empty / coming-soon placeholder */
.ms-empty {
  padding: 32px 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.86rem;
  font-style: italic;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  margin-top: 16px;
}
[data-theme="light"] .ms-empty {
  color: rgba(15, 23, 42, 0.5);
  border-color: rgba(15, 23, 42, 0.14);
}

@media (max-width: 700px) {
  .ms-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 32px);
    border-radius: 12px;
  }
  /* Mobile = bottom navigation bar: main content fills, the sidebar becomes a
     full-width bar pinned at the BOTTOM with evenly-spread icon-over-label tabs. */
  .ms-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .ms-main { grid-row: 1; padding: 16px 16px 20px; }
  .ms-sidebar {
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    gap: 4px;
    overflow-x: auto;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  [data-theme="light"] .ms-sidebar { border-top-color: rgba(15, 23, 42, 0.08); }
  .ms-tab {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    padding: 6px 4px;
    font-size: 0.62rem;
    border-radius: 12px;
  }
  .ms-tab span {
    max-width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ms-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }
  .ms-select {
    width: 100%;
    min-width: 0;
  }
  /* Section labels = Hide affects only the in-pane sub-headers here; the bottom
     navigation bar always keeps its labels + full-width layout. */
  #msPanel.ms-hide-headers .ms-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  #msPanel.ms-hide-headers .ms-tab {
    flex: 1 1 0;
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
  }
  #msPanel.ms-hide-headers .ms-tab span {
    max-width: 100%;
    max-height: none;
    opacity: 1;
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ms-panel,
  .ms-pane,
  .ms-backdrop,
  .ms-switch-thumb,
  .ms-switch-track {
    transition: none !important;
    animation: none !important;
  }
}
