:root {
  --bg-main: #050509;
  --bg-panel: #111116;
  --bg-elevated: #1e1f24;
  --border-subtle: #2a2b32;
  --text-main: #f5f5f5;
  --text-muted: #a0a0a8;
  --accent: #3b82f6;
  --danger: #ef4444;
  --success: #10b981;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: system-ui, sans-serif; background: var(--bg-main); color: var(--text-main); }
body { display: flex; min-height: 100vh; }
.app { display: flex; flex: 1; min-height: 100vh; position: relative; }

.sidebar { width: 260px; background: #020308; border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; }
.sidebar-header { padding: 16px 14px 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.chat-item { display: flex; align-items: center; padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--text-main); cursor: pointer; gap: 8px; border: 1px solid transparent; }
.chat-item:hover { background: var(--bg-elevated); border-color: var(--border-subtle); }
.chat-item.active { background: var(--bg-elevated); border-color: var(--accent); }
.chat-item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.new-chat-btn { margin: 8px; padding: 6px 10px; width: calc(100% - 16px); border-radius: 999px; border: 1px solid var(--border-subtle); background: transparent; color: var(--text-main); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.new-chat-btn:hover { background: var(--bg-elevated); }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 999px; background: #10b981; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #022c22; }

.main { flex: 1; display: flex; justify-content: center; background: radial-gradient(circle at top, #111827 0, #020617 45%); position: relative; }
.main-inner { width: 100%; max-width: 960px; display: flex; flex-direction: column; padding: 32px 16px 18px; }
.empty-state { text-align: center; font-size: 30px; margin-top: 80px; margin-bottom: 40px; font-weight: 500; color: #e5e7eb; display: none; }
.messages { flex: 1; overflow-y: auto; padding: 0 6px 12px; display: flex; flex-direction: column; gap: 10px; }

.message-row { display: flex; gap: 8px; align-items: flex-end; }
.message-row.user { justify-content: flex-end; }
.bubble { max-width: 70%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; border: 1px solid transparent; }
.bubble.user { background: #1d4ed8; border-color: #1d4ed8; }
.bubble.assistant { background: #111827; border-color: #1f2937; }
.bubble img { max-width: 100%; border-radius: 10px; display: block; }
.bubble audio { width: 100%; }
.avatar-small { width: 26px; height: 26px; border-radius: 999px; background: #1f2937; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.message-row.user .avatar-small { display: none; }

.composer { margin-top: 8px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 999px; background: rgba(15, 23, 42, 0.95); border: 1px solid var(--border-subtle); }
.composer input[type="text"] { flex: 1; border: none; outline: none; background: transparent; color: var(--text-main); font-size: 14px; }
.icon-button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 999px; font-size: 18px; }
.icon-button:hover { background: #111827; }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.icon-circle { width: 32px; height: 32px; border-radius: 999px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; transition: transform 0.12s ease; }
.icon-circle:active { transform: scale(0.96); }
.voice-btn { background: #f9fafb; color: #111827; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35); }
.voice-btn.active-call { background: var(--danger); color: white; animation: pulse-red 2s infinite; }
.send-btn { background: var(--accent); color: #ffffff; box-shadow: 0 3px 10px rgba(37, 99, 235, 0.6); }
.voice-bars { display: flex; gap: 2px; height: 12px; }
.voice-bars span { width: 3px; background: currentColor; border-radius: 2px; height: 100%; }

.auth-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.9); display: flex; align-items: center; justify-content: center; z-index: 999; }
.auth-card { width: 100%; max-width: 360px; background: #020617; border-radius: 16px; padding: 24px 22px 20px; border: 1px solid #1f2937; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6); }
.auth-card h2 { margin: 0 0 14px; font-size: 20px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.field input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #1f2937; background: #020617; color: var(--text-main); font-size: 13px; }
.auth-btn { margin-top: 8px; padding: 8px 0; border-radius: 999px; border: none; background: var(--accent); color: #fff; cursor: pointer; font-size: 14px; font-weight: 500; }
.auth-switch { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--text-muted); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0 2px; }
.auth-error { margin-top: 4px; font-size: 12px; color: #f97373; min-height: 16px; text-align: center; }
.hidden { display: none !important; }

.call-overlay { position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 400px; background: rgba(17, 24, 39, 0.95); backdrop-filter: blur(10px); border: 1px solid var(--border-subtle); border-radius: 20px; padding: 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; z-index: 100; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.call-visualizer { width: 80px; height: 80px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; position: relative; }
.visualizer-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.mode-speaking .visualizer-ring { animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite; border-color: var(--accent); }
.mode-listening .visualizer-ring { animation: pulse 2s infinite; border-color: var(--success); }
.end-call-btn { padding: 8px 24px; background: var(--danger); color: white; border: none; border-radius: 999px; cursor: pointer; font-weight: 500; }

@keyframes ping { 75%, 100% { transform: scale(1.6); opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
@media (max-width: 800px) { .sidebar { display: none; } }
