:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --line: #262d36;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4ea8ff;
  --speak: #2ea043;
  --warn: #f0883e;
  --err: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 { font-size: 18px; margin: 0; letter-spacing: .02em; }

.link {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.link[data-link="online"] { color: var(--speak); border-color: #1f4d2c; }
.link[data-link="connecting"] { color: var(--warn); border-color: #5a3a1c; }
.link[data-link="offline"] { color: var(--muted); }

.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.orb {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #21262d;
  border: 2px solid var(--line);
  transition: background .2s, border-color .2s, transform .2s;
}

/* L'orbe est le seul retour visuel utilisable d'un coup d'oeil en courant. */
.stage[data-state="listening"] .orb { border-color: var(--accent); animation: breathe 2.4s ease-in-out infinite; }
.stage[data-state="speech"] .orb { background: #17324d; border-color: var(--accent); transform: scale(1.08); }
.stage[data-state="transcribing"] .orb,
.stage[data-state="thinking"] .orb { border-color: var(--warn); animation: spin 1.1s linear infinite; }
.stage[data-state="speaking"] .orb { background: #10331d; border-color: var(--speak); animation: breathe 1.4s ease-in-out infinite; }
.stage[data-state="error"] .orb { border-color: var(--err); }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.status { margin: 0; font-size: 15px; min-height: 1.5em; }

.toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: #21262d;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 13px 30px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 180px;
  min-height: 48px;
}
.toggle:active { background: #2d333b; }
.toggle[data-on="true"] { background: #3d1d1d; border-color: #6b2b2b; }

.hint { margin: 0; font-size: 13px; color: var(--muted); max-width: 34ch; }

.log ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.log li {
  padding: 10px 13px;
  border-radius: 11px;
  max-width: 85%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.log li.user { background: #1c2a3a; align-self: flex-end; }
.log li.assistant { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
.log li.error { background: #3d1d1d; border: 1px solid #6b2b2b; align-self: stretch; max-width: 100%; font-size: 14px; }

footer { color: var(--muted); font-size: 13px; }
.metrics { font-variant-numeric: tabular-nums; min-height: 1.5em; }
summary { cursor: pointer; padding: 6px 0; }
pre {
  background: #010409;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}
