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

:root {
  --primary: #3b82f6;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;

  --success: #10b981;
  --success-dark: #047857;
  --success-light: #d1fae5;

  --error: #ef4444;
  --error-dark: #b91c1c;
  --error-light: #fee2e2;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-border: #334155;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
    'Cantarell', sans-serif;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
  padding: 0;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

body.dark-mode {
  background: var(--dark-bg);
  color: #e2e8f0;
}

/* ── App Layout ───────────────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--gray-200);
  background: white;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

body.dark-mode .app-header {
  background: var(--dark-surface);
  border-bottom-color: var(--dark-border);
}

.app-branding {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-branding .app-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--gray-700);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.hamburger-btn:hover {
  background: var(--gray-100);
}

body.dark-mode .hamburger-btn {
  color: #e2e8f0;
}

body.dark-mode .hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-overlay {
  display: none;
}

.app-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-mode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-600);
}

body.dark-mode .header-mode-label {
  color: #cbd5e1;
}

.header-new-wrapper {
  position: relative;
}

.header-new-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 1.3rem;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.header-new-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

body.dark-mode .header-new-btn {
  color: var(--gray-400);
}

body.dark-mode .header-new-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.header-new-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 300;
  min-width: 180px;
  animation: menuFadeIn 0.15s ease;
}

body.dark-mode .header-new-menu {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.header-new-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.12s ease;
  text-align: left;
}

.header-new-menu-item:hover {
  background: var(--gray-100);
}

body.dark-mode .header-new-menu-item {
  color: #e2e8f0;
}

body.dark-mode .header-new-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.header-new-menu-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.install-btn {
  padding: 0.4rem 0.9rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.install-btn:hover {
  background: var(--primary-dark);
}

.install-icon {
  display: none;
}

@media (max-width: 768px) {
  .install-label {
    display: none;
  }
  .install-icon {
    display: block;
  }
  .install-btn {
    padding: 0.4rem;
  }
}

.theme-toggle {
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--space-sm);
  background: var(--gray-100);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
  user-select: none;
}

.theme-toggle:hover {
  background: var(--gray-200);
}

body.dark-mode .theme-toggle {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--dark-border);
  color: #f1f5f9;
}

body.dark-mode .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ── Status Banner ────────────────────────────────────────────────────────── */

.status-banner {
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(229, 62, 62, 0.15);
  border-bottom: 1px solid rgba(229, 62, 62, 0.3);
  color: #fc8181;
  font-size: 13px;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fc8181;
  flex-shrink: 0;
  animation: pulse-red 1.5s ease-in-out infinite;
}

@keyframes pulse-red {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

#chatSidebar {
  width: 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: white;
  padding: var(--space-lg);
  border-right: 1px solid var(--gray-200);
  overflow: hidden;
}

body.dark-mode #chatSidebar {
  background: var(--dark-surface);
  border-right-color: var(--dark-border);
}

#newChatBtn {
  width: 100%;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

#newChatBtn:hover {
  background: var(--gray-200);
}

body.dark-mode #newChatBtn {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--dark-border);
  color: #e2e8f0;
}

body.dark-mode #newChatBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#conversationList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-sm);
}

#conversationList::-webkit-scrollbar {
  width: 4px;
}

#conversationList::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 2px;
}

body.dark-mode #conversationList::-webkit-scrollbar-thumb {
  background: var(--dark-border);
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--gray-700);
  gap: 8px;
  transition: background 0.15s ease;
}

.conversation-item:hover {
  background: var(--gray-100);
}

.conversation-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

body.dark-mode .conversation-item {
  color: #cbd5e1;
}

body.dark-mode .conversation-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .conversation-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.conversation-mode-badge {
  font-size: 0.75rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

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

.conversation-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 0.75rem;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.conversation-item:hover .conversation-delete-btn {
  opacity: 1;
}

.conversation-item.active .conversation-delete-btn {
  opacity: 0.5;
}

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

/* ── Landing View ─────────────────────────────────────────────────────────── */

.landing-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-content {
  text-align: center;
  max-width: 1000px;
  padding: var(--space-xl);
}

.landing-greeting {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.02em;
}

body.dark-mode .landing-greeting {
  color: #f1f5f9;
}

.landing-subtitle {
  font-size: 1rem;
  color: var(--gray-500);
  margin-bottom: var(--space-2xl);
}

body.dark-mode .landing-subtitle {
  color: var(--gray-400);
}

.landing-pills {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.landing-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.5rem;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  min-width: 160px;
}

.landing-pill:hover {
  background: var(--gray-50);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
  transform: translateY(-2px);
}

body.dark-mode .landing-pill {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  color: #e2e8f0;
}

body.dark-mode .landing-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.pill-icon {
  font-size: 1.1rem;
}

.pill-label {
  font-weight: 500;
}

.pill-desc {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gray-500);
}

body.dark-mode .pill-desc {
  color: #94a3b8;
}

/* ── Chat Container ───────────────────────────────────────────────────────── */

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  background: transparent;
  border-radius: 0;
  border: none;
  overflow: hidden;
}

body.dark-mode .chat-container {
  background: transparent;
  border-color: transparent;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.chat-history::-webkit-scrollbar {
  width: 6px;
}

.chat-history::-webkit-scrollbar-track {
  background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

body.dark-mode .chat-history::-webkit-scrollbar-thumb {
  background: var(--dark-border);
}

/* ── Messages ─────────────────────────────────────────────────────────────── */

.message {
  padding: 0;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.6;
  animation: messageSlideIn 0.25s ease;
}

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

.user-message {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-bottom-right-radius: var(--radius-sm);
}

.ai-message {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-900);
  padding: var(--space-sm) var(--space-md);
  border-bottom-left-radius: var(--radius-sm);
}

body.dark-mode .ai-message {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.loading-msg {
  opacity: 0.7;
}

/* User prompt collapse */
.user-prompt {
  display: flex;
  flex-direction: column;
}

.user-prompt-toggle {
  position: absolute;
  top: 0.35rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.25rem;
  z-index: 1;
}

.user-prompt-chevron {
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
  transform: rotate(-90deg);
  transition: transform 0.25s ease;
}

.user-prompt-chevron.expanded {
  transform: rotate(0deg);
}

.user-prompt-body {
  max-height: calc(1.55 * 0.82rem * 3 + 1rem);
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.user-prompt-body.expanded {
  max-height: 600px;
}

.user-prompt-pre {
  margin: 0;
  font-family:
    ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  padding-right: 1.5rem;
  color: inherit;
}

/* ── Chat Input ───────────────────────────────────────────────────────────── */

.chat-input-area {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--gray-200);
  background: white;
}

body.dark-mode .chat-input-area {
  background: var(--dark-surface);
  border-top-color: var(--dark-border);
}

.chat-input-wrapper {
  position: relative;
  width: 100%;
}

.chat-input-wrapper textarea {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  padding-right: 56px;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  background: var(--gray-50);
  color: var(--gray-900);
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.chat-input-wrapper textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

body.dark-mode .chat-input-wrapper textarea {
  background: rgba(15, 23, 42, 0.5);
  border-color: var(--dark-border);
  color: #e2e8f0;
}

body.dark-mode .chat-input-wrapper textarea:focus {
  border-color: var(--primary);
}

.chat-icon-btn {
  position: absolute;
  bottom: 12px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-icon-btn.send svg {
  transform: rotate(90deg);
}

.chat-icon-btn.send {
  background: var(--gray-200);
  color: var(--gray-700);
}

.chat-icon-btn.send:hover {
  background: var(--gray-300);
}

.chat-icon-btn.send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

body.dark-mode .chat-icon-btn.send {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.dark-mode .chat-icon-btn.send:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-icon-btn.stop {
  background: var(--gray-200);
  color: var(--gray-600);
}

.chat-icon-btn.stop:hover {
  background: var(--gray-300);
}

body.dark-mode .chat-icon-btn.stop {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.dark-mode .chat-icon-btn.stop:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ── Variants Response (Auto-correct) ─────────────────────────────────────── */

.variants-response {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.variant-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

body.dark-mode .variant-card {
  border-color: var(--dark-border);
}

.variant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

body.dark-mode .variant-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom-color: var(--dark-border);
}

.variant-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

body.dark-mode .variant-label {
  color: var(--gray-400);
}

.variant-copy {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.variant-copy:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

body.dark-mode .variant-copy {
  color: var(--gray-400);
}

body.dark-mode .variant-copy:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.variant-text {
  padding: var(--space-md);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--gray-800);
  background: white;
}

body.dark-mode .variant-text {
  color: #e2e8f0;
  background: var(--dark-surface);
}

/* ── Prompt Gen ───────────────────────────────────────────────────────────── */

.chat-landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-xl);
}

.chat-landing-greeting {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-xs);
}

body.dark-mode .chat-landing-greeting {
  color: #f1f5f9;
}

.chat-landing-subtitle {
  font-size: 0.95rem;
  color: var(--gray-500);
  margin-bottom: var(--space-xl);
}

body.dark-mode .chat-landing-subtitle {
  color: var(--gray-400);
}

.prompt-gen-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
}

.prompt-gen-pill {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--gray-200);
  background: transparent;
  color: var(--gray-600);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.prompt-gen-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.prompt-gen-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

body.dark-mode .prompt-gen-pill {
  border-color: var(--dark-border);
  color: var(--gray-400);
}

body.dark-mode .prompt-gen-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

body.dark-mode .prompt-gen-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.prompt-gen-output {
  width: 100%;
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 0;
}

body.dark-mode .prompt-gen-output {
  border-color: var(--dark-border);
}

.prompt-gen-output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  background: var(--primary-light);
}

body.dark-mode .prompt-gen-output-header {
  background: rgba(59, 130, 246, 0.15);
}

.prompt-gen-output-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-dark);
  letter-spacing: 0.02em;
}

body.dark-mode .prompt-gen-output-label {
  color: var(--primary);
}

.prompt-gen-output-text {
  padding: var(--space-md);
  font-family:
    ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: white;
  color: var(--gray-800);
  margin: 0;
}

body.dark-mode .prompt-gen-output-text {
  background: var(--dark-bg);
  color: #e2e8f0;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.copy-btn:hover {
  background: rgba(59, 130, 246, 0.1);
}

body.dark-mode .copy-btn {
  color: var(--primary);
}

/* ── Chat markdown rendering ──────────────────────────────────────────────── */

.ai-message .message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

body.dark-mode .ai-message .message-content code {
  background: rgba(255, 255, 255, 0.1);
}

.ai-message .message-content pre {
  background: rgba(0, 0, 0, 0.04);
  padding: 10px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 8px 0;
  position: relative;
  border: 1px solid var(--gray-200);
}

body.dark-mode .ai-message .message-content pre {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--dark-border);
}

.ai-message .message-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  margin: -10px -10px 10px -10px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

body.dark-mode .code-block-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom-color: var(--dark-border);
}

.code-block-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

body.dark-mode .code-block-label {
  color: var(--gray-400);
}

.code-block-copy {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.code-block-copy:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

body.dark-mode .code-block-copy {
  color: var(--gray-400);
}

body.dark-mode .code-block-copy:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.ai-message .message-content ul,
.ai-message .message-content ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.ai-message .message-content li {
  margin-bottom: 3px;
}

.ai-message .message-content h1,
.ai-message .message-content h2,
.ai-message .message-content h3 {
  margin: 10px 0 4px;
  font-size: 1em;
  font-weight: 700;
}

.ai-message .message-content p {
  margin: 4px 0;
}

.ai-message .message-content p:first-child {
  margin-top: 0;
}

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

.ai-message .message-content blockquote {
  border-left: 3px solid var(--gray-400);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--gray-600);
}

body.dark-mode .ai-message .message-content blockquote {
  border-left-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.65);
}

/* ── Message latency ──────────────────────────────────────────────────────── */

.msg-latency {
  font-size: 0.7rem;
  color: var(--text-muted, #999);
  margin-top: 4px;
  text-align: right;
  opacity: 0.6;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--success);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: toastSlideIn 0.3s ease;
  font-size: 0.9rem;
}

.toast.toast-error {
  background: var(--error);
}

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

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

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .hamburger-btn {
    display: flex;
  }

  #chatSidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 200;
    border-right: 1px solid var(--gray-200);
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: calc(var(--space-lg) + 8px);
  }

  #chatSidebar.open {
    transform: translateX(0);
  }

  body.dark-mode #chatSidebar {
    border-right-color: var(--dark-border);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
  }

  .sidebar-overlay.open {
    display: block;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: var(--space-sm) var(--space-md);
  }

  .chat-container {
    border-radius: var(--radius-md);
    border: none;
  }

  .chat-history {
    padding: var(--space-md) var(--space-sm);
    gap: var(--space-md);
  }

  .message {
    max-width: 85%;
    font-size: 0.9rem;
  }

  .user-message {
    padding: var(--space-xs) var(--space-sm);
  }

  .ai-message {
    max-width: 100%;
  }

  .ai-message .message-content pre {
    padding: 8px;
    padding-top: 28px;
    font-size: 0.8rem;
  }

  .landing-greeting {
    font-size: 1.5rem;
  }

  .landing-pills {
    flex-direction: column;
    align-items: center;
  }

  .landing-pill {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .chat-input-area {
    padding: var(--space-sm) var(--space-sm);
  }
}

@media (max-width: 480px) {
  .landing-greeting {
    font-size: 1.25rem;
  }

  .landing-subtitle {
    font-size: 0.9rem;
  }
}

/* ── General button reset ─────────────────────────────────────────────────── */

button {
  font-family: inherit;
  cursor: pointer;
}

button:active {
  transform: scale(0.98);
}

/* ── Privacy banner ────────────────────────────────────────────────────────── */

.privacy-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(99, 102, 241, 0.12);
  border-bottom: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
}

.privacy-banner p {
  margin: 0;
  flex: 1;
}

.privacy-dismiss-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.2);
  color: inherit;
  font-size: 12px;
  white-space: nowrap;
}
