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

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #ef4444 0%, #3b82f6 100%);
  --accent-gradient-hover: linear-gradient(135deg, #dc2626 0%, #2563eb 100%);
  --border-color: #334155;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse at 20% 50%, rgba(239, 68, 68, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
              var(--bg-primary);
}

/* ===== App Layout ===== */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), opacity var(--transition);
  z-index: 10;
  animation: slideInLeft 0.4s ease;
}

@keyframes slideInLeft {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  transition: opacity var(--transition);
}

.logo:hover { opacity: 0.85; }

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  animation: fadeInUp 0.4s ease 0.1s both;
}

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

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.new-chat-btn:active { transform: translateY(0); }

.history-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.history-section::-webkit-scrollbar { width: 4px; }
.history-section::-webkit-scrollbar-track { background: transparent; }
.history-section::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.clear-all-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
}

.clear-all-btn:hover { color: var(--accent-red); background: rgba(239, 68, 68, 0.1); }

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

.history-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  animation: fadeInUp 0.3s ease both;
  position: relative;
}

.history-item:hover { background: var(--bg-hover); }

.history-item.active {
  background: var(--bg-hover);
  border-left: 3px solid var(--accent-blue);
}

.history-item .history-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.history-item .history-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.history-item .history-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: opacity var(--transition), color var(--transition);
  display: flex;
  flex-shrink: 0;
}

.history-item:hover .history-delete { opacity: 1; }
.history-item .history-delete:hover { color: var(--accent-red); background: rgba(239, 68, 68, 0.1); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
}

.footer-text {
  font-size: 11px;
  color: var(--text-muted);
}

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

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }
.chat-container::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Welcome Screen ===== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
  animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-logo {
  margin-bottom: 16px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.welcome-screen h1 {
  font-size: 48px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.welcome-screen > p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 480px;
  line-height: 1.6;
}

.welcome-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 600px;
}

.example-pill {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeInUp 0.4s ease both;
}

.example-pill:nth-child(1) { animation-delay: 0.1s; }
.example-pill:nth-child(2) { animation-delay: 0.2s; }
.example-pill:nth-child(3) { animation-delay: 0.3s; }
.example-pill:nth-child(4) { animation-delay: 0.4s; }

.example-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* ===== Messages ===== */
.messages {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  animation: messageSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.message.user { flex-direction: row; }
.message.assistant { flex-direction: row; }

.message-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
}

.message.user .message-avatar {
  background: var(--accent-gradient);
  color: white;
}

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

.message-content {
  flex: 1;
  max-width: 80%;
}

.message.user .message-content {
  margin-left: auto;
}

.sender-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.75;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .message-bubble {
  background: var(--accent-gradient);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: transparent;
  border: none;
}

/* ===== Typing Cursor ===== */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent-blue);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s ease-in-out infinite;
}

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

/* ===== Thinking Indicator ===== */
.thinking-indicator {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
  animation: messageSlideIn 0.3s ease both;
}

.thinking-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thinking-text {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

.thinking-word {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
  font-style: normal;
}

.thinking-dots span {
  animation: thinkingDot 1.4s ease-in-out infinite;
  font-size: 18px;
  line-height: 1;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingDot {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

.thinking-bar {
  width: 120px;
  height: 3px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.thinking-bar-fill {
  height: 100%;
  width: 40%;
  background: var(--accent-gradient);
  border-radius: 3px;
  animation: thinkingBar 1.2s ease-in-out infinite;
}

@keyframes thinkingBar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ===== Code Blocks ===== */
.message-bubble code.inline-code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

.message-bubble .code-block {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #0d1117;
}

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

.message-bubble .code-lang {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: lowercase;
}

.message-bubble .code-actions {
  display: flex;
  gap: 6px;
}

.message-bubble .copy-btn,
.message-bubble .run-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font);
  transition: all var(--transition);
}

.message-bubble .copy-btn:hover,
.message-bubble .run-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.message-bubble .run-btn {
  border-color: #238636;
  color: #3fb950;
}

.message-bubble .run-btn:hover {
  background: rgba(35, 134, 54, 0.15);
  border-color: #3fb950;
  color: #56d364;
}

.message-bubble pre {
  background: #0d1117;
  padding: 16px;
  overflow-x: auto;
  margin: 0;
  border-radius: 0;
}

.message-bubble pre code {
  background: none;
  padding: 0;
  font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e6edf3;
  tab-size: 2;
}

.message-bubble pre code .kw { color: #ff7b72; }
.message-bubble pre code .str { color: #a5d6ff; }
.message-bubble pre code .cmt { color: #8b949e; font-style: italic; }
.message-bubble pre code .num { color: #79c0ff; }

.message-bubble a {
  color: var(--accent-blue);
  text-decoration: underline;
}

.message-bubble img.generated-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  display: block;
  object-fit: contain;
}

.image-generation-prompt {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== Input Area ===== */
.input-area {
  padding: 12px 24px 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeInUp 0.3s ease both;
}

.input-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  resize: none;
  max-height: 200px;
  line-height: 1.5;
  padding: 6px 0;
}

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

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

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

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

/* ===== Image Upload ===== */
.attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.attach-btn:hover {
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

/* ===== Mic Button ===== */
.mic-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.mic-btn:hover {
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.mic-btn.recording {
  color: white;
  background: var(--accent-red);
  animation: micPulse 1.2s ease-in-out infinite;
}

.mic-btn.recording:hover {
  background: #dc2626;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.mic-status {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--accent-red);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 50;
  animation: fadeInUp 0.3s ease;
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.2);
}

.mic-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: dotPulse 1s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.mic-status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.mic-status-lang {
  font-size: 11px;
  color: var(--accent-blue);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

.image-preview-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 24px 4px;
  animation: fadeIn 0.3s ease;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.preview-header span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clear-images-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition), background var(--transition);
}

.clear-images-btn:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

.preview-thumbnails {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-thumbnail {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-color);
  transition: border-color var(--transition);
  animation: fadeInUp 0.3s ease both;
}

.preview-thumbnail:hover {
  border-color: var(--accent-blue);
}

.preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumbnail .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--transition);
}

.preview-thumbnail:hover .remove-btn {
  opacity: 1;
}

.input-footer {
  text-align: center;
  margin-top: 8px;
}

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Delete Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

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

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

.modal-btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

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

.cancel-btn:hover { background: var(--border-color); }

.delete-btn {
  background: var(--accent-red);
  color: white;
}

.delete-btn:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ===== Code Preview Modal ===== */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.preview-modal {
  width: 90vw;
  height: 85vh;
  max-width: 1200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s ease;
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

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

.preview-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

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

.preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: white;
}

/* ===== Mobile Sidebar Toggle ===== */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.menu-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9;
  backdrop-filter: blur(2px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    opacity: 0;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
  }

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

  .menu-toggle { display: flex; }

  .main-area {
    width: 100%;
  }

  .chat-container {
    padding: 16px 0;
    padding-top: 56px;
  }

  .welcome-screen {
    padding: 60px 16px 100px;
  }

  .welcome-screen h1 {
    font-size: 28px;
  }

  .welcome-screen > p {
    font-size: 14px;
    margin-bottom: 24px;
  }

  .welcome-logo img {
    width: 48px;
    height: 48px;
  }

  .welcome-examples {
    gap: 8px;
  }

  .example-pill {
    padding: 8px 14px;
    font-size: 12px;
  }

  .messages {
    padding: 0 12px;
    gap: 16px;
  }

  .message {
    gap: 10px;
    padding: 8px 0;
  }

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

  .message-avatar {
    width: 30px;
    height: 30px;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
  }

  .message.user .message-content {
    margin-left: auto;
  }

  .sender-name {
    font-size: 11px;
  }

  .input-area {
    padding: 8px 10px 12px;
    max-width: 100%;
  }

  .input-wrapper {
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius);
  }

  .chat-input {
    font-size: 16px;
    padding: 4px 0;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }

  .attach-btn, .mic-btn {
    width: 36px;
    height: 36px;
  }

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

  .input-footer {
    display: none;
  }

  .preview-thumbnail {
    width: 52px;
    height: 52px;
  }

  .image-preview-section {
    padding: 8px 12px 2px;
  }

  .thinking-indicator {
    padding-left: 12px;
    padding-right: 12px;
  }

  .thinking-avatar {
    width: 30px;
    height: 30px;
  }

  .preview-modal {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    border-radius: 0;
  }

  .modal {
    width: 90%;
    padding: 24px;
    margin: 16px;
  }

  .welcome-name-modal {
    padding: 28px 24px;
    max-width: 340px;
  }

  .welcome-name-modal h2 {
    font-size: 20px;
  }

  .name-input {
    font-size: 16px;
    padding: 12px 14px;
  }

  .name-submit-btn {
    padding: 12px;
    font-size: 14px;
  }

  .code-block pre {
    font-size: 12px;
  }

  .code-block .code-header {
    padding: 6px 10px;
  }

  .code-block .copy-btn, .code-block .run-btn {
    padding: 3px 8px;
    font-size: 11px;
  }

  .mic-status {
    bottom: 80px;
    padding: 8px 16px;
  }

  .generated-img {
    max-height: 220px;
  }

  .new-chat-btn {
    padding: 9px 12px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .welcome-screen h1 {
    font-size: 24px;
  }

  .welcome-examples {
    flex-direction: column;
    align-items: stretch;
  }

  .example-pill {
    text-align: center;
  }

  .messages {
    padding: 0 8px;
  }

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

  .message-bubble {
    padding: 8px 12px;
    font-size: 13px;
  }

  .input-area {
    padding: 6px 6px 10px;
  }

  .input-wrapper {
    padding: 5px 8px;
  }

  .sidebar {
    width: 260px;
    min-width: 260px;
  }
}

/* ===== Scrollbar global ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* ===== Welcome Name Modal ===== */
.welcome-name-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fadeIn 0.4s ease;
}

.welcome-name-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-name-logo {
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

.welcome-name-modal h2 {
  font-size: 24px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.welcome-name-modal > p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.name-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-align: center;
}

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

.name-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.name-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.name-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.name-submit-btn:active { transform: translateY(0); }

/* ===== Selection ===== */
::selection {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

/* ===== Focus ===== */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
