/* ============================================================
   AI Chat Application — Premium Stylesheet
   ============================================================
   Fonts: JetBrains Mono (UI) + Inter (content)
   Themes: Dark (default) + Light ([data-theme='light'])
   ============================================================ */

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

/* -------------------------------------------------------
   § CSS Custom Properties — Dark Theme (default)
   ------------------------------------------------------- */
:root {
  /* Backgrounds */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-chat: #0e0e16;

  /* Surfaces */
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-active: rgba(255, 255, 255, 0.09);

  /* Glassmorphism */
  --glass: rgba(18, 18, 30, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* Text */
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Accents */
  --accent: #00d4ff;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #00d4ff, #7c3aed);

  /* Message Bubbles */
  --user-msg-bg: linear-gradient(135deg, #1e40af, #7c3aed);
  --ai-msg-bg: rgba(255, 255, 255, 0.04);

  /* Semantic */
  --danger: #ef4444;
  --success: #22c55e;

  /* Borders & Shadows */
  --border: rgba(255, 255, 255, 0.06);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --glow: 0 0 20px rgba(0, 212, 255, 0.15);
}

/* -------------------------------------------------------
   § CSS Custom Properties — Light Theme
   ------------------------------------------------------- */
[data-theme='light'] {
  --bg-primary: #f8f9fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f5;
  --bg-chat: #f4f5f7;

  --surface: rgba(0, 0, 0, 0.03);
  --surface-hover: rgba(0, 0, 0, 0.06);
  --surface-active: rgba(0, 0, 0, 0.09);

  --glass: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;

  --accent: #2563eb;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #2563eb, #7c3aed);

  --user-msg-bg: linear-gradient(135deg, #2563eb, #7c3aed);
  --ai-msg-bg: rgba(0, 0, 0, 0.02);

  --danger: #dc2626;
  --success: #16a34a;

  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --glow: 0 0 20px rgba(37, 99, 235, 0.1);
}

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

html,
body {
  height: 100%;
  font-family: 'JetBrains Mono', monospace;
}

html {
  transition: background-color 0.3s, color 0.3s;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

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

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

/* Selection */
::selection {
  background: var(--accent);
  color: #fff;
}

/* -------------------------------------------------------
   § Links & Buttons Reset
   ------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

/* -------------------------------------------------------
   § App Container (root layout)
   ------------------------------------------------------- */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* -------------------------------------------------------
   § Sidebar
   ------------------------------------------------------- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  transition: transform 0.3s ease;
  z-index: 100;
}

/* — Sidebar Header — */
.sidebar-header {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}

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

/* — Chat List — */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

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

.chat-item.active {
  background: var(--surface-active);
  border-color: var(--accent);
}

.chat-item-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.chat-item.active .chat-item-title {
  color: var(--accent);
}

.chat-item-delete {
  opacity: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* — Sidebar Footer — */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

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

/* — Sidebar Overlay (mobile) — */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}

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

/* -------------------------------------------------------
   § Main Area
   ------------------------------------------------------- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-chat);
}

/* — Main Header — */
.main-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: var(--surface-hover);
}

/* -------------------------------------------------------
   § Model Selector
   ------------------------------------------------------- */
.model-selector {
  position: relative;
}

.model-selector-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.current-model-icon,
.model-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 350px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  padding: 8px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
  overflow: hidden;
}

.model-search-wrapper {
  padding: 4px 4px 8px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.model-search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.model-options-container {
  overflow-y: auto;
  flex-grow: 1;
  max-height: 320px;
  padding-right: 2px;
}

.model-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.model-category {
  padding: 8px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

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

.model-option.active {
  background: var(--surface-active);
  border-left-color: var(--accent);
  color: var(--accent);
}

/* — Header Actions — */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* -------------------------------------------------------
   § Theme Toggle
   ------------------------------------------------------- */
.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.theme-toggle-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: var(--accent);
}

/* -------------------------------------------------------
   § Settings Button (header)
   ------------------------------------------------------- */
.settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

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

/* -------------------------------------------------------
   § Chat Area
   ------------------------------------------------------- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------
   § Welcome Screen
   ------------------------------------------------------- */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: var(--accent-gradient);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  font-size: 36px;
  color: #fff;
  animation: pulse 2s infinite;
}

.welcome-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.welcome-subtitle {
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 32px;
  line-height: 1.7;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 560px;
  width: 100%;
}

.suggestion-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.suggestion-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.suggestion-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.suggestion-card-desc {
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  line-height: 1.5;
}

/* -------------------------------------------------------
   § Messages
   ------------------------------------------------------- */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 75%;
  animation: fadeInUp 0.3s ease forwards;
}

.message.user {
  justify-content: flex-end;
  align-self: flex-end;
}

.message.assistant {
  justify-content: flex-start;
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.message.user .message-avatar {
  background: var(--accent-gradient);
  color: #fff;
  order: 2;
}

.message.assistant .message-avatar {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

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

.message-bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .message-bubble {
  background: var(--user-msg-bg);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.message.assistant .message-bubble {
  background: var(--ai-msg-bg);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
}

.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

.message.user .message-meta {
  text-align: right;
}

/* -------------------------------------------------------
   § Code Blocks (inside messages)
   ------------------------------------------------------- */
.code-block-wrapper {
  position: relative;
  margin: 8px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.code-block-header {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.code-lang {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-code-btn {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  padding: 2px 8px;
  border-radius: 4px;
}

.copy-code-btn:hover {
  opacity: 1;
  color: var(--accent);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.2);
}

.code-block-wrapper code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Inline code */
.message-bubble code:not(.code-block-wrapper code) {
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
}

[data-theme='light'] .code-block-wrapper pre {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme='light'] .code-block-header {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme='light'] .message-bubble code:not(.code-block-wrapper code) {
  background: rgba(0, 0, 0, 0.06);
}

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

.typing-indicator .message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 16px;
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--ai-msg-bg);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* -------------------------------------------------------
   § Input Area
   ------------------------------------------------------- */
.input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--glow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-container:focus-within {
  border-color: var(--accent);
  box-shadow: var(--glow), 0 0 0 3px rgba(0, 212, 255, 0.08);
}

[data-theme='light'] .input-container:focus-within {
  box-shadow: var(--glow), 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-primary);
  min-height: 24px;
  max-height: 200px;
  line-height: 1.6;
  padding: 6px 0;
  outline: none;
}

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

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

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

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

.stop-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.stop-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.stop-btn:active {
  transform: scale(0.95);
}

/* -------------------------------------------------------
   § Settings Modal
   ------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 24px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--surface);
  transition: background 0.15s, color 0.15s;
}

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

.modal-body {
  padding: 24px;
}

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

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

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

.setting-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.setting-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

[data-theme='light'] .setting-input:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* — Range Slider — */
.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-active);
  outline: none;
  margin: 8px 0;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.setting-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.setting-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* — Primary Button — */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: #fff;
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.btn-primary:hover {
  transform: scale(1.02);
}

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

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

/* — Secondary Button — */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

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

/* -------------------------------------------------------
   § Toast Notifications
   ------------------------------------------------------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 12px;
  z-index: 300;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInRight 0.3s ease forwards;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.toast.success {
  background: var(--success);
  color: #fff;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.dismiss {
  animation: fadeOut 0.3s ease forwards;
}

/* -------------------------------------------------------
   § Keyframe Animations
   ------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(0, 212, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 212, 255, 0);
  }
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* -------------------------------------------------------
   § Responsive — Mobile (< 768px)
   ------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-header {
    padding: 12px 16px;
  }

  .chat-area {
    padding: 16px;
  }

  .message {
    max-width: 90%;
  }

  .welcome-suggestions {
    grid-template-columns: 1fr;
  }

  .welcome-title {
    font-size: 24px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }

  .model-dropdown {
    width: calc(100vw - 32px);
    left: auto;
    right: -60px;
  }

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

  .modal {
    width: 95%;
    border-radius: 20px;
  }

  .modal-header {
    padding: 20px;
  }

  .modal-body {
    padding: 20px;
  }
}

/* -------------------------------------------------------
   § Responsive — Small Mobile (< 480px)
   ------------------------------------------------------- */
@media (max-width: 480px) {
  .message {
    max-width: 95%;
  }

  .welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    font-size: 28px;
  }

  .welcome-title {
    font-size: 22px;
  }

  .header-actions {
    gap: 4px;
  }

  .theme-toggle-btn,
  .settings-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
}

/* -------------------------------------------------------
   § Utility Classes
   ------------------------------------------------------- */
.hidden {
  display: none !important;
}

/* -------------------------------------------------------
   § Accessibility — Reduced Motion
   ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
