/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0c0c0e;
  --surface:   #141417;
  --surface2:  #1c1c21;
  --border:    #26262e;
  --text:      #e8e8f0;
  --muted:     #6b6b80;
  --accent:    #7c6ef0;
  --accent2:   #4f9ef0;
  --danger:    #e05560;
  --success:   #4caf80;
  --radius:    12px;
  --sidebar-w: 260px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; }

/* ===== Layout ===== */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.logo-mark { font-size: 22px; color: var(--accent); }

.agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}

.loading-agents { color: var(--muted); font-size: 13px; padding: 16px 10px; }

.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.agent-item:hover { background: var(--surface2); }
.agent-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.agent-item-icon { font-size: 22px; flex-shrink: 0; }
.agent-item-info { overflow: hidden; }
.agent-item-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Main ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== Empty state ===== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}
.empty-icon { font-size: 52px; opacity: 0.3; }
.empty-state h2 { font-size: 20px; color: var(--text); opacity: 0.6; font-weight: 500; }
.empty-state p { font-size: 14px; max-width: 300px; }

/* ===== Agent Panel ===== */
.agent-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--border);
}
.agent-icon { font-size: 40px; }
.agent-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.agent-header p { font-size: 13px; color: var(--muted); margin-top: 2px; max-width: 480px; }

/* ===== Voice Area ===== */
.voice-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
}

/* Orb */
.orb-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

/* Outer ring — slow ambient pulse */
.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.orb-ring-outer {
  inset: 8px;
  border-color: var(--accent2);
  opacity: 0.08;
  transition: opacity 0.4s;
}
.orb-ring-mid {
  inset: 18px;
  border-color: var(--accent);
  opacity: 0.12;
  transition: opacity 0.4s;
}

.orb {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent2), var(--accent));
  opacity: 0.12;
  box-shadow: 0 0 0 0 transparent;
  transition: opacity 0.4s, box-shadow 0.4s, transform 0.3s;
}

/* ── Listening state ── */
.orb.listening {
  opacity: 0.5;
  box-shadow: 0 0 28px 4px color-mix(in srgb, var(--accent) 35%, transparent);
  animation: orb-pulse 2s ease-in-out infinite;
}
.orb.listening ~ .orb-ring-outer,
.orb-wrap:has(.orb.listening) .orb-ring-outer {
  opacity: 0;
}
.orb-wrap:has(.orb.listening) .orb-ring-outer {
  opacity: 0.18;
  animation: ring-expand-slow 2s ease-in-out infinite;
}
.orb-wrap:has(.orb.listening) .orb-ring-mid {
  opacity: 0.28;
  animation: ring-expand-slow 2s ease-in-out infinite 0.4s;
}

/* ── Speaking state ── */
.orb.speaking {
  opacity: 0.9;
  box-shadow: 0 0 40px 10px color-mix(in srgb, var(--accent2) 45%, transparent),
              0 0 80px 20px color-mix(in srgb, var(--accent) 20%, transparent);
  animation: orb-throb 0.55s ease-in-out infinite;
}
.orb-wrap:has(.orb.speaking) .orb-ring-outer {
  opacity: 0.35;
  animation: ring-expand-fast 0.55s ease-out infinite;
}
.orb-wrap:has(.orb.speaking) .orb-ring-mid {
  opacity: 0.5;
  animation: ring-expand-fast 0.55s ease-out infinite 0.12s;
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}
@keyframes orb-throb {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.13); }
}
@keyframes ring-expand-slow {
  0%   { transform: scale(0.96); opacity: 0.22; }
  50%  { transform: scale(1.06); opacity: 0.10; }
  100% { transform: scale(0.96); opacity: 0.22; }
}
@keyframes ring-expand-fast {
  0%   { transform: scale(0.92); opacity: 0.55; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* ── Viz stack (shown while connected) ── */
.viz-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 340px;
  max-width: calc(100% - 48px);
}

.viz-agent {
  width: 100%;
  height: 60px;
  border-radius: 6px;
  display: block;
  background: #04040e;
}

.viz-mic {
  width: 100%;
  height: 46px;
  border-radius: 6px;
  display: block;
  background: #000;
}

/* Status */
.status-text {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.02em;
  min-height: 20px;
  text-align: center;
}

/* Controls */
.controls { display: flex; gap: 12px; align-items: center; }

.btn-connect {
  padding: 12px 36px;
  border-radius: 40px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  letter-spacing: -0.01em;
}
.btn-connect:hover:not(:disabled) { background: #6a5de0; }
.btn-connect:active:not(:disabled) { transform: scale(0.97); }
.btn-connect:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-connect.disconnect { background: var(--danger); }
.btn-connect.disconnect:hover:not(:disabled) { background: #c94550; }

.btn-mute {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-mute:hover { background: var(--surface); }
.btn-mute.muted { background: color-mix(in srgb, var(--danger) 20%, transparent); border-color: var(--danger); }

/* ===== Transcript ===== */
.transcript {
  border-top: 1px solid var(--border);
  height: 180px;
  overflow-y: auto;
  padding: 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transcript-line {
  font-size: 13px;
  line-height: 1.5;
  padding: 4px 0;
}
.transcript-line .who {
  font-weight: 600;
  margin-right: 6px;
}
.transcript-line.agent .who { color: var(--accent); }
.transcript-line.user  .who { color: var(--accent2); }
.transcript-line.interim { opacity: 0.5; font-style: italic; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  :root { --sidebar-w: 200px; }
  .agent-header { padding: 16px 18px; }
  .voice-area { padding: 20px; }
  .transcript { padding: 10px 18px; }
}

/* ===== Download area ===== */
.download-area {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
}
.btn-download {
  display: inline-block;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn-download:hover { opacity: 0.85; }
