:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --surface: #1e293b;
  --surface-light: #334155;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--primary);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
}

.logo-section {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--accent);
}

.logo-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.login-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 1rem;
  text-align: center;
  min-height: 1.2em;
}

.security-notice {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

/* ===== VOICE SCREEN ===== */
#voice-screen {
  flex-direction: column;
}

.voice-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.voice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-small {
  width: 36px;
  height: 36px;
  color: var(--accent);
}

.header-left h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.status-badge.connecting {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.status-badge.connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Voice Main */
.voice-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem 0;
  gap: 1rem;
}

.visualizer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0;
}

.visualizer {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visualizer-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.2;
  transition: all 0.3s;
}

.ring-1 { width: 100%; height: 100%; }
.ring-2 { width: 80%; height: 80%; }
.ring-3 { width: 60%; height: 60%; }

.visualizer.active .ring-1 {
  animation: pulse 2s ease-in-out infinite;
  opacity: 0.4;
}
.visualizer.active .ring-2 {
  animation: pulse 2s ease-in-out infinite 0.3s;
  opacity: 0.5;
}
.visualizer.active .ring-3 {
  animation: pulse 2s ease-in-out infinite 0.6s;
  opacity: 0.6;
}

.visualizer.speaking .ring-1 {
  animation: speak-pulse 0.6s ease-in-out infinite;
  border-color: var(--success);
  opacity: 0.5;
}
.visualizer.speaking .ring-2 {
  animation: speak-pulse 0.6s ease-in-out infinite 0.1s;
  border-color: var(--success);
  opacity: 0.6;
}
.visualizer.speaking .ring-3 {
  animation: speak-pulse 0.6s ease-in-out infinite 0.2s;
  border-color: var(--success);
  opacity: 0.7;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.1); opacity: 0.5; }
}

@keyframes speak-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.mic-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  z-index: 1;
}

.visualizer.active .mic-icon { color: var(--accent); }
.visualizer.speaking .mic-icon { color: var(--success); }

.ai-status {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* Transcript */
.transcript-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
}

.transcript-placeholder {
  color: var(--text-dim);
  text-align: center;
  padding: 2rem;
}

.transcript-entry {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.transcript-entry.user {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent);
}

.transcript-entry.assistant {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--success);
}

.transcript-entry .role {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.transcript-entry.user .role { color: var(--accent); }
.transcript-entry.assistant .role { color: var(--success); }

/* Function Log */
.function-log-section {
  max-height: 150px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.function-log-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.function-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.log-entry:last-child { border-bottom: none; }

.log-entry .log-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.log-entry.success .log-icon { background: var(--success); }
.log-entry.error .log-icon { background: var(--danger); }

.log-placeholder {
  color: var(--text-dim);
  padding: 0.5rem;
  text-align: center;
}

/* Controls */
.voice-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}

.btn-connect {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-connect:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.btn-connect:active {
  transform: scale(0.95);
}

.btn-connect.active {
  background: var(--danger);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-connect svg {
  width: 28px;
  height: 28px;
}

.btn-secondary {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary.muted {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn-secondary svg {
  width: 20px;
  height: 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Responsive */
@media (max-width: 640px) {
  .voice-container {
    padding: 0 0.75rem;
  }
  
  .visualizer-section {
    padding: 1rem 0;
  }
  
  .visualizer {
    width: 100px;
    height: 100px;
  }
}
