: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;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 20px;
  overflow-y: auto;
}

/* Status */
.status-area {
  text-align: center;
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 16px;
  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.speaking {
  color: var(--ai-color);
  background: rgba(108, 99, 255, 0.1);
}

/* Visualizer */
.visualizer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.visualizer-wrapper {
  position: relative;
  width: 220px;
  height: 220px;
  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: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, rgba(108, 99, 255, 0.4) 60%, transparent 70%);
  box-shadow: 0 0 40px var(--accent-glow);
  transition: all 0.1s ease;
}

/* Active speaking animation */
.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; }
}

/* Idle breathing animation */
.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;
  gap: 24px;
  width: 280px;
}

.level-meter {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-meter label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.meter-bar {
  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));
}

/* Text Display */
.text-display {
  width: 100%;
  max-width: 500px;
  min-height: 40px;
  max-height: 80px;
  overflow-y: auto;
}

.transcript {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn-connect {
  width: 72px;
  height: 72px;
  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);
  position: relative;
}

.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: 28px;
  height: 28px;
}

.hidden {
  display: none !important;
}

.control-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Timer */
.timer {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* History */
.history-toggle {
  margin-top: auto;
}

.history-panel {
  width: 100%;
  max-width: 500px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.history-list {
  padding: 12px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition);
}

.history-item:hover {
  background: var(--bg-card);
}

.history-item .time {
  color: var(--text-muted);
  font-size: 12px;
}

.history-item .duration {
  color: var(--accent);
}

.history-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* 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-main {
    padding: 12px;
    gap: 16px;
  }
  .visualizer-wrapper {
    width: 180px;
    height: 180px;
  }
  .orb-core {
    width: 60px;
    height: 60px;
  }
}
