/* ============================================================
   DEXLEE AI – DESIGN SYSTEM
   Modern, glassmorphic, responsive | Auto dark / light mode
   ============================================================ */

/* ── Google Font ─────────────────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ── CSS Variables (Light) ───────────────────────────────── */
:root {
  --font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Palette */
  --bg: #f0f2f5;
  --bg-secondary: #e4e7ec;
  --surface: #ffffff;
  --surface-hover: #f7f8fa;
  --surface-active: #eef0f4;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.45);
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-ghost: rgba(99, 102, 241, 0.1);
  --accent: #a78bfa;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --sidebar-w: 280px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Message colors */
  --msg-user-bg: linear-gradient(135deg, #6366f1, #8b5cf6);
  --msg-user-text: #ffffff;
  --msg-ai-bg: var(--surface);
  --msg-ai-border: var(--border);
}

/* ── Dark Mode (auto) ────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d11;
    --bg-secondary: #111318;
    --surface: #16181f;
    --surface-hover: #1e2028;
    --surface-active: #252830;
    --glass: rgba(22, 24, 31, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --primary-ghost: rgba(99, 102, 241, 0.15);
    --border: #2a2d35;
    --border-light: #1e2028;
    --danger-light: #1c1012;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.6);
    --msg-ai-bg: var(--surface);
    --msg-ai-border: var(--border);
  }
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
}
button {
  font-family: inherit;
  cursor: pointer;
}

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

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform var(--transition-slow);
  z-index: 100;
  position: relative;
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* New Chat Button */
.btn-new-chat {
  margin: 12px 16px 8px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.btn-new-chat svg {
  width: 18px;
  height: 18px;
}

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

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  margin-bottom: 2px;
}
.chat-item:hover {
  background: var(--surface-hover);
}
.chat-item.active {
  background: var(--primary-ghost);
}
.chat-item.active .chat-item-title {
  color: var(--primary);
  font-weight: 600;
}

.chat-item-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary-ghost);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.85rem;
}

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

.chat-item-delete {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
}
.chat-item:hover .chat-item-delete {
  display: flex;
}
.chat-item-delete:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
}
.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-credits {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-actions {
  display: flex;
  gap: 6px;
}
.sidebar-actions button {
  flex: 1;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all var(--transition);
}
.sidebar-actions button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-ghost);
}

/* ── Mobile Sidebar ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.menu-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 110;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-btn {
    display: flex;
  }
  .main-content {
    margin-left: 0 !important;
  }
}

/* ════════════════════════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  min-height: 52px;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.desktop-only { display: flex; }
.mobile-only { display: none; }

.model-select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 30px 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  max-width: 280px;
  transition: all var(--transition);
}
.model-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-ghost);
}
.model-select:hover {
  background-color: var(--surface-hover);
}


.top-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search Grounding Toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.toggle-switch input {
  display: none;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background var(--transition);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked ~ .toggle-thumb {
  transform: translateX(16px);
}

/* ── Chat Messages Area ──────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 16px;
  opacity: 0.7;
}
.chat-welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.chat-welcome h2 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.chat-welcome p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 400px;
}

/* Messages */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  max-width: 850px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 2px;
}
.message-avatar.ai-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
}

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

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.message-name {
  font-size: 0.85rem;
  font-weight: 600;
}
.message-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.message-content {
  font-size: 0.93rem;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* User messages */
.message.user .message-content {
  background: var(--msg-user-bg);
  color: var(--msg-user-text);
  padding: 12px 16px;
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
  display: inline-block;
}

/* AI messages */
.message.assistant .message-content {
  background: var(--msg-ai-bg);
  border: 1px solid var(--msg-ai-border);
  padding: 14px 18px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

/* Thinking Content */
.thinking-block {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface-hover);
  border: none;
  width: 100%;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: inherit;
  transition: all var(--transition);
}
.thinking-toggle:hover {
  background: var(--surface-active);
}
.thinking-toggle .arrow {
  transition: transform var(--transition);
  font-size: 0.7rem;
}
.thinking-toggle.open .arrow {
  transform: rotate(90deg);
}
.thinking-body {
  display: none;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid var(--border-light);
}
.thinking-body.open {
  display: block;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Status Banner */
.status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 auto 12px;
  max-width: 850px;
  background: var(--primary-ghost);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--primary);
  animation: fadeIn 0.2s ease;
}
.status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--primary-ghost);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Markdown Content Styles ─────────────────────────────── */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 16px 0 8px;
  line-height: 1.3;
}
.message-content h1 {
  font-size: 1.4rem;
}
.message-content h2 {
  font-size: 1.2rem;
}
.message-content h3 {
  font-size: 1.05rem;
}
.message-content p {
  margin: 8px 0;
}
.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}
.message-content li {
  margin: 4px 0;
}
.message-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 8px 14px;
  margin: 8px 0;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 0.85rem;
}
.message-content th,
.message-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.message-content th {
  background: var(--surface-hover);
  font-weight: 600;
}
.message-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.message-content strong {
  font-weight: 600;
}
.message-content em {
  font-style: italic;
}
.message-content code:not(pre code) {
  background: var(--surface-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;
  color: var(--primary);
  border: 1px solid var(--border-light);
}

/* ── Upload Progress ─────────────────────────────────────── */
/* ── Upload Progress ─────────────────────────────────────── */
.attachment-progress {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-hover); /* Ensure visibility */
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.attachment-progress .attachment-thumb,
.attachment-progress .attachment-file-thumb {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 1px solid var(--border);
  opacity: 0.8;
}

.progress-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.2s linear;
}

/* Disabled Send Button */
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-active);
  color: var(--text-muted);
}

/* Code Blocks */
.code-block-wrapper {
  position: relative;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #181825;
  font-size: 0.75rem;
  color: #a6adc8;
}
.code-block-header .lang {
  text-transform: uppercase;
  font-weight: 600;
}
.code-copy-btn {
  border: none;
  background: transparent;
  color: #a6adc8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
  font-family: inherit;
}
.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.code-copy-btn.copied {
  color: var(--success);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  background: var(--code-bg);
  font-size: 0.85rem;
  line-height: 1.5;
}
.code-block-wrapper pre code {
  font-family: "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;
  color: var(--code-text);
}

/* Generated Images in Chat */
.message-content img {
  border-radius: var(--radius-sm);
  max-width: 100%;
  max-height: 400px;
  cursor: pointer;
  transition: transform var(--transition);
  border: 1px solid var(--border);
}
.message-content img:hover {
  transform: scale(1.02);
}

/* ── Message Attachments ────────────────────────────────── */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.message-body .msg-attachment-img,
.message-body .msg-attachment-file {
  max-width: 100%;
}

.message-body .msg-attachment-img img {
  border-radius: 12px !important;
  max-width: 100%;
  max-height: 400px; /* Reasonable max height */
  width: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
  display: block;
}
.message-body .msg-attachment-img img:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}

.msg-attachment-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.msg-attachment-file:hover {
  background: var(--surface-active);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.msg-attachment-file .file-icon {
  font-size: 1.3rem;
}

/* ── Input Area ──────────────────────────────────────────── */
.input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.input-container {
  max-width: 850px;
  margin: 0 auto;
}

.attachment-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.attachment-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-thumb .remove-att {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-file-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  position: relative;
  padding: 4px;
  text-align: center;
  overflow: hidden;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 16px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
.input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}

.input-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}
.input-tool-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.input-tool-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

#chatInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.93rem;
  color: var(--text);
  resize: none;
  min-height: 40px;
  max-height: 150px;
  line-height: 1.5;
  padding: 9px 0;
}
#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.4);
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

/* ════════════════════════════════════════════════════════════
   IMAGE MARKUP OVERLAY
   ════════════════════════════════════════════════════════════ */
.markup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.85);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.markup-overlay.active {
  display: flex;
}

.markup-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  box-shadow: var(--shadow-lg);
}
.markup-tool {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.markup-tool:hover {
  border-color: var(--primary);
}
.markup-tool.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.markup-color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}
.markup-color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.markup-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}
.markup-color-picker::-moz-color-swatch {
  border: none;
  border-radius: 2px;
}
.markup-color-picker:hover {
  border-color: var(--primary);
}

.markup-canvas-wrap {
  position: relative;
  max-width: 90vw;
  max-height: 70vh;
  display: inline-block;
}
.markup-canvas-wrap canvas {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-sm);
}
.markup-canvas {
  box-shadow: var(--shadow-xl);
  display: block;
}
.markup-draft-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.markup-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.markup-actions button {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.markup-save {
  background: var(--primary);
  color: #fff;
}
.markup-cancel {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border) !important;
}

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

/* Error messages */
.error-banner {
  padding: 10px 14px;
  margin: 0 auto 12px;
  max-width: 850px;
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--danger);
  animation: fadeIn 0.2s ease;
}

/* Empty state */
.empty-chats {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── Responsive (Tablet) ─────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 260px;
  }
  .chat-area {
    padding: 16px;
  }
}

/* ── Responsive (Mobile) ─────────────────────────────────── */
@media (max-width: 768px) {
  .top-bar {
    padding: 10px 14px 10px 56px;
  }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .model-selector {
    gap: 3px;
  }
  .model-select {
    font-size: 0.8rem;
    padding: 6px 24px 6px 10px;
    background-size: 12px;
    max-width: 180px;
  }
  .chat-area {
    padding: 12px 10px;
  }
  .message {
    gap: 8px;
  }
  .input-area {
    padding: 8px 10px 12px;
  }
  .toggle-wrap span {
    /* Always show search label */
    display: inline;
  }
  .top-bar-right {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .model-select {
    max-width: 140px;
  }
}

/* -- Start Prompts ----------------------------------------- */
.start-prompts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 600px;
  margin-top: 32px;
  animation: fadeIn 0.4s ease 0.1s backwards;
}
@media (max-width: 600px) {
  .start-prompts-grid {
    grid-template-columns: 1fr;
  }
}

.start-prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}
.start-prompt-card:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.start-prompt-card-icon {
  font-size: 1.1em;
  opacity: 0.7;
  min-width: 20px;
}

/* Aspect Ratio Selector */
.ratio-select {
  appearance: none;
  background-color: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  font-weight: 500;
  text-align: center;
}
.ratio-select:hover {
  background: var(--surface-active);
  color: var(--primary);
}
.ratio-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-ghost);
}
.ratio-select option {
  background: var(--surface);
  color: var(--text);
}


/* Image Viewer */
.viewer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  overflow: hidden;
}
.viewer-overlay.visible {
  display: flex;
}

.viewer-content {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  position: relative;
}
.viewer-content:active {
  cursor: grabbing;
}
.viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transition: transform 0.1s ease-out;
  transform-origin: center;
  pointer-events: none; /* Let clicks pass to container for drag */
}

.viewer-controls {
  position: absolute;
  bottom: 30px;
  background: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 999px;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  z-index: 10001;
}

.viewer-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.viewer-btn:active {
  transform: scale(0.9);
}
.viewer-btn.success {
  background: rgba(16, 185, 129, 0.3) !important;
  color: #10b981;
}
.viewer-btn.loading {
  animation: pulse 1s infinite alternate;
  pointer-events: none;
}
@keyframes pulse {
  from { opacity: 0.6; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1.05); }
}
.viewer-sep {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}
.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.viewer-btn.close {
  background: rgba(255, 59, 48, 0.2);
  color: #ff3b30;
}
.viewer-btn.close:hover {
  background: rgba(255, 59, 48, 0.4);
}
.viewer-sep {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.2);
}

li:not(ul li):not(ol li) {
    margin-left: 17px !important;
}

/* Message Actions */
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.message:hover .message-actions {
  opacity: 1;
}
@media (max-width: 768px) {
  .message-actions { opacity: 1; }
}
.msg-action-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}
.msg-action-btn:hover {
  background: var(--surface-active);
  color: var(--text);
  border-color: var(--text-muted);
}
.message.user .msg-action-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.message.user .msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}
.message-edit-box {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message-edit-textarea {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
}
.message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.message-edit-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
}
.message-edit-btn.cancel {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.message-edit-btn.save {
  background: var(--primary);
  color: white;
}



