:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(17, 24, 39, 0.78);
  --surface-strong: #111827;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --danger: #fb7185;
  --success: #34d399;
  --warning: #fbbf24;
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.16), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(129, 140, 248, 0.15), transparent 30%),
    linear-gradient(145deg, #050a13, var(--bg));
  color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 5vw, 48px); }
.hero p { color: var(--muted); max-width: 680px; line-height: 1.9; margin-bottom: 0; }

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(18px);
}

.status-card div { display: grid; gap: 4px; }
.status-card small { color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 999px; box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.08); }
.status-dot.idle { background: #64748b; }
.status-dot.connecting { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.connected { background: var(--success); }
.status-dot.listening { background: var(--accent); animation: pulse 0.8s infinite; }
.status-dot.speaking { background: var(--accent-2); animation: pulse 0.7s infinite; }
.status-dot.error { background: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  min-height: 650px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.controls {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.orb-wrap {
  display: grid;
  place-items: center;
  min-height: 250px;
  text-align: center;
}

.voice-orb {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.22), transparent 22%), linear-gradient(145deg, #0ea5e9, #6366f1);
  box-shadow: 0 0 0 12px rgba(56, 189, 248, 0.06), 0 24px 60px rgba(56, 189, 248, 0.22);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.voice-orb.active {
  transform: scale(1.04);
  box-shadow: 0 0 0 18px rgba(56, 189, 248, 0.07), 0 28px 80px rgba(99, 102, 241, 0.33);
}

.voice-orb span {
  width: 6px;
  height: 24px;
  border-radius: 999px;
  background: white;
  opacity: 0.92;
  transform-origin: center;
}

.voice-orb.active span:nth-child(1) { animation: bars .75s infinite ease-in-out; }
.voice-orb.active span:nth-child(2) { animation: bars .55s infinite ease-in-out .08s; }
.voice-orb.active span:nth-child(3) { animation: bars .8s infinite ease-in-out .12s; }
.voice-orb.active span:nth-child(4) { animation: bars .6s infinite ease-in-out .04s; }
.voice-orb.active span:nth-child(5) { animation: bars .7s infinite ease-in-out .16s; }

.orb-wrap p { color: var(--muted); margin: 24px 0 0; }

.button {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  transition: transform 120ms ease, background 120ms ease;
}
.button:not(:disabled):active { transform: translateY(1px); }
.button.primary { color: #07111f; background: linear-gradient(90deg, #38bdf8, #a5b4fc); font-weight: 700; }
.button.secondary { color: var(--text); background: rgba(51, 65, 85, 0.75); }
.button.ghost { color: #fecdd3; background: rgba(244, 63, 94, 0.09); border: 1px solid rgba(244, 63, 94, 0.18); }

.meta-list { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 8px; }
.meta-list div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; color: var(--muted); font-size: 13px; }
.meta-list strong { color: #dbeafe; font-weight: 600; }
.security-note { color: #7dd3fc; font-size: 12px; line-height: 1.8; margin: auto 0 0; padding: 12px; border-radius: 12px; background: rgba(14, 165, 233, 0.07); }

.chat { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--border); }
.chat-header h2 { margin-bottom: 6px; }
.chat-header p { margin: 0; color: var(--muted); font-size: 13px; }
.clear-button { color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.empty-state { margin: auto; text-align: center; color: var(--muted); display: grid; gap: 8px; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 8px; border-radius: 16px; color: var(--accent); background: rgba(56, 189, 248, 0.08); font-size: 28px; }

.message { max-width: min(78%, 680px); padding: 13px 15px; border-radius: 17px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.message.user { align-self: flex-start; background: linear-gradient(135deg, rgba(14,165,233,.22), rgba(59,130,246,.18)); border-bottom-right-radius: 5px; }
.message.assistant { align-self: flex-end; background: rgba(51, 65, 85, 0.72); border: 1px solid rgba(148,163,184,.08); border-bottom-left-radius: 5px; }
.message.pending::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-right: 5px; background: currentColor; animation: blink 0.8s steps(1) infinite; vertical-align: -2px; opacity: .55; }
.message .label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 18px; border-top: 1px solid var(--border); }
.composer input { min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: rgba(15,23,42,.72); color: var(--text); padding: 13px 15px; outline: none; }
.composer input:focus { border-color: rgba(56, 189, 248, .55); box-shadow: 0 0 0 3px rgba(56, 189, 248, .08); }
.composer button { border: 0; border-radius: 13px; padding: 0 22px; color: #06111e; background: #7dd3fc; font-weight: 700; }

.toast { position: fixed; left: 24px; bottom: 24px; max-width: min(430px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 13px; background: #7f1d1d; color: white; box-shadow: 0 18px 60px rgba(0,0,0,.35); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0.06); } }
@keyframes bars { 50% { transform: scaleY(2.1); } }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 850px) {
  .hero { align-items: stretch; flex-direction: column; }
  .status-card { min-width: 0; }
  .workspace { grid-template-columns: 1fr; }
  .controls { order: 2; }
  .chat { min-height: 600px; }
  .orb-wrap { min-height: 200px; }
  .message { max-width: 90%; }
}
