:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --border: #262a31;
  --text: #e8eaed;
  --muted: #8b919a;
  --accent: #6aa8ff;
  --accent-2: #9b7bff;
  --danger: #ff6b6b;
  --user: #1f2a3a;
  --assistant: #1b1f25;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.view { display: flex; flex-direction: column; gap: 16px; min-height: calc(100dvh - 32px); }
.view[hidden] { display: none; }
h1 { margin: 24px 0 0; font-size: 28px; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 0 0 4px; font-size: 20px; }

.card {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
label.row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type="checkbox"] { width: 20px; height: 20px; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; }

button {
  font: inherit; font-weight: 600; color: #0b0d10; background: var(--accent);
  border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.icon { background: transparent; color: var(--muted); font-size: 20px; padding: 6px 10px; }

.hint { margin: 0; font-size: 13px; color: var(--muted); }
code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
.error { margin: 0; min-height: 1.2em; color: var(--danger); font-size: 14px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details[open] { display: flex; flex-direction: column; gap: 10px; }

.topbar { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 18px; }
.usage { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8vh 0 4vh; }

.orb {
  width: min(56vw, 220px); aspect-ratio: 1; border-radius: 50%; padding: 0;
  background: radial-gradient(circle at 35% 30%, #cfe1ff, var(--accent) 45%, var(--accent-2));
  box-shadow: 0 0 0 0 rgba(106, 168, 255, 0.35);
  display: grid; place-items: center;
  transition: transform 0.3s ease, filter 0.3s ease, box-shadow 0.3s ease;
}
.orb-core { width: 30%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.orb[data-state="idle"] { filter: saturate(0.5) brightness(0.7); }
.orb[data-state="connecting"] { animation: pulse 1.2s ease-in-out infinite; }
.orb[data-state="listening"] { box-shadow: 0 0 0 10px rgba(106, 168, 255, 0.12); }
.orb[data-state="thinking"] { animation: pulse 0.8s ease-in-out infinite; }
.orb[data-state="speaking"] { animation: speak 0.5s ease-in-out infinite alternate; }

@keyframes pulse { 50% { transform: scale(0.94); filter: brightness(0.85); } }
@keyframes speak { to { transform: scale(1.06); box-shadow: 0 0 0 18px rgba(155, 123, 255, 0.15); } }

.status { margin: 0; font-size: 17px; color: var(--muted); text-align: center; }
.idle-warning { margin: 0; font-size: 14px; color: #ffcf6b; }

.transcript { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.transcript li { padding: 10px 14px; border-radius: 14px; max-width: 85%; overflow-wrap: anywhere; }
.transcript li.user { align-self: flex-end; background: var(--user); }
.transcript li.assistant { align-self: flex-start; background: var(--assistant); border: 1px solid var(--border); }

dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none !important; transition: none; }
}

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
