:root {
  /* Glassy dark theme */
  --bg-void: #06040c;
  --bg-glow-1: rgba(168, 85, 247, 0.35);
  --bg-glow-2: rgba(236, 72, 153, 0.20);
  --bg-glow-3: rgba(124, 58, 237, 0.25);

  --card: rgba(255, 255, 255, 0.045);
  --card-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);

  --text-primary: #F5F3FF;
  --text-secondary: rgba(245, 243, 255, 0.62);
  --text-tertiary: rgba(245, 243, 255, 0.34);

  --accent: #B388FF;
  --accent-2: #F0ABFC;
  --accent-light: rgba(179, 136, 255, 0.16);
  --accent-hover: #C7A6FF;
  --purple: #7C6FF0;
  --purple-light: rgba(124, 111, 240, 0.14);

  --success: #34D399;
  --danger: #FB7185;
  --danger-light: rgba(251, 113, 133, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app-shell {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.5s ease;
  background:
    radial-gradient(60% 50% at 30% 20%, var(--bg-glow-1) 0%, transparent 60%),
    radial-gradient(50% 45% at 75% 30%, var(--bg-glow-2) 0%, transparent 65%),
    radial-gradient(70% 60% at 50% 90%, var(--bg-glow-3) 0%, transparent 70%),
    var(--bg-void);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* NAVBAR */
.navbar {
  height: 68px;
  /* background: rgba(10, 8, 20, 0.55); */
  /* backdrop-filter: blur(18px); */
  /* -webkit-backdrop-filter: blur(18px); */
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  z-index: 5;
}

.navbar-left { display: flex; align-items: center; gap: 12px; }

.logo-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
  box-shadow: 0 0 18px rgba(179, 136, 255, 0.5);
}

.navbar-title { display: flex;align-items: center;gap:5px; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.brand-sub { font-size: 12px; color: var(--text-secondary); }

.navbar-right { display: flex; align-items: center; gap: 12px; }

/* CONNECTION STATUS — top of widget */
.status-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-tertiary);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 0 4px rgba(52,211,153,0.18), 0 0 10px rgba(52,211,153,0.6); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(251,113,133,0.18), 0 0 10px rgba(251,113,133,0.6); }

.powered-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 500;
}

/* HAMBURGER — hidden on desktop, shown only on mobile (see media query) */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, transform 0.18s ease;
}
.hamburger-btn:hover { background: rgba(255, 255, 255, 0.12); }
.hamburger-btn:active { transform: scale(0.94); }

/* Overlay shown behind the sidebar when it's open on mobile */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* MAIN LAYOUT */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 66% 34%;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ASSISTANT PANEL */
.assistant-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 40px;
  overflow: hidden;
  border-right: 1px solid var(--border);
  gap: 42px;
}

.orb-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* BIGGER, GLASSY ORB */
.orb-wrapper {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.orb {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s ease;
}

.orb-glow {
  position: absolute;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(179,136,255,0.55) 0%, rgba(240,171,252,0.25) 40%, transparent 72%);
  filter: blur(10px);
  animation: glowBreathe 3.5s ease-in-out infinite;
}

.orb-core {
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.9) 0%, transparent 32%),
    conic-gradient(from 180deg, #C7A6FF, #F0ABFC, #7C6FF0, #B388FF, #C7A6FF);
  box-shadow:
    0 0 70px rgba(179, 136, 255, 0.55),
    0 0 140px rgba(124, 111, 240, 0.25),
    inset 0 0 40px rgba(255, 255, 255, 0.28),
    inset 0 -20px 50px rgba(20, 6, 40, 0.35);
  animation: breathe 3.5s ease-in-out infinite, coreSpin 10s linear infinite;
  filter: saturate(1.15);
}

/* Glass highlight overlay for depth */
.orb-core::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255,255,255,0.35) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.15) 100%);
}

.orb-swirl {
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 62% 68%, rgba(255,255,255,0.35), transparent 45%),
              radial-gradient(circle at 28% 72%, rgba(255,255,255,0.18), transparent 40%);
  mix-blend-mode: overlay;
  animation: swirlDrift 6s ease-in-out infinite;
  pointer-events: none;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(199, 166, 255, 0.55);
  opacity: 0;
}
.ring-1 { width: 220px; height: 220px; }
.ring-2 { width: 258px; height: 258px; }
.ring-3 { width: 296px; height: 296px; }

@keyframes glowBreathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes coreSpin {
  0% { filter: hue-rotate(0deg) saturate(1.15); }
  100% { filter: hue-rotate(360deg) saturate(1.15); }
}

@keyframes swirlDrift {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(15deg) scale(1.03); }
}

.orb.listening .orb-core { animation: pulseListen 1.4s ease-in-out infinite, coreSpin 10s linear infinite; }
@keyframes pulseListen {
  0%, 100% { transform: scale(1); box-shadow: 0 0 70px rgba(179,136,255,0.55), 0 0 140px rgba(124,111,240,0.25), inset 0 0 40px rgba(255,255,255,0.28); }
  50% { transform: scale(1.1); box-shadow: 0 0 100px rgba(179,136,255,0.85), 0 0 170px rgba(124,111,240,0.4), inset 0 0 46px rgba(255,255,255,0.38); }
}

/* AI SPEAKING — orb pulses larger + rings ripple outward continuously */
.orb.speaking .orb-core {
  animation: speakPulse 0.9s ease-in-out infinite, coreSpin 4s linear infinite;
}
.orb.speaking .orb-glow {
  animation: speakGlow 0.9s ease-in-out infinite;
}
.orb.speaking .orb-ring {
  animation: ringPulse 1.6s ease-out infinite;
  opacity: 1;
}
.orb.speaking .ring-2 { animation-delay: 0.35s; }
.orb.speaking .ring-3 { animation-delay: 0.7s; }

@keyframes speakPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 70px rgba(179,136,255,0.6), 0 0 140px rgba(124,111,240,0.3), inset 0 0 40px rgba(255,255,255,0.28); }
  50% { transform: scale(1.14); box-shadow: 0 0 110px rgba(179,136,255,0.9), 0 0 190px rgba(124,111,240,0.5), inset 0 0 50px rgba(255,255,255,0.4); }
}
@keyframes speakGlow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.18); opacity: 1; }
}

@keyframes ringPulse {
  0% { opacity: 0.75; transform: scale(0.88); }
  100% { opacity: 0; transform: scale(1.5); }
}

.orb.thinking .orb-core {
  animation: coreSpin 1.1s linear infinite, breathe 2s ease-in-out infinite;
}

.orb.idle .orb-core { transform: scale(0.88); filter: saturate(0.7) brightness(0.85); }
.orb.idle .orb-glow { opacity: 0.5; }

.assistant-name {
  margin-top: 22px;
  font-size: 26px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(179,136,255,0.35);
}

.assistant-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.state-indicator {
  margin-top: 18px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.state-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-tertiary);
}
.state-indicator.listening .state-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.state-indicator.thinking .state-dot { background: var(--purple); box-shadow: 0 0 8px var(--purple); }
.state-indicator.speaking .state-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }

/* CONTROLS — enhanced Start / Clear */
.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 0;
}

.btn {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 24px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--purple) 55%, var(--accent-2));
  background-size: 200% 200%;
  color: #14061f;
  box-shadow: 0 10px 30px rgba(179, 136, 255, 0.45), 0 0 0 1px rgba(255,255,255,0.15) inset;
  animation: primaryGradient 6s ease infinite;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 38px rgba(179, 136, 255, 0.6), 0 0 0 1px rgba(255,255,255,0.2) inset;
}
@keyframes primaryGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(251, 113, 133, 0.25);
}
.btn-danger:hover { background: rgba(251, 113, 133, 0.22); transform: translateY(-1px); }

.btn-secondary {
  background: var(--card-strong);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.btn-secondary.active { background: var(--accent-light); color: var(--accent-2); border-color: rgba(179,136,255,0.4); }

/* Clear — glassy outlined pill, distinct from destructive/danger actions */
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}

.hidden { display: none !important; }

/* SIDEBAR */
.sidebar {
  padding: 22px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.card-value-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-row { display: flex; align-items: center; justify-content: space-between; }

.mono { font-variant-numeric: tabular-nums; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge-blue { background: var(--accent-light); color: var(--accent-2); }

.mic-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-tertiary);
}
.mic-dot.on { background: var(--success); box-shadow: 0 0 8px rgba(52,211,153,0.7); }
.mic-dot.muted { background: #F59E0B; box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.mic-dot.denied { background: var(--danger); box-shadow: 0 0 8px rgba(251,113,133,0.6); }

/* CHAT CARD — first in sidebar, gets more vertical room */
.card-chat {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.conversation-panel {
  width: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  min-height: 120px;
  padding-right: 2px;
}

.conversation-empty {
  margin: auto;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12.5px;
  padding: 12px 0;
}

.message-card {
  max-width: 92%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  animation: slideUp 0.28s ease;
  box-shadow: var(--shadow-sm);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-card.user {
  align-self: flex-end;
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
}

.message-card.assistant {
  align-self: flex-start;
  background: var(--purple-light);
  border: 1px solid rgba(179, 136, 255, 0.18);
  border-bottom-left-radius: 4px;
}

.message-meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.message-text { color: var(--text-primary); }

.card-events { flex: 1; display: flex; flex-direction: column; min-height: 120px; }
.event-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
}
.event-empty { font-size: 12px; color: var(--text-tertiary); }

.event-item {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding: 6px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'SF Mono', Consolas, monospace;
  animation: slideUp 0.2s ease;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.event-item .event-time { color: var(--text-tertiary); flex-shrink: 0; }

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background: rgba(20, 14, 32, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  max-width: 320px;
  animation: toastIn 0.3s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* SCROLLBARS */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* RESPONSIVE */
@media (max-width: 1024px) {
  /* Show the hamburger and switch the sidebar to an off-canvas panel */
  .hamburger-btn { display: flex; }

  .app-shell { overflow: hidden; }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    overflow: hidden;
  }

  /* Center the orb + Start Conversation button in the middle of the screen */
  .assistant-panel {
    border-right: none;
    border-bottom: none;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .orb-wrapper { height: 240px; }
  .orb, .orb-core, .orb-swirl { width: 180px; height: 180px; }
  .orb-glow { width: 280px; height: 280px; }
  .ring-1 { width: 180px; height: 180px; }
  .ring-2 { width: 212px; height: 212px; }
  .ring-3 { width: 244px; height: 244px; }

  /* Sidebar becomes a slide-in panel from the right, opened via the hamburger */
  .sidebar {
    position: fixed;
    top: 68px;
    right: 0;
    bottom: 0;
    width: min(85vw, 360px);
    background: rgba(10, 8, 20, 0.95);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
}

@media (max-width: 600px) {
  .navbar { padding: 0 16px; }
  .powered-badge { display: none; }
  .assistant-panel { padding: 24px 16px; gap: 28px; }
  .controls { width: 100%; }
  .btn { flex: 1; justify-content: center; }
  .sidebar { width: 100%; top: 68px; }
}