:root {
  --bg: #121212;
  --bg-soft: #1a1a1a;
  --card: #1e1e1e;
  --card-2: #242424;
  --line: #323232;
  --text: #e0e0e0;
  --muted: #a7a7a7;
  --accent: #2196f3;
  --accent-2: #1976d2;
  --warn: #ff9800;
  --ok: #52d67a;
  --bad: #ff6f6f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", "Roboto", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 700px at -20% -20%, #1d2b3d 0%, transparent 55%),
    radial-gradient(1100px 650px at 120% -30%, #2e2215 0%, transparent 50%),
    linear-gradient(180deg, #121212 0%, #171717 100%);
}

body.app-locked {
  overflow: hidden;
}

body.app-locked main {
  filter: blur(2px);
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 8, 8, 0.78);
  backdrop-filter: blur(6px);
}

.access-gate[hidden] {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.access-card {
  width: min(460px, 100%);
  display: grid;
  gap: 10px;
  border-radius: 14px;
  border: 1px solid #3e3e3e;
  padding: 18px;
  background: linear-gradient(180deg, #232323 0%, #1b1b1b 100%);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}

.access-card h2 {
  margin: 0;
}

.access-error {
  min-height: 18px;
  color: var(--bad);
}

main {
  max-width: 1450px;
  margin: 0 auto;
  padding: 20px;
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #222 0%, #1b1b1b 100%);
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 44px;
  width: auto;
  flex: 0 0 auto;
}

a.brand-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 8px;
  transition: opacity 0.15s ease;
}
a.brand-logo-link:hover { opacity: 0.78; }
a.brand-logo-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

.header-action-btn {
  min-width: 160px;
  background: linear-gradient(180deg, #303030 0%, #232323 100%);
  border: 1px solid #4d4d4d;
}

.header-action-btn-danger {
  background: linear-gradient(180deg, #d95b5b 0%, #ba3e3e 100%);
  border-color: #a43d3d;
  color: #fff;
}

.room-header-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #4b5e74;
  background: #142131;
  color: #9dd0ff;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.brand-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-name {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 700;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 2.1vw, 1.8rem);
  line-height: 1.15;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

p {
  color: var(--muted);
  margin-top: 0;
}

.host-dashboard {
  display: grid;
  grid-template-columns: 1.05fr 1.2fr 1fr;
  gap: 14px;
  align-items: start;
}

.dash-col {
  min-width: 0;
}

.dashboard-top-card {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.card {
  background: linear-gradient(180deg, var(--card-2) 0%, var(--card) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.compact-card {
  padding: 12px;
}

.compact-card h2 {
  margin-bottom: 10px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #d8d8d8;
  font-size: 0.88rem;
}

input,
select,
button,
summary {
  border-radius: 9px;
  padding: 9px 10px;
  min-height: 40px;
}

input,
select {
  border: 1px solid #434343;
  background: #171717;
  color: var(--text);
}

input {
  min-width: 210px;
}

select {
  min-width: 220px;
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
}

button:hover {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-cta {
  background: linear-gradient(180deg, #ffb74d 0%, var(--warn) 100%);
  color: #111;
}

.danger-btn {
  background: linear-gradient(180deg, #d95b5b 0%, #ba3e3e 100%);
  border-color: #a43d3d;
  color: #fff;
}

.danger-btn:hover {
  filter: brightness(1.04);
}

.status {
  margin-top: 8px;
  color: var(--ok);
  font-size: 0.95rem;
  font-weight: 600;
}

.status.error {
  color: var(--bad);
}

.status-chip {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #4b5e74;
  background: #172533;
  min-width: 220px;
  text-align: center;
}

.status-chip.error {
  border-color: #7e3232;
  background: #2a1818;
}

.room-occupancy {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #4b5e74;
  background: #172533;
  font-size: 0.84rem;
  font-weight: 600;
}

.room-occupancy-free {
  color: #b8f4cd;
  border-color: #2e9c64;
  background: #15281f;
}

.room-occupancy-busy {
  color: #ffd7d7;
  border-color: #b44f4f;
  background: #2a1818;
}

.room-occupancy-loading {
  color: #cde5ff;
  border-color: #4b5e74;
  background: #172533;
}

.room-occupancy-error {
  color: #ffb4b4;
  border-color: #a14747;
  background: #2a1818;
}

.small {
  font-size: 0.88rem;
  color: var(--muted);
}

a.small {
  color: #cfe4ff;
  text-decoration: underline;
}

.link-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.link-field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.compact-card-title-row {
  align-items: start;
}




.compact-primary-link {
  margin-bottom: 10px;
}

.operator-links-details {
  margin-top: 10px;
  border: 1px dashed #3a4a5e;
  background: #1a2230;
  border-radius: 10px;
}

.operator-links-details summary {
  min-height: 0;
  padding: 10px 14px;
  color: #cfe4ff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.operator-links-details summary:hover {
  background: #1f2a3a;
}

.operator-links-summary-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #ffffff;
}

.operator-links-summary-icon {
  font-size: 1rem;
}

.operator-links-summary-hint {
  flex: 1 1 auto;
  color: #8aa0bd;
  font-size: 0.78rem;
}

.operator-links-summary-chevron {
  display: inline-block;
  font-size: 0.85rem;
  color: #9db8d2;
  transition: transform 0.18s ease;
  margin-left: auto;
}

.operator-links-details[open] .operator-links-summary-chevron {
  transform: rotate(180deg);
}

.operator-links-details[open] {
  border-style: solid;
  border-color: #2a3a52;
}

.operator-links-details[open] > *:not(summary) {
  padding-left: 14px;
  padding-right: 14px;
  padding-bottom: 12px;
}

/* --- Stream profile (right column) --------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.stream-profile-group {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #2a2a2a;
}
.stream-profile-group:last-of-type {
  margin-bottom: 10px;
  border-bottom: none;
  padding-bottom: 4px;
}

.stream-profile-group-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8aa0bd;
  margin-bottom: 8px;
}

.stream-profile-group-hint {
  margin-top: 6px;
  color: #7d8a99;
  font-size: 0.78rem;
  line-height: 1.4;
}

.stream-profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.stream-profile-field:last-child { margin-bottom: 0; }

.stream-profile-field-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.stream-profile-advanced {
  margin-top: 6px;
  border: 1px solid #2f3a48;
  background: #161b22;
}
.stream-profile-advanced > summary {
  min-height: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.stream-profile-advanced > summary:hover {
  background: #1a212c;
}
.advanced-summary-text {
  font-weight: 600;
  font-size: 0.88rem;
  color: #d7d7d7;
}
.advanced-summary-chevron {
  font-size: 0.85rem;
  color: #9db8d2;
  transition: transform 0.18s ease;
}
.stream-profile-advanced[open] > summary .advanced-summary-chevron {
  transform: rotate(180deg);
}
.stream-profile-advanced-fields {
  padding: 4px 14px 14px;
  display: grid;
  gap: 8px;
}

.dashboard-card-sources .row,
.dashboard-card-incoming-audio .row {
  margin-bottom: 8px;
}

.dashboard-card-sources label,
.dashboard-card-incoming-audio label {
  gap: 4px;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

/* Segmented preset buttons use smaller text+padding so all five
 * (LOW/BALANCED/HIGH/ULTRA/CUSTOM) fit even in the narrow right column. */
.segmented button {
  font-size: 0.78rem;
  padding: 6px 4px;
  letter-spacing: 0.02em;
}

.segmented button {
  font-weight: 700;
  min-height: 36px;
  background: #232323;
  border: 1px solid #4a4a4a;
  color: #d7d7d7;
}

.segmented button.active {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
  color: #fff;
}

details {
  margin-top: 10px;
  border: 1px solid #3d3d3d;
  border-radius: 10px;
  background: #191919;
}

summary {
  cursor: pointer;
  color: #d9d9d9;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

details[open] {
  border-color: #4f637a;
}

details .row {
  padding: 0 10px 10px;
}

video,
audio {
  width: 100%;
  border-radius: 10px;
  background: #000;
}

#directorTalkbackAudio {
  display: none;
}

video {
  min-height: 260px;
  max-height: 62vh;
}

#incomingAudioList audio {
  margin-top: 8px;
}

.meter-wrap {
  margin-top: 8px;
}

.meter-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.meter-bar {
  width: 100%;
  height: 10px;
  background: #121212;
  border: 1px solid #3e3e3e;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ok) 0%, #ffd35f 65%, var(--bad) 100%);
}

.monitor-meter-wrap {
  margin-top: 12px;
}

.director-meter-wrap {
  margin-top: 12px;
  max-width: 480px;
}

.preview-audio-meter-wrap {
  margin-top: 4px;
  margin-bottom: 12px;
}

.monitor-history {
  width: 100%;
  height: 120px;
  display: block;
  margin-top: 10px;
  border: 1px solid #2d3f53;
  border-radius: 10px;
  background: #0f141a;
}

.monitor-history-hint {
  margin-top: 6px;
}

.direction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  margin: 8px 0 12px;
}

.direction-card {
  border: 1px solid #34475b;
  border-radius: 10px;
  background: #161d24;
  padding: 10px;
}

.direction-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.direction-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #d6e5f5;
}

.direction-card .quality-badge {
  margin-top: 0;
}

.quality-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.quality-excellent {
  color: #a8f6c7;
  border-color: #2e9c64;
}

.quality-good {
  color: #ffe69d;
  border-color: #937e2c;
}

.quality-poor {
  color: #ffacac;
  border-color: #a84949;
}

.link-list a {
  color: var(--text);
  display: block;
  margin: 8px 0;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  background: #1b1b1b;
}

.link-list a:hover {
  border-color: #5b5b5b;
  background: #202020;
}

@media (max-width: 1280px) {
  .host-dashboard {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .dash-col {
    display: contents;
  }

  .dashboard-top-card {
    order: 1;
  }

  .dashboard-card-incoming-audio {
    order: 2;
  }

  .dashboard-card-sources {
    order: 3;
  }

  .dashboard-card-links {
    order: 4;
  }

  .dashboard-card-preview {
    order: 5;
  }

  .dashboard-card-stream-profile {
    order: 6;
  }

  .dashboard-card-remote-director {
    order: 7;
  }

  video {
    min-height: 220px;
  }
}

@media (max-width: 980px) {
  .direction-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  main {
    padding: 14px;
  }

  .brand-logo {
    height: 34px;
  }

  .brand-name {
    font-size: 0.88rem;
  }

  input,
  select,
  button {
    width: 100%;
    min-width: 0;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(80px, 1fr));
  }

  .link-field-row {
    grid-template-columns: 1fr;
  }

  .status-chip {
    min-width: 0;
    width: 100%;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-action-btn {
    min-width: 0;
  }

  .room-header-chip {
    width: 100%;
    justify-content: center;
  }

}

.mic-control-row {
  align-items: center;
  gap: 10px;
}

.mic-toggle {
  min-width: 180px;
}

.mic-toggle.on {
  background: linear-gradient(180deg, #38c76a 0%, #2da558 100%);
  color: #08140d;
}

.mic-toggle.off {
  background: linear-gradient(180deg, #d95b5b 0%, #ba3e3e 100%);
  color: #fff;
}

.relay-toggle {
  min-width: 180px;
}

.relay-toggle.on {
  background: linear-gradient(180deg, #38c76a 0%, #2da558 100%);
  color: #08140d;
}

.relay-toggle.off {
  background: linear-gradient(180deg, #7a4fe0 0%, #5c3ec7 100%);
  color: #fff;
}

.program-volume-group {
  min-width: 320px;
}

.program-volume-group input[type="range"] {
  width: 100%;
  margin: 0;
}

.mic-level-group {
  min-width: 280px;
}


.mic-vu {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #0f141a;
  border: 1px solid #2d3f53;
  overflow: hidden;
}

.mic-vu-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ed47a 0%, #f8d24d 65%, #ff6f6f 100%);
  transition: width 80ms linear;
}

.mic-vu-peak {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.95);
  left: 0;
  pointer-events: none;
}

.timecode {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #9dd0ff;
  border: 1px solid #37516d;
  border-radius: 10px;
  padding: 8px 12px;
  background: #142131;
  white-space: nowrap;
}

.logs-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.logs-table th,
.logs-table td {
  border-bottom: 1px solid #2d2d2d;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.88rem;
  color: #d7d7d7;
  vertical-align: top;
}

.logs-table th {
  color: #9db8d2;
  background: #171d24;
  position: sticky;
  top: 0;
}

/* Readable variant: zebra striping, severity tint, click-to-expand. */
.logs-table-readable tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.logs-table-readable tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.015); }
.logs-table-readable tbody tr:hover { background: rgba(33, 150, 243, 0.07); }
.logs-table-readable tbody tr.sev-error { background: rgba(255, 111, 111, 0.10); }
.logs-table-readable tbody tr.sev-error:hover { background: rgba(255, 111, 111, 0.18); }
.logs-table-readable tbody tr.sev-warning { background: rgba(255, 152, 0, 0.08); }
.logs-table-readable tbody tr.sev-warning:hover { background: rgba(255, 152, 0, 0.16); }
.logs-table-readable tbody tr.sev-presence { background: rgba(33, 150, 243, 0.06); }
.logs-table-readable tbody tr.sev-presence:hover { background: rgba(33, 150, 243, 0.14); }
.logs-table-readable tbody tr.sev-network-bad { background: rgba(255, 111, 111, 0.08); }

.logs-table-readable .log-time {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  color: #b6c2cf;
  white-space: nowrap;
}

.event-type-badge {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2a2f37;
  color: #d7d7d7;
  white-space: nowrap;
}
.event-type-badge.sev-error { background: rgba(255, 111, 111, 0.22); color: #ffb3b3; }
.event-type-badge.sev-warning { background: rgba(255, 152, 0, 0.22); color: #ffce80; }
.event-type-badge.sev-presence { background: rgba(33, 150, 243, 0.22); color: #9ec8ff; }
.event-type-badge.sev-network { background: rgba(82, 214, 122, 0.18); color: #9ce5b5; }

.source-pill {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: #1e2630;
  color: #c0d4e8;
  border: 1px solid #2c3a4a;
  white-space: nowrap;
}
.source-pill.src-host { background: #1d2a3d; color: #b3d3ff; border-color: #2b4b78; }
.source-pill.src-commentator { background: #1f2e23; color: #b3e9c6; border-color: #2c5a3e; }
.source-pill.src-monitor { background: #2c2a1d; color: #ffe4a8; border-color: #6a5a2c; }

.id-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: #9aa6b2;
}

.logs-table-readable .log-details {
  font-size: 0.86rem;
  color: #d7d7d7;
  line-height: 1.45;
  max-width: 720px;
  word-break: break-word;
}

.logs-table-readable tr.log-expanded-row td {
  background: #14181d;
  padding: 12px 14px;
}
.log-expanded-pre {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: #c0c0c0;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}

.log-filters-row {
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.log-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.log-filter-label input,
.log-filter-label select {
  margin-left: 0;
}
.log-filter-count {
  margin-left: auto;
  color: var(--muted);
}

.log-category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.log-category-chip {
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1d2229;
  color: #9aa6b2;
  border: 1px solid #2a323b;
}
.log-category-chip.has-errors { background: rgba(255, 111, 111, 0.18); color: #ffb3b3; border-color: rgba(255, 111, 111, 0.4); }
.log-category-chip.has-warnings { background: rgba(255, 152, 0, 0.16); color: #ffce80; border-color: rgba(255, 152, 0, 0.4); }


.room-start-row {
  align-items: end;
}

.room-select-label {
  min-width: 260px;
}

.room-status-groups {
  display: grid;
  gap: 14px;
}

.room-status-group {
  display: grid;
  gap: 10px;
}

.room-status-group-title {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c9d9ed;
}

.room-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.room-status-card {
  border: 1px solid #3a4b5f;
  border-radius: 10px;
  background: #162230;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.room-status-card:hover {
  transform: translateY(-1px);
}

.room-status-card.room-status-selected {
  border-color: #5ea8ff;
  box-shadow: 0 0 0 1px rgba(94, 168, 255, 0.35);
}

.room-status-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e7eef8;
  margin-bottom: 8px;
}

.room-status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
  margin-bottom: 8px;
}

.room-status-badge-free {
  color: #b8f4cd;
  border-color: #2e9c64;
  background: #15281f;
}

.room-status-badge-busy {
  color: #ffd7d7;
  border-color: #b44f4f;
  background: #2a1818;
}

.room-status-badge-loading {
  color: #cde5ff;
  border-color: #4b5e74;
  background: #172533;
}

.room-status-badge-error {
  color: #ffb4b4;
  border-color: #a14747;
  background: #2a1818;
}

.room-status-free {
  border-color: #2e9c64;
  background: #14231d;
}

.room-status-busy {
  border-color: #b44f4f;
  background: #271818;
}

.room-status-loading {
  border-color: #4b5e74;
  background: #162230;
}

.room-status-error {
  border-color: #a14747;
  background: #2a1818;
}

.room-status-details {
  line-height: 1.3;
}

.room-fixed-row {
  align-items: center;
}

.room-fixed-note {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 2px;
  color: #cfd8e6;
  font-size: 0.9rem;
  font-weight: 600;
}

.room-fixed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #4b5e74;
  background: #172533;
  color: #9dd0ff;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row h2 {
  margin-bottom: 0;
}

.panel-toggle-btn {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2f3b48 0%, #24303c 100%);
  border: 1px solid #4b5e74;
  color: #d8e8ff;
  font-size: 0.84rem;
  font-weight: 700;
}

.source-settings-panel[hidden] {
  display: none !important;
}

.dashboard-card-sources .source-settings-panel .row:last-child {
  margin-bottom: 0;
}


.logs-clickable-row {
  cursor: pointer;
}

.logs-clickable-row:hover td {
  background: rgba(33, 150, 243, 0.08);
}

.logs-selected-row td {
  background: rgba(33, 150, 243, 0.14);
}

.logs-scope-badge {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #4b5e74;
  background: #172533;
  color: #9dd0ff;
}

.issue-details-card {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2f3c49;
  background: rgba(13, 20, 28, 0.65);
}

.issue-details-card h3 {
  margin: 0;
  font-size: 1rem;
}

.issue-details-block {
  margin-top: 12px;
}

.issue-details-label {
  margin-bottom: 6px;
  color: #9db8d2;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.issue-details-pre {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #121820;
  border: 1px solid #2a3340;
  color: #d7d7d7;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

/* Keyboard focus indicator — visible across all interactive controls. */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Inline hint shown under a label to demystify jargon (mix-minus, TURN, ПТС, etc.). */
.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Help marker — small "?" badge next to a control with a native tooltip. */
.help-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid #5a6878;
  background: #1d2733;
  color: #9dd0ff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}

.help-marker:hover {
  border-color: #7aa3c8;
  color: #c8e2ff;
}

/* Loading state for action buttons (e.g. "Применить и в эфир"). */
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}

button.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 10px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  vertical-align: middle;
  animation: btn-spin 0.8s linear infinite;
}

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

/* "Already in broadcast" state for the commentator's Join button.
 * Looks like a passive status indicator (green tinted, not bright accent)
 * with a check-style dot, so clicking it doesn't read as "do something".
 */
button.btn-joined,
button.btn-joined:disabled {
  background: rgba(82, 214, 122, 0.18);
  color: var(--ok);
  border: 1px solid rgba(82, 214, 122, 0.45);
  opacity: 1;
  cursor: default;
  pointer-events: none;
}
button.btn-joined::before {
  content: "●";
  display: inline-block;
  margin-right: 8px;
  color: var(--ok);
  font-size: 0.7rem;
  vertical-align: middle;
  animation: btn-joined-pulse 1.8s ease-in-out infinite;
}
@keyframes btn-joined-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Prominent ON-AIR badge for the commentator — must read from across the room. */
.quality-badge.on-air-prominent {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 8px 14px;
  border-radius: 10px;
  text-transform: uppercase;
}

.quality-badge.on-air-prominent.quality-good {
  background: linear-gradient(180deg, #38c76a 0%, #2da558 100%);
  color: #08140d;
  border: 1px solid #1f7a3f;
  box-shadow: 0 0 0 2px rgba(56, 199, 106, 0.18);
}

.quality-badge.on-air-prominent.quality-poor {
  background: linear-gradient(180deg, #d95b5b 0%, #ba3e3e 100%);
  color: #fff;
  border: 1px solid #8a2c2c;
}

/* Inline media-access error block (shown when getUserMedia fails). */
.media-error {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #7a3232;
  background: #2a1414;
  color: #ffbcbc;
  font-size: 0.88rem;
  line-height: 1.4;
}

.media-error[hidden] {
  display: none !important;
}

.media-error a {
  color: #ffd9d9;
  text-decoration: underline;
}

/* Toast notifications. */
.toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #3e3e3e;
  background: linear-gradient(180deg, #2a2a2a 0%, #1f1f1f 100%);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.35;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  cursor: pointer;
  word-break: break-word;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-ok {
  border-color: #1f7a3f;
  background: linear-gradient(180deg, #1b3c25 0%, #14301c 100%);
  color: #c4f3d5;
}

.toast-error {
  border-color: #8a2c2c;
  background: linear-gradient(180deg, #3c1b1b 0%, #2a1414 100%);
  color: #ffd0d0;
}

.toast-info {
  border-color: #2d5274;
  background: linear-gradient(180deg, #182b3d 0%, #122131 100%);
  color: #cfe5ff;
}

@media (max-width: 640px) {
  .toast-root {
    top: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
}

/* ---------------------------------------------------------------------------
 * Compact, less-noisy UI tier overrides.
 * Tighter button heights, predictable text fitting, three button tiers,
 * iOS-style switches, tighter cards, smaller section headings.
 * ------------------------------------------------------------------------- */

button {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 100%;
}

/* Segmented preset buttons need to show their full short label (LOW, BALANCED,
 * HIGH, ULTRA, CUSTOM) — don't clip them with the global ellipsis rule. */
.segmented button {
  text-overflow: clip;
  overflow: visible;
  padding: 6px 10px;
}

button.btn-secondary {
  background: transparent;
  border: 1px solid #4d4d4d;
  color: var(--text);
  font-weight: 600;
}

button.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}

button.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 600;
}

button.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}

button.btn-icon {
  min-width: 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #4d4d4d;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

button.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #6a6a6a;
  filter: none;
}

button.btn-icon.danger-btn {
  border-color: #6b3030;
  color: #ff9b9b;
  background: transparent;
}

button.btn-icon.danger-btn:hover {
  background: rgba(217, 91, 91, 0.12);
}

/* Reduce min-widths from earlier rules so buttons size to their content. */
.mic-toggle,
.relay-toggle {
  min-width: 0;
}

/* iOS-style switch — visually distinct from regular button. The element
 * keeps `<button>` semantics (and existing JS); only the look changes via
 * the `.switch` class. `.on`/`.off` keep working from existing JS. */
button.switch,
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 10px;
  min-height: 36px;
  height: 36px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid #3a3a3a;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
}

button.switch::before,
.switch::before {
  content: "";
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #3a3a3a;
  position: relative;
  transition: background 0.18s ease;
  flex: 0 0 auto;
}

button.switch::after,
.switch::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d0d0d0;
  transition: transform 0.18s ease, background 0.18s ease;
}

button.switch.on::before,
.switch.on::before {
  background: var(--ok);
}

button.switch.on::after,
.switch.on::after {
  transform: translate(14px, -50%);
  background: #fff;
}

button.switch:disabled,
.switch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.switch:hover:not(:disabled),
.switch:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}

/* Card compaction — slightly tighter padding and section headings,
 * keeps readability but reclaims ~20% vertical space. */
.card {
  padding: 12px 14px;
  margin-bottom: 10px;
}

.card h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.row {
  gap: 8px;
  margin-bottom: 8px;
}

/* Mobile: still let buttons size by content rather than 100%-width forced.
 * Earlier rule forced width:100% in @media(max-width:640px). Soften it so
 * short labels keep their natural width. Long ones still wrap to full row. */
@media (max-width: 640px) {
  button {
    width: auto;
  }

  button.btn-icon {
    width: 36px;
  }

  /* Primary action buttons stay full-width for thumb-friendliness. */
  button#joinBtn,
  button#startBtn,
  button#applyAllSettingsBtn {
    width: 100%;
  }
}
