:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #0a0a12;
  --surface: #141422;
  --raised: #242437;
  --well: #0d0d17;
  --line: #302840;
  --text: #e8e0f0;
  --muted: #a59bb3;
  --accent: #ff4286;
  --accent-ink: #200011;
  --accent-soft: #39172e;
  --voice: #00ffcc;
  --voice-soft: #142b2a;
  --warning: #ffe04a;
  --danger: #ff727a;
  --danger-fill: #ff414b;
  --danger-ink: #180607;
  --danger-soft: #30151f;
  --card-shadow: none;
  --voice-glow: 0 0 16px #00ffcc26;
  --danger-glow: 0 0 16px #ff414b24;
  --panel-glow: 0 0 24px #ff2d781c;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text);
  background: var(--bg);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fa;
  --surface: #fff;
  --raised: #edf2f7;
  --well: #f4f7fa;
  --line: #dce4ef;
  --text: #0f172a;
  --muted: #475569;
  --accent: #006c49;
  --accent-ink: #fff;
  --accent-soft: #e1f8ee;
  --voice: #007b56;
  --voice-soft: #e8faf3;
  --warning: #8a5500;
  --danger: #a71723;
  --danger-fill: #d82126;
  --danger-ink: #fff;
  --danger-soft: #fff3f3;
  --card-shadow: 0 1px 3px #0f172a0b;
  --voice-glow: 0 0 0 1px #10b981;
  --danger-glow: none;
  --panel-glow: var(--card-shadow);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { color: var(--accent-ink); background: var(--accent); }
.shell { width: min(100%, 1720px); margin-inline: auto; padding-inline: clamp(12px, 2.5vw, 36px); }
.topbar { min-height: 65px; display: flex; align-items: center; gap: 18px; position: relative; isolation: isolate; }
.topbar::before { content: ""; position: absolute; z-index: -1; inset: 0; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 0 0 100vmax var(--surface); clip-path: inset(0 -100vmax); }
.brand { flex: 0 1 106px; min-width: 60px; }
.brand img { display: block; width: 100%; height: auto; }
.brand .brand-light, .theme-moon { display: none; }
[data-theme="light"] :is(.brand-dark, .theme-sun) { display: none; }
[data-theme="light"] :is(.brand-light, .theme-moon) { display: block; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.room-status { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); color: var(--muted); font: 600 11px var(--mono); }
.room-status[data-connected] { color: var(--voice); }
.status-dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
#duration { padding-inline-start: 7px; border-inline-start: 1px solid var(--line); }
.theme-toggle { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--raised); font-size: 20px; line-height: 1; }
.theme-toggle:hover { color: var(--accent); }

.icon { display: inline-block; flex: none; position: relative; color: inherit; }
.mic { width: 7px; height: 11px; border: 1.5px solid currentColor; border-radius: 5px; margin-inline: 4px; margin-bottom: 4px; }
.mic::before { content: ""; position: absolute; inset: 3px -4px -4px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px; }
.mic::after { content: ""; position: absolute; width: 1px; height: 3px; top: 11px; left: 1.5px; background: currentColor; }
.headphones { width: 14px; height: 13px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 8px 8px 0 0; }
.headphones::before, .headphones::after { content: ""; position: absolute; bottom: 0; width: 4px; height: 6px; border: 1px solid currentColor; border-radius: 2px; }
.headphones::before { left: -1px; }
.headphones::after { right: -1px; }
.speaker-icon { width: 10px; height: 10px; background: currentColor; clip-path: polygon(0 33%, 33% 33%, 80% 0, 80% 100%, 33% 67%, 0 67%); flex: none; }

.layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; padding-block: clamp(20px, 2.5vw, 32px) 24px; }
.layout[data-view="servers"] { align-items: start; }
.layout[data-view="room"] { grid-template-columns: minmax(0, 2.05fr) minmax(285px, 1fr); align-items: start; }
.stage, .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--card-shadow); }
.panel { min-width: 0; padding: clamp(16px, 2vw, 25px); }
.stage { position: relative; min-height: 440px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(20px, 4vw, 48px); isolation: isolate; }
.stage-content { position: relative; z-index: 1; }
h1, h2, h3, p { margin: 0; }
.eyebrow { color: var(--voice); font: 700 11px var(--mono); letter-spacing: .12em; margin-bottom: 16px; }
.stage h1 { max-width: 12ch; font-size: clamp(36px, 6vw, 68px); letter-spacing: -.065em; line-height: 1; }
.stage h1 span { color: var(--accent); }
.stage-note { margin-top: 16px; color: var(--muted); line-height: 1.6; }
.stage-status { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); color: var(--voice); font: 12px var(--mono); }
.visual { position: absolute; z-index: -1; width: min(60%, 350px); aspect-ratio: 1; right: -5%; bottom: -12%; opacity: .8; }
.orbit, .orb { position: absolute; border-radius: 50%; inset: 50% auto auto 50%; transform: translate(-50%, -50%); aspect-ratio: 1; }
.orbit { border: 1px solid var(--line); }
.orbit-outer { width: 100%; }
.orbit-middle { width: 78%; border-style: dashed; }
.orbit-inner { width: 57%; }
.orb { width: 43%; display: grid; place-items: center; background: var(--accent-soft); }
.wave { display: flex; align-items: center; gap: 6px; }
.wave i { width: 3px; height: 14px; border-radius: 4px; background: var(--accent); }
.wave i:nth-child(2n) { height: 26px; }
.wave i:nth-child(4) { height: 39px; }

.roster { min-width: 0; }
.roster-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 24px; margin: 0 3px 12px; }
.roster-heading h1 { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.roster-heading p { color: var(--muted); font: 600 11px var(--mono); white-space: nowrap; }
.people-icon { width: 15px; height: 15px; position: relative; color: var(--voice); }
.people-icon::before { content: ""; position: absolute; left: 5px; top: 2px; width: 5px; height: 5px; border: 1px solid currentColor; border-radius: 50%; box-shadow: 4px 0 0 -1px currentColor; }
.people-icon::after { content: ""; position: absolute; left: 2px; bottom: 1px; width: 11px; height: 6px; border: 1px solid currentColor; border-radius: 6px 6px 2px 2px; }
.roster-empty { padding: 18px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; }
.participants { display: grid; gap: 11px; list-style: none; padding: 0; margin: 0; }
.participant-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--card-shadow); }
.participant-card:is([data-quality="unstable"], [data-quality="disconnected"], [data-quality="failed"]) { border-color: color-mix(in srgb, var(--danger) 46%, var(--line)); box-shadow: var(--danger-glow); }
[data-theme="light"] .participant-card:is([data-quality="unstable"], [data-quality="disconnected"], [data-quality="failed"]):not([data-speaking]) { background: var(--danger-soft); }
.participant-card[data-speaking] { border-color: var(--voice); box-shadow: var(--voice-glow); }
.participant-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 12px; }
.participant-profile, .self-heading { display: flex; align-items: center; min-width: 0; gap: 10px; }
.participant-avatar { display: grid; place-items: center; position: relative; flex: none; width: 33px; height: 33px; border: 1px solid var(--line); border-radius: 5px; background: var(--raised); color: var(--muted); font: 700 11px var(--mono); }
[data-speaking] .participant-avatar { color: var(--voice); background: var(--voice-soft); }
[data-speaking] .participant-avatar::after { content: ""; width: 7px; height: 7px; position: absolute; top: -2px; right: -2px; background: var(--voice); border-radius: 50%; box-shadow: var(--voice-glow); }
.participant-identity { min-width: 0; display: grid; gap: 3px; }
.participant-name { overflow-wrap: anywhere; font-size: 14px; font-weight: 750; line-height: 1.15; }
.participant-status { color: var(--muted); font: 11px/1.2 var(--mono); overflow-wrap: anywhere; }
[data-speaking] .participant-status { color: var(--voice); }
.participant-card:is([data-quality="unstable"], [data-quality="disconnected"], [data-quality="failed"]) .participant-status { color: var(--danger); }
.participant-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.connection-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; gap: 5px; min-height: 29px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--well); font: 600 11px var(--mono); white-space: nowrap; }
.connection-toggle:hover, .connection-toggle[aria-expanded="true"] { border-color: currentColor; }
.connection-toggle[data-quality="good"] { color: var(--voice); }
.connection-toggle[data-quality="connecting"] { color: var(--warning); }
.connection-toggle:is([data-quality="unstable"], [data-quality="disconnected"], [data-quality="failed"]) { color: var(--danger); background: var(--danger-soft); }
.signal-bars { display: flex; align-items: end; gap: 1px; }
.signal-bars i { width: 2px; height: 4px; border-radius: 1px; background: currentColor; }
.signal-bars i:nth-child(2) { height: 7px; }
.signal-bars i:nth-child(3) { height: 10px; }
.connection-toggle:not([data-quality="good"]) .signal-bars i:last-child, .connection-toggle[data-quality="failed"] .signal-bars i:nth-child(2) { opacity: .3; }
.participant-volume { min-width: 0; width: 152px; min-height: 29px; display: grid; grid-template-columns: auto minmax(0, 1fr) 4ch; align-items: center; gap: 6px; margin: 0; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--raised); color: var(--muted); font: 600 11px var(--mono); }
.participant-volume input { width: 100%; min-width: 0; margin: 0; accent-color: var(--voice); cursor: pointer; }
.volume-value { text-align: end; }
.connection-details { margin: 0 12px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--well); color: var(--muted); font-size: 12px; }
.connection-details h3 { color: var(--text); font-size: 12px; margin-bottom: 3px; }
.connection-details dl { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 14px; margin: 7px 0 0; font: 11px var(--mono); }
.connection-details dl div { display: flex; gap: 5px; }
.connection-details dd { margin: 0; color: var(--text); font-weight: 700; white-space: nowrap; }

.layout[data-view="room"] .panel { border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); box-shadow: var(--panel-glow); }
[data-theme="light"] .layout[data-view="room"] .panel { border-color: var(--line); }
.self-heading { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.self-heading .participant-avatar { width: 40px; height: 40px; border-radius: 8px; color: var(--accent); background: var(--accent-soft); }
#room-title { margin: 0; overflow-wrap: anywhere; font-size: 17px; letter-spacing: -.02em; }
#room-title small { color: var(--accent); background: var(--accent-soft); padding: 2px 5px; border-radius: 3px; font: 700 11px var(--mono); }
#self-mic-status { color: var(--voice); font: 11px var(--mono); }
[data-muted] #self-mic-status { color: var(--danger); }
.input-monitor, .room-telemetry { padding: 11px; margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); }
.input-monitor > div { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.input-monitor label { display: flex; align-items: center; gap: 5px; margin: 0; color: var(--muted); font: 11px var(--mono); }
.input-monitor .mic { color: var(--accent); }
#input-value { color: var(--voice); font: 700 11px var(--mono); white-space: nowrap; }
#input-meter { display: block; width: 100%; height: 10px; margin: 8px 0 6px; appearance: none; background: var(--raised); border: 0; border-radius: 3px; overflow: hidden; }
#input-meter::-webkit-meter-bar { background: var(--raised); border: 0; border-radius: 3px; }
#input-meter::-webkit-meter-optimum-value { background: var(--voice); }
#input-meter::-moz-meter-bar { background: var(--voice); }
.meter-scale { color: var(--muted); font: 9px var(--mono); }
.gate-control { flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.gate-control input[type="checkbox"] { margin: 0; accent-color: var(--voice); }
.gate-threshold input { width: 58px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: var(--surface); }
#gate-status { margin: 6px 0 0; font-size: 12px; }
#gate-status:empty { display: none; }
.room-controls { display: grid; gap: 8px; margin-top: 20px; }
.noise-control { margin-top: 4px; }
.noise-control select { width: 100%; min-height: 38px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); color: var(--text); font-size: 13px; }
.noise-control .form-note { margin: 5px 0 0; font-size: 12px; }
.noise-control .form-note:empty { display: none; }
.room-audio-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.room-audio-controls .button { min-height: 82px; flex-direction: column; padding: 7px 4px; font-size: 12px; }
.control-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 5px; background: var(--well); color: inherit; }
#mute:not([aria-pressed="true"]) .control-icon { color: var(--voice); background: var(--voice-soft); }
.room-telemetry h3 { margin-bottom: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.room-telemetry dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.room-telemetry dl div { padding: 6px 3px; text-align: center; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.room-telemetry dt { color: var(--muted); font: 10px var(--mono); }
.room-telemetry dd { margin: 4px 0 0; color: var(--voice); font: 700 12px var(--mono); }
#leave { margin-top: 19px; background: var(--danger-fill); color: var(--danger-ink); box-shadow: var(--danger-glow); }
#leave:hover { filter: brightness(.9); }
.room-invite { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.room-invite summary { padding-block: 4px; color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; }
.room-invite[open] summary { margin-bottom: 9px; }
.room-invite .form-note { font-size: 12px; }
.room-invite .room-note { margin-bottom: 0; }
#room-server { overflow-wrap: anywhere; }

h2 { font-size: 26px; margin: 15px 0; letter-spacing: -.035em; }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); background: var(--well); border-radius: 8px; }
.segments button { min-height: 38px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 650; }
.segments button[aria-pressed="true"] { border-color: var(--line); background: var(--raised); color: var(--text); }
form { margin-top: 17px; }
#room-form { display: grid; gap: 14px; }
#room-form .field, #create-note { margin-bottom: 0; }
.room-form-buttons { display: grid; gap: 8px; }
.form-note, .muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.form-note { margin-bottom: 13px; }
.room-note { margin-top: 9px; }
.panel-foot { display: flex; gap: 6px; align-items: center; border-top: 1px solid var(--line); margin-top: 17px; padding-top: 13px; font-size: 12px; }
.servers { margin-top: 12px; color: var(--accent); font-size: 13px; }
.servers summary { width: fit-content; padding: 4px 0; cursor: pointer; }
.layout[data-view="servers"] .servers { margin-top: 0; }
.layout[data-view="servers"] .servers summary { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font-weight: 650; }
.server-selection { display: flex; gap: 8px; margin-bottom: 14px; }
.server-selection select, .server-input { min-width: 0; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); color: var(--text); }
.server-input { margin-bottom: 11px; resize: vertical; }
.servers input[type="file"] { max-width: 100%; margin-bottom: 10px; }
#server-status:empty { display: none; }
.button { width: 100%; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; font-size: 14px; }
.primary { color: var(--accent-ink); background: var(--accent); }
.primary:hover { filter: brightness(.92); }
.secondary { color: var(--text); border-color: var(--line); background: var(--raised); }
.secondary:hover { border-color: var(--accent); }
.secondary[aria-pressed="true"], .secondary[data-muted] { color: var(--danger); background: var(--danger-soft); }
label { display: block; margin-bottom: 6px; color: var(--text); font-size: 13px; font-weight: 650; }
.field { display: flex; gap: 4px; margin-bottom: 9px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); }
.field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input { min-width: 0; width: 100%; height: 40px; border: 0; outline: none; color: var(--text); background: transparent; }
.field input[type="password"], #room-code { font: 13px var(--mono); }
.field input:focus-visible { outline: none; }
.plain { color: var(--accent); background: transparent; border: 0; padding: 0 4px; font-size: 12px; }
.plain:hover { text-decoration: underline; }
.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-top: 12px; font-size: 13px; }

@media (max-width: 950px) {
  .layout { gap: 16px; }
  .participant-row { gap: 7px; padding-inline: 8px; }
  .participant-volume { width: 114px; }
}

@media (max-width: 720px) {
  .layout, .layout[data-view="room"] { grid-template-columns: minmax(0, 1fr); }
  .layout[data-view="room"] .panel { grid-row: 1; }
  .stage { min-height: 270px; }
  .layout[data-view="servers"] .stage { min-height: 230px; }
}

@media (max-width: 430px) {
  .topbar { flex-wrap: wrap; gap: 5px 8px; padding-block: 8px; }
  .room-status { order: 1; width: fit-content; }
  .participant-actions { gap: 5px; }
}
