:root {
  --bg: #f6f7f9;
  --fg: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b91c1c;
  --ok: #047857;
  --warn: #b45309;
  --card: #ffffff;
  --surface: #f3f4f6;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: grid;
  place-items: start center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

#hint {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.field select {
  width: 100%;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  padding: 0.75rem 2.5rem 0.75rem 0.85rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.field select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* Connection status row */
.call-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-idle { background: var(--muted); }
.dot-connecting { background: var(--warn); animation: pulse 1s infinite; }
.dot-connected { background: var(--ok); }
.dot-error { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.status-text { flex: 1; }

.call-timer {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--muted);
}
.call-timer.active { color: var(--accent); font-weight: 600; }

/* Primary button */
button.primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease;
  width: 100%;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary.danger { background: var(--danger); }
button.primary.danger:hover:not(:disabled) { background: #991b1b; }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Transcript */
.transcript {
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}
.transcript:empty { display: none; }

.msg { margin-bottom: 0.6rem; }
.msg:last-child { margin-bottom: 0; }
.msg .speaker {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}
.msg.agent .speaker { color: var(--accent); }
.msg.user .speaker { color: var(--ok); }
.msg .text { color: var(--fg); }
.msg.interim .text { color: var(--muted); font-style: italic; }

/* Event log */
.log-wrap {
  margin-top: 1rem;
  font-size: 0.85rem;
}
.log-wrap summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
  padding: 0.25rem 0;
}
.log-wrap summary:hover { color: var(--fg); }

.log {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 160px;
  overflow-y: auto;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
}
.log:empty::before { content: "No events yet."; color: var(--muted); }
.log .ts { color: #9ca3af; margin-right: 0.5rem; }
.log .info { color: var(--ok); }
.log .error { color: var(--danger); }
