* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #383838 transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: #383838;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #484848;
}

:root {
  --sidebar-bg: #121212;
  --main-bg: #1a1a1a;
  --text-primary: #ececec;
  --text-secondary: #9b9b9b;
  --border-color: #2d2d2d;
  --accent-blue: #4c82fb;
  --hover-bg: #2a2a2a;
  --input-bg: #242424;
  --sidebar-width: 260px;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  height: 100vh;
  margin: 0;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 12px;
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
  white-space: nowrap;
}

.app-container.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  border-right: none;
  opacity: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-blue);
}

/* Wordmark Logo Styles */
.wordmark-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.wordmark-wrapper.large {
  flex-direction: column;
  gap: 20px;
}

.wordmark-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-blue);
}

.large .wordmark-icon {
  width: 64px;
  height: 64px;
}

.wordmark-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  align-items: center;
}

.large .wordmark-text {
  font-size: 36px;
}

.q-letter {
  color: var(--accent-blue);
}

.dev-part {
  color: var(--text-primary);
}

.ai-part {
  color: var(--text-secondary);
  font-weight: 400;
}

.sidebar-toggle, .sidebar-toggle-main {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sidebar-toggle:hover, .sidebar-toggle-main:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.sidebar-toggle-main {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: none;
}

.app-container.sidebar-collapsed .sidebar-toggle-main {
  display: flex;
}

.new-chat-btn {
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background: #333;
}

.new-chat-btn-main {
  position: absolute;
  top: 12px;
  left: 56px;
  z-index: 10;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.app-container.sidebar-collapsed .new-chat-btn-main {
  display: flex;
}

.main-header {
  height: 0;
  position: relative;
  z-index: 10;
}

.plus-icon {
  font-size: 18px;
  font-weight: 300;
}

.history-container {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.history-section {
  margin-bottom: 20px;
}

.history-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
  padding-left: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  gap: 8px;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.1);
}

.history-title-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.history-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.history-title-input {
  background: var(--input-bg);
  border: 1px solid var(--accent-blue);
  color: var(--text-primary);
  font-size: 13px;
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  font-family: inherit;
  width: 100%;
}

.history-action-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
}

.history-item:hover .history-action-btn {
  opacity: 1;
}

.history-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.delete-history-btn:hover {
  color: #ef4444;
}

/* Main Content Styling */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--main-bg);
  min-width: 0;
  overflow: hidden;
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding-bottom: 100px;
  width: 100%;
  max-width: 100%;
  padding-left: 20px;
  padding-right: 20px;
  text-align: center;
}

.welcome-title {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  transition: padding-left 0.3s ease;
}

.chat-title-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title-input {
  background: var(--input-bg);
  border: 1px solid var(--accent-blue);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  padding: 4px 8px;
  outline: none;
  font-family: inherit;
}

.edit-title-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.edit-title-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.app-container.sidebar-collapsed .chat-header {
  padding-left: 100px;
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 40px 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px;
  animation: fadeIn 0.3s ease;
  position: relative;
}

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

.message.user {
  align-items: flex-end;
}

.message.bot {
  align-items: flex-start;
}

/* Message Content Styling */
.message-content {
  width: 100%;
  max-width: 100%;
}

.message.user .message-content {
  width: fit-content;
  max-width: 100%;
}

.message.bot .message-content {
  max-width: 100%;
}

.message-text {
  display: block;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
}

.message.user .message-text {
  display: inline-block;
  max-width: 100%;
  background: #303030;
  color: var(--text-primary);
  border-bottom-right-radius: 2px;
}

.message.bot .message-text {
  background: transparent;
  color: var(--text-primary);
  padding-left: 0;
}

.message-text p {
  margin-bottom: 12px;
}

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

.msg-h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0 12px;
  color: var(--text-primary);
}

.message-text ol, .message-text ul {
  margin: 12px 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-text li {
  font-size: 15px;
  line-height: 1.6;
}

.inline-code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent-blue);
}

.message-text strong {
  font-weight: 700;
  color: var(--text-primary);
}

/* Code Block Styling */
.code-block-container {
  margin: 16px 0;
  background: #0d1117;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.code-block-header {
  background: #161b22;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.code-lang {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-copy-btn {
  background: transparent;
  border: 1px solid #30363d;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.code-copy-btn:hover {
  background: #30363d;
  color: var(--text-primary);
  border-color: #8b949e;
}

.code-copy-btn.success {
  color: #3fb950;
  border-color: #3fb950;
}

.code-block-container pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 14px;
  line-height: 1.5;
  background: transparent;
}

.code-block-container code {
  color: #e6edf3;
  white-space: pre;
}

/* Syntax Highlighting Colors (VS Code Dark+ Style) */
.token-keyword { color: #ff7b72; font-weight: 500; }
.token-function { color: #d2a8ff; }
.token-string { color: #a5d6ff; }
.token-number { color: #79c0ff; }
.token-comment { color: #8b949e; font-style: italic; }
.token-bracket { color: #e6edf3; }
.token-operator { color: #ff7b72; }

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

.message.user .message-actions {
  justify-content: flex-end;
  margin-right: 4px;
}

.message.bot .message-actions {
  justify-content: flex-start;
  margin-left: 0;
}

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

.message-action-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.message-action-btn svg {
  width: 16px;
  height: 16px;
}

.message-action-btn.copied {
  color: #10b981;
}

/* Input Area Styling */
.input-container {
  padding: 0 40px 24px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.composer {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 16px;
  transition: border-color 0.2s ease;
}

.composer:focus-within {
  border-color: #444;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Image Preview Bar */
.image-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border-color);
  animation: fadeIn 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.image-preview-bar.hidden {
  display: none;
}

.preview-images-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.preview-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.remove-thumb-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  border: 2px solid var(--input-bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.remove-thumb-btn:hover {
  transform: scale(1.15);
}

.image-count-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 4px;
}

/* Audio preview thumb */
.preview-thumb.audio {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  width: 56px;
  height: 56px;
}

.preview-thumb.audio svg {
  width: 24px;
  height: 24px;
  color: var(--accent-blue);
}

.audio-filename {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* User message audio */
.message.user .message-audios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.message-audio-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.message-audio-tag svg {
  width: 18px;
  height: 18px;
  color: var(--accent-blue);
  flex-shrink: 0;
}

/* User message images */
.message.user .message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.message.user .message-image {
  max-width: 240px;
  max-height: 240px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.image-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

#messageInput {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  outline: none;
  padding: 4px 0;
  max-height: 200px;
  font-family: inherit;
}

/* Recording Indicator */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 12px 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  font-size: 13px;
}

.recording-indicator.hidden {
  display: none;
}

.recording-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.recording-wave span {
  display: block;
  width: 3px;
  height: 12px;
  background: #ef4444;
  border-radius: 3px;
  animation: waveAnim 0.8s ease-in-out infinite;
}

.recording-wave span:nth-child(2) { animation-delay: 0.1s; height: 16px; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; height: 20px; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; height: 14px; }
.recording-wave span:nth-child(5) { animation-delay: 0.4s; height: 10px; }

@keyframes waveAnim {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

.recording-text {
  color: #ef4444;
  font-weight: 500;
}

.recording-tap-hint {
  color: var(--text-secondary);
  font-size: 11px;
  margin-left: auto;
}

.image-mode-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 12px 8px;
  background: rgba(76, 130, 251, 0.1);
  border: 1px solid rgba(76, 130, 251, 0.3);
  border-radius: 12px;
  font-size: 13px;
  color: var(--accent-blue);
}

.image-mode-banner.hidden {
  display: none;
}

.exit-image-mode-btn {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.exit-image-mode-btn:hover {
  opacity: 1;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.input-actions-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.add-btn-wrapper {
  position: relative;
}

.add-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.add-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.add-menu {
  position: absolute;
  bottom: 40px;
  left: 0;
  background: #2f2f2f;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.add-menu.hidden {
  display: none;
}

.add-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
  text-align: left;
}

.add-menu-item:hover {
  background: #3a3a3a;
}

.add-menu-divider {
  height: 1px;
  background: #444;
  margin: 4px 0;
}

.mic-btn {
  position: relative;
}

.mic-btn.recording {
  color: #ef4444;
}

.mic-btn.recording svg {
  animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.input-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.attach-btn, .send-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.attach-btn:hover {
  color: var(--text-primary);
}

.send-btn {
  width: 32px;
  height: 32px;
  background: #333;
  border-radius: 50%;
  color: #666;
  transition: all 0.2s ease;
}

.send-btn:not(:disabled) {
  background: var(--accent-blue);
  color: white;
}

/* Image Viewer Modal */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-viewer-overlay.hidden {
  display: none;
}

.image-viewer-content {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

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

.image-viewer-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.image-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-viewer-action-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.image-viewer-action-btn:hover {
  background: var(--hover-bg);
  border-color: var(--text-secondary);
}

.image-viewer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.image-viewer-close-btn:hover {
  color: var(--text-primary);
}

.image-viewer-body {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer-body img {
  max-width: 100%;
  max-height: 500px;
  border-radius: 12px;
}

.image-viewer-edit-panel {
  display: flex;
  gap: 8px;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border-color);
}

.image-viewer-edit-panel.hidden {
  display: none;
}

.image-viewer-edit-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.image-viewer-edit-input:focus {
  border-color: var(--accent-blue);
}

.image-viewer-edit-submit {
  padding: 10px 18px;
  background: var(--accent-blue);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: filter 0.2s ease;
}

.image-viewer-edit-submit:hover {
  filter: brightness(1.1);
}

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* Typing Indicator */
.typing {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 40px 20px;
  box-sizing: border-box;
}

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

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

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

.hidden { display: none !important; }

/* Modal & Toast Styles (Keep from original) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  width: min(400px, 90%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.btn-primary, .btn-secondary {
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

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

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: #333;
  color: var(--text-primary);
}

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Responsive Styling */
@media (max-width: 768px) {
  .sidebar {
    position: relative;
    left: 0;
    z-index: auto;
    height: 100%;
    width: 30%;
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  }

  .main-content {
    flex: 0 0 70%;
    width: 70%;
  }

  .app-container.sidebar-collapsed .main-content {
    flex: 1;
    width: 100%;
  }

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

  .messages {
    padding: 20px 0;
  }

  .message-content {
    max-width: 95%;
  }
}

.toast {
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.toast.success {
  border-left: 4px solid #10b981;
  background: #064e3b;
  color: #d1fae5;
}

.toast.error {
  border-left: 4px solid #ef4444;
  background: #7f1d1d;
  color: #fee2e2;
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(20%) scale(0.9); }
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    width: 280px;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 20px rgba(0, 0, 0, 0.3);
  }

  .app-container.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    width: 280px;
    padding: 12px;
    border-right: 1px solid var(--border-color);
    opacity: 1;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
  }

  .main-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
  }

  .sidebar-toggle-main, .new-chat-btn-main {
    display: flex !important;
    pointer-events: auto;
    top: 12px;
  }

  .welcome-title {
    font-size: 24px;
    padding: 0 20px;
    text-align: center;
  }

  .large .wordmark-text {
    font-size: 28px;
  }

  .large .wordmark-icon {
    width: 48px;
    height: 48px;
  }

  .input-container {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    margin-bottom: 0;
  }

  .composer {
    width: 100%;
    max-width: 100%;
  }

  .messages {
    padding: 20px 0;
    gap: 20px;
    width: 100%;
    max-width: 100%;
  }

  .message {
    padding: 0 16px;
    max-width: 100%;
  }

  .message.user .message-content {
    max-width: 85%;
  }

  .message.bot .message-content {
    max-width: 100%;
  }

  .message-text {
    font-size: 14px;
    padding: 10px 14px;
  }

  .chat-header {
    padding: 12px 15px 12px 85px !important;
    height: 60px;
    display: flex;
    align-items: center;
  }

  .chat-title {
    font-size: 16px;
  }

  .disclaimer {
    font-size: 10px;
  }

  .composer {
    padding: 8px 10px;
    border-radius: 12px;
  }

  #messageInput {
    font-size: 14px;
    padding: 2px 0;
    max-height: 120px;
  }

  .attach-btn, .send-btn {
    width: 30px;
    height: 30px;
  }

  .attach-btn svg, .send-btn svg {
    width: 18px;
    height: 18px;
  }

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

  .input-footer {
    padding-top: 4px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .input-actions-right {
    gap: 6px;
  }

  .input-actions-left {
    flex-shrink: 0;
  }

  .typing {
    padding: 0 16px 16px;
  }

  .history-item {
    padding: 12px;
    border-radius: 10px;
  }

  .history-title {
    font-size: 14px;
  }

  .new-chat-btn {
    margin-bottom: 16px;
    padding: 8px 12px;
  }

  .add-menu {
    bottom: 100%;
    top: auto;
    left: 0;
    margin-bottom: 8px;
  }

  .image-mode-banner {
    font-size: 12px;
    padding: 6px 10px;
  }
}

/* ----- Tables ----- */
.message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
}
.message-text th, .message-text td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}
.message-text th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}
.message-text tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

/* ----- Blockquotes ----- */
.message-text blockquote {
  border-left: 3px solid var(--accent-blue);
  padding: 8px 16px;
  margin: 12px 0;
  background: rgba(76, 130, 251, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}
.message-text blockquote p {
  margin: 0;
}

/* ----- Horizontal Rules ----- */
.message-text hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

/* ----- Strikethrough ----- */
.message-text s {
  text-decoration: line-through;
  opacity: 0.7;
}

/* ----- Header Action Buttons ----- */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.header-action-btn:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}



/* ----- Print Styles for PDF Export ----- */
@media print {
  body {
    background: white;
    color: black;
    overflow: visible;
  }
  .sidebar,
  .input-container,
  .chat-header-actions,
  .header-action-btn,
  .typing {
    display: none !important;
  }
  .app-container {
    display: block;
    height: auto;
    width: 100%;
  }
  .main-content {
    display: block;
    height: auto;
    overflow: visible;
  }
  .chat-area {
    display: block !important;
    overflow: visible;
  }
  .chat-header {
    border-bottom: 1px solid #ccc;
  }
  .messages {
    overflow: visible;
    padding: 20px;
    max-width: 100%;
  }
  .message {
    page-break-inside: avoid;
  }
  .message-text {
    color: black;
  }
  .message.user .message-text {
    background: #f0f0f0;
    color: black;
  }
  .message.bot .message-text {
    color: black;
  }
  .message-text strong { color: black; }
  .inline-code {
    background: #eee;
    color: #333;
  }
  .code-block-container {
    border: 1px solid #ccc;
  }
  .code-block-header {
    background: #f5f5f5;
    border-bottom: 1px solid #ccc;
  }
  .code-block-container code { color: #333; }
  .token-keyword { color: #d73a49; }
  .token-function { color: #6f42c1; }
  .token-string { color: #032f62; }
  .token-number { color: #005cc5; }
  .token-comment { color: #6a737d; }
  .message-text table th {
    background: #f5f5f5;
    color: black;
  }
  .message-text table td { color: black; }
  .message-text blockquote {
    border-left-color: #0366d6;
    color: #555;
  }
}
