:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #1e293b;
  --accent: #38bdf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --danger: #f87171;
  --ok: #4ade80;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.status {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: #fbbf24;
}

.live-panel {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #0c1222;
  border: 1px solid #334155;
  border-radius: 10px;
  font-size: 0.85rem;
}

.live-panel__status {
  margin: 0;
  color: var(--ok);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-panel__heard {
  margin: 0.35rem 0 0;
  color: var(--muted);
  word-break: break-word;
}

.live-panel__heard span {
  color: var(--accent);
  font-weight: 600;
}

.live-panel__hint {
  margin: 0.25rem 0 0;
  font-size: 0.7rem;
  color: #64748b;
}

.log {
  flex: 1;
  min-height: 0;
  max-height: 50vh;
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--card);
  border-radius: 12px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.45;
}

.log .msg {
  margin-bottom: 0.75rem;
}

.log .msg--user {
  color: var(--accent);
}

.log .msg--bot {
  color: var(--text);
}

.log .msg--sys {
  color: var(--muted);
  font-size: 0.8rem;
}

.controls {
  text-align: center;
}

.mic {
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #0284c7, var(--accent));
  color: #0f172a;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
}

.mic:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.mic.wake {
  background: linear-gradient(145deg, #0ea5e9, #7dd3fc);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.45);
  animation: wakePulse 2.4s ease-in-out infinite;
}

.mic.listening {
  transform: scale(1.06);
  background: linear-gradient(145deg, var(--danger), #fb923c);
  box-shadow: 0 8px 28px rgba(248, 113, 113, 0.45);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes wakePulse {
  50% {
    box-shadow: 0 8px 32px rgba(125, 211, 252, 0.55);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.92;
  }
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.wake-toggle {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #334155;
  background: transparent;
  color: var(--ok);
  font-size: 0.75rem;
  cursor: pointer;
}

.wake-toggle--off {
  color: var(--muted);
}

.hint code {
  font-size: 0.85em;
}

.text-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.text-form input {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

.text-form button {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}
