:root {
  --bg: #0f1419;
  --card: #1a2332;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --bot: #1e3a5f;
  --user: #1a3d2e;
  --route: #3d2a1a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--card);
  border: 1px solid var(--border);
}

.status-pill.ok {
  border-color: var(--success);
  color: var(--success);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

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

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
  min-width: 140px;
}

select,
input[type="text"] {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.actions {
  margin-top: 1rem;
}

.btn {
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn.mic {
  background: var(--bot);
  border-color: var(--accent);
  min-width: 160px;
}

.btn.mic.recording {
  background: var(--danger);
  border-color: var(--danger);
  animation: pulse 1s infinite;
}

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

.main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
}

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

.bot-panel,
.user-panel,
.route-panel {
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.bot-panel {
  background: var(--bot);
}

.user-panel {
  background: var(--user);
}

.route-panel {
  background: var(--route);
}

.label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.bot-text {
  margin: 0 0 0.75rem;
  line-height: 1.5;
  font-size: 1.05rem;
}

#botAudio {
  width: 100%;
  margin-top: 0.5rem;
}

.user-input {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.mic-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.text-fallback {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

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

.log {
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}

.log-entry {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry .time {
  color: var(--muted);
  font-size: 0.75rem;
}

.log-entry.bot { color: #93c5fd; }
.log-entry.user { color: #86efac; }
.log-entry.route { color: #fdba74; }
.log-entry.system { color: var(--muted); }

.debug-panel dl {
  margin: 0;
  font-size: 0.85rem;
}

.debug-panel dt {
  color: var(--muted);
  margin-top: 0.6rem;
}

.debug-panel dt:first-child {
  margin-top: 0;
}

.debug-panel dd {
  margin: 0.15rem 0 0;
  word-break: break-word;
}

.progress-wrap {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

#audioTime {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
