/* ============================================
   CODE MIND - Claude-Style Design System
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables - Light Mode (Claude-style warm cream) */
:root {
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --bg-primary: #FAF9F6;
  --bg-secondary: #F5F4F0;
  --bg-sidebar: #FFFFFF;
  --bg-user-bubble: #F0EBE3;
  --bg-code: #F5F4F0;
  --bg-hover: #F0EFEA;
  --bg-overlay: rgba(0,0,0,0.4);

  --text-primary: #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-muted: #9E9E9E;
  --text-inverse: #FFFFFF;

  --accent: #D97757;
  --accent-hover: #C46A4D;
  --accent-light: rgba(217, 119, 87, 0.12);
  --accent-border: rgba(217, 119, 87, 0.3);

  --border: #E8E6E1;
  --border-light: #F0EEEA;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --sidebar-width: 280px;
  --header-height: 56px;
  --input-height: 72px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode (Claude-style deep warm) */
[data-theme="dark"] {
  --bg-primary: #111111;
  --bg-secondary: #1A1A1A;
  --bg-sidebar: #161616;
  --bg-user-bubble: #2A2520;
  --bg-code: #1E1E1E;
  --bg-hover: #222222;
  --bg-overlay: rgba(0,0,0,0.7);

  --text-primary: #E5E5E5;
  --text-secondary: #A0A0A0;
  --text-muted: #666666;
  --text-inverse: #111111;

  --accent: #D97757;
  --accent-hover: #E08A6E;
  --accent-light: rgba(217, 119, 87, 0.15);
  --accent-border: rgba(217, 119, 87, 0.25);

  --border: #2A2A2A;
  --border-light: #222222;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* Reset & Base */
*, *::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;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

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

/* ============================================
   APP SHELL
   ============================================ */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, var(--transition);
  z-index: 100;
}

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

.sidebar-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.sidebar-close:hover { background: var(--bg-hover); }

/* New Chat Button */
.new-chat-btn {
  margin: 12px 16px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.new-chat-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-border);
}

.new-chat-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Sidebar Sections */
.sidebar-section {
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.sidebar-section-title {
  padding: 8px 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.sidebar-section-title svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.sidebar-section-title.collapsed svg {
  transform: rotate(-90deg);
}

/* Folder */
.folder {
  margin: 2px 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.folder-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.folder-header:hover { background: var(--bg-hover); }

.folder-header svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.folder-header.expanded svg { transform: rotate(90deg); }

.folder-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}

.folder-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 10px;
}

.folder-chats {
  padding-left: 28px;
}

/* Chat Item */
.chat-item {
  padding: 8px 12px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  position: relative;
}

.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
  background: var(--accent-light);
  border-left: 2px solid var(--accent);
}

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

.chat-item-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item-model {
  font-size: 0.65rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.chat-item-actions {
  display: none;
  gap: 4px;
}

.chat-item:hover .chat-item-actions { display: flex; }

.chat-item-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
}

.chat-item-actions button:hover { color: var(--text-primary); background: var(--bg-secondary); }

/* Projects Section */
.projects-list {
  padding: 0 12px;
}

.project-item {
  padding: 10px 12px;
  margin: 4px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.project-item:hover {
  border-color: var(--accent-border);
  background: var(--bg-hover);
}

.project-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

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

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}

.settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

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

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Header */
.header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
  z-index: 50;
}

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

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover { background: var(--bg-hover); }

.header-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Model Selector (Claude-style top center) */
.model-selector {
  position: relative;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

.model-selector-btn svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

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

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  z-index: 200;
}

.model-dropdown.show { display: block; }

.model-option {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.model-option-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.model-option-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.model-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

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

/* ============================================
   CHAT AREA
   ============================================ */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding-bottom: 20px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 24px;
  padding: 40px 20px;
  text-align: center;
}

.chat-empty-logo {
  width: 64px;
  height: 64px;
  background: var(--accent-light);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.chat-empty-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.chat-empty-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.5;
}

.chat-empty-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 500px;
}

.suggestion-btn {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* Messages */
.messages {
  max-width: 768px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  display: flex;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

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

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

.message-avatar.user {
  background: var(--accent);
  color: white;
}

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

.message-content {
  flex: 1;
  min-width: 0;
}

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

.message-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.message-model {
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* User Message Bubble */
.message.user .message-bubble {
  background: var(--bg-user-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* AI Message - Flat on background (Claude style) */
.message.ai .message-bubble {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.7;
  font-family: var(--font-serif);
}

.message.ai .message-bubble p { margin-bottom: 1em; }
.message.ai .message-bubble p:last-child { margin-bottom: 0; }

/* Markdown Styling */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 1.5em 0 0.75em;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.message-bubble h1 { font-size: 1.5rem; }
.message-bubble h2 { font-size: 1.25rem; }
.message-bubble h3 { font-size: 1.1rem; }

.message-bubble ul,
.message-bubble ol {
  margin: 0.75em 0;
  padding-left: 1.5em;
}

.message-bubble li { margin: 0.35em 0; }

.message-bubble strong { font-weight: 600; color: var(--text-primary); }
.message-bubble em { font-style: italic; }

.message-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

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

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

.message-bubble th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Inline Code */
.message-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--accent);
}

/* Code Blocks */
.code-block {
  margin: 1em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-code);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.code-block-lang {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block-actions {
  display: flex;
  gap: 6px;
}

.code-block-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

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

.code-block pre {
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
}

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

/* Message Actions */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

.message-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

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

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

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

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error / Rate Limit Banner */
.banner {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

.banner.error {
  background: #FEF2F2;
  color: #DC2626;
  border-bottom: 1px solid #FECACA;
}

[data-theme="dark"] .banner.error {
  background: #450A0A;
  color: #FCA5A5;
  border-bottom: 1px solid #7F1D1D;
}

.banner.warning {
  background: #FFFBEB;
  color: #D97706;
  border-bottom: 1px solid #FDE68A;
}

[data-theme="dark"] .banner.warning {
  background: #451A03;
  color: #FCD34D;
  border-bottom: 1px solid #78350F;
}

.banner.offline {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.banner-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px;
  opacity: 0.6;
}

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

/* ============================================
   INPUT AREA
   ============================================ */
.input-area {
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 12px 20px 20px;
  z-index: 50;
}

.input-wrapper {
  max-width: 768px;
  margin: 0 auto;
  position: relative;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 10px 14px;
  transition: var(--transition);
}

.input-box:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

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

.input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.input-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

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

.input-btn.send {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
}

.input-btn.send:hover { background: var(--accent-hover); }

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

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================
   FLOATING ACTION BUTTON (New Chat)
   ============================================ */
.fab {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: var(--transition);
}

.fab:hover {
  transform: scale(1.05);
  background: var(--accent-hover);
}

.fab svg { width: 22px; height: 22px; }

/* ============================================
   MODALS / OVERLAYS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

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

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

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

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

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

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

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

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

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

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

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

.btn-danger {
  background: #DC2626;
  color: white;
  border-color: #DC2626;
}

.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* Toggle Switch */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-switch {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-switch { background: var(--accent); }
.toggle input:checked + .toggle-switch::after { transform: translateX(18px); }

.toggle input { display: none; }

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.settings-row-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

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

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .menu-toggle { display: flex; }

  .header { padding: 0 12px; }
  .header-title { display: none; }

  .messages { padding: 12px; gap: 16px; }
  .message { gap: 10px; }

  .input-area { padding: 10px 12px 16px; }

  .fab { bottom: 90px; right: 16px; }

  .model-dropdown { width: 280px; }

  .chat-empty-title { font-size: 1.4rem; }
  .chat-empty-subtitle { font-size: 0.85rem; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 240px; }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Image Upload Preview */
.image-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.image-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Export Dropdown */
.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
  display: none;
  z-index: 150;
}

.export-menu.show { display: block; }

.export-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast.success { border-left: 3px solid #22C55E; }
.toast.error { border-left: 3px solid #DC2626; }

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