:root {
  color-scheme: dark;
  --bg: #010818;
  --bg-secondary: #07142c;
  --card: rgba(5, 14, 33, 0.92);
  --surface: rgba(8, 20, 45, 0.7);
  --chip-bg: rgba(10, 22, 47, 0.65);
  --border: rgba(107, 147, 214, 0.35);
  --border-soft: rgba(107, 147, 214, 0.18);
  --text: #eff4ff;
  --text-muted: rgba(205, 216, 238, 0.78);
  --accent: #7dd3fc;
  --accent-strong: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.18);
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #34d399;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Noto Sans Thai", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at 20% 15%, rgba(96, 165, 250, 0.18), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(59, 130, 246, 0.12), transparent 55%),
    linear-gradient(155deg, var(--bg) 0%, var(--bg-secondary) 70%, #020b1d 100%);
  color: var(--text);
  overflow-x: hidden;
}

#visCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.4;
  mix-blend-mode: lighten;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: clamp(1.5rem, 3vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 3rem);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 52rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.1;
}

.hero-subtitle {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 48rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 1.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: 0 35px 70px rgba(1, 6, 18, 0.55);
  backdrop-filter: blur(18px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.panel-head .eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.panel-head h2 {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
}

#subtitles {
  font-size: 1.5rem;
  color: var(--accent-strong);
  text-shadow: 0 0 24px rgba(96, 165, 250, 0.35);
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1.5rem;
}

#subtitles.bottom {
  transform: none;
  position: static;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-soft);
  background: var(--chip-bg);
  color: var(--text-muted);
}

.chip-idle {
  color: var(--text);
  background: rgba(96, 165, 250, 0.2);
  border-color: rgba(96, 165, 250, 0.35);
}

.chip-listening {
  color: #031023;
  background: linear-gradient(135deg, #7dd3fc, #60a5fa);
  border-color: rgba(96, 165, 250, 0.65);
}

.chip-thinking {
  color: #e0f2ff;
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(148, 197, 255, 0.35);
}

.chip-speaking {
  color: #e0f2ff;
  background: rgba(125, 211, 252, 0.25);
  border-color: rgba(125, 211, 252, 0.4);
}

.chip-muted {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.35);
}

.chip-connected {
  color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
}

.chip-connecting {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(96, 165, 250, 0.35);
}

.chip-disconnected {
  color: rgba(239, 246, 255, 0.75);
  background: rgba(15, 23, 42, 0.45);
}

.chip-error {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.2);
  border-color: rgba(251, 113, 133, 0.35);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 28rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.empty-state {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  text-align: center;
}

.bubble {
  padding: 1rem 1.25rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bubble-user {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(37, 99, 235, 0.25);
}

.bubble-assistant {
  border-color: rgba(125, 211, 252, 0.4);
  background: rgba(8, 47, 73, 0.45);
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bubble-role {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
}

.bubble-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}

.metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.metric {
  flex: 1;
  min-width: 120px;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.metric-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.metric-value {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.25rem;
}

.mic-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

#startCircle {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.08), rgba(3, 10, 25, 0.65)),
    linear-gradient(140deg, #0b1e46, #1d4ed8 55%, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: 0 40px 70px rgba(1, 8, 25, 0.65);
  cursor: pointer;
  transition: transform 0.4s ease, opacity 0.4s ease;
  position: relative;
}

#startCircle span {
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#startCircle small {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.85;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

#startCircle::before {
  content: "";
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.35), transparent 70%);
  filter: blur(14px);
  z-index: -1;
  opacity: 0.7;
}

#startCircle:hover {
  transform: scale(1.05);
}

#controls {
  width: 100%;
  display: none;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border);
  background: var(--accent-soft);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.ghost {
  border-color: var(--border-soft);
}

.btn.danger {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.08);
}

.status-log {
  width: 100%;
  margin-top: 1.5rem;
}

.status-lines {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 14rem;
  overflow-y: auto;
}

.status-line {
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  font-size: 0.9rem;
  align-items: baseline;
}

.status-time {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-text {
  margin: 0;
}

.status-info {
  border-color: rgba(96, 165, 250, 0.45);
}

.status-success {
  border-color: rgba(34, 197, 94, 0.45);
}

.status-error {
  border-color: rgba(248, 113, 113, 0.45);
}

.link {
  background: none;
  border: none;
  color: rgba(224, 236, 255, 0.8);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0;
}

.link:hover {
  color: var(--text);
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  #startCircle {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.25rem;
  }

  .panel {
    padding: 1.25rem;
  }

  .metrics {
    flex-direction: column;
  }
}
