/* ============================================================
   AI Panel v3 — Dark/Light Theme with Glassmorphism
   ============================================================ */

/* ── Dark theme (default) ── */
:root {
  --bg-primary:    #0f0f1a;
  --bg-secondary:  #1a1a2e;
  --bg-tertiary:   #252542;
  --bg-hover:      #2a2a4a;
  --bg-message-ai: #1e1e36;

  --accent:           #667eea;
  --accent-secondary: #764ba2;
  --accent-dim:       rgba(102, 126, 234, 0.14);
  --accent-dim2:      rgba(102, 126, 234, 0.24);
  --accent-gradient:  linear-gradient(135deg, #667eea, #764ba2);
  --user-gradient:    linear-gradient(135deg, #667eea, #764ba2);

  --text-primary:   #f0f0f8;
  --text-secondary: #9898b8;
  --text-muted:     #60607a;

  --border:        rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(102, 126, 234, 0.35);

  --glow:       0 0 20px rgba(102, 126, 234, 0.15);
  --glow-hover: 0 0 30px rgba(102, 126, 234, 0.25);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-sm:  0 4px 16px rgba(0, 0, 0, 0.3);

  --error:   #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  --radius:    16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:  54px;

  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;

  --transition: 0.3s ease;
  --transition-fast: 0.15s ease;
}

/* ── Light theme — Clean Professional ── */
[data-theme="light"] {
  --bg-primary:    #ffffff;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #f5f5f7;
  --bg-hover:      #f0f0f2;
  --bg-message-ai: #ffffff;

  --accent:           #667eea;
  --accent-secondary: #764ba2;
  --accent-dim:       rgba(102, 126, 234, 0.08);
  --accent-dim2:      rgba(102, 126, 234, 0.15);
  --accent-gradient:  linear-gradient(135deg, #667eea, #764ba2);
  --user-gradient:    linear-gradient(135deg, #667eea, #764ba2);

  --text-primary:   #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted:     #888899;

  --border:        rgba(0, 0, 0, 0.1);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-accent: rgba(102, 126, 234, 0.3);

  --glow:       0 0 20px rgba(102, 126, 234, 0.1);
  --glow-hover: 0 0 30px rgba(102, 126, 234, 0.2);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-sm:  0 4px 16px rgba(0, 0, 0, 0.06);

  --error:   #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}
.hidden { display: none !important; }
button { font-family: var(--font); }

/* ── Screens ── */
.screen { position: fixed; inset: 0; display: flex; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: #000;
}

#matrix-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: 16px;
  background: rgba(10, 10, 30, 0.80);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
              0 0 60px rgba(102, 126, 234, 0.1);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  font-size: 12px;
  color: #6666aa;
  margin-top: 2px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  min-height: 40px;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: #7777aa;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.auth-tab.active {
  background: rgba(102, 126, 234, 0.2);
  color: #f0f0f8;
  box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.35);
}

.auth-tab:hover:not(.active) { color: #f0f0f8; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: #8888b8;
}

.hint { color: #6666aa; font-weight: 400; }

.field input, .field-textarea {
  padding: 11px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xs);
  color: #f0f0f8;
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field input:focus, .field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.field-textarea {
  resize: vertical;
  line-height: 1.5;
  min-height: 120px;
}

/* App screen fields - use CSS vars */
#app-screen .field input,
#app-screen .field-textarea {
  background: var(--bg-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}

#app-screen .field input::placeholder,
#app-screen .field-textarea::placeholder { color: var(--text-muted); }

#app-screen .field label { color: var(--text-secondary); }
#app-screen .hint { color: var(--text-muted); }

.btn-primary {
  min-height: 44px;
  padding: 11px 20px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover { opacity: 0.9; box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  min-height: 44px;
  padding: 11px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-secondary:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-danger {
  min-height: 44px;
  padding: 11px 20px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

.auth-error {
  font-size: 13px;
  color: var(--error);
  min-height: 20px;
}

.pwd-field {
  position: relative;
  display: flex;
  align-items: center;
}

.pwd-field input { width: 100%; padding-right: 44px; }

.pwd-toggle {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #6666aa;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  min-width: 32px;
  min-height: 32px;
}

.pwd-toggle:hover { color: #9898c8; }

/* ============================================================
   APP SCREEN — Layout
   ============================================================ */
#app-screen {
  flex-direction: row;
  background: var(--bg-primary);
}

body.impersonating #app-screen {
  top: 38px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 105;
  backdrop-filter: blur(3px);
  cursor: pointer;
}

/* ── Drop overlay ── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 500;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 48px 64px;
  animation: pulse-border 1.5s ease infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--accent); opacity: 1; }
  50%       { border-color: var(--accent-secondary); opacity: 0.7; }
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(26, 26, 46, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  height: 100%;
  z-index: 110;
  transition: width 0.3s ease;
  overflow: hidden;
}

[data-theme="light"] .sidebar {
  background: #f5f5f7;
  border-right: 1px solid #e0e0e5;
}

/* Collapsed sidebar */
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar.collapsed .sidebar-text { display: none; }
.sidebar.collapsed .sidebar-section-header .sidebar-text { display: none; }
.sidebar.collapsed .sidebar-section-header .btn-section-action { display: none; }
.sidebar.collapsed .project-name { display: none; }
.sidebar.collapsed .project-edit-btn { display: none !important; }
.sidebar.collapsed .session-title { display: none; }
.sidebar.collapsed .session-delete { display: none !important; }
.sidebar.collapsed .sidebar-username { display: none; }
.sidebar.collapsed .sidebar-footer-user { justify-content: center; padding-bottom: 6px; }
.sidebar.collapsed .sessions-empty,
.sidebar.collapsed .projects-empty { display: none; }

.sidebar.collapsed .btn-new-chat {
  justify-content: center;
  padding: 10px;
  min-width: 0;
}

.sidebar.collapsed .sidebar-footer {
  align-items: center;
  padding: 8px 6px 10px;
}

.sidebar.collapsed .btn-footer-action {
  width: 40px;
  min-height: 40px;
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .btn-footer-action .sidebar-text { display: none; }

.sidebar.collapsed .theme-btn { width: 32px; height: 32px; }

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform 0.3s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.btn-new-chat {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.25);
  white-space: nowrap;
  overflow: hidden;
}

.btn-new-chat:hover { opacity: 0.9; box-shadow: 0 4px 18px rgba(102, 126, 234, 0.4); }

.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Sidebar sections ── */
.sidebar-section {
  padding: 8px 8px 0;
}

.sidebar-section-flex {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.btn-section-action {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-section-action:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 12px;
}

/* Projects list */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 4px;
}

.project-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  gap: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}

.project-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.project-item.active {
  background: linear-gradient(90deg, rgba(102,126,234,0.18) 0%, rgba(102,126,234,0.08) 100%);
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
  font-weight: 500;
}

[data-theme="light"] .project-item.active {
  background: linear-gradient(90deg, rgba(102,126,234,0.12) 0%, rgba(102,126,234,0.04) 100%);
  border-left-color: var(--accent);
}

.project-item .project-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.project-item .project-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item .project-edit-btn {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  min-width: 24px;
  min-height: 24px;
}

.project-item:hover .project-edit-btn { opacity: 1; }
.project-item .project-edit-btn:hover { color: var(--accent); }

/* Sessions list */
.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sessions-list::-webkit-scrollbar { width: 4px; }
.sessions-list::-webkit-scrollbar-track { background: transparent; }
.sessions-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.session-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  gap: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  min-height: 40px;
  white-space: nowrap;
  overflow: hidden;
}

.session-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.session-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  font-weight: 500;
}

[data-theme="light"] .session-item.active {
  background: rgba(102, 126, 234, 0.08);
  border-left-color: var(--accent);
}

.session-item .session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-rename-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  padding: 2px 6px;
  outline: none;
  min-width: 0;
}

.session-item .session-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-item:hover .session-delete { opacity: 1; }
.session-item .session-delete:hover { color: var(--error); }

.sessions-empty, .projects-empty {
  padding: 12px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-footer-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 6px;
  min-height: 30px;
  gap: 4px;
}

.sidebar-username {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.btn-footer-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  min-height: 40px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  text-align: left;
  flex-shrink: 0;
}

.btn-footer-action svg {
  flex-shrink: 0;
}

.btn-footer-action .sidebar-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-footer-action:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.btn-footer-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.theme-btn:hover { color: var(--accent); }

/* ── Chat Main ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.chat-topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

[data-theme="light"] .chat-topbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.menu-btn { display: none; }

.chat-topbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.chat-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-project-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-spacer { flex: 1; }

/* Model selector */
.model-selector {
  position: relative;
  flex-shrink: 0;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.model-selector-btn:hover {
  border-color: var(--border-accent);
  background: var(--accent-dim);
}

.model-chevron {
  transition: transform 0.15s ease;
  opacity: 0.6;
}

.model-selector.open .model-chevron {
  transform: rotate(180deg);
}

.model-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.model-badge-sonnet {
  background: rgba(102, 126, 234, 0.18);
  border: 1px solid rgba(102, 126, 234, 0.35);
  color: #8fa8f5;
}

.model-badge-opus {
  background: rgba(118, 75, 162, 0.22);
  border: 1px solid rgba(118, 75, 162, 0.45);
  color: #b07de0;
}

.model-badge-haiku {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.model-badge-deepseek {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.35);
  color: #fb923c;
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
}

.model-option:hover {
  background: var(--bg-hover);
}

.model-option.active {
  background: var(--accent-dim);
}

.model-option-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.model-option-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.model-option-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.model-option-check {
  color: var(--accent);
  opacity: 0;
  flex-shrink: 0;
}

.model-option.active .model-option-check {
  opacity: 1;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.messages::-webkit-scrollbar-thumb:hover { background: var(--bg-tertiary); }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: var(--glow);
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p { font-size: 14px; }

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  min-height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), transform var(--transition-fast),
              box-shadow var(--transition-fast);
}

.quick-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-accent);
  transform: translateY(-1px);
  box-shadow: var(--glow);
}

/* Message bubbles */
.message {
  display: flex;
  gap: 10px;
  max-width: 820px;
  width: 100%;
  align-self: center;
  animation: msg-appear 0.25s ease;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: var(--accent-gradient);
  color: white;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.message.user .message-avatar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--accent);
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.message.user .message-content { align-items: flex-end; }
.message.assistant .message-content { align-items: flex-start; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.message-role {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
  max-width: 100%;
}

.message.user .message-bubble {
  background: var(--user-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
  white-space: pre-wrap;
}

.message.assistant .message-bubble {
  background: var(--bg-message-ai);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

/* Tool use indicator */
.tool-use-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 500px;
  align-self: flex-start;
  margin-left: 42px;
}

.tool-use-indicator svg {
  color: var(--accent);
  flex-shrink: 0;
  animation: spin 1.5s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Markdown */
.message-bubble h1, .message-bubble h2,
.message-bubble h3, .message-bubble h4 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.3;
}
.message-bubble h1 { font-size: 1.4em; }
.message-bubble h2 { font-size: 1.2em; }
.message-bubble h3 { font-size: 1.05em; }
.message-bubble p { margin: 0 0 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 8px 0; padding-left: 22px; }
.message-bubble li { margin: 3px 0; }

.message-bubble code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(102, 126, 234, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  color: #a78bfa;
}

.message.user .message-bubble code {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

[data-theme="light"] .message.assistant .message-bubble code {
  background: rgba(102, 126, 234, 0.1);
  color: #7c3aed;
}

.message-bubble pre {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0d0d18;
  border: 1px solid rgba(255,255,255,0.08);
}

.message-bubble pre code {
  display: block;
  padding: 14px 16px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  overflow-x: auto;
}

.message-bubble pre code::-webkit-scrollbar { height: 4px; }
.message-bubble pre code::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

.message-bubble blockquote {
  border-left: 3px solid var(--accent);
  margin: 10px 0;
  padding: 4px 14px;
  color: var(--text-secondary);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.message-bubble th, .message-bubble td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  text-align: left;
}

.message-bubble th { background: var(--bg-tertiary); font-weight: 600; }
.message-bubble a { color: #a78bfa; text-decoration: none; }
.message-bubble a:hover { text-decoration: underline; }
.message-bubble hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Code block wrapper */
.code-block-wrapper { position: relative; margin: 12px 0; }

.code-lang {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.code-block-wrapper:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255,255,255,0.14); color: white; }
.code-copy-btn.copied { color: #4ade80; }

/* Message stats */
.message-stats {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.85;
  padding: 2px 2px 0;
  user-select: none;
}

/* Thinking indicator */
.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 10px 72px;
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.thinking-dots { display: flex; gap: 4px; }

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.input-area {
  padding: 8px 20px 20px;
  flex-shrink: 0;
}

.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 8px;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent);
  max-width: 200px;
}

.attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip-remove {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  font-size: 14px;
  line-height: 1;
  min-width: 16px;
  min-height: 16px;
}

.attach-chip-remove:hover { opacity: 1; }

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-attach {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-attach:hover { color: var(--accent); background: var(--accent-dim); }

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

#message-input::placeholder { color: var(--text-muted); }
#message-input::-webkit-scrollbar { width: 4px; }
#message-input::-webkit-scrollbar-thumb { background: var(--border); }

.btn-send {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.btn-send:hover:not(:disabled) { opacity: 0.9; box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45); }
.btn-send:active:not(:disabled) { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
/* ===== IMPERSONATION BANNER ===== */
.impersonate-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: #f59e0b;
  color: #1a1a1a;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 600;
}

.impersonate-restore-btn {
  background: rgba(0,0,0,0.15);
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.impersonate-restore-btn:hover {
  background: rgba(0,0,0,0.25);
}

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  min-width: 300px;
  max-width: 500px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  pointer-events: all;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: #3d1010;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

[data-theme="light"] .toast-error {
  background: #fff0f0;
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.toast-success {
  background: #0e2e1a;
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

[data-theme="light"] .toast-success {
  background: #f0fdf4;
  border-color: rgba(34, 197, 94, 0.3);
  color: #16a34a;
}

.toast-info {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
}

.toast-close {
  background: transparent;
  border: none;
  color: currentColor;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.toast-close:hover { opacity: 1; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--glow);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  animation: modal-appear 0.2s ease;
}

.modal-box-lg { max-width: 620px; }

@keyframes modal-appear {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h2 { font-size: 17px; font-weight: 600; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Upload area */
.upload-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.upload-area:hover { border-color: var(--accent); background: var(--accent-dim); }

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-label svg { color: var(--accent); }

.files-list, .project-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xs);
  font-size: 13px;
  transition: background var(--transition-fast);
}

.file-item:hover { background: var(--bg-hover); }

.file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.file-item .file-size { color: var(--text-muted); flex-shrink: 0; font-size: 12px; }

.file-item .file-action {
  min-width: 32px;
  min-height: 32px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-item .file-action:hover { color: var(--accent); background: var(--accent-dim); }
.file-item .file-action.delete:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }

.files-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px; }

.project-files-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.project-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-upload-small {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  min-height: 32px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xs);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-upload-small:hover { background: var(--accent-dim2); }

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.confirm-box {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: modal-appear 0.2s ease;
}

.confirm-box p {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   STATS SCREEN (Full Page)
   ============================================================ */
.stats-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

.stats-screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.stats-screen-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-back:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.stats-screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 900px;
  width: 100%;
  align-self: center;
}

.stats-screen-body::-webkit-scrollbar { width: 6px; }
.stats-screen-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.stats-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.stats-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stats-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--glow);
}

.stats-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.stats-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.stats-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.stats-row:last-child { border-bottom: none; }

.stats-row-label { color: var(--text-secondary); }

.stats-row-value {
  font-weight: 600;
  color: var(--text-primary);
}

.stats-row-value.accent { color: var(--accent); font-size: 15px; }

/* Activity chart */
.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding: 8px 0 0;
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.chart-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  height: 16px;
  display: flex;
  align-items: center;
}

.chart-bar-col {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.chart-bar {
  width: 100%;
  background: var(--accent-gradient);
  border-radius: 4px 4px 2px 2px;
  min-height: 4px;
  transition: height 0.4s ease;
  opacity: 0.85;
}

.chart-bar:hover { opacity: 1; }

.chart-day-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  height: 24px;
  display: flex;
  align-items: center;
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 720px) {
  .sidebar-collapse-btn { display: none; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    width: min(var(--sidebar-w), 88vw) !important;
    z-index: 110;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: min(var(--sidebar-w), 88vw) !important; }
  .sidebar.collapsed .sidebar-text { display: inline !important; }
  .sidebar.collapsed .project-name { display: block !important; }
  .sidebar.collapsed .session-title { display: block !important; }
  .sidebar.collapsed .sidebar-username { display: block !important; }
  .sidebar.collapsed .sidebar-footer { flex-direction: column !important; align-items: stretch !important; }
  .sidebar.collapsed .sidebar-footer-user { justify-content: space-between !important; }
  .sidebar.collapsed .btn-footer-action { width: 100% !important; padding: 0 10px !important; justify-content: flex-start !important; }
  .sidebar.collapsed .sidebar-section-header .sidebar-text { display: block !important; }
  .sidebar.collapsed .btn-section-action { display: flex !important; }
  .sidebar.collapsed .btn-new-chat { justify-content: flex-start !important; padding: 9px 12px !important; }

  .sidebar-close-btn { display: flex; }

  .menu-btn {
    display: flex;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .chat-topbar { padding: 0 12px; }
  .messages { padding: 16px 12px; gap: 16px; }
  .input-area { padding: 6px 12px 16px; }
  .input-wrapper { padding: 8px 10px; gap: 6px; }
  #message-input { font-size: 16px; }
  .message-bubble { font-size: 14px; }
  .thinking { padding-left: 20px; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .quick-actions { flex-direction: column; align-items: stretch; }
  .quick-action-btn { justify-content: center; }

  .session-item .session-delete {
    opacity: 1;
    min-width: 36px;
    min-height: 44px;
  }

  .project-item .project-edit-btn {
    opacity: 1;
    min-width: 36px;
    min-height: 44px;
  }

  .file-item .file-action { min-width: 44px; min-height: 44px; }
  .session-item { min-height: 44px; }
  .project-item { min-height: 44px; }

  .stats-screen-body { padding: 16px; gap: 16px; }
  .stats-screen-header { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 18px; margin: 12px; }
  .auth-logo h1 { font-size: 20px; }
  .empty-state h2 { font-size: 18px; }
  .empty-state { padding: 24px 16px; }
  .sidebar-footer { padding: 8px 10px 12px; }
  .sidebar-footer-user { padding-bottom: 8px; }
  .modal-box { margin: 8px; max-height: 93vh; }
  .messages { padding: 10px 8px; gap: 12px; }
  .message-bubble { font-size: 14px; padding: 10px 12px; }
  .chat-topbar { padding: 0 8px; }
  .modal-actions { flex-direction: column; gap: 8px; }
  .modal-actions-right { width: 100%; }
  .modal-actions-right .btn-secondary,
  .modal-actions-right .btn-primary { flex: 1; }
}

/* ============================================================
   REMEMBER BUTTON
   ============================================================ */

.message-remember {
  margin-top: 6px;
  display: flex;
  align-items: center;
}

.remember-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.6;
}

.remember-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(102, 126, 234, 0.08);
}

.remember-btn.remembered {
  color: var(--success, #4caf50);
  border-color: transparent;
  cursor: default;
}

.remember-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   USER SETTINGS MODAL
   ============================================================ */

.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child { border-bottom: none; }

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.settings-section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.settings-row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.settings-select:focus { border-color: var(--accent); }

.settings-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.settings-input:focus { border-color: var(--accent); }

.settings-msg {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}

.settings-msg-ok {
  color: var(--success, #4caf50);
  background: rgba(76, 175, 80, 0.1);
}

.settings-msg-error {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* Password field with eye toggle */
.password-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field-wrap input {
  flex: 1;
  padding-right: 42px;
  font-size: 16px; /* iOS zoom fix */
}
.pwd-toggle-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color var(--transition-fast);
  line-height: 0;
}
.pwd-toggle-btn:hover { color: var(--text-primary); }

/* Theme toggle switch */
.theme-toggle-row { align-items: center; gap: 8px; }
.theme-toggle-row > svg { color: var(--text-muted); flex-shrink: 0; }

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-switch-track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s;
}
.theme-switch input:checked + .theme-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(20px);
}

/* Textarea with counter */
.textarea-wrap { position: relative; }
.textarea-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  opacity: 0.85;
}

/* Loading skeleton for textareas */
.skeleton-textarea {
  height: 160px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s infinite linear;
}
@keyframes skeleton-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Disabled save buttons */
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Mobile: stack actions vertically */
@media (max-width: 480px) {
  .settings-section-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-section-actions .btn-primary {
    width: 100%;
    text-align: center;
  }
}

/* ============================================================
   ADMIN PANEL SCREEN
   ============================================================ */

.admin-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
}

.admin-screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.admin-screen-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-tabs-bar {
  display: flex;
  gap: 2px;
  padding: 8px 24px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
  overflow-x: auto;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  transition: all 0.2s;
  white-space: nowrap;
}

.admin-tab-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.admin-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.admin-tab-pane { min-height: 200px; }

.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Admin table */

.admin-table-wrap { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--bg-hover); }
.admin-td-sm { white-space: nowrap; color: var(--text-muted); font-size: 12px; }

.btn-sm {
  font-size: 11px !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  min-height: 28px !important;
}

/* Admin sessions */

.admin-sessions-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-session-title { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Monitoring panel (replaces iframe) ── */
.monitoring-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 8px 0;
}

.monitoring-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .monitoring-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .monitoring-stats-grid { grid-template-columns: 1fr 1fr; }
}

.monitoring-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: 14px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.monitoring-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.16);
}

.monitoring-stat-icon {
  font-size: 26px;
  line-height: 1;
}

.monitoring-stat-value {
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.monitoring-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.monitoring-grafana-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.monitoring-grafana-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--accent-gradient);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.monitoring-grafana-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 28px rgba(102, 126, 234, 0.5);
}

.monitoring-grafana-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* Admin stats filter */

.admin-stats-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-period-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-period-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-period-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.admin-period-custom {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Session view modal */

.admin-session-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.admin-msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.admin-msg-user { background: var(--bg-secondary); }
.admin-msg-assistant { background: rgba(102, 126, 234, 0.06); border-left: 3px solid var(--accent); }

.admin-msg-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.admin-msg-content { color: var(--text-primary); line-height: 1.5; word-break: break-word; }
.admin-msg-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Logs */

.logs-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.logs-output {
  background: #0d0d17;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  height: 480px;
  overflow-y: auto;
  font-family: "Fira Code", "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-line { color: #b0b8cc; padding: 1px 0; word-break: break-all; }
.log-error { color: #ff6b6b; }
.log-warn { color: #ffd93d; }
.log-info { color: #6bcb77; }

/* Terminal */

.terminal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.terminal-status {
  font-size: 12px;
  color: #b0b8cc;
}

.terminal-status.connected {
  color: #6bcb77;
}

.terminal-output {
  background: #0d0d17;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  height: 520px;
  overflow-y: auto;
  font-family: "Fira Code", "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #c8d0e0;
  white-space: pre-wrap;
  word-break: break-all;
  cursor: text;
  outline: none;
}

.terminal-output:focus {
  border-color: var(--accent);
}

/* Admin env settings */

.admin-env-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: monospace;
}

.admin-env-input:focus { border-color: var(--accent); }

/* ============================================================
   RESPONSIVE — Admin
   ============================================================ */

@media (max-width: 768px) {
  .admin-screen-header { padding: 10px 16px; }
  .admin-screen-body { padding: 16px; }
  .admin-tabs-bar { padding: 6px 16px 0; }
  .admin-tab-btn { padding: 7px 10px; font-size: 12px; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 7px 8px; }
  .logs-output { height: 320px; }
}

/* ============================================================
   AUTH — SCI-FI ENHANCEMENTS
   ============================================================ */

/* Particles canvas */
#auth-particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Pulsating glow border around card */
@keyframes cardGlow {
  0%, 100% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 40px rgba(102, 126, 234, 0.08),
      0 0 0 1px rgba(102, 126, 234, 0.15);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 70px rgba(118, 75, 162, 0.25),
      0 0 0 1px rgba(118, 75, 162, 0.4);
  }
}

.auth-card {
  animation: cardGlow 4s ease-in-out infinite;
  border: 1px solid rgba(102, 126, 234, 0.25) !important;
}

/* Star logo animation */
@keyframes starPulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 6px rgba(102, 126, 234, 0.5)); }
  33%       { transform: scale(1.08) rotate(15deg); filter: drop-shadow(0 0 14px rgba(118, 75, 162, 0.8)); }
  66%       { transform: scale(1.04) rotate(-10deg); filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.6)); }
}

.auth-star-svg {
  animation: starPulse 3.5s ease-in-out infinite;
  transform-origin: center;
}

.auth-logo-icon {
  overflow: visible !important;
}

/* Typing cursor */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.auth-cursor {
  animation: blink 1s step-end infinite;
  color: #667eea;
  font-weight: 300;
  margin-left: 1px;
}

/* Input: gradient underline on focus (Material Design style) */
.auth-form .field input {
  border-bottom: 2px solid transparent !important;
  border-top: 1px solid rgba(255,255,255,0.08) !important;
  border-left: 1px solid rgba(255,255,255,0.08) !important;
  border-right: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0 !important;
  background: rgba(0, 0, 0, 0.25) !important;
  transition: border-bottom-color 0.25s ease, box-shadow 0.25s ease, background 0.2s !important;
  position: relative;
}

.auth-form .field input:focus {
  border-bottom-color: #667eea !important;
  border-top-color: rgba(255,255,255,0.14) !important;
  border-left-color: rgba(255,255,255,0.14) !important;
  border-right-color: rgba(255,255,255,0.14) !important;
  box-shadow:
    0 2px 0 0 #764ba2,
    0 0 18px rgba(102, 126, 234, 0.12) !important;
  background: rgba(0, 0, 0, 0.35) !important;
}

/* Login button: shimmer + scale */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.auth-form .btn-primary {
  position: relative;
  overflow: hidden;
  background-size: 200% auto;
  background-image: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #9b59b6 55%, #667eea 100%);
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.auth-form .btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,0.18) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  background-position: -200% 0;
  transition: none;
}

.auth-form .btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.55) !important;
  opacity: 1 !important;
}

.auth-form .btn-primary:hover::after {
  animation: shimmer 0.7s linear;
}

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

/* ============================================================
   STATUS INDICATOR (topbar)
   ============================================================ */

.status-indicator-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.status-indicator-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-ok      { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-dot-err     { background: var(--error);   box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.status-dot-unknown { background: var(--text-muted); }

.status-indicator-label { font-size: 12px; }

/* ============================================================
   ANNOUNCEMENT BANNER
   ============================================================ */

.announcement-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 13px;
  flex-shrink: 0;
  border-bottom: 1px solid transparent;
}
.ann-banner-info        { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.3); color: #93c5fd; }
.ann-banner-warning     { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.3); color: #fcd34d; }
.ann-banner-maintenance { background: rgba(249,115,22,0.15); border-color: rgba(249,115,22,0.3); color: #fdba74; }
.ann-banner-incident    { background: rgba(239,68,68,0.15);  border-color: rgba(239,68,68,0.3);  color: #fca5a5; }
.ann-banner-critical    { background: rgba(239,68,68,0.2);   border-color: rgba(239,68,68,0.5);  color: #fca5a5; font-weight: 600; }

.ann-banner-icon { font-size: 16px; flex-shrink: 0; }
.ann-banner-text { flex: 1; }
.ann-banner-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: currentColor;
  opacity: 0.6;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.ann-banner-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* ============================================================
   STATUS SCREEN
   ============================================================ */

.status-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.status-page-header {
  margin-bottom: 28px;
}
.status-page-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.status-overall {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.status-overall-ok  { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.status-overall-err { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }

.status-section { margin-bottom: 28px; }
.status-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Components */
.status-components { display: flex; flex-direction: column; gap: 1px; }
.status-component {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 6px;
}
.status-comp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.status-comp-icon { font-size: 14px; flex-shrink: 0; }
.status-comp-name { flex: 1; font-size: 14px; color: var(--text-primary); font-weight: 500; }
.status-comp-status { font-size: 13px; }
.status-comp-ms { font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.text-ok   { color: var(--success); }
.text-err  { color: var(--error); }
.text-muted { color: var(--text-muted); }

/* Uptime bars */
.uptime-bars {
  display: flex;
  gap: 1px;
  height: 24px;
  align-items: flex-end;
}
.uptime-bar {
  width: 3px;
  flex: none;
  border-radius: 1px;
  height: 100%;
}
.uptime-bar-ok      { background: var(--success); opacity: 0.85; }
.uptime-bar-warn    { background: var(--warning); opacity: 0.85; }
.uptime-bar-err     { background: var(--error);   opacity: 0.85; }
.uptime-bar-unknown { background: var(--bg-tertiary); }
.uptime-bar:hover   { opacity: 1; }
.uptime-bar-current {
  opacity: 1 !important;
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
  animation: uptime-bar-pulse 1.4s ease-in-out infinite;
}
@keyframes uptime-bar-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
  50%       { box-shadow: 0 0 0 3px rgba(255,255,255,0); }
}

/* Custom tooltip for uptime bars */
#uptime-tooltip {
  position: fixed;
  background: rgba(15,15,30,0.96);
  color: #f0f0f8;
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.12s;
}
#uptime-tooltip.visible { opacity: 1; }

.uptime-bars-legend {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Announcements on status page */
.status-announcement {
  border-left: 3px solid var(--border);
  padding: 12px 14px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  background: var(--bg-secondary);
  margin-bottom: 8px;
}
.status-ann-info        { border-color: #3b82f6; }
.status-ann-warning     { border-color: #f59e0b; }
.status-ann-maintenance { border-color: #f97316; }
.status-ann-incident    { border-color: #ef4444; }
.status-ann-critical    { border-color: #ef4444; background: rgba(239,68,68,0.07); }

.status-ann-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-ann-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 500;
}
.status-ann-date { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.status-ann-body { margin-top: 6px; font-size: 13px; color: var(--text-secondary); }

/* ============================================================
   ADMIN ANNOUNCEMENTS TAB
   ============================================================ */

.ann-admin-panel { padding: 20px; max-width: 700px; }
.ann-form { background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 20px; margin-bottom: 8px; }
.ann-form-row { display: flex; gap: 16px; }
.ann-form-row .field { flex: 1; }
.admin-section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; }
.ann-list { display: flex; flex-direction: column; gap: 8px; }
.ann-list-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 12px 14px;
}
.ann-list-info        { border-left-color: #3b82f6; }
.ann-list-warning     { border-left-color: #f59e0b; }
.ann-list-maintenance { border-left-color: #f97316; }
.ann-list-incident    { border-left-color: #ef4444; }
.ann-list-critical    { border-left-color: #ef4444; background: rgba(239,68,68,0.07); }
.ann-list-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ann-list-date { font-size: 12px; color: var(--text-muted); }
.ann-source-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 8px; }
.ann-source-manual { background: rgba(102,126,234,0.15); color: #a0b0f0; border: 1px solid rgba(102,126,234,0.3); }
.ann-source-auto   { background: rgba(245,158,11,0.15);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.ann-list-body { margin-top: 6px; font-size: 13px; color: var(--text-secondary); }
.ann-list-expires { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.admin-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ============================================================
   SIDEBAR FOOTER — Full-width buttons + collapsed tooltips
   ============================================================ */

/* Ensure footer buttons are always full-width, 40px, icon+text */
.sidebar-footer {
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 12px;
}

.btn-footer-action {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: left;
  position: relative;
  flex-shrink: 0;
}

/* Collapsed: icon centered, custom tooltip via CSS */
.sidebar.collapsed .btn-footer-action {
  width: 40px;
  padding: 0;
  justify-content: center;
}

/* Custom tooltip for collapsed sidebar buttons */
.sidebar.collapsed .btn-footer-action::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}

.sidebar.collapsed .btn-footer-action:hover::after {
  opacity: 1;
}

/* Light theme specific accents */
[data-theme="light"] .btn-footer-action:hover {
  background: rgba(102, 126, 234, 0.08);
  color: var(--accent);
}

[data-theme="light"] .btn-footer-logout:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--error);
}

/* ============================================================
   CHAT MATRIX CANVAS (subtle background)
   ============================================================ */

#chat-matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}

#app-screen .main-area,
#app-screen .sidebar {
  position: relative;
  z-index: 1;
}

/* ============================================================
   LIGHT THEME — Message bubbles and buttons
   ============================================================ */

[data-theme="light"] .message.user .message-bubble {
  background: var(--user-gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

[data-theme="light"] .message.user .message-bubble::before {
  display: none;
}

[data-theme="light"] .message.assistant .message-bubble {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-left: 3px solid var(--accent);
  color: #1a1a2e;
}

[data-theme="light"] .message.ai .message-bubble {
  background: #ffffff;
  border-color: rgba(102, 126, 234, 0.2);
}

[data-theme="light"] .btn-primary {
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

[data-theme="light"] .btn-primary:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

[data-theme="light"] .btn-new-chat {
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.25);
}

[data-theme="light"] .btn-new-chat:hover {
  box-shadow: 0 4px 18px rgba(102, 126, 234, 0.4);
}

[data-theme="light"] .input-area {
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .input-wrapper {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .message-bubble pre {
  background: #f4f4f8;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-bubble pre code {
  color: #1a1a2e;
}

[data-theme="light"] .ann-banner-info        { color: #1d4ed8; }
[data-theme="light"] .ann-banner-warning     { color: #b45309; }
[data-theme="light"] .ann-banner-maintenance { color: #c2410c; }
[data-theme="light"] .ann-banner-incident    { color: #b91c1c; }
[data-theme="light"] .ann-banner-critical    { color: #b91c1c; }

/* ============================================================
   BLOCKED IPs ADMIN TABLE
   ============================================================ */

.blocked-ips-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.blocked-ips-table th,
.blocked-ips-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.blocked-ips-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.blocked-ips-table td { color: var(--text-primary); }
.blocked-ips-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
