:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent2: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

header h1 { font-size: 1.75rem; font-weight: 700; }
.subtitle { color: var(--muted); margin-top: 0.25rem; }

.status-bar { display: flex; gap: 0.5rem; margin-top: 1rem; }

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge.offline { background: #3f1d1d; color: #fca5a5; }
.badge.online { background: #14532d; color: #86efac; }
.badge.idle { background: var(--surface); color: var(--muted); }
.badge.speaking { background: #1e3a5f; color: #93c5fd; animation: pulse 1s infinite; }

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0;
  align-items: center;
}

.btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: white; }
.btn.ptt { background: var(--surface); color: var(--text); border: 2px solid var(--border); }
.btn.ptt.active { background: var(--warn); color: #000; border-color: var(--warn); }
.btn:not(:disabled):active { transform: scale(0.97); }

select {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.captions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .captions { grid-template-columns: 1fr; }
}

.caption-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 140px;
}

.caption-panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.caption-text {
  font-size: 1.25rem;
  line-height: 1.6;
  min-height: 3rem;
}

.lang-tag {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  color: var(--accent2);
}

.latency-dashboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.latency-dashboard h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.latency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.75rem;
}

.metric {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.metric.highlight { border: 1px solid var(--accent); }

.metric .label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.metric .value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.75rem; }

.log-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.log-panel h2 {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#eventLog {
  list-style: none;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--muted);
}

#eventLog li { padding: 0.15rem 0; border-bottom: 1px solid var(--bg); }
