:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --border: #2a2a4a;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #555577;
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --accent-bright: #8b83ff;
  --success: #4ecdc4;
  --danger: #ff6b6b;
  --warning: #ffd93d;
  --ai-color: #6c63ff;
  --user-color: #4ecdc4;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* Screens */
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* Login Screen */
#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg-secondary) 0%, var(--bg-primary) 70%);
}

.login-container { width: 100%; max-width: 400px; padding: 40px; }

.logo { text-align: center; margin-bottom: 40px; }

.logo-icon {
  width: 80px; height: 80px; margin: 0 auto 20px;
  color: var(--accent);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.logo h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; font-weight: 300; }

.input-group { margin-bottom: 16px; }

.input-group input {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary);
  font-size: 15px; font-family: inherit;
  transition: border-color var(--transition); outline: none;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group input::placeholder { color: var(--text-muted); }

.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #5a52d5 100%);
  color: white; font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all var(--transition); margin-top: 8px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 20px; }

/* Chat Screen */
#chat-screen { flex-direction: column; background: var(--bg-primary); }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.logo-small { width: 32px; height: 32px; color: var(--accent); }
.header-title { font-weight: 600; font-size: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.user-badge {
  font-size: 13px; color: var(--text-secondary);
  padding: 4px 10px; background: var(--bg-card); border-radius: 20px;
}

.btn-ghost {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary); padding: 6px 14px;
  border-radius: var(--radius-sm); font-size: 13px;
  font-family: inherit; cursor: pointer; transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* Main Chat Area */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}

/* Chat Messages */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}

.welcome-msg {
  text-align: center; color: var(--text-muted);
  font-size: 14px; padding: 40px 20px;
}

.msg {
  max-width: 80%; padding: 10px 16px;
  border-radius: var(--radius); font-size: 14px;
  line-height: 1.5; word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.msg.user {
  align-self: flex-end; background: rgba(78, 205, 196, 0.15);
  color: var(--user-color); border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start; background: rgba(108, 99, 255, 0.12);
  color: var(--text-primary); border-bottom-left-radius: 4px;
}

.msg.tool {
  align-self: flex-start; background: rgba(255, 217, 61, 0.1);
  color: var(--warning); font-size: 12px; font-style: italic;
  border-left: 2px solid var(--warning); padding-left: 12px;
}

.msg.thinking {
  align-self: flex-start; color: var(--text-muted); font-style: italic;
}

.msg .typing-dots::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Bottom Panel */
.bottom-panel {
  flex-shrink: 0; padding: 16px 24px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
}

/* Status */
.status-area { text-align: center; }

.status-text {
  font-size: 13px; color: var(--text-secondary);
  padding: 4px 14px; background: var(--bg-card);
  border-radius: 20px; display: inline-block;
  transition: all var(--transition);
}
.status-text.connected { color: var(--success); background: rgba(78, 205, 196, 0.1); }
.status-text.error { color: var(--danger); background: rgba(255, 107, 107, 0.1); }
.status-text.listening { color: var(--user-color); background: rgba(78, 205, 196, 0.1); }
.status-text.thinking { color: var(--warning); background: rgba(255, 217, 61, 0.1); }
.status-text.speaking { color: var(--ai-color); background: rgba(108, 99, 255, 0.1); }

/* Visualizer */
.visualizer-container { display: flex; align-items: center; gap: 24px; }

.visualizer-wrapper {
  position: relative; width: 100px; height: 100px;
  display: flex; align-items: center; justify-content: center;
}

.ai-orb {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

.orb-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid var(--accent); opacity: 0.15;
  transition: all 0.1s ease;
}
.ring-1 { width: 100%; height: 100%; }
.ring-2 { width: 80%; height: 80%; }
.ring-3 { width: 60%; height: 60%; }

.orb-core {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, rgba(108, 99, 255, 0.4) 60%, transparent 70%);
  box-shadow: 0 0 30px var(--accent-glow);
  transition: all 0.1s ease;
}

.ai-orb.active .ring-1 { opacity: 0.4; border-width: 2px; animation: pulse-ring 1.5s ease-in-out infinite; }
.ai-orb.active .ring-2 { opacity: 0.5; border-width: 2px; animation: pulse-ring 1.5s ease-in-out infinite 0.2s; }
.ai-orb.active .ring-3 { opacity: 0.6; border-width: 2px; animation: pulse-ring 1.5s ease-in-out infinite 0.4s; }
.ai-orb.active .orb-core { box-shadow: 0 0 60px var(--accent-glow), 0 0 120px rgba(108, 99, 255, 0.15); }

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.08); opacity: 0.6; }
}

.ai-orb.idle .orb-core { animation: breathe 4s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* Level Meters */
.level-meters { display: flex; flex-direction: column; gap: 8px; width: 120px; }

.level-meter { display: flex; align-items: center; gap: 8px; }

.level-meter label {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 500; width: 20px;
}

.meter-bar { flex: 1; height: 4px; background: var(--bg-card); border-radius: 2px; overflow: hidden; }

.meter-fill { height: 100%; width: 0%; border-radius: 2px; transition: width 0.05s ease; }
.user-fill { background: linear-gradient(90deg, var(--user-color), #45b7aa); }
.ai-fill { background: linear-gradient(90deg, var(--ai-color), var(--accent-bright)); }

/* Controls */
.controls { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.btn-connect {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg-card);
  color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-connect:hover { border-color: var(--accent); background: rgba(108, 99, 255, 0.1); transform: scale(1.05); }
.btn-connect.active { border-color: var(--danger); background: rgba(255, 107, 107, 0.1); animation: pulse-btn 2s ease-in-out infinite; }
.btn-connect.active:hover { background: rgba(255, 107, 107, 0.2); }

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(255, 107, 107, 0); }
}

.btn-connect svg { width: 26px; height: 26px; }
.hidden { display: none !important; }
.control-label { font-size: 11px; color: var(--text-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 600px) {
  .login-container { padding: 24px; }
  .chat-messages { padding: 12px 16px; }
  .bottom-panel { padding: 12px 16px 16px; }
  .visualizer-wrapper { width: 80px; height: 80px; }
  .orb-core { width: 32px; height: 32px; }
  .msg { max-width: 90%; }
}
