/* ============================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
============================================================ */
:root {
  /* Colors - Dark Theme (default) */
  --bg-primary: #0f0f1a;
  --bg-secondary: #161622;
  --bg-tertiary: #1e1e2e;
  --bg-elevated: #252535;
  --bg-hover: #2a2a3d;
  --bg-active: #313148;

  --surface-glass: rgba(255, 255, 255, 0.04);
  --surface-glass-hover: rgba(255, 255, 255, 0.07);
  --surface-border: rgba(255, 255, 255, 0.08);
  --surface-border-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a70;
  --text-inverse: #0f0f1a;

  --accent-primary: #76b900;        /* NVIDIA Green */
  --accent-primary-dark: #5a8c00;
  --accent-primary-light: #9fda00;
  --accent-secondary: #00c8ff;      /* NVIDIA Blue */
  --accent-secondary-dark: #0098cc;
  --accent-gradient: linear-gradient(135deg, #76b900 0%, #00c8ff 100%);
  --accent-gradient-hover: linear-gradient(135deg, #9fda00 0%, #33d6ff 100%);

  --user-bubble-bg: linear-gradient(135deg, #1a3a5c 0%, #1e4a7a 100%);
  --user-bubble-border: rgba(0, 200, 255, 0.2);
  --ai-bubble-bg: var(--bg-tertiary);
  --ai-bubble-border: var(--surface-border);

  --error-color: #ff4d4d;
  --error-bg: rgba(255, 77, 77, 0.1);
  --warning-color: #ffb347;
  --warning-bg: rgba(255, 179, 71, 0.1);
  --success-color: #76b900;
  --success-bg: rgba(118, 185, 0, 0.1);
  --info-color: #00c8ff;
  --info-bg: rgba(0, 200, 255, 0.1);

  --code-bg: #1a1a2e;
  --code-header-bg: #12122a;
  --code-border: rgba(255, 255, 255, 0.06);

  /* Sidebar */
  --sidebar-width: 280px;
  --sidebar-bg: #0c0c18;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  --line-height-tight: 1.3;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.8;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 0 0 3px rgba(118, 185, 0, 0.25);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.06);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sidebar: 200;
  --z-overlay: 199;
  --z-modal: 300;
  --z-toast: 400;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f0f0f8;
  --bg-secondary: #e8e8f2;
  --bg-tertiary: #ffffff;
  --bg-elevated: #f5f5fc;
  --bg-hover: #eaeaf5;
  --bg-active: #e0e0ee;

  --surface-glass: rgba(255, 255, 255, 0.7);
  --surface-glass-hover: rgba(255, 255, 255, 0.85);
  --surface-border: rgba(0, 0, 0, 0.08);
  --surface-border-hover: rgba(0, 0, 0, 0.15);

  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #8888aa;
  --text-inverse: #ffffff;

  --user-bubble-bg: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  --user-bubble-border: rgba(59, 130, 246, 0.2);
  --ai-bubble-bg: #ffffff;
  --ai-bubble-border: rgba(0, 0, 0, 0.08);

  --error-color: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.08);
  --success-color: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --info-color: #0284c7;
  --info-bg: rgba(2, 132, 199, 0.08);

  --code-bg: #f8f8ff;
  --code-header-bg: #ededf8;
  --code-border: rgba(0, 0, 0, 0.08);

  --sidebar-bg: #e8e8f2;
  --sidebar-border: rgba(0, 0, 0, 0.08);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ============================================================
   RESET & BASE STYLES
============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: inherit;
  transition: all var(--transition-fast);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input, textarea, select {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
}

ul, ol {
  list-style: none;
}

/* ============================================================
   SCROLLBAR STYLING
============================================================ */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--surface-border-hover);
}

/* ============================================================
   APP SHELL LAYOUT
============================================================ */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-base);
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.brand-name {
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--surface-glass);
}

.sidebar-close-btn svg {
  width: 18px;
  height: 18px;
}

.sidebar-close-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

/* New Chat Button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-gradient);
  color: white;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-md), 0 0 20px rgba(118, 185, 0, 0.2);
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.new-chat-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: var(--accent-gradient-hover);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(118, 185, 0, 0.35);
  transform: translateY(-1px);
}

.new-chat-btn:active {
  transform: translateY(0);
}

/* Sidebar Search */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-search:focus-within {
  border-color: var(--accent-primary);
  background: var(--surface-glass-hover);
}

.sidebar-search svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-search input {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

/* Chat History */
.chat-history-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-3);
  display: flex;
  flex-direction: column;
}

.history-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-2) var(--space-2);
  flex-shrink: 0;
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

/* History Item */
.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  group: true;
}

.history-item:hover {
  background: var(--surface-glass-hover);
}

.history-item.active {
  background: var(--bg-active);
}

.history-item-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.history-item-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item-actions {
  display: none;
  gap: var(--space-1);
  flex-shrink: 0;
}

.history-item:hover .history-item-actions {
  display: flex;
}

.history-action-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.history-action-btn:hover {
  background: var(--surface-glass);
  color: var(--text-primary);
}

.history-action-btn.delete:hover {
  background: var(--error-bg);
  color: var(--error-color);
}

.history-action-btn svg {
  width: 13px;
  height: 13px;
}

/* Empty History */
.empty-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  gap: var(--space-2);
  text-align: center;
  color: var(--text-muted);
}

.empty-history svg {
  width: 40px;
  height: 40px;
  opacity: 0.4;
  margin-bottom: var(--space-2);
}

.empty-history p {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-history span {
  font-size: var(--font-size-xs);
}

/* Sidebar Footer */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-action-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.sidebar-action-btn.danger:hover {
  background: var(--error-bg);
  color: var(--error-color);
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* ============================================================
   MAIN CONTENT
============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
  min-width: 0;
}

/* ============================================================
   TOP BAR
============================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  height: 60px;
  min-height: 60px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  z-index: var(--z-base);
  flex-shrink: 0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Hamburger */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 36px;
  height: 36px;
  padding: 9px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.hamburger-btn span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
}

.hamburger-btn:hover {
  background: var(--surface-glass-hover);
}

.hamburger-btn:hover span {
  background: var(--text-primary);
}

.current-chat-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* Model Selector */
.model-selector-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.model-selector {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 220px;
}

.model-selector option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.model-selector:hover {
  border-color: var(--surface-border-hover);
  background: var(--surface-glass-hover);
}

.model-selector:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-accent);
}

.select-arrow {
  position: absolute;
  right: 8px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Theme Toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  position: absolute;
  transition: all var(--transition-base);
}

.theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.theme-toggle:hover {
  background: var(--surface-glass-hover);
  border-color: var(--surface-border-hover);
  color: var(--text-primary);
}

/* ============================================================
   CHAT CONTAINER
============================================================ */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
}

.messages-wrapper {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ============================================================
   WELCOME SCREEN
============================================================ */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100% - 20px);
  padding: var(--space-8) var(--space-5);
}

.welcome-content {
  text-align: center;
  max-width: 680px;
  width: 100%;
}

.welcome-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-5);
  animation: floatLogo 3s ease-in-out infinite;
}

.welcome-logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 20px rgba(118, 185, 0, 0.3));
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-2);
  letter-spacing: -0.03em;
}

.welcome-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  line-height: var(--line-height-relaxed);
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  text-align: left;
}

.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: left;
}

.suggestion-card:hover {
  background: var(--surface-glass-hover);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md), 0 0 20px rgba(118, 185, 0, 0.1);
  transform: translateY(-2px);
}

.suggestion-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
}

.suggestion-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.suggestion-text strong {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.suggestion-text span {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================================
   MESSAGES
============================================================ */
.message {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  animation: messageAppear 0.3s ease-out forwards;
  opacity: 0;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User Message */
.message.user {
  align-items: flex-end;
}

.message.user .message-bubble {
  background: var(--user-bubble-bg);
  border: 1px solid var(--user-bubble-border);
  color: var(--text-primary);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
  max-width: 75%;
}

/* AI Message */
.message.ai {
  align-items: flex-start;
}

.message.ai .message-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.ai-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(118, 185, 0, 0.3);
}

.ai-avatar svg {
  width: 16px;
  height: 16px;
  color: white;
}

.ai-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.message.ai .message-bubble {
  background: var(--ai-bubble-bg);
  border: 1px solid var(--ai-bubble-border);
  border-radius: var(--radius-sm) var(--radius-xl) var(--radius-xl) var(--radius-xl);
  max-width: 100%;
  box-shadow: var(--shadow-sm);
}

/* Message Bubble */
.message-bubble {
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Message Footer */
.message-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-1);
}

.message-timestamp {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.message-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.message:hover .message-actions {
  opacity: 1;
}

.msg-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--surface-glass);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.msg-action-btn svg {
  width: 13px;
  height: 13px;
}

.msg-action-btn:hover {
  background: var(--surface-glass-hover);
  border-color: var(--surface-border);
  color: var(--text-primary);
}

.msg-action-btn.copied {
  color: var(--success-color);
  border-color: var(--success-color);
  background: var(--success-bg);
}

/* ============================================================
   MARKDOWN CONTENT STYLES
============================================================ */
.message-content {
  line-height: var(--line-height-relaxed);
}

.message-content p {
  margin-bottom: var(--space-3);
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  font-weight: 700;
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.message-content h1 { font-size: var(--font-size-xl); }
.message-content h2 { font-size: var(--font-size-lg); }
.message-content h3 { font-size: var(--font-size-md); }
.message-content h4 { font-size: var(--font-size-base); }

.message-content ul,
.message-content ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
}

.message-content ul { list-style: disc; }
.message-content ol { list-style: decimal; }

.message-content li {
  margin-bottom: var(--space-1);
  line-height: var(--line-height-relaxed);
}

.message-content li::marker {
  color: var(--accent-primary);
}

.message-content strong {
  font-weight: 700;
  color: var(--text-primary);
}

.message-content em {
  font-style: italic;
}

.message-content blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
  background: var(--surface-glass);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--surface-border);
}

.message-content th,
.message-content td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--surface-border);
}

.message-content th {
  background: var(--surface-glass);
  font-weight: 600;
  color: var(--text-primary);
}

.message-content td {
  color: var(--text-secondary);
}

.message-content tr:last-child td {
  border-bottom: none;
}

.message-content tr:hover td {
  background: var(--surface-glass);
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--surface-border);
  margin: var(--space-4) 0;
}

/* Inline Code */
.message-content code:not(.hljs) {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--accent-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--code-border);
}

/* Code Block */
.code-block-wrapper {
  margin: var(--space-4) 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  box-shadow: var(--shadow-md);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  background: var(--code-header-bg);
  border-bottom: 1px solid var(--code-border);
}

.code-lang-label {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.copy-code-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  transition: all var(--transition-fast);
  font-family: var(--font-mono);
}

.copy-code-btn svg {
  width: 13px;
  height: 13px;
}

.copy-code-btn:hover {
  color: var(--text-primary);
  background: var(--surface-glass-hover);
  border-color: var(--surface-border-hover);
}

.copy-code-btn.copied {
  color: var(--success-color);
  border-color: var(--success-color);
  background: var(--success-bg);
}

.code-block-wrapper pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  background: var(--code-bg) !important;
}

.code-block-wrapper pre code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.7;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  color: inherit;
}

/* ============================================================
   TYPING INDICATOR
============================================================ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent-primary);
  margin-left: 2px;
  vertical-align: middle;
  border-radius: 1px;
  animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ============================================================
   SCROLL TO BOTTOM BUTTON
============================================================ */
.scroll-bottom-btn {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-5);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all var(--transition-base);
  z-index: var(--z-base);
}

.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.scroll-bottom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--surface-border-hover);
  transform: translateY(-2px);
}

.scroll-bottom-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   INPUT AREA
============================================================ */
.input-area {
  flex-shrink: 0;
  background: var(--bg-primary);
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-top: 1px solid var(--surface-border);
}

/* Action Bar */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  min-height: 32px;
}

.action-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.action-pill svg {
  width: 15px;
  height: 15px;
}

.action-pill:hover {
  background: var(--bg-hover);
  border-color: var(--surface-border-hover);
  color: var(--text-primary);
}

#stopGenerationBtn:hover {
  border-color: var(--error-color);
  color: var(--error-color);
  background: var(--error-bg);
}

#regenerateBtn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--success-bg);
}

/* Input Box Wrapper */
.input-box-wrapper {
  max-width: 820px;
  margin: 0 auto;
}

.input-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-glass);
  transition: all var(--transition-base);
}

.input-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glass), 0 0 0 3px rgba(118, 185, 0, 0.15);
}

.message-input {
  display: block;
  width: 100%;
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: var(--line-height-base);
  resize: none;
  min-height: 52px;
  max-height: 280px;
  overflow-y: auto;
  background: transparent;
}

.message-input::placeholder {
  color: var(--text-muted);
}

/* Input Footer */
.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--surface-border);
}

.input-tools {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  transition: all var(--transition-fast);
}

.tool-btn svg {
  width: 17px;
  height: 17px;
}

.tool-btn:hover {
  background: var(--surface-glass);
  color: var(--text-secondary);
}

.tool-btn.danger:hover {
  background: var(--error-bg);
  color: var(--error-color);
}

.input-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.char-counter {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  transition: color var(--transition-fast);
}

.char-counter.warning {
  color: var(--warning-color);
}

.char-counter.danger {
  color: var(--error-color);
}

/* Send Button */
.send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(118, 185, 0, 0.4);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}

.send-btn:not(:disabled):hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 4px 16px rgba(118, 185, 0, 0.5);
  transform: scale(1.05);
}

.send-btn:not(:disabled):hover svg {
  transform: translateX(1px) translateY(-1px);
}

.send-btn:not(:disabled):active {
  transform: scale(0.97);
}

.send-btn:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  box-shadow: none;
}

/* Disclaimer */
.input-disclaimer {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
  line-height: 1.5;
}

/* ============================================================
   ERROR MESSAGE
============================================================ */
.error-message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--error-bg);
  border: 1px solid rgba(255, 77, 77, 0.2);
  border-radius: var(--radius-lg);
  color: var(--error-color);
  margin: var(--space-2) 0;
}

.error-message svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.error-message-content {
  flex: 1;
  min-width: 0;
}

.error-message-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: 4px;
}

.error-message-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-base);
}

.error-retry-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  color: var(--error-color);
  border: 1px solid var(--error-color);
  background: transparent;
  transition: all var(--transition-fast);
}

.error-retry-btn:hover {
  background: var(--error-color);
  color: white;
}

/* ============================================================
   MODALS
============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: modalBackdropIn 0.2s ease-out;
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: modalBoxIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalBoxIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}

.modal-icon.warning {
  background: var(--warning-bg);
  color: var(--warning-color);
}

.modal-icon svg {
  width: 28px;
  height: 28px;
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.modal-message {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-6);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
}

.modal-btn {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.modal-btn.secondary {
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.modal-btn.secondary:hover {
  background: var(--surface-glass-hover);
  border-color: var(--surface-border-hover);
}

.modal-btn.danger {
  background: var(--error-color);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 77, 77, 0.4);
}

.modal-btn.danger:hover {
  background: #ff3333;
  box-shadow: 0 6px 16px rgba(255, 77, 77, 0.5);
  transform: translateY(-1px);
}

/* ============================================================
   TOAST NOTIFICATIONS
============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  pointer-events: all;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  backdrop-filter: blur(20px);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.removing {
  animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.9);
  }
}

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--success-color); }
.toast.error .toast-dot { background: var(--error-color); }
.toast.info .toast-dot { background: var(--info-color); }
.toast.warning .toast-dot { background: var(--warning-color); }

/* ============================================================
   LOADING STATE
============================================================ */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   UTILITY CLASSES
============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE — TABLET
============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }

  .model-selector {
    max-width: 180px;
  }

  .current-chat-title {
    max-width: 200px;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE
============================================================ */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  /* Sidebar becomes overlay on mobile */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  .sidebar-close-btn {
    display: flex;
  }

  .hamburger-btn {
    display: flex;
  }

  .current-chat-title {
    max-width: 160px;
    font-size: var(--font-size-sm);
  }

  .model-selector {
    max-width: 140px;
    font-size: var(--font-size-xs);
    padding: var(--space-2) var(--space-6) var(--space-2) var(--space-2);
  }

  .messages-wrapper {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-3);
  }

  .message.user .message-bubble {
    max-width: 90%;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }

  .welcome-title {
    font-size: var(--font-size-xl);
  }

  .welcome-subtitle {
    font-size: var(--font-size-sm);
  }

  .input-area {
    padding: var(--space-2) var(--space-3) var(--space-3);
  }

  .message-bubble {
    padding: var(--space-3) var(--space-4);
  }

  .input-disclaimer {
    display: none;
  }

  .top-bar {
    padding: 0 var(--space-3);
  }
}

@media (max-width: 480px) {
  .model-selector-wrapper {
    display: none;
  }

  .welcome-logo {
    width: 60px;
    height: 60px;
  }

  .welcome-title {
    font-size: var(--font-size-lg);
  }

  .modal-box {
    padding: var(--space-6);
  }
}

/* ============================================================
   PRINT STYLES
============================================================ */
@media print {
  .sidebar,
  .top-bar,
  .input-area,
  .scroll-bottom-btn,
  .action-bar {
    display: none !important;
  }

  .main-content {
    height: auto;
    overflow: visible;
  }

  .chat-container {
    overflow: visible;
    height: auto;
  }

  .messages-wrapper {
    max-width: 100%;
  }
}

/* ============================================================
   HIGHLIGHT.JS THEME OVERRIDE (Light mode)
============================================================ */
[data-theme="light"] .code-block-wrapper {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] #hljs-theme {
  /* will be swapped via JS */
}