:root {
  --bg: #f5f5fa;
  --card: #ffffff;
  --text: #1c1c28;
  --muted: #6b6b80;
  --accent: #4f46e5;
  --stop: #dc2626;
  --user: #e0e7ff;
  --lea: #ffffff;
  --border: #e2e2ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111118;
    --card: #1c1c26;
    --text: #ececf1;
    --muted: #9a9ab0;
    --user: #2e2a6b;
    --lea: #1c1c26;
    --border: #2c2c3a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
header { text-align: center; }
h1 { margin: 4px 0 0; font-size: 2rem; color: var(--accent); letter-spacing: 0.05em; }
.tagline { margin: 0; color: var(--muted); font-size: 0.95rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
select, input {
  width: 100%;
  font-size: 17px; /* 16px+ prevents iOS zoom on focus */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
#settings.locked { opacity: 0.6; pointer-events: none; }

button.big {
  width: 100%;
  min-height: 64px;
  font-size: 1.3rem;
  font-weight: 600;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}
button.big.stop { background: var(--stop); }
button.big:disabled { opacity: 0.6; }
button.secondary {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.status .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.status.connecting .dot { background: #f59e0b; animation: pulse 1s infinite; }
.status.listening .dot { background: #16a34a; }
.status.speaking .dot { background: var(--accent); animation: pulse 0.6s infinite; }
.status.error .dot { background: var(--stop); }
.status.error { color: var(--stop); }
#timer { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
@keyframes pulse { 50% { opacity: 0.35; } }

.message {
  margin: 0;
  white-space: pre-line;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef3c7;
  color: #7c2d12;
}

#transcript { display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg .who { display: block; font-size: 0.75rem; color: var(--muted); }
.msg.user { align-self: flex-end; background: var(--user); }
.msg.lea { align-self: flex-start; background: var(--lea); }
.msg.pending .text { color: var(--muted); }
