:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #181c20;
  --surface-2: #222830;
  --line: #344047;
  --text: #f4f5ef;
  --muted: #aeb7ad;
  --accent: #5fd3bc;
  --accent-2: #b7f25c;
  --danger: #ff6b63;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

body[data-theme="blue"] {
  --bg: #0c1218;
  --surface: #141c25;
  --surface-2: #1d2a38;
  --line: #31465a;
  --accent: #60c8ff;
  --accent-2: #9ee7ff;
}

body[data-theme="purple"] {
  --bg: #120f18;
  --surface: #1c1724;
  --surface-2: #2a2036;
  --line: #483b5b;
  --accent: #c48cff;
  --accent-2: #f1b6ff;
}

body[data-theme="black"] {
  --bg: #08090a;
  --surface: #111315;
  --surface-2: #1a1d20;
  --line: #303337;
  --accent: #e8ecef;
  --accent-2: #a9b0b6;
}

body[data-theme="red"] {
  --bg: #160d0f;
  --surface: #211417;
  --surface-2: #2f1d21;
  --line: #553239;
  --accent: #ff7a70;
  --accent-2: #ffd06b;
}

body[data-theme="yellow"] {
  --bg: #12110b;
  --surface: #1c1a11;
  --surface-2: #292615;
  --line: #4a4322;
  --accent: #ffd45a;
  --accent-2: #8ddfbc;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent 42%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 76%, #000) 0%, var(--bg) 58%, #050607 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid color-mix(in srgb, var(--accent) 72%, white);
  border-radius: 6px;
  padding: 9px 13px;
  background: var(--accent);
  color: #07100e;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

button.danger {
  border-color: color-mix(in srgb, var(--danger) 72%, white);
  background: color-mix(in srgb, var(--danger) 18%, var(--surface-2));
  color: var(--text);
}

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

.wide-button {
  width: 100%;
  margin-bottom: 14px;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
}

.is-hidden {
  display: none !important;
}

.brand-header,
.room-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.brand-header {
  display: block;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.5rem, 8vw, 6rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.04rem;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.home-panel,
.theme-panel,
.controls-panel {
  padding: 18px;
}

.field,
.slider-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span,
.slider-field span,
.theme-panel > span,
.status-strip span,
.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #0c0f12;
  color: var(--text);
  outline: none;
}

input[type="range"] {
  accent-color: var(--accent);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.segmented,
.theme-row,
.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.room-type-choice {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.theme-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 10px 0 0;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

.segmented span,
.theme-button {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1114;
  color: var(--muted);
  text-align: center;
}

.segmented input:checked + span,
.theme-button.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, #0d1114);
  color: var(--text);
}

.theme-panel {
  margin-top: 18px;
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.room-code {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: #0c0f12;
  color: var(--accent-2);
  font-weight: 900;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
}

.control-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.input-list,
.user-list {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.input-unit,
.user-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d1114;
}

.input-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 160ms ease;
}

.input-summary:hover,
.input-summary:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.input-summary div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.input-summary span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accordion-indicator {
  transition: transform 140ms ease;
}

.input-unit:has(.input-body.is-collapsed) .accordion-indicator {
  transform: rotate(-90deg);
}

.input-body {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 1200px;
  overflow: hidden;
  opacity: 1;
  transition:
    max-height 240ms ease,
    opacity 180ms ease,
    margin-top 240ms ease;
}

.input-body.is-collapsed {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  pointer-events: none;
}

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

.user-pill-label {
  flex: 1;
  min-width: 0;
}

.user-pill.is-singer {
  border-color: var(--accent, #5cd2a0);
  box-shadow: 0 0 0 1px var(--accent, #5cd2a0) inset;
}

.user-pill-action {
  flex-shrink: 0;
}

.karaoke-singer-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: rgba(20, 25, 30, 0.6);
  color: var(--muted);
}

.karaoke-singer-status:empty {
  display: none;
}

.karaoke-singer-status.is-singer {
  border-color: var(--accent, #5cd2a0);
  color: var(--text);
}

.karaoke-singer-status.is-receiver {
  border-color: rgba(120, 140, 180, 0.4);
  color: var(--text);
}

.input-unit h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.input-runtime {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.input-check-row {
  min-height: 42px;
  align-self: end;
  margin-bottom: 14px;
  padding: 8px 0;
}

.input-placeholder {
  min-height: 42px;
}

.switch-row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "track label";
  align-items: center;
  column-gap: 10px;
  min-height: 42px;
  align-self: end;
  margin-bottom: 14px;
  color: var(--muted);
  cursor: pointer;
}

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

.switch-track {
  grid-area: track;
  position: relative;
  width: 46px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c0f12;
  transition: background 140ms ease, border-color 140ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.switch-row input:checked + .switch-track {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, #0c0f12);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(20px);
  background: var(--accent);
}

.switch-label {
  grid-area: label;
  font-size: 0.86rem;
  font-weight: 700;
}

.spatial-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.spatial-panel > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.spatial-pad {
  position: relative;
  width: 100%;
  height: 162px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(color-mix(in srgb, var(--accent) 18%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 18%, transparent) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 45%),
    #0b0e10;
  background-size: 24px 24px, 24px 24px, 100% 100%, 100% 100%;
  touch-action: none;
}

.spatial-head {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 54px;
  border: 2px solid color-mix(in srgb, var(--text) 72%, transparent);
  border-radius: 48% 48% 42% 42%;
  transform: translate(-50%, -50%);
}

.spatial-head::before,
.spatial-head::after {
  content: "";
  position: absolute;
  top: 18px;
  width: 8px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--text) 58%, transparent);
  border-radius: 999px;
}

.spatial-head::before { left: -12px; }
.spatial-head::after { right: -12px; }

.spatial-dot {
  position: absolute;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: 999px;
  padding: 0;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}

.permission-gate {
  display: grid;
  gap: 8px;
  border: 1px solid color-mix(in srgb, #f5be54 44%, var(--line));
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: color-mix(in srgb, #f5be54 10%, #0d1114);
}

.permission-gate p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

#configurePermissionsButton {
  animation: permissionPulse 1.45s ease-in-out infinite;
}

@keyframes permissionPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 32%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
}

select.needs-attention {
  animation: selectDance 0.75s ease-in-out;
  border-color: #f5be54;
}

@keyframes selectDance {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.input-list.is-inputs-blocked {
  opacity: 0.38;
  pointer-events: none;
}

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

.input-row.three {
  grid-template-columns: 1fr 1fr;
}

.input-action-row {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.start-mic-button {
  width: 100%;
  min-height: 52px;
  font-size: 1rem;
}

.start-mic-button.is-ready {
  animation: micStartPulse 1.8s ease-in-out infinite;
}

.start-mic-button.is-running {
  border-color: color-mix(in srgb, var(--danger) 66%, var(--line));
  background: color-mix(in srgb, var(--danger) 16%, var(--surface-2));
  color: var(--text);
}

@keyframes micStartPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 28%, transparent);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent);
    transform: translateY(-1px);
  }
}

.stage {
  min-width: 0;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  margin-bottom: 18px;
}

.status-strip div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  background: var(--surface-2);
}

.connection-status-cell {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.connection-status-cell span {
  grid-column: 1 / -1;
}

.status-strip strong {
  overflow-wrap: anywhere;
}

.status-strip small {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.stream-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.stream-card.is-entering.presence-scale {
  animation: streamScaleIn 520ms cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.stream-card.is-leaving.presence-scale {
  animation: streamScaleOut 520ms cubic-bezier(0.32, 0, 0.67, 0) both;
  pointer-events: none;
}

.stream-card.is-entering.presence-fade {
  animation: streamFadeIn 520ms ease both;
}

.stream-card.is-leaving.presence-fade {
  animation: streamFadeOut 520ms ease both;
  pointer-events: none;
}

@keyframes streamScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes streamScaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes streamFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes streamFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.stream-card.is-speaking {
  border-color: color-mix(in srgb, var(--accent) 74%, white);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) var(--speaking-mix, 36%), transparent),
    0 0 var(--speaking-glow, 28px) color-mix(in srgb, var(--accent) var(--speaking-mix, 36%), transparent),
    var(--shadow);
}

.stream-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 14px 0;
}

.stream-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stream-name strong {
  overflow-wrap: anywhere;
}

.role-badge,
.muted-badge {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.muted-badge {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--line));
  color: var(--danger);
}

.stream-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.buffer-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 14px 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface-2));
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

.buffer-alert[data-level="warn"] {
  border-color: color-mix(in srgb, #f5a524 55%, var(--line));
  background: color-mix(in srgb, #f5a524 14%, var(--surface-2));
  color: #e68900;
}

.buffer-alert[data-level="critical"] {
  border-color: color-mix(in srgb, var(--danger) 80%, var(--line));
  background: color-mix(in srgb, var(--danger) 22%, var(--surface-2));
  color: var(--danger);
  animation: bufferPulse 1.2s ease-in-out infinite;
}

.buffer-alert button {
  padding: 4px 10px;
  font-size: 0.74rem;
}

.buffer-alert.is-hidden {
  display: none;
}

.stream-card.is-buffer-warn {
  border-color: color-mix(in srgb, #f5a524 45%, var(--line));
}

.stream-card.is-buffer-critical {
  border-color: color-mix(in srgb, var(--danger) 70%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent), var(--shadow);
}

@keyframes bufferPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.stream-metrics div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2);
}

.stream-metrics .buffer-metric {
  gap: 6px;
}

.buffer-submetric {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
}

.buffer-submetric small {
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buffer-submetric strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quality-line {
  grid-column: 1 / -1;
}

.meter-wrap {
  padding: 0 14px 14px;
}

.meter-bar {
  position: relative;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #0b0e10;
  background-size: 24px 100%;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.72;
  transition: width 80ms linear;
}

.meter-db {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.stream-card.is-muted .meter-fill {
  background: linear-gradient(90deg, #6b7076, #9ba1a6);
  opacity: 0.52;
}

.stream-card.is-muted {
  border-color: #4a4f55;
  box-shadow: var(--shadow);
}

.stream-card.is-muted .meter-bar {
  border-color: #5b6066;
}

.stream-card.is-muted input[type="range"] {
  accent-color: #7b8086;
}

.stream-controls {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.stream-controls .control-row {
  margin: 0;
}

.chat-box {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 10;
  width: min(360px, calc(100vw - 32px));
}

.chat-toggle {
  width: 100%;
}

.chat-panel {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-box.is-open .chat-panel {
  display: block;
}

.chat-messages {
  display: grid;
  align-content: end;
  gap: 8px;
  height: 280px;
  overflow: auto;
  padding: 12px;
}

.chat-message {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 54%, transparent);
  padding-bottom: 7px;
}

.chat-message strong {
  font-size: 0.84rem;
}

.chat-message span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px;
}

.notification-stack {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 48px));
  pointer-events: none;
}

.notification {
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, #2a6dff 12%, var(--surface));
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: notificationIn 160ms ease-out;
}

.notification-status {
  border-color: rgba(101, 165, 255, 0.42);
  background: color-mix(in srgb, #4d9cff 13%, var(--surface));
  color: #cfe3ff;
}

.notification-warning {
  border-color: rgba(245, 190, 84, 0.52);
  background: color-mix(in srgb, #f5be54 14%, var(--surface));
  color: #ffe3a5;
}

.notification-danger {
  border-color: rgba(255, 107, 99, 0.58);
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  color: #ffd0cc;
}

.notification.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

@keyframes notificationIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.identity-bar {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity-button,
.identity-logout {
  max-width: min(260px, calc(100vw - 48px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-view {
  position: relative;
  display: grid;
  grid-template-rows:
    auto      /* 1: título (arriba) */
    1fr       /* 2: aire superior */
    auto      /* 3: botones (centro absoluto) */
    1fr       /* 4: aire inferior espejo del 2 — centra los botones */
    auto      /* 5: selector de temas (intermedio entre botones y footer) */
    1fr       /* 6: aire hacia el footer */
    auto;     /* 7: footer (abajo) */
  width: 100vw;
  min-height: calc(100vh - 56px);
  margin-left: calc(50% - 50vw);
  overflow: hidden;
  padding: 6vh 16px 3vh;
}

.home-view .brand-header {
  position: relative;
  z-index: 1;
  grid-row: 1;
  display: grid;
  width: 100%;
  justify-self: center;
  justify-items: center;
  text-align: center;
  margin: 0;
}

.home-view h1 {
  width: 100%;
  margin-bottom: 0;
  text-align: center;
}

.wave-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(9px, 2vw, 28px);
  opacity: 0.28;
  pointer-events: none;
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 36%, transparent));
}

.wave-backdrop span {
  width: clamp(12px, 4vw, 58px);
  height: 22vh;
  border: 1px solid color-mix(in srgb, var(--accent) 78%, white);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent-2) 72%, transparent));
  transform-origin: center;
  animation: soundWave 2.5s ease-in-out infinite;
}

.wave-backdrop span:nth-child(2) { animation-delay: -0.35s; }
.wave-backdrop span:nth-child(3) { animation-delay: -0.7s; }
.wave-backdrop span:nth-child(4) { animation-delay: -1.05s; }
.wave-backdrop span:nth-child(5) { animation-delay: -1.4s; }
.wave-backdrop span:nth-child(6) { animation-delay: -1.75s; }
.wave-backdrop span:nth-child(7) { animation-delay: -2.1s; }
.wave-backdrop span:nth-child(8) { animation-delay: -2.45s; }

@keyframes soundWave {
  0%,
  100% {
    transform: scaleY(0.42);
  }
  45% {
    transform: scaleY(1.35);
  }
  70% {
    transform: scaleY(0.72);
  }
}

.home-actions {
  position: relative;
  z-index: 1;
  grid-row: 3;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  place-content: center;
  align-items: center;
  gap: 16px;
}

.home-action-button {
  min-height: 82px;
  padding: 18px 24px;
  font-size: 1.18rem;
}

.home-theme-panel {
  position: relative;
  z-index: 1;
  grid-row: 5;
  justify-self: center;
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.home-footer {
  position: relative;
  z-index: 1;
  grid-row: 7;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
}

.home-footer p {
  margin: 0;
}

.home-footer a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.users-online {
  padding-top: 4px;
  color: var(--accent-2);
  font-weight: 800;
}

.users-online strong {
  color: var(--text);
}

.theme-row,
.theme-row.compact,
.room-theme-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 0;
}

.theme-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 999px;
  padding: 0;
  color: transparent;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.theme-button[data-theme="green"] {
  background: linear-gradient(145deg, #5fd3bc, #b7f25c);
}

.theme-button[data-theme="blue"] {
  background: linear-gradient(145deg, #60c8ff, #0f4d8a);
}

.theme-button[data-theme="purple"] {
  background: linear-gradient(145deg, #c48cff, #5d2b86);
}

.theme-button[data-theme="black"] {
  background: linear-gradient(145deg, #e8ecef, #111315 64%);
}

.theme-button[data-theme="red"] {
  background: linear-gradient(145deg, #ff7a70, #7a1c27);
}

.theme-button[data-theme="yellow"] {
  background: linear-gradient(145deg, #ffd45a, #4b6b40);
}

.theme-button.is-active {
  border-color: var(--text);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: color-mix(in srgb, var(--surface) 96%, #000);
  box-shadow: var(--shadow);
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.room-probe {
  min-height: 22px;
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.panel-title-row h2 {
  margin: 0;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.audio-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  box-shadow: none;
}

.inline-value {
  float: right;
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.volume-control {
  position: relative;
  justify-self: start;
}

.volume-trigger {
  display: inline-flex;
  width: auto;
  min-width: 86px;
  gap: 8px;
  padding: 0 10px;
}

.volume-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.volume-control[data-volume-level="mute"] .volume-wave,
.volume-control[data-volume-level="low"] .volume-wave-two {
  display: none;
}

.volume-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 6;
  width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.volume-control:hover .volume-popover,
.volume-control:focus-within .volume-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.preserve-audio-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.release-notes-button {
  position: fixed;
  right: 24px;
  bottom: 22px;
  z-index: 3;
}

.admin-config-button {
  position: fixed;
  right: 24px;
  bottom: 74px;
  z-index: 3;
}

.release-notes-card {
  width: min(720px, 100%);
}

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

.release-notes-list {
  display: grid;
  gap: 12px;
  max-height: min(58vh, 520px);
  overflow: auto;
}

.release-version-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1114;
  overflow: hidden;
}

.release-version-item summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
}

.release-version-item summary span {
  color: var(--muted);
  font-size: 0.8rem;
}

.release-version-body {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.release-note-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d1114;
}

.admin-config-card {
  width: min(860px, 100%);
}

.admin-config-status,
.identity-tooltip {
  color: var(--muted);
  font-size: 0.88rem;
}

.identity-tooltip {
  margin: -4px 0 12px;
  border: 1px solid color-mix(in srgb, #f5be54 48%, var(--line));
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, #f5be54 10%, var(--surface));
  color: #ffe3a5;
}

.admin-config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.admin-config-field {
  margin-bottom: 0;
}

.admin-config-switch {
  align-self: end;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.admin-config-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.release-note-item h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.release-note-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions.single {
  grid-template-columns: 1fr;
}

.karaoke-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  box-shadow: none;
}

.karaoke-status {
  align-self: center;
  color: var(--accent-2);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.karaoke-status.sync-very-good {
  color: #55d66b;
}

.karaoke-status.sync-good {
  color: #f2c94c;
}

.karaoke-status.sync-bad {
  color: #ff5f5f;
}

.karaoke-status.sync-very-bad {
  color: #ff2f2f;
}

.karaoke-load-row,
.karaoke-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.karaoke-controls {
  grid-template-columns: auto auto minmax(180px, 1fr);
}

.karaoke-load-row .field,
.karaoke-controls .slider-field {
  margin-bottom: 0;
}

.karaoke-progress {
  display: grid;
  gap: 8px;
}

.karaoke-time-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.karaoke-progress input[type="range"] {
  width: 100%;
  margin: 0;
}

.karaoke-track-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.karaoke-track {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #0d1114;
}

.karaoke-track.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #0d1114);
}

.karaoke-track-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.karaoke-track-copy strong,
.karaoke-track-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.karaoke-track-copy span,
.karaoke-duration {
  color: var(--muted);
  font-size: 0.82rem;
}

.audio-bar .field,
.audio-bar .slider-field {
  margin-bottom: 0;
}

.audio-bar button {
  white-space: nowrap;
}

.chat-toggle {
  position: relative;
}

.chat-unread {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 999px;
  padding: 0 6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
}

@media (max-width: 1020px) {
  .home-grid,
  .room-layout {
    grid-template-columns: 1fr;
  }

  .audio-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .room-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .theme-row,
  .status-strip,
  .stream-metrics,
  .input-row,
  .input-row.three,
  .control-row {
    grid-template-columns: 1fr;
  }

  .home-actions,
  .audio-bar,
  .karaoke-load-row,
  .karaoke-controls,
  .karaoke-track,
  .admin-config-form,
  .admin-config-actions {
    grid-template-columns: 1fr;
  }

  .identity-bar {
    top: 10px;
    right: 10px;
  }

  .notification-stack {
    left: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .segmented {
    grid-template-columns: 1fr;
  }
}
