:root {
  --bg: #0f172a;
  --bg-paper: #1e293b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #22c55e;
  --accent-text: #06210f;
  --danger: #ef4444;
  --line: rgba(148, 163, 184, 0.22);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  padding: 12px 12px 20px;
  overflow-y: auto;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex: 0 0 auto;
}

.titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

h1 {
  font-size: 14px;
  margin: 0;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  color: var(--text-dim);
  font-size: 11px;
}

.dot {
  margin-left: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.off {
  background: #64748b;
}

.dot.on {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.dot.speaking {
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.9);
}

.dot.muted {
  background: var(--danger);
}

.card {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
}

h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 8px;
  font-weight: 600;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row.wrap {
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
  font-family: inherit;
}

button:hover:not(:disabled) {
  border-color: var(--text-dim);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  flex: 1;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

button.primary.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.icon {
  min-width: 58px;
}

button.icon[aria-pressed="true"] {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

button.small {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
}

button.ghost {
  color: var(--text-dim);
}

button.ghost:hover:not(:disabled) {
  color: var(--text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 11px;
}

.field span {
  display: flex;
  justify-content: space-between;
}

.field output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

select,
input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
}

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

.meter {
  height: 5px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transition: width 0.08s linear;
}

.hint {
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 1.45;
  margin: 8px 0 0;
}

.hintbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

.value {
  font-weight: 600;
  font-size: 12px;
  margin-right: auto;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.peer {
  display: grid;
  grid-template-columns: 10px 1fr 52px 78px;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.peer.speaking {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.peer-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
}

.peer-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.peer-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-sub {
  color: var(--text-dim);
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-meter {
  height: 4px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  overflow: hidden;
}

.peer-meter div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.08s linear;
}

.peer.offline .peer-name {
  color: var(--text-dim);
}

.peer-volume {
  width: 100%;
}

#log {
  margin: 8px 0 0;
  max-height: 180px;
  overflow: auto;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Mono", Consolas, monospace;
}

#log .err {
  color: #fca5a5;
}

#log .warn {
  color: #fcd34d;
}

h2.toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0;
}

#diag-body {
  margin-top: 8px;
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 9.5px;
  margin-top: 4px;
}

#toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
}

.toast {
  background: #0b1220;
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-dim);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}

.toast.success {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warn {
  border-left-color: #f59e0b;
}

.toast.info {
  border-left-color: #38bdf8;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
