:root {
  --bg: #080d16;
  --bg-glow: #15264a;
  --surface: #111a2b;
  --line: #22304a;
  --ink: #eef3fb;
  --ink-dim: #97a6c0;
  --accent: #4da3ff;
  --accent-warm: #ffb060;
  --listening: #3ddc97;
  --thinking: #ffc859;
  --speaking: #4da3ff;
  --error: #ff7a6b;
  --tap: 60vmin;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-glow) 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 ui-rounded, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.stage {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-warm));
  box-shadow: 0 0 14px rgba(77, 163, 255, 0.7);
}

.talk-area {
  flex: 1;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
}

.talk {
  position: relative;
  width: clamp(190px, var(--tap), 320px);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--ink);
  background: radial-gradient(circle at 50% 35%, #1d2c48 0%, #121b2c 70%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 220ms ease;
  touch-action: manipulation;
}

.talk:active {
  transform: scale(0.975);
}

.talk-icon {
  width: 32%;
  grid-row: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.talk-label {
  grid-row: 2;
  font-size: clamp(15px, 4.2vw, 19px);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.talk-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  opacity: 0;
  pointer-events: none;
}

.talk[data-state='connecting'] .talk-ring {
  opacity: 1;
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}

.talk[data-state='listening'] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(61, 220, 151, 0.5),
    0 0 48px rgba(61, 220, 151, 0.28);
}

.talk[data-state='listening'] .talk-ring,
.talk[data-state='listening'] .talk-ring-2 {
  opacity: 1;
  border-color: rgba(61, 220, 151, 0.45);
  animation: pulse 2.4s ease-out infinite;
}

.talk[data-state='listening'] .talk-ring-2 {
  animation-delay: 1.2s;
}

.talk[data-state='thinking'] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 200, 89, 0.5),
    0 0 44px rgba(255, 200, 89, 0.22);
}

.talk[data-state='thinking'] .talk-ring {
  opacity: 1;
  border-top-color: var(--thinking);
  animation: spin 1.5s linear infinite;
}

.talk[data-state='speaking'] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(77, 163, 255, 0.55),
    0 0 56px rgba(77, 163, 255, 0.3);
}

.talk[data-state='speaking'] .talk-ring,
.talk[data-state='speaking'] .talk-ring-2 {
  opacity: 1;
  border-color: rgba(77, 163, 255, 0.5);
  animation: pulse 1.3s ease-out infinite;
}

.talk[data-state='speaking'] .talk-ring-2 {
  animation-delay: 0.65s;
}

.talk[data-state='error'] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 122, 107, 0.6);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.22);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .talk-ring,
  .talk-ring-2 {
    animation: none !important;
  }
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  min-height: 44px;
  max-width: 34ch;
  text-align: center;
  font-size: 16px;
  color: var(--ink);
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: background 200ms ease;
}

.status[data-state='listening'] .status-dot {
  background: var(--listening);
  box-shadow: 0 0 10px var(--listening);
}
.status[data-state='thinking'] .status-dot {
  background: var(--thinking);
  box-shadow: 0 0 10px var(--thinking);
}
.status[data-state='speaking'] .status-dot {
  background: var(--speaking);
  box-shadow: 0 0 10px var(--speaking);
}
.status[data-state='connecting'] .status-dot {
  background: var(--accent);
}
.status[data-state='error'] .status-dot {
  background: var(--error);
  box-shadow: 0 0 10px var(--error);
}

.hint {
  margin: 0;
  max-width: 32ch;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}

.foot {
  margin-top: 10px;
}

.ghost {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.ghost:hover {
  color: var(--ink);
  border-color: #33456a;
}

.dev {
  width: 100%;
  max-width: 560px;
  margin-top: 4px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 13px;
  -webkit-user-select: text;
  user-select: text;
}

.dev-note {
  margin: 0 0 10px;
  color: var(--ink-dim);
}

.dev code {
  color: var(--accent);
}

.dev-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.dev-row label {
  color: var(--ink-dim);
  min-width: 68px;
}

/* A grid keeps each label beside its own input at phone widths, where flex wrap
   would otherwise strand "Longitude" on a line above its field. */
.dev-coords {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}

.dev-coords label {
  min-width: 0;
}

.dev input {
  flex: 1 1 110px;
  min-width: 0;
  background: #0b1320;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.dev input:focus {
  outline: 2px solid rgba(77, 163, 255, 0.5);
  outline-offset: 0;
}

.dev-presets span {
  color: var(--ink-dim);
  min-width: 68px;
}

.chip {
  appearance: none;
  background: #0b1320;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.chip:hover {
  color: var(--ink);
}

.dev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.dev-status {
  margin: 10px 0 0;
  color: var(--ink-dim);
  min-height: 18px;
}

.dev-status[data-kind='error'] {
  color: var(--error);
}

.dev-status[data-kind='ok'] {
  color: var(--listening);
}

.dev-out {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  background: #070c15;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c6d4ea;
}

.dev-transcript {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
}

@media (min-height: 720px) {
  :root {
    --tap: 54vmin;
  }
}
