/* VOX web peer: a compact dark UI that mirrors the native client's density. */

:root {
  --bg: #090c12;
  --panel: #0e121b;
  --card: #131823;
  --line: #222a38;
  --text: #dee4ee;
  --dim: #8b96a8;
  --accent: #40dcc8;
  --warn: #ffbe5a;
  --bad: #ff646e;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--dim); font-size: 12px; }
.sep { width: 1px; height: 14px; background: var(--line); display: inline-block; }

/* --- top bar ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.logo { color: var(--accent); font-weight: 700; font-size: 20px; letter-spacing: 0.5px; }
.tagline { color: var(--dim); font-size: 11px; }

.status { display: flex; align-items: center; gap: 8px; font-size: 12px; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #5a6474; display: inline-block;
}
.dot.connecting { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.connected { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.offline { background: #5a6474; }

@keyframes pulse { 50% { opacity: 0.35; } }

.pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.pill.ok { color: var(--accent); border-color: rgba(64, 220, 200, 0.4); }
.pill.warn { color: var(--warn); border-color: rgba(255, 190, 90, 0.4); }

.actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* --- controls ---------------------------------------------------------- */

button {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #1a2230;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #212b3b; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { border-color: rgba(64, 220, 200, 0.45); color: var(--accent); }
button.toggle[aria-pressed="true"] {
  background: rgba(255, 100, 110, 0.14);
  border-color: rgba(255, 100, 110, 0.5);
  color: var(--bad);
}
kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 3px;
  color: var(--dim);
}

input[type="text"], input[type="password"] {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #0a0f17;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  width: 100%;
}
input[type="range"] { accent-color: var(--accent); width: 100%; }
input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- layout ------------------------------------------------------------ */

main {
  display: grid;
  gap: 12px;
  padding: 12px 16px 40px;
  max-width: 1100px;
  margin: 0 auto;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-head .state { margin-left: auto; font-size: 11px; color: var(--dim); }
.panel-head .state.active { color: var(--accent); }
.panel-head .state.muted { color: var(--bad); }
.panel-head #identity { margin-left: auto; }

/* --- meter ------------------------------------------------------------- */

.meter {
  height: 10px;
  background: #080b11;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1f8f80, var(--accent));
  transition: width 60ms linear;
}

.capture-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.capture-controls .field { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; }
.capture-controls .field span { font-size: 11px; color: var(--dim); white-space: nowrap; }
.capture-controls output { white-space: nowrap; }

/* --- channels ---------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0f141d;
  color: var(--text);
  cursor: pointer;
}
.chip:hover { border-color: var(--dim); }
.chip.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(64, 220, 200, 0.08);
}
.chip .count { color: var(--dim); margin-left: 6px; }

/* --- peers ------------------------------------------------------------- */

.peers { width: 100%; border-collapse: collapse; font-size: 12px; }
.peers th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--dim);
  font-weight: 600;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
.peers td { padding: 5px 8px; border-bottom: 1px solid rgba(34, 42, 56, 0.5); }
.peers tr:last-child td { border-bottom: none; }
.peers tr.empty td { color: var(--dim); padding: 14px 8px; }
.peer-name { display: flex; align-items: center; gap: 6px; }

.speaking {
  width: 7px; height: 7px; border-radius: 50%;
  background: #2d3442; display: inline-block;
}
.speaking.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 190, 90, 0.12);
  color: var(--warn);
  border: 1px solid rgba(255, 190, 90, 0.3);
}

.level-bar {
  width: 60px; height: 7px;
  background: #080b11;
  border-radius: 3px;
  overflow: hidden;
}
.level-bar > i { display: block; height: 100%; background: var(--accent); width: 0; }

/* --- form -------------------------------------------------------------- */

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.form .field { display: flex; flex-direction: column; gap: 4px; }
.form .field span { font-size: 10px; text-transform: uppercase; color: var(--dim); letter-spacing: 0.4px; }
.form .field.wide { grid-column: 1 / -1; }
.form .row { display: flex; gap: 6px; align-items: center; }
.form .row input { flex: 1 1 auto; min-width: 0; }
.form .row button { flex: 0 0 auto; white-space: nowrap; }

.connect .hint { margin-top: 9px; }

.hint { color: var(--dim); font-size: 11px; margin: 10px 0 0; }
.hint code { font-family: var(--mono); color: var(--text); }

/* --- stats ------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 12px;
  margin: 0;
}
.stats dt { font-size: 10px; text-transform: uppercase; color: var(--dim); letter-spacing: 0.4px; }
.stats dd { margin: 0 0 6px; font-family: var(--mono); font-size: 12px; }

/* --- log --------------------------------------------------------------- */

.log ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
}
.log li { padding: 1px 0; }

/* --- toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b2230;
  border: 1px solid var(--line);
  border-left: 3px solid var(--bad);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 12px;
  max-width: min(560px, calc(100vw - 32px));
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

@media (max-width: 720px) {
  .actions { margin-left: 0; width: 100%; }
  .peers { font-size: 11px; }
  .peers th:nth-child(4), .peers td:nth-child(4),
  .peers th:nth-child(7), .peers td:nth-child(7) { display: none; }
}


/* Optional video plane. Hidden entirely in audio-only builds. */
.video-panel .panel-head {
  gap: 10px;
  flex-wrap: wrap;
}
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.video-tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line, #30363d);
  border-radius: 8px;
  background: #05070a;
  aspect-ratio: 16 / 9;
}
.video-tile.local {
  border-color: var(--ok, #40c9a0);
}
.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #e6edf3;
  font-size: 12px;
}
