/* ===== Font Import ===== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== Theme Variables ===== */
:root,
[data-theme="dark"] {
  --bg-primary: #09090b;
  --bg-secondary: #0f0f12;
  --bg-tertiary: #16161a;
  --bg-hover: #1c1c22;
  --bg-active: #25252d;
  --text-primary: #ececef;
  --text-secondary: #8a8a97;
  --text-muted: #4a4a56;
  --border: #1e1e26;
  --border-light: #2a2a35;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-dim: rgba(139, 92, 246, 0.10);
  --accent-glow: rgba(139, 92, 246, 0.25);
  --user-msg: rgba(139, 92, 246, 0.06);
  --user-msg-border: rgba(139, 92, 246, 0.12);
  --ai-msg: rgba(255, 255, 255, 0.02);
  --ai-msg-border: rgba(255, 255, 255, 0.04);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.08);
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.08);
  --warning: #eab308;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --code-bg: #0c0c0f;
  --code-header: #141418;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 272px;
  --input-bg: #141418;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.06);
  --gradient-1: #8b5cf6;
  --gradient-2: #ec4899;
  --gradient-3: #06b6d4;
}

[data-theme="light"] {
  --bg-primary: #fafaf9;
  --bg-secondary: #f3f3f1;
  --bg-tertiary: #eaeae7;
  --bg-hover: #e2e2de;
  --bg-active: #d9d9d4;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b76;
  --text-muted: #a3a3af;
  --border: #e2e2de;
  --border-light: #ebebea;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-dim: rgba(124, 58, 237, 0.06);
  --accent-glow: rgba(124, 58, 237, 0.15);
  --user-msg: rgba(124, 58, 237, 0.04);
  --user-msg-border: rgba(124, 58, 237, 0.10);
  --ai-msg: rgba(0, 0, 0, 0.015);
  --ai-msg-border: rgba(0, 0, 0, 0.04);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.05);
  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.05);
  --warning: #ca8a04;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.10);
  --code-bg: #f0f0ed;
  --code-header: #e5e5e2;
  --input-bg: #f0f0ed;
  --glass: rgba(0, 0, 0, 0.02);
  --glass-border: rgba(0, 0, 0, 0.05);
  --gradient-1: #7c3aed;
  --gradient-2: #db2777;
  --gradient-3: #0891b2;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
}

/* ===== Sidebar ===== */
#sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

#sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--accent-dim) 30%,
    var(--accent-dim) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.sidebar-top {
  padding: 16px 14px 12px;
}

.new-chat-btn {
  width: 100%;
  padding: 11px 16px;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.2);
}

.new-chat-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.12) 100%);
  opacity: 0;
  transition: opacity 0.25s;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}
.new-chat-btn:hover::before { opacity: 1; }

.new-chat-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

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

.conv-item.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
  font-weight: 500;
  border-color: var(--user-msg-border);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--gradient-1), var(--gradient-2));
  border-radius: 0 3px 3px 0;
}

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

.conv-delete {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 5px;
  line-height: 1;
  transition: all 0.15s;
}
.conv-item:hover .conv-delete { display: flex; }
.conv-delete:hover { color: var(--danger); background: var(--danger-dim); }

.sidebar-bottom {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-secondary);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.18s;
}
.sidebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-icon::before { content: "\263E"; font-size: 18px; }
[data-theme="light"] .theme-icon::before { content: "\2600"; }

/* ===== Main ===== */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-primary);
  position: relative;
}

/* Subtle ambient top gradient */
#main::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: radial-gradient(
    ellipse 60% 80% at 50% -20%,
    var(--accent-dim) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ===== Header ===== */
#chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 2;
}

#chat-title {
  flex: 1;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-btn, .delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
}
.menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.delete-btn:hover { background: var(--danger-dim); color: var(--danger); }
.menu-btn { display: none; }

/* ===== Messages ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

/* Welcome / Empty state */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  position: relative;
}

.welcome-icon {
  font-size: 20px;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* Animated gradient orb behind the welcome icon */
.welcome-icon::before {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--gradient-1),
    var(--gradient-2),
    var(--gradient-3),
    var(--gradient-1)
  );
  filter: blur(32px);
  opacity: 0.5;
  animation: orb-spin 8s linear infinite, orb-breathe 4s ease-in-out infinite;
  z-index: -1;
}

.welcome-icon::after {
  content: '';
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: conic-gradient(
    from 180deg,
    var(--gradient-3),
    var(--gradient-1),
    var(--gradient-2),
    var(--gradient-3)
  );
  filter: blur(20px);
  opacity: 0.35;
  animation: orb-spin 6s linear infinite reverse, orb-breathe 3s ease-in-out infinite 1s;
  z-index: -1;
}

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

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

.welcome h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome p {
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* Message Row */
.msg-row {
  padding: 2px 0;
  display: flex;
  justify-content: center;
  animation: msg-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.msg-content {
  width: 100%;
  max-width: 760px;
  padding: 18px 28px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-radius: var(--radius);
  margin: 2px auto;
  transition: background 0.2s;
}

.msg-user .msg-content {
  background: var(--user-msg);
  border: 1px solid var(--user-msg-border);
}

.msg-ai .msg-content {
  background: var(--ai-msg);
  border: 1px solid var(--ai-msg-border);
}

.msg-ai .msg-content:hover {
  background: var(--glass);
  border-color: var(--glass-border);
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
  transition: transform 0.2s;
}

.msg-row:hover .msg-avatar {
  transform: scale(1.05);
}

.msg-user .msg-avatar {
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

.msg-ai .msg-avatar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 15px;
}

.msg-body {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  line-height: 1.72;
  letter-spacing: -0.005em;
}

.msg-body p { margin-bottom: 12px; }
.msg-body p:last-child { margin-bottom: 0; }

.msg-body ul, .msg-body ol {
  margin: 10px 0;
  padding-left: 22px;
}

.msg-body li { margin-bottom: 5px; }
.msg-body strong { font-weight: 600; }
.msg-body em { font-style: italic; }

.msg-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  transition: border-color 0.15s;
}
.msg-body a:hover {
  border-color: var(--accent);
}

/* Inline Code */
.msg-body code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 12.5px;
}

/* Code Blocks */
.code-block {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--code-header);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.copy-code-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 5px;
  transition: all 0.18s;
  text-transform: none;
  letter-spacing: 0;
}
.copy-code-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  background: var(--code-bg);
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.code-block pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Typing Cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: linear-gradient(180deg, var(--gradient-1), var(--gradient-2));
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: cursor-blink 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes cursor-blink {
  0%, 40% { opacity: 1; }
  50%, 90% { opacity: 0; }
  100% { opacity: 1; }
}

/* ===== Input Area ===== */
.input-area {
  padding: 0 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
}

.input-wrap {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 10px 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.input-wrap::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 19px;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2), var(--gradient-3));
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
  pointer-events: none;
}

.input-wrap:focus-within {
  border-color: transparent;
  box-shadow: 0 0 0 1px var(--accent-dim), 0 4px 24px var(--accent-dim);
}

.input-wrap:focus-within::before {
  opacity: 0.4;
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  padding: 4px 2px;
  outline: none;
}

#chat-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.send-btn, .stop-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.send-btn {
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.25);
}
.send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.4);
}
.send-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.send-btn:disabled {
  opacity: 0.25;
  cursor: default;
  box-shadow: none;
}

.stop-btn {
  background: var(--danger);
  color: #fff;
  animation: stop-pulse 1.5s ease-in-out infinite;
}

@keyframes stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.stop-btn:hover { opacity: 0.9; }

.input-footer {
  width: 100%;
  max-width: 760px;
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.model-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 3px 12px;
  border-radius: 99px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlay-in 0.2s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-in {
  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 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 22px; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.form-input, .form-select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.005em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 13px 20px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.5);
}
.toast-success {
  background: rgba(34, 197, 94, 0.9);
  color: #fff;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.toast-info {
  background: rgba(139, 92, 246, 0.9);
  color: #fff;
  border: 1px solid rgba(139, 92, 246, 0.5);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 900;
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 899;
  }

  .menu-btn { display: flex !important; }

  .msg-content {
    padding: 14px 16px;
    margin: 2px auto;
  }

  .input-area { padding: 0 12px 14px; }
}

@media (min-width: 769px) {
  .menu-btn { display: none; }
}

/* ===== Empty state for conv list ===== */
.conv-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: -0.01em;
}

/* ===== Login Screen ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 24px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
  grid-column: 1 / -1;
}

/* Ambient background glow for login */
.login-screen::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: conic-gradient(
    from 45deg,
    var(--gradient-1),
    var(--gradient-2),
    var(--gradient-3),
    var(--gradient-1)
  );
  filter: blur(100px);
  opacity: 0.15;
  animation: login-orb 12s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes login-orb {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Subtle glow ring around login card */
.login-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  background: linear-gradient(
    135deg,
    var(--accent-dim) 0%,
    transparent 40%,
    transparent 60%,
    var(--accent-dim) 100%
  );
  z-index: -1;
  pointer-events: none;
}
