/* =============================================
   BrainStorm — Refined Aesthetic Design System
   Claude-inspired warm, light, sophisticated minimalism
   ============================================= */

/* ===== CSS Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

/* ===== Design Tokens ===== */
:root {
  /* Core Backgrounds */
  --bg-app: #fcfbf9;       /* Paper-like off-white */
  --bg-sidebar: #f3efe9;   /* Warm sophisticated beige */
  --bg-surface: #ffffff;   /* Pure white for cards/modals */
  --bg-user-msg: #f0ebe1;  /* Soft tonal background for user */
  --bg-hover: #ebe5dc;     /* Hover state on warm backgrounds */
  
  /* Borders and Lines */
  --border-light: #e6e2d8;
  --border-medium: #d6d1c7;
  --border-strong: #bfbaa8;
  
  /* Typography Colors */
  --text-main: #1c1a19;    /* Rich charcoal instead of pure black */
  --text-body: #3c3a38;    /* Softer for long reading */
  --text-muted: #6b665f;   /* Muted information */
  --text-faint: #9c978f;   /* Icons, subtle dividers */
  
  /* Accents */
  --accent-primary: #cd5c45;  /* Earthy Terracotta */
  --accent-hover: #b84a35;
  --accent-subtle: #f6efe1;   /* Pale warm tint */
  
  /* Status */
  --success: #3c8253;
  --warning: #c27d14;
  --error: #b83a3a;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(28, 26, 25, 0.04);
  --shadow-md: 0 4px 12px rgba(28, 26, 25, 0.05);
  --shadow-float: 0 12px 32px rgba(28, 26, 25, 0.08); /* Sophisticated floating shadow */
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Animation & Layout */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration: 300ms;
  --sidebar-width: 270px;
  --input-max-height: 250px;
}

/* ===== Typography System ===== */
body {
  font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .serif-text {
  font-family: 'Crimson Pro', Georgia, serif;
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ===== App Layout ===== */
.app {
  display: flex;
  height: 100vh;
  position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  margin-left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  transition: transform var(--duration) var(--ease), margin-left var(--duration) var(--ease);
}

.sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-header {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.logo-text {
  font-family: 'Crimson Pro', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

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

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

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

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  margin-bottom: 4px;
  position: relative;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

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

.session-item.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.session-item .session-icon {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  width: 0;
  transition: all var(--duration) var(--ease);
}

.session-item.active .session-icon {
  opacity: 1;
  visibility: visible;
  width: auto;
}

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

.session-item .session-delete {
  opacity: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: all 0.2s;
}

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.btn-settings {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

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

/* ===== Sidebar Toggle (Global) ===== */
.btn-sidebar-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 30;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-10px);
  transition: all var(--duration) var(--ease);
}

.sidebar.collapsed ~ .main .btn-sidebar-toggle,
.sidebar.collapsed ~ .btn-sidebar-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

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

/* ===== Main Content ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-app);
}

/* ===== Step Tracker ===== */
.step-tracker {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  background: transparent;
  flex-shrink: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.5;
  transition: all 400ms var(--ease);
  cursor: default;
}

.step.active {
  opacity: 1;
}

.step.completed {
  opacity: 0.8;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: all 400ms var(--ease);
}

.step.active .step-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(205, 92, 69, 0.15);
}

.step.completed .step-dot {
  background: var(--text-faint);
}

.step-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  transition: color 400ms var(--ease);
}

.step.active .step-label { 
  color: var(--accent-primary); 
  font-weight: 600;
}

.step-line {
  width: 32px;
  height: 1px;
  background: var(--border-light);
  margin: 0 12px;
  transition: background 400ms var(--ease);
}

.step-line.completed {
  background: var(--border-medium);
}

/* ===== Chat Area ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
  padding-bottom: 24px;
}

/* Scrollbars - delicate */
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; border: 2px solid var(--bg-app); }
.chat-area::-webkit-scrollbar-thumb:hover { background: var(--border-medium); }

/* ===== Welcome Screen ===== */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  min-height: 90%;
  animation: fadeIn 1s var(--ease);
}

.welcome-title {
  font-size: 2.25rem;
  margin-bottom: 12px;
  color: var(--text-main);
  animation: slideUp 0.8s var(--ease);
}

.welcome-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.6;
  margin-bottom: 48px;
  animation: slideUp 1s var(--ease);
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 600px;
  animation: slideUp 1.2s var(--ease);
}

.suggestion {
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  color: var(--text-body);
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease);
  font-family: inherit;
}

.suggestion:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--text-main);
}

/* ===== Chat Messages ===== */
.chat-messages {
  padding: 0 24px;
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  animation: messageSlideUp 0.6s var(--ease) forwards;
  opacity: 0;
  transform: translateY(16px);
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Crimson Pro', serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 4px;
}

.message.assistant .message-avatar {
  color: var(--accent-primary);
  background: transparent;
}

.message.user .message-avatar {
  display: none; /* Hide user avatar for a cleaner look */
}

.message-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.message.user .message-body {
  align-items: flex-end;
}

.message-content {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text-body);
}

.message.assistant .message-content {
  max-width: 100%;
}

.message.user .message-content {
  background: var(--bg-user-msg);
  color: var(--text-main);
  padding: 14px 20px;
  border-radius: var(--radius-xl);
  border-bottom-right-radius: 4px;
  max-width: 85%;
  font-size: 0.95rem;
}

/* Elegant Markdown styling */
.message-content h1, .message-content h2, .message-content h3 { 
  font-family: 'Crimson Pro', serif;
  color: var(--text-main);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

.message-content h1 { font-size: 1.6rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3em; }
.message-content h2 { font-size: 1.35rem; }
.message-content h3 { font-size: 1.15rem; }
.message-content p { margin-bottom: 1.2em; }
.message-content p:last-child { margin-bottom: 0; }

.message-content ul, .message-content ol {
  margin: 1.2em 0;
  padding-left: 24px;
}

.message-content li { margin-bottom: 0.4em; }
.message-content li::marker { color: var(--accent-primary); }

.message-content strong { color: var(--text-main); font-weight: 600; }
.message-content em { font-family: 'Crimson Pro', serif; font-size: 1.1em; color: var(--text-main); }

.message-content a {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(205, 92, 69, 0.3);
  transition: all var(--duration) ease;
}
.message-content a:hover { border-bottom-color: var(--accent-primary); }

.message-content code {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.message-content pre {
  background: #f8f6f2;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 1.5em 0;
  overflow-x: auto;
}

.message-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-body);
  font-size: 0.85rem;
}

.message-content blockquote {
  border-left: 2px solid var(--accent-primary);
  padding: 4px 0 4px 20px;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
  font-family: 'Crimson Pro', serif;
  font-size: 1.15rem;
  line-height: 1.6;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 2em 0;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

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

.message-content th {
  background: var(--bg-sidebar);
  font-weight: 600;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ===== Input Area ===== */
.input-area {
  padding: 0 24px 24px;
  flex-shrink: 0;
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
  background: linear-gradient(to top, var(--bg-app) 80%, transparent);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 10px 10px 10px 20px;
  box-shadow: var(--shadow-float);
  transition: all var(--duration) var(--ease);
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 8px 32px rgba(205, 92, 69, 0.08);
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.6;
  resize: none;
  max-height: var(--input-max-height);
  padding: 6px 0;
}

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

.btn-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-main);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--duration) var(--ease);
}

.btn-send:not(:disabled):hover {
  background: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(205, 92, 69, 0.2);
}

.btn-send:disabled { 
  background: var(--border-light); 
  color: var(--text-faint);
  cursor: not-allowed; 
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  font-family: inherit;
}

.btn-export:hover { 
  color: var(--text-main); 
  background: var(--bg-hover); 
}

.btn-toggle-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  font-family: inherit;
}

.btn-toggle-search:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.btn-toggle-search.active {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}

.btn-toggle-search.active svg {
  stroke: #3b82f6;
}

/* Tool Status Card in Assistant Messages */
.tool-status-card {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-md, 8px);
  font-size: 0.82rem;
  background: var(--bg-subtle, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.06));
  transition: all 0.2s ease;
}

.tool-status-card.loading {
  color: var(--text-muted);
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.15);
}

.tool-status-card.completed {
  color: var(--text-main);
  background: var(--bg-subtle, rgba(0, 0, 0, 0.02));
}

.tool-status-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.tool-status-header .icon-spin {
  animation: spin 1s linear infinite;
  color: #3b82f6;
}

.tool-status-header .icon-check {
  color: #10b981;
}

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

.tool-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tool-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: none;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.tool-source-chip:hover {
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.08);
}

.step-hint {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: 'Crimson Pro', serif;
  font-style: italic;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 25, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 300ms var(--ease);
}

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

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-float);
  animation: scaleIn 400ms var(--ease);
}

.modal-lg { max-width: 760px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 16px;
}

.modal-header h2 {
  font-size: 1.3rem;
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all var(--duration) var(--ease);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-main); }

.modal-body { padding: 0 32px 24px; }
.modal-footer {
  padding: 20px 32px;
  background: var(--bg-app);
  border-top: 1px solid var(--border-light);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 24px; }
.form-group:last-child { margin-bottom: 0; }

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

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all var(--duration) var(--ease);
}

.form-group input::placeholder { color: var(--text-faint); }
.form-group input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 4px rgba(205, 92, 69, 0.1);
}

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

/* ===== Buttons ===== */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--duration) var(--ease);
}

.btn-primary {
  background: var(--text-main);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(205, 92, 69, 0.15);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-body);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--text-main);
}

/* ===== Export Preview ===== */
.export-preview {
  background: #f8f6f2;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 32px;
  max-height: 55vh;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.7;
}

.export-preview::-webkit-scrollbar { width: 6px; }
.export-preview::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: var(--text-main);
  border-radius: var(--radius-full);
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-float);
  z-index: 200;
  opacity: 0;
  transition: all 400ms var(--ease);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Error Feedback ===== */
.message.error .message-content {
  background: #fdf3f3;
  color: var(--error);
  border: 1px solid #fad2d2;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes messageSlideUp {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

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

.streaming-cursor::after {
  content: '▋';
  display: inline-block;
  vertical-align: text-bottom;
  color: var(--accent-primary);
  animation: cursor-blink 1s step-end infinite;
  margin-left: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    height: 100%;
    margin-left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-float);
  }

  /* .collapsed has no special meaning on mobile, we use .open for sliding in */
  .sidebar.collapsed {
    margin-left: 0;
  }

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

  .btn-sidebar-toggle { 
    display: flex; 
    opacity: 1;
    pointer-events: auto;
    position: fixed;
    transform: none;
  }

  /* On mobile, show delete button always since there's no hover */
  .session-item .session-delete { opacity: 0.6; }

  .step-tracker {
    padding: 12px 16px;
    justify-content: flex-start;
    overflow-x: auto;
  }
  
  .step-label { display: none; }
  .step.active .step-label { display: inline; margin-left: 4px; }
  .step-line { width: 16px; margin: 0 8px; }

  .chat-messages { padding: 0 16px; }
  .input-area { padding: 0 16px 16px; }
  .message { gap: 12px; }
  .message.user .message-content { max-width: 90%; }

  .welcome { padding: 40px 20px; }
  .welcome-title { font-size: 1.8rem; }
  .welcome-suggestions { flex-direction: column; align-items: stretch; width: 100%;}
  .suggestion { text-align: left; padding: 14px 20px;}
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 25, 0.3);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.sidebar-overlay.show { 
  display: block; 
  opacity: 1;
}

/* =============================================
   LLM API Settings Modal — UI/UX Pro Max Styles
   ============================================= */

.modal-settings {
  max-width: 600px;
  width: 92%;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: normal;
}

.btn-icon-back {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

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

.settings-body {
  padding: 16px 28px 24px;
  max-height: 75vh;
  overflow-y: auto;
}

/* Config List Topbar */
.config-list-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.config-list-count-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-primary-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Config Cards */
.config-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-card {
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 0.2s var(--ease);
  position: relative;
}

.config-card:hover {
  border-color: var(--border-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.config-card.active {
  border: 2px solid var(--accent-primary);
  background: rgba(205, 92, 69, 0.02);
  box-shadow: 0 4px 16px rgba(205, 92, 69, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.provider-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.88rem;
}

.provider-icon {
  display: flex;
  align-items: center;
}

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

.status-tag.active {
  background: rgba(16, 163, 127, 0.1);
  color: #10A37F;
  border: 1px solid rgba(16, 163, 127, 0.25);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-label {
  color: var(--text-faint);
}

.meta-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-main);
}

.meta-url {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-key {
  font-family: monospace;
  letter-spacing: 0.5px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.active-indicator-text {
  font-size: 0.82rem;
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-card-action {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.btn-card-action:hover {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.action-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-card-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.btn-card-icon:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-card-icon.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Empty State */
.config-empty {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-app);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  margin-top: 8px;
}

.empty-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent-primary);
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.config-empty-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* Config Form Controls */
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.danger-text {
  color: #EF4444;
}

.label-optional {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: normal;
}

.select-wrapper {
  position: relative;
}

.form-select {
  width: 100%;
  padding: 11px 16px;
  appearance: none;
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.92rem;
  outline: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.form-select:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 4px rgba(205, 92, 69, 0.1);
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.model-quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.model-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.model-tag:hover, .model-tag.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

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

.api-key-field input {
  padding-right: 44px;
}

.btn-toggle-key {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-toggle-key:hover {
  color: var(--text-main);
}

.form-group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-app);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.toggle-info {
  display: flex;
  flex-direction: column;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.toggle-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Toggle Switch (iOS Style) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-medium);
  transition: .25s var(--ease);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s var(--ease);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: var(--accent-primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Small Toggle Switch for Cards */
.toggle-switch-sm {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.toggle-switch-sm input { opacity: 0; width: 0; height: 0; }

.toggle-slider-sm {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-medium);
  transition: .2s var(--ease);
  border-radius: 18px;
}

.toggle-slider-sm:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s var(--ease);
  border-radius: 50%;
}

input:checked + .toggle-slider-sm {
  background-color: var(--accent-primary);
}

input:checked + .toggle-slider-sm:before {
  transform: translateX(16px);
}

/* Test Connection Result Card */
.test-result {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  animation: fadeIn 200ms var(--ease);
}

.test-result.success {
  background: rgba(16, 163, 127, 0.08);
  border: 1px solid rgba(16, 163, 127, 0.3);
  color: #0D7D62;
}

.test-result.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #DC2626;
}

.test-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.test-msg {
  line-height: 1.4;
}

.spinning {
  animation: spin 0.8s linear infinite;
}

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

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Sidebar Active Model Indicator */
.sidebar-active-model {
  padding: 8px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green {
  background: #10A37F;
  box-shadow: 0 0 6px rgba(16, 163, 127, 0.5);
}

.status-dot.amber {
  background: #F59E0B;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.active-model-text {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

