:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-hover: #22222f;
  
  --text-primary: #f5f5f7;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  
  --accent-1: #ff6b6b;
  --accent-2: #feca57;
  --accent-3: #48dbfb;
  --accent-gradient: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  
  --success: #2ed573;
  --warning: #ffa502;
  --danger: #ff4757;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  
  --sidebar-width: 280px;
  --header-height: 60px;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

::selection {
  background: var(--accent-1);
  color: var(--bg-primary);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

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

.setup-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.setup-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(255, 107, 107, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(72, 219, 251, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(254, 202, 87, 0.05) 0%, transparent 60%);
}

.setup-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.setup-hero {
  text-align: center;
  margin-bottom: 40px;
}

.setup-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.setup-logo svg {
  width: 100%;
  height: 100%;
  animation: pulse 3s ease-in-out infinite;
}

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

.setup-hero h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 500;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.setup-tagline {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.setup-step {
  display: none;
}

.setup-step.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.step-number {
  width: 28px;
  height: 28px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg-primary);
}

.step-header h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

.step-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

.input-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.connection-test {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.test-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.test-status .status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.test-status.success .status-icon {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.test-status.error .status-icon {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

.test-status.loading .status-icon {
  background: var(--accent-2);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.cors-help {
  margin-top: 20px;
}

.help-card {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
}

.help-card h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--danger);
}

.help-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.help-note {
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
  margin-top: 12px !important;
}

.help-note code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.code-block {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
}

.code-block code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-2);
}

.copy-btn {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Model Tabs */
.model-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.model-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.model-tab:hover {
  color: var(--text-primary);
}

.model-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.model-tab-content {
  display: none;
}

.model-tab-content.active {
  display: block;
}

/* Models List */
.models-list {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.loading-models {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.model-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.model-option.selected {
  border-color: var(--accent-1);
  background: rgba(255, 107, 107, 0.1);
}

.model-radio {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.model-option.selected .model-radio {
  border-color: var(--accent-1);
}

.model-option.selected .model-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--accent-1);
  border-radius: 50%;
}

.model-name {
  flex: 1;
  font-weight: 500;
}

.model-size {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.no-models-hint {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
}

.empty-models-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.no-models-hint .hint-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Download Categories */
.download-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.category-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.category-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: var(--bg-primary);
}

/* Available Models */
.available-models,
.available-models-manager {
  max-height: 280px;
  overflow-y: auto;
}

.available-model-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.available-model-card:hover {
  border-color: var(--border-light);
}

.available-model-card.installed {
  opacity: 0.6;
}

.available-model-info {
  flex: 1;
  min-width: 0;
}

.available-model-name {
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.available-model-name .badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--success);
  color: var(--bg-primary);
  border-radius: 4px;
  font-weight: 600;
}

.available-model-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.available-model-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.available-model-size {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.btn-download {
  padding: 8px 14px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-download:hover:not(:disabled) {
  transform: scale(1.02);
}

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

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

/* Download Progress */
.download-progress-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-1);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.download-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.download-model-name {
  font-weight: 500;
}

.download-percent {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-1);
}

.download-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.download-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.download-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* Installed Models List (Manager) */
.installed-models-list {
  max-height: 350px;
  overflow-y: auto;
}

.installed-model-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.installed-model-icon {
  font-size: 1.5rem;
}

.installed-model-details {
  flex: 1;
  min-width: 0;
}

.installed-model-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.installed-model-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-delete-model {
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-model:hover {
  background: rgba(255, 71, 87, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.no-installed-models {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.no-installed-models p {
  margin-bottom: 8px;
}

.step-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-outline:hover {
  background: rgba(255, 71, 87, 0.1);
}

.btn-danger-outline svg {
  width: 16px;
  height: 16px;
}

.setup-footer {
  text-align: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

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

.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-1);
}

.brand span {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
}

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-new svg {
  width: 18px;
  height: 18px;
}

.sidebar-search {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-search svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 4px;
}

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

.chat-item.active {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
}

.chat-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-item .title {
  flex: 1;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item .date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.no-chats {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.connection-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.connection-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-badge.disconnected .dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.btn-github {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

.btn-github svg {
  width: 18px;
  height: 18px;
}

.btn-github:hover {
  background: var(--accent-gradient);
  color: var(--bg-primary);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transform: translateY(-1px);
}

.btn-github-label {
  letter-spacing: 0.02em;
}

.btn-settings {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

.header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-icon.danger:hover {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
}

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

.chat-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-select {
  padding: 8px 32px 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23606070' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.model-select:focus {
  outline: none;
  border-color: var(--accent-1);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  color: var(--accent-1);
  opacity: 0.6;
}

.welcome h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.welcome p {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 600px;
}

.quick-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-prompt:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.message {
  max-width: 800px;
  margin: 0 auto 24px;
  animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.message.user .message-avatar {
  background: var(--accent-gradient);
  color: var(--bg-primary);
}

.message.assistant .message-avatar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.message-role {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.message-content {
  padding-left: 38px;
  line-height: 1.7;
}

.message-content p {
  margin-bottom: 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.message-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-content em {
  font-style: italic;
  color: var(--text-secondary);
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 38px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.message:hover .message-footer {
  opacity: 1;
}

/* Always show footer when stats are present */
.message-footer.has-stats {
  opacity: 1;
}

.message-stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.stat-item span {
  font-family: var(--font-mono);
}

.stat-label {
  color: var(--text-muted);
  opacity: 0.7;
}

.message-actions {
  display: flex;
  gap: 4px;
}

.msg-action-btn {
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

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

.msg-action-btn svg {
  width: 14px;
  height: 14px;
}

.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 18px;
  background: var(--accent-1);
  margin-left: 2px;
  animation: cursorBlink 0.8s infinite;
  vertical-align: text-bottom;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.input-area {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

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

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

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 8px auto 0;
  padding: 0 4px;
}

.shortcut {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.shortcut kbd {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.model-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

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

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-content.modal-large {
  max-width: 600px;
}

.modal.open .modal-content {
  transform: scale(1);
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.setting-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.setting-group input:focus {
  outline: none;
  border-color: var(--accent-1);
}

.setting-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.setting-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.setting-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.setting-status.connected .dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.setting-status.disconnected .dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease-out;
  max-width: 360px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.hiding {
  animation: toastOut 0.3s ease-out forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.info .toast-icon {
  color: var(--accent-3);
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
}

.toast-close {
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

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

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: flex;
  }

  .setup-card {
    padding: 32px 24px;
  }

  .setup-hero h1 {
    font-size: 2rem;
  }

  .quick-prompts {
    flex-direction: column;
  }

  .header-actions {
    gap: 4px;
  }

  .model-select {
    max-width: 120px;
  }
}

@media (max-width: 480px) {
  .setup-card {
    padding: 24px 20px;
  }

  .step-actions {
    flex-direction: column;
  }

  .step-actions button {
    width: 100%;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    max-width: 100%;
  }
}
