/* ========================================
   MINIMAL.CSS - Ultra Clean UI
   ======================================== */

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #0066cc;
  --primary-hover: #0052a3;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --text: #f0f6fc;
    --text-secondary: #8b949e;
    --border: #30363d;
    --primary: #58a6ff;
    --primary-hover: #79c0ff;
  }
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body { overflow: hidden; }

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  z-index: 10000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.glow-primary {
  box-shadow: 0 0 20px rgba(0, 102, 204, 0.3);
}

.grad-text {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (prefers-color-scheme: dark) {
  .glow-primary {
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
  }
}

.sidebar-close { display: none; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 250;
  opacity: 0;
  transition: opacity 0.25s ease;
}

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

@media (max-width: 767px) {
  .sidebar-overlay.visible { display: block; }
}

.sidebar-model-select {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.model-select-wrapper {
  position: relative;
}

.model-select-dropdown {
  width: 100%;
  padding: 10px 12px;
  padding-right: 32px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.model-select-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

@media (prefers-color-scheme: dark) {
  .model-select-dropdown:focus {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
  }
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px;
}

.sidebar-actions {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

@media (prefers-color-scheme: dark) {
  .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
  }
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}

.new-chat-btn:hover { background: var(--primary-hover); }

.history-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 16px 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 500;
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

@media (prefers-color-scheme: dark) {
  .nav-item.active {
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.1);
  }
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.glass-premium {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (prefers-color-scheme: dark) {
  .glass-premium {
    background: rgba(22, 27, 34, 0.8);
  }
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.breathe {
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.sidebar-links {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
}

.sidebar-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.sidebar-links a:hover {
  color: var(--primary);
}

.underline-hover {
  position: relative;
  text-decoration: none;
}

.underline-hover::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--primary);
  transition: width 0.2s ease;
}

.underline-hover:hover::after {
  width: 100%;
}

.sidebar-copy {
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Main Area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-menu { display: none; }

.topbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.mode-badge {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
}

.model-badge.active {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
  color: #22c55e;
}

.model-name-top {
  font-size: 0.75rem;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.export-wrap {
  position: relative;
}

.export-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  display: none;
  z-index: 100;
}

.export-menu.show {
  display: block;
}

.export-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease;
}

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

/* Chat */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-inner {
  max-width: 800px;
  margin: 0 auto;
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 60px 20px;
}

.welcome-inner {
  max-width: 600px;
  margin: 0 auto;
}

.welcome-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.welcome-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 32px;
}

.chips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 32px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.chip:hover {
  background: var(--bg);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.chip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.chip-copy {
  font-size: 0.9rem;
  color: var(--text);
}

/* Messages */
#messageList {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  display: flex;
  gap: 12px;
}

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

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.msg-avatar.ai-avatar {
  background: var(--primary);
  color: white;
}

.msg-avatar.user-avatar {
  background: var(--primary);
  color: white;
}

.msg-body {
  flex: 1;
  max-width: calc(100% - 44px);
}

.message.user-message .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-bubble {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease;
}

.msg-bubble:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message.user-message .msg-bubble {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
}

@media (prefers-color-scheme: dark) {
  .message.user-message .msg-bubble {
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.2);
  }
}

.msg-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.message.user-message .msg-footer {
  flex-direction: row-reverse;
}

.msg-time {
  color: var(--text-secondary);
}

.msg-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.message-bubble {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease;
}

.message-bubble:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-row.user .message-bubble {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
}

@media (prefers-color-scheme: dark) {
  .message-row.user .message-bubble {
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.2);
  }
}

.message-text pre {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.9em;
}

.message-text code {
  font-family: monospace;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Conversation History */
.conv-history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.conv-history-overlay.visible {
  display: block;
  opacity: 1;
}

.conv-history {
  position: fixed;
  top: 0;
  right: -100%;
  width: 320px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.25s ease;
  overflow-y: auto;
  padding: 20px;
}

.conv-history.open {
  right: 0;
}

@media (max-width: 480px) {
  .conv-history { width: 100%; }
}

/* Typing */
.typing-row {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.typing-row.hidden { display: none; }

.typing-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Agent Indicator (hidden - agent mode removed) */
.agent-indicator {
  display: none;
}

.agent-indicator.hidden {
  display: none !important;
}

/* Input */
.input-wrap {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.file-previews {
  max-width: 800px;
  width: 100%;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-input-hidden {
  display: none;
}

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

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

.input-actions {
  display: flex;
  gap: 8px;
}

.input-shell {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.input-shell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

@media (prefers-color-scheme: dark) {
  .input-shell:focus-within {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
  }
}

.input-field {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
}

.input-field::placeholder {
  color: var(--text-secondary);
}

.send-btn, .stop-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}

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

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

.stop-btn {
  background: #dc3545;
  color: white;
  display: none;
}

.input-footer {
  max-width: 800px;
  width: 100%;
  margin: 8px auto 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.save-status {
  color: #22c55e;
  font-weight: 500;
}

.char-count {
  color: var(--text-secondary);
}

.input-hint {
  color: var(--text-secondary);
}

/* Scroll button */
.scroll-btn {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scroll-btn.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

@media (prefers-color-scheme: dark) {
  .scroll-btn:hover {
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== COMPREHENSIVE RESPONSIVE BREAKPOINTS ===== */

/* Extra Small Phones (< 380px) */
@media (max-width: 379px) {
  .sidebar {
    position: fixed;
    left: -100%;
    width: 100%;
    height: 100vh;
    z-index: 300;
    transition: left 0.25s ease;
  }
  
  .sidebar.open { left: 0; }
  .sidebar-close { display: flex; }
  
  .sidebar-header { padding: 12px 16px; }
  .sidebar-model-select { padding: 12px 16px; }
  .sidebar-actions { padding: 12px 16px; }
  
  .topbar {
    padding: 10px 12px;
    min-height: 52px;
  }
  
  .topbar-menu {
    display: flex;
    width: 40px;
    height: 40px;
  }
  
  .topbar-center { gap: 6px; }
  .topbar-label { 
    font-size: 0.85rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .model-badge { display: none; }
  .mode-badge { display: none; }
  
  .topbar-actions { gap: 2px; }
  .icon-btn { width: 36px; height: 36px; }
  
  .chat-scroll { padding: 12px; }
  
  .message { gap: 8px; }
  .msg-avatar { width: 28px; height: 28px; }
  .msg-body { max-width: calc(100% - 36px); }
  .msg-bubble {
    padding: 10px 12px;
    font-size: 0.9rem;
    max-width: 100%;
  }
  
  .msg-footer { font-size: 0.7rem; }
  .action-btn { padding: 4px 6px; font-size: 0.7rem; }
  
  .welcome { padding: 30px 12px; }
  .welcome-title { font-size: 1.2rem; }
  .welcome-sub { font-size: 0.8rem; padding: 0 8px; }
  
  .chips-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .chip {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  
  .input-wrap { padding: 10px 12px; }
  .input-shell { padding: 10px 12px; gap: 8px; }
  .input-field { font-size: 16px; min-height: 44px; }
  .send-btn, .stop-btn { width: 36px; height: 36px; }
  .attach-btn { width: 36px; height: 36px; }
  
  .input-footer {
    font-size: 0.7rem;
    text-align: center;
    flex-direction: column;
    gap: 4px;
  }
  
  .scroll-btn {
    right: 12px;
    bottom: 90px;
    width: 36px;
    height: 36px;
  }
  
  .toast {
    left: 12px;
    right: 12px;
    transform: translateY(100px);
    text-align: center;
    font-size: 0.85rem;
  }
  
  .typing-wrap { padding: 0 12px; }
  .typing-bubble { padding: 10px 12px; }
}

/* Small Phones (380px - 479px) */
@media (min-width: 380px) and (max-width: 479px) {
  .sidebar {
    position: fixed;
    left: -100%;
    width: 100%;
    height: 100vh;
    z-index: 300;
    transition: left 0.25s ease;
  }
  
  .sidebar.open { left: 0; }
  .sidebar-close { display: flex; }
  
  .topbar {
    padding: 10px 14px;
    min-height: 54px;
  }
  
  .topbar-menu { display: flex; }
  .topbar-label { 
    font-size: 0.9rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .model-badge { display: none; }
  .mode-badge { display: none; }
  
  .chat-scroll { padding: 14px; }
  
  .message { gap: 10px; }
  .msg-avatar { width: 30px; height: 30px; }
  .msg-body { max-width: calc(100% - 40px); }
  .msg-bubble {
    padding: 11px 14px;
    font-size: 0.9rem;
    max-width: 100%;
  }
  
  .msg-footer { font-size: 0.75rem; }
  
  .welcome { padding: 40px 16px; }
  .welcome-title { font-size: 1.3rem; }
  .welcome-sub { font-size: 0.85rem; }
  
  .chips-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .chip {
    padding: 11px 14px;
    font-size: 0.9rem;
  }
  
  .input-wrap { padding: 12px 14px; }
  .input-shell { padding: 11px 14px; gap: 10px; }
  .input-field { font-size: 16px; }
  .send-btn, .stop-btn { width: 38px; height: 38px; }
  .attach-btn { width: 38px; height: 38px; }
  
  .input-footer {
    font-size: 0.75rem;
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }
  
  .scroll-btn {
    right: 14px;
    bottom: 85px;
    width: 38px;
    height: 38px;
  }
  
  .typing-wrap { padding: 0 14px; }
  .typing-bubble { padding: 11px 14px; }
}

/* Large Phones & Small Tablets (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -300px;
    width: 300px;
    height: 100vh;
    z-index: 300;
    transition: left 0.25s ease;
  }
  
  .sidebar.open { left: 0; }
  .sidebar-close { display: flex; }
  .topbar-menu { display: flex; }
  
  .topbar-label { 
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .chat-scroll { padding: 16px 20px; }
  
  .message { gap: 12px; }
  .msg-avatar { width: 32px; height: 32px; }
  .msg-body { max-width: calc(100% - 44px); }
  .msg-bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
    max-width: 100%;
  }
  
  .welcome-title { font-size: 1.5rem; }
  .welcome-sub { font-size: 0.9rem; }
  
  .chips-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .input-wrap { padding: 14px 20px; }
  .input-shell { padding: 12px 16px; gap: 12px; }
  .send-btn, .stop-btn { width: 40px; height: 40px; }
  .attach-btn { width: 40px; height: 40px; }
  
  .input-footer {
    font-size: 0.75rem;
  }
  
  .scroll-btn {
    right: 20px;
    bottom: 90px;
  }
  
  .typing-wrap { padding: 0 20px; }
  .typing-bubble { padding: 12px 16px; }
}

/* Tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 240px; }
  .sidebar-header { padding: 16px; }
  .sidebar-model-select { padding: 12px 16px; }
  .sidebar-actions { padding: 12px 16px; }
  
  .topbar { padding: 12px 16px; }
  .topbar-label { 
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .chat-scroll { padding: 20px 24px; }
  .chat-inner { max-width: 100%; }
  .input-shell { max-width: 100%; }
  .input-footer { max-width: 100%; }
  
  .message { gap: 12px; }
  .msg-avatar { width: 32px; height: 32px; }
  .msg-body { max-width: calc(100% - 44px); }
  .msg-bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
    max-width: 90%;
  }
  
  .welcome-title { font-size: 1.6rem; }
  .welcome-sub { font-size: 0.95rem; }
  
  .chips-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .scroll-btn { right: 24px; }
  
  .typing-wrap { padding: 0 24px; }
  .typing-bubble { padding: 12px 16px; }
}

/* Small Laptops (1025px - 1200px) */
@media (min-width: 1025px) and (max-width: 1200px) {
  .sidebar { width: 250px; }
  
  .chat-inner { max-width: 750px; }
  .input-shell { max-width: 750px; }
  .input-footer { max-width: 750px; }
  .typing-wrap { max-width: 750px; }
  
  .message { gap: 12px; }
  .msg-avatar { width: 32px; height: 32px; }
  .msg-body { max-width: calc(100% - 44px); }
  .msg-bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
  }
  
  .welcome-title { font-size: 1.7rem; }
  .welcome-sub { font-size: 0.95rem; }
  
  .chips-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* Large Desktops (> 1400px) */
@media (min-width: 1400px) {
  .sidebar { width: 280px; }
  .sidebar-header { padding: 20px 24px; }
  .sidebar-model-select { padding: 16px 24px; }
  .sidebar-actions { padding: 16px 24px; }
  
  .chat-inner { max-width: 900px; }
  .input-shell { 
    max-width: 900px;
    padding: 14px 20px;
  }
  .input-footer { max-width: 900px; }
  .typing-wrap { max-width: 900px; }
  
  .chat-scroll { padding: 24px 32px; }
  
  .message { gap: 12px; }
  .msg-avatar { width: 32px; height: 32px; }
  .msg-body { max-width: calc(100% - 44px); }
  .msg-bubble {
    padding: 12px 16px;
    font-size: 1rem;
    line-height: 1.6;
  }
  
  .welcome-title { font-size: 1.8rem; }
  .welcome-sub { font-size: 1rem; }
  
  .chips-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .input-wrap { padding: 20px 32px; }
  
  .scroll-btn {
    right: 40px;
    bottom: 120px;
    width: 44px;
    height: 44px;
  }
  
  .typing-wrap { padding: 0 32px; }
  .typing-bubble { padding: 12px 16px; }
}

/* Extra Large Screens (> 1920px) */
@media (min-width: 1920px) {
  .chat-inner { max-width: 1000px; }
  .input-shell { max-width: 1000px; }
  .input-footer { max-width: 1000px; }
  .typing-wrap { max-width: 1000px; }
  
  body { font-size: 15px; }
  .message-bubble { font-size: 1.05rem; }
}

/* Landscape Orientation on Mobile */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 767px) {
  .sidebar { overflow-y: auto; }
  
  .welcome { padding: 20px; }
  .welcome-logo { display: none; }
  .welcome-sub { display: none; }
  
  .input-wrap { padding: 8px 12px; }
  .scroll-btn { bottom: 70px; }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  .icon-btn, .send-btn, .stop-btn, .new-chat-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .model-select-dropdown {
    min-height: 44px;
    font-size: 16px;
  }
  
  .message-bubble {
    -webkit-tap-highlight-color: transparent;
  }
  
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .sidebar { transition: none; }
  .typing-dots span { animation: none; }
}

/* High DPI / Retina Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo-mark, .msg-avatar, .welcome-logo {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Safe Area Insets (Notch/Island Support) */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (max-width: 767px) {
    .topbar {
      padding-top: max(10px, env(safe-area-inset-top));
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    
    .sidebar {
      padding-top: env(safe-area-inset-top);
      padding-left: env(safe-area-inset-left);
    }
    
    .input-wrap {
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    .toast {
      bottom: max(20px, env(safe-area-inset-bottom));
    }
  }
}

/* Print Styles */
@media print {
  .sidebar, .topbar, .input-wrap, .scroll-btn, .typing-row { display: none !important; }
  .main-area { height: auto; overflow: visible; }
  .chat-scroll { overflow: visible; padding: 20px; }
  .message-bubble { border: 1px solid #ccc; break-inside: avoid; }
}

/* Utility Classes */
.hidden { display: none !important; }
.hide-mobile { display: inherit; }
.show-mobile-only { display: none; }

@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .show-mobile-only { display: inherit !important; }
}
