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

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e2a;
  --border: rgba(255,255,255,0.07);
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --accent-glow: rgba(108,99,255,0.25);
  --text: #e8eaf0;
  --text2: #9196a8;
  --text3: #5a5f72;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 4px; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .badge,
.sidebar.collapsed .sidebar-files,
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }

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

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }

.sidebar-toggle {
  background: none; border: none; color: var(--text2);
  cursor: pointer; padding: 6px; border-radius: 6px; transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg3); color: var(--text); }

/* NAV */
.sidebar-nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all var(--transition); width: 100%; text-align: left;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent2); }
.nav-item svg { flex-shrink: 0; }
.badge {
  margin-left: auto; background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}

/* FILES LIST */
.sidebar-files { flex: 1; padding: 12px 8px; overflow-y: auto; }
.files-header { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 8px 8px; }
.files-empty { font-size: 13px; color: var(--text3); padding: 8px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.file-item:hover { background: var(--bg3); }
.file-icon { font-size: 16px; flex-shrink: 0; }
.file-name { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* SIDEBAR FOOTER */
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 4px; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 10px; flex: 1; min-width: 0; border-radius: var(--radius-sm); transition: background var(--transition); }
.user-info:hover { background: var(--bg3); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; text-transform: uppercase;
}
.user-name { font-size: 13px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 11px; color: var(--text3); }
.logout-btn {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: none; border: none; color: var(--text3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,0.12); color: var(--danger); }

/* ===== AUTH SCREEN ===== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 40px 32px;
  width: 100%; max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: fadeIn 0.3s ease;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px; justify-content: center;
}
.auth-logo .logo-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.auth-logo span { font-size: 18px; font-weight: 800; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text2); text-align: center; margin-bottom: 24px; }
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg3);
  border-radius: 10px; padding: 4px; margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 8px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: none; color: var(--text2); transition: all var(--transition);
}
.auth-tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 12px; font-weight: 600; color: var(--text2); }
.auth-field input {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 14px;
  font-size: 14px; color: var(--text); outline: none; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: 'Inter', sans-serif;
}
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.auth-error {
  font-size: 13px; color: var(--danger);
  background: rgba(239,68,68,0.08); border-radius: 8px;
  padding: 0; max-height: 0; overflow: hidden;
  transition: all 0.2s ease;
}
.auth-error.visible { padding: 10px 12px; max-height: 60px; }
.auth-submit { width: 100%; justify-content: center; padding: 13px; font-size: 15px; margin-top: 4px; }
.auth-footer-note {
  text-align: center; margin-top: 20px;
  font-size: 13px; color: var(--text2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.auth-link {
  background: none; border: none; color: var(--accent2);
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: color var(--transition);
}
.auth-link:hover { color: var(--accent); }

/* ===== MAIN ===== */
.main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg);
}

/* TOPBAR */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px; height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
}
.topbar-menu-btn {
  display: none; background: none; border: none;
  color: var(--text2); cursor: pointer; padding: 6px;
  border-radius: 6px;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
.status-text { font-size: 12px; color: var(--text2); }

/* ===== VIEWS ===== */
.view { display: none; flex: 1; overflow-y: auto; padding: 32px 28px; }
.view.active { display: flex; flex-direction: column; gap: 24px; }

.view-header h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.view-header p { font-size: 14px; color: var(--text2); }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  transition: all var(--transition);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108,99,255,0.05);
  box-shadow: 0 0 40px var(--accent-glow);
}
.upload-zone-inner {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px 32px; gap: 12px; text-align: center;
}
.upload-icon-wrap {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg3); display: flex; align-items: center;
  justify-content: center; color: var(--accent2);
  margin-bottom: 4px;
}
.upload-title { font-size: 20px; font-weight: 600; }
.upload-subtitle { font-size: 14px; color: var(--text2); }
.upload-formats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 4px 0; }
.format-tag {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.format-tag.pdf { background: rgba(239,68,68,0.15); color: #f87171; }
.format-tag.audio { background: rgba(34,197,94,0.15); color: #4ade80; }
.format-tag.video { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* ===== QUEUE ===== */
.upload-queue {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
}
.queue-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.queue-header h3 { font-size: 15px; font-weight: 600; }
.queue-list { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.queue-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg3);
}
.queue-item-icon { font-size: 20px; }
.queue-item-info { flex: 1; min-width: 0; }
.queue-item-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-size { font-size: 11px; color: var(--text3); margin-top: 2px; }
.queue-item-status { font-size: 12px; color: var(--text3); white-space: nowrap; }
.queue-item-remove {
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 4px; border-radius: 4px;
  transition: all var(--transition); font-size: 16px; line-height: 1;
}
.queue-item-remove:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.queue-actions { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== CHAT ===== */
.chat-container {
  flex: 1; display: flex; flex-direction: column;
  height: calc(100vh - 60px); overflow: hidden;
}
#view-chat { padding: 0; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; margin: auto; max-width: 480px; gap: 12px;
}
.welcome-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 8px 32px var(--accent-glow);
  margin-bottom: 4px;
}
.chat-welcome h2 { font-size: 22px; font-weight: 700; }
.chat-welcome p { font-size: 14px; color: var(--text2); line-height: 1.6; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); border-radius: 20px; padding: 8px 16px;
  font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.chip:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* MESSAGES */
.msg { display: flex; gap: 12px; max-width: 720px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.msg.ai .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.msg.user .msg-avatar { background: var(--bg3); color: var(--text2); }
.msg-bubble {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.65; max-width: 100%;
}
.msg.ai .msg-bubble { background: var(--bg2); border: 1px solid var(--border); }
.msg.user .msg-bubble { background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; }
.msg-time { font-size: 11px; color: var(--text3); margin-top: 4px; text-align: right; }

/* TYPING INDICATOR */
.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text3);
  animation: dot-bounce 1.2s infinite ease;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce { 0%,80%,100%{ transform:scale(0.6); } 40%{ transform:scale(1); } }

/* CHAT INPUT */
.chat-input-area {
  padding: 16px 28px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  transition: border-color var(--transition);
}
.chat-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chat-textarea {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; font-family: 'Inter', sans-serif;
  resize: none; line-height: 1.5; max-height: 160px; overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--text3); }
.chat-input-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: none; border: none; color: var(--text3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.send-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); box-shadow: 0 2px 8px var(--accent-glow);
}
.send-btn:hover { transform: scale(1.05); }
.chat-hint { font-size: 11px; color: var(--text3); text-align: center; margin-top: 8px; }

/* ===== SUMMARIES ===== */
.summary-empty, .timeline-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 12px; margin: auto; padding: 48px 0;
}
.empty-icon { color: var(--text3); margin-bottom: 4px; }
.summary-empty h3, .timeline-empty h3 { font-size: 18px; font-weight: 600; }
.summary-empty p, .timeline-empty p { font-size: 14px; color: var(--text2); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.summary-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color var(--transition);
  animation: fadeIn 0.3s ease;
}
.summary-card:hover { border-color: rgba(108,99,255,0.4); }
.summary-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.summary-card-icon { font-size: 22px; }
.summary-card-name { font-size: 14px; font-weight: 600; }
.summary-card-type { font-size: 11px; color: var(--text3); margin-top: 2px; }
.summary-card-body { font-size: 13px; color: var(--text2); line-height: 1.7; }
.summary-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.summary-tag {
  background: var(--bg3); padding: 3px 10px; border-radius: 20px;
  font-size: 11px; color: var(--text2);
}

/* ===== TIMELINE ===== */
.media-player-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.player-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.player-file-info { display: flex; align-items: center; gap: 12px; }
.player-file-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.video-icon { background: rgba(59,130,246,0.15); color: #60a5fa; }
.player-file-name { font-size: 14px; font-weight: 600; }
.player-file-size { font-size: 12px; color: var(--text3); margin-top: 2px; }
.player-controls { display: flex; align-items: center; gap: 12px; }
.player-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.player-btn:hover { background: var(--accent2); transform: scale(1.05); }
.player-progress-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.player-time { font-size: 12px; color: var(--text2); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.player-progress {
  flex: 1; height: 6px; background: var(--bg3);
  border-radius: 4px; cursor: pointer; position: relative; overflow: hidden;
}
.player-progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px; width: 0%; transition: width 0.5s linear;
}
.volume-ctrl { display: flex; align-items: center; gap: 6px; }
.volume-slider { width: 70px; accent-color: var(--accent); cursor: pointer; }

.timestamps-list { display: flex; flex-direction: column; gap: 8px; }
.ts-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  transition: all var(--transition); animation: fadeIn 0.3s ease;
}
.ts-item:hover { border-color: var(--accent); background: rgba(108,99,255,0.05); }
.ts-time {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--accent2); background: var(--bg3);
  padding: 4px 10px; border-radius: 6px; white-space: nowrap; flex-shrink: 0;
}
.ts-label { flex: 1; font-size: 13px; color: var(--text); }
.ts-play-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); border-radius: 6px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); display: flex; align-items: center; gap: 6px;
}
.ts-play-btn:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* ===== OVERLAY ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
}
.overlay-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 48px;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; min-width: 320px; text-align: center;
}
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--bg3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-card h3 { font-size: 17px; font-weight: 600; }
.overlay-card p { font-size: 13px; color: var(--text2); }
.progress-bar-wrap {
  width: 100%; height: 6px; background: var(--bg3);
  border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px; transition: width 0.4s ease;
}
.progress-label { font-size: 13px; color: var(--text2); font-family: 'JetBrains Mono', monospace; }

/* ===== TOASTS ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 2000;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 13px; min-width: 260px; max-width: 360px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity:0; } to { transform:none; opacity:1; } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-text { flex: 1; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); display: flex; align-items: center;
  justify-content: center; z-index: 2000;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; width: 480px; max-width: 95vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: fadeIn 0.2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 18px; padding: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 20px 24px; display: flex; flex-direction: column; gap: 16px;
}
.modal-body > p { font-size: 13px; color: var(--text2); line-height: 1.6; }
.api-key-field { display: flex; flex-direction: column; gap: 6px; }
.api-key-field label { font-size: 12px; font-weight: 600; color: var(--text2); }
.api-key-input-wrap { display: flex; gap: 8px; }
.api-key-input-wrap input, .api-key-field select {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; color: var(--text); font-family: 'JetBrains Mono', monospace;
  outline: none; transition: border-color var(--transition);
  width: 100%;
}
.api-key-field select { font-family: 'Inter', sans-serif; cursor: pointer; }
.api-key-input-wrap input:focus, .api-key-field select:focus {
  border-color: var(--accent);
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .topbar-menu-btn { display: flex; }
  .main { width: 100%; }
  .view { padding: 20px 16px; }
  .chat-messages { padding: 16px; }
  .chat-input-area { padding: 12px 16px 16px; }
  .summary-grid { grid-template-columns: 1fr; }
}
