@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    color-scheme: dark;
    --night: #020617;
    --panel: #0f172a;
    --edge: #334155;
    --sky: #38bdf8;
    --sky-bright: #7dd3fc;
    --amber: #fbbf24;
    --text: #cbd5e1;
    --muted: #94a3b8;
    --signal: var(--amber);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100svh;
    background: radial-gradient(ellipse at 50% 12%, #0c4a6e66, transparent 58%), var(--night);
    color: var(--text);
    font: 14px/1.6 Inter, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image: linear-gradient(#38bdf808 1px, transparent 1px), linear-gradient(90deg, #38bdf808 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: linear-gradient(black, transparent);
}
body[data-state="connected"], body[data-state="listen-only"] { --signal: #34d399; }
body[data-state="error"], body[data-state="permission"], body[data-state="missing-token"] { --signal: #fb7185; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: Rajdhani, system-ui, sans-serif; font-weight: 700; line-height: 1.1; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--sky-bright); }
:focus-visible { outline: 2px solid var(--sky-bright); outline-offset: 5px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.site-header {
    max-width: 1200px;
    margin: auto;
    padding: 22px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid #38bdf81a;
}
.brand { display: flex; align-items: center; gap: 12px; font: 700 24px Rajdhani, system-ui, sans-serif; color: #f8fafc; }
.brand img { object-fit: contain; filter: drop-shadow(0 0 12px #38bdf830); }
.brand small { display: block; color: var(--muted); font: 11px Inter, system-ui, sans-serif; }
.header-tag, .eyebrow, .chassis-rail, .display-topline, .tuning-scale, .terminal-footer, .volume-module small, #micStatus {
    font-family: Rajdhani, system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: .15em;
}
.header-tag { display: flex; align-items: center; gap: 10px; color: var(--sky-bright); font-size: 12px; }
.lamp { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; flex-shrink: 0; }
.radio-shell { width: min(1100px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 28px; }
.page-heading { text-align: center; margin-bottom: 30px; animation: arrive .7s ease-out both; }
.eyebrow { color: var(--sky); font-size: 11px; }
.page-heading h1 { color: #f8fafc; font-size: clamp(34px, 4.6vw, 54px); margin: 10px 0 12px; letter-spacing: -.02em; }
.page-heading h1 span { color: var(--sky-bright); }
.page-heading > p:last-child { color: var(--muted); font-size: 13px; }
.radio-chassis {
    position: relative;
    border: 1px solid #475569;
    border-radius: 3px 24px 3px 24px;
    background: linear-gradient(145deg, #1e293b, #0f172a 46%, #162439);
    box-shadow: 0 30px 80px #0009, 0 0 60px #0ea5e910, inset 0 1px 0 #ffffff12;
    padding: 0 12px 12px;
    animation: arrive .8s .1s ease-out both;
}
.radio-chassis::before, .radio-chassis::after {
    content: "+";
    position: absolute;
    bottom: 8px;
    font: 12px monospace;
    color: #64748b;
}
.radio-chassis::before { left: 6px; }
.radio-chassis::after { right: 6px; }
.chassis-rail { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 11px; color: var(--muted); }
.radio-inner { background: #02061799; border: 1px solid #334155; border-radius: 2px 14px 2px 14px; }
.radio-content { padding: 24px; }
.display-assembly { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; gap: 18px; }
.speaker-grille {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 14px 0;
    border: 1px solid #020617;
    border-radius: 3px;
    background: radial-gradient(circle, #020617 1.7px, transparent 2px) 0 0 / 6px 6px, linear-gradient(110deg, #1e293b, #0f172a);
    box-shadow: inset 0 2px 8px #0009;
}
.speaker-grille span { color: #64748b; font: 700 18px Rajdhani, sans-serif; background: #0f172a; padding: 2px 8px; border: 1px solid #334155; }
.signal-display {
    position: relative;
    isolation: isolate;
    min-height: 306px;
    padding: 22px 26px 18px;
    border: 1px solid #0ea5e950;
    border-radius: 2px 12px 2px 12px;
    background: radial-gradient(ellipse at 35% 0%, #07598544, transparent 80%), #020c1b;
    box-shadow: inset 0 0 28px #0009, 0 0 0 4px #020617;
}
.signal-display::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    background: repeating-linear-gradient(transparent 0 3px, #0002 3px 4px);
}
.display-topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #94a3b8; font-size: 10px; }
#statusDot { display: inline-flex; align-items: center; gap: 8px; color: var(--signal); white-space: nowrap; }
.signal-copy { margin-top: 25px; min-height: 106px; }
.signal-copy .eyebrow { color: var(--signal); }
.signal-copy h2 { color: #e0f2fe; font-size: clamp(26px, 3.8vw, 38px); margin: 6px 0 10px; text-shadow: 0 0 28px #38bdf830; }
.signal-copy > p:last-child { max-width: 560px; color: #a8bed2; font-size: 12px; line-height: 1.7; }
.tuning-scale { display: flex; align-items: center; gap: 12px; color: #64748b; font-size: 9px; margin: 18px 0 22px; }
.tuning-track {
    position: relative;
    height: 20px;
    flex: 1;
    border-bottom: 1px solid #0ea5e933;
    background: repeating-linear-gradient(90deg, #38bdf84a 0 1px, transparent 1px 12px) bottom / 100% 8px no-repeat,
        repeating-linear-gradient(90deg, #38bdf84a 0 1px, transparent 1px 60px) bottom / 100% 16px no-repeat;
}
.tuning-track i { position: absolute; width: 2px; top: 0; bottom: -3px; left: 50%; background: var(--signal); box-shadow: 0 0 12px var(--signal); }
body[data-state="standby"] .tuning-track i { animation: tune 6s ease-in-out infinite; }
body[data-state="requesting"] .tuning-track i, body[data-state="connecting"] .tuning-track i,
body[data-state="authenticating"] .tuning-track i, body[data-state="reconnecting"] .tuning-track i { animation: tune 2.5s ease-in-out infinite; }
body[data-state="standby"] #statusDot .lamp, body[data-state="reconnecting"] #statusDot .lamp { animation: breathe 2.5s ease-in-out infinite; }
.connection-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.terminal-button { min-height: 44px; border: 1px solid #334155; border-radius: 2px 9px 2px 9px; padding: 10px 18px; background: #0f172a; color: #cbd5e1; font-weight: 600; font-size: 12px; transition: background .2s, box-shadow .2s; }
.terminal-button:hover:not(:disabled) { background: #1e293b; border-color: var(--sky); }
.primary-button { background: #0ea5e9; border-color: #38bdf8; color: #020617; box-shadow: 0 0 22px #0ea5e926; }
.primary-button:hover:not(:disabled) { background: #38bdf8; box-shadow: 0 0 26px #0ea5e94d; }
.primary-button > span:first-child { font-size: 18px; margin-right: 7px; }
.connection-hint { color: #94a3b8; font-size: 10px; margin-top: 10px; }
fieldset { min-width: 0; border: 0; margin: 0; padding: 0; }
.control-deck { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px 52px; gap: 26px; align-items: center; margin: 26px 0 30px; padding: 22px 0; border-block: 1px solid #33415580; }
.volume-module label { display: flex; align-items: center; gap: 10px; color: #e2e8f0; font: 600 19px Rajdhani, sans-serif; }
output { margin-left: auto; color: var(--sky-bright); font: 12px ui-monospace, monospace; }
.knob-mark { display: inline-block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #475569; background: conic-gradient(from 225deg, #64748b, #1e293b 35%, #0f172a 70%, #64748b); box-shadow: inset 0 0 0 3px #0f172a, 0 2px 5px #0009; position: relative; }
.knob-mark::after { content: ""; width: 2px; height: 7px; position: absolute; top: 3px; left: 12px; background: var(--sky); transform: rotate(25deg); }
.volume-module small { color: var(--muted); font-size: 9px; }
input[type="range"] { display: block; appearance: none; width: 100%; height: 6px; margin: 18px 0 14px; border-radius: 2px; background: linear-gradient(90deg, #0ea5e9 var(--level, 0%), #334155 var(--level, 0%)); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 22px; border: 1px solid #bae6fd; border-radius: 2px; background: linear-gradient(90deg, #0c4a6e, #38bdf8); box-shadow: 0 0 10px #38bdf830; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 22px; border: 1px solid #bae6fd; border-radius: 2px; background: #38bdf8; }
input[type="range"]:disabled { cursor: not-allowed; opacity: .45; }
.icon-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex-shrink: 0; border: 1px solid #475569; background: linear-gradient(145deg, #1e293b, #0f172a); border-radius: 3px 10px 3px 10px; color: var(--sky-bright); box-shadow: 0 3px 0 #020617; }
.icon-button svg { width: 25px; height: 25px; }
.icon-button:hover:not(:disabled) { border-color: var(--sky); background: #0c4a6e; }
.mutedButton, #mutedButton { color: #fb7185; }
.mic-module { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; }
#micStatus { font-size: 9px; color: var(--muted); white-space: nowrap; }
body[data-speaking="true"] #micStatus { color: #34d399; }
#speakingHalo { position: absolute; top: 0; width: 48px; height: 48px; border-radius: 10px; box-shadow: 0 0 22px #34d39980; pointer-events: none; }
.nearby-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.nearby-heading h2 { font-size: 28px; color: #f1f5f9; margin-top: 4px; }
#searchDiv { position: relative; width: min(240px, 50%); }
input[type="text"], select { width: 100%; background: #020617; border: 1px solid #334155; border-radius: 3px; padding: 10px 12px; color: var(--text); }
input[type="text"] { padding-right: 38px; font-size: 12px; }
input::placeholder { color: #94a3b8; }
.search-icon { position: absolute; top: 12px; right: 12px; color: #64748b; pointer-events: none; }
.search-icon svg { width: 16px; height: 16px; }
.network-count { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; margin: 16px 0; }
.network-count .lamp { color: #475569; box-shadow: none; }
body[data-state="connected"] .network-count .lamp, body[data-state="listen-only"] .network-count .lamp { color: #34d399; box-shadow: 0 0 10px #34d39966; }
#userCount { color: var(--sky-bright); font-family: ui-monospace, monospace; }
.empty-users { display: flex; flex-direction: column; align-items: center; padding: 24px 16px 20px; border: 1px dashed #334155; background: #02061755; text-align: center; }
.empty-users h3 { color: #cbd5e1; font-size: 21px; margin: 12px 0 7px; }
.empty-users p { font-size: 11px; color: var(--muted); }
.empty-radar { width: 32px; height: 32px; border: 1px solid #0ea5e94d; border-radius: 50%; box-shadow: inset 0 0 0 7px #020617, inset 0 0 0 8px #0ea5e94d; position: relative; }
.empty-radar::after { content: ""; position: absolute; inset: 6px; border-top: 1px solid var(--sky); border-radius: 50%; animation: orbit 8s linear infinite; }
#users { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-height: 340px; overflow: auto; padding: 3px; }
.user { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid #334155; background: #0f172a; border-radius: 3px 10px 3px 10px; }
.logo { object-fit: cover; border: 1px solid #475569; image-rendering: pixelated; flex-shrink: 0; }
.user-details { flex: 1; min-width: 0; }
.username { color: #e0f2fe; font-size: 12px; overflow-wrap: anywhere; }
.user .icon-button { width: 36px; height: 44px; }
.user .icon-button svg { width: 20px; height: 20px; }
.user-volume { margin-bottom: 4px !important; }
.terminal-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 24px; border-top: 1px solid #33415580; font-size: 10px; color: var(--muted); }
.terminal-footer > span { display: flex; gap: 8px; align-items: center; }
.terminal-footer .lamp { color: var(--sky); }
.terminal-footer a { text-decoration: underline; text-underline-offset: 3px; letter-spacing: .04em; }
.page-footnote { text-align: center; color: #94a3b8; font-size: 11px; margin-top: 22px; }
dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100svh - 48px); padding: 0; margin: auto; overflow: auto; border: 1px solid #0ea5e970; border-radius: 3px 18px 3px 18px; background: #0f172a; color: var(--text); box-shadow: 0 30px 100px #000b; }
dialog::backdrop { background: #020617cc; backdrop-filter: blur(8px); }
.settings-panel { padding: 28px; }
.settings-heading h2 { font-size: 32px; color: #e0f2fe; margin: 8px 0; }
.settings-heading > p:last-child { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
#microphoneSettings > label { display: flex; align-items: center; gap: 12px; margin: 22px 0 8px; font-size: 13px; }
#microphoneSelectDiv label { display: block; margin-bottom: 8px; }
#thresholdDescription { font-size: 11px; color: var(--muted); }
meter { width: 100%; height: 8px; display: block; margin: 12px 0 20px; }
.setting-toggle { display: flex; gap: 12px; align-items: center; margin-top: 20px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: #0ea5e9; flex-shrink: 0; }
.setting-toggle label { font-size: 13px; }
.setting-toggle small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
fieldset:disabled .setting-toggle, #microphoneSettings:disabled { opacity: .6; }
.settings-footer { display: flex; justify-content: flex-end; margin-top: 26px; }
.error-note { color: #fecdd3; background: #88133733; border: 1px solid #fb71854d; padding: 12px 16px; margin: 12px 0; font-size: 12px; overflow-wrap: anywhere; }
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: #020617; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::selection { background: #0ea5e955; color: #f8fafc; }
@keyframes tune { 0%, 100% { left: 12%; } 50% { left: 88%; } }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 850px) {
    .display-assembly { grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 12px; }
    .speaker-grille span { font-size: 12px; padding: 2px; }
    #users { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .control-deck { gap: 18px; }
}
@media (max-width: 600px) {
    .site-header { padding: 16px 20px; }
    .brand { font-size: 22px; }
    .brand small { font-size: 9px; }
    .header-tag { display: none; }
    .radio-shell { width: calc(100% - 24px); padding-top: 28px; }
    .page-heading { padding-inline: 10px; margin-bottom: 22px; }
    .page-heading h1 span { display: block; }
    .radio-chassis { padding: 0 6px 8px; }
    .chassis-rail { font-size: 9px; padding: 12px 8px; letter-spacing: .08em; }
    .radio-content { padding: 14px; }
    .display-assembly { grid-template-columns: minmax(0, 1fr); }
    .speaker-grille { display: none; }
    .signal-display { padding: 18px 16px; }
    .display-topline { font-size: 8px; letter-spacing: .07em; }
    .signal-copy { min-height: 130px; }
    .control-deck { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 22px 0; }
    .volume-module label { gap: 6px; font-size: 17px; }
    .knob-mark { width: 24px; height: 24px; }
    .knob-mark::after { left: 9px; }
    .volume-module small { font-size: 8px; letter-spacing: .08em; }
    .mic-module { flex-direction: row; justify-content: center; }
    #paramButton { justify-self: center; }
    .nearby-heading { align-items: stretch; flex-direction: column; gap: 14px; }
    #searchDiv { width: 100%; }
    #users { grid-template-columns: minmax(0, 1fr); }
    .terminal-footer { padding: 14px; flex-wrap: wrap; gap: 10px; font-size: 9px; }
    .settings-panel { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
