/* ========== CHAT LAYOUT (Session Sidebar + Chat) ========== */
.chat-layout { display: flex; height: calc(100vh - var(--header-h) - 48px); height: calc(100dvh - var(--header-h) - 48px); gap: 0; position: relative; }

/* Session Sidebar */
.session-sidebar {
  width: 280px; min-width: 280px;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: margin-left 0.25s ease, opacity 0.25s ease;
  position: relative;
}
.session-sidebar::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 1px; height: 100%;
  background: linear-gradient(to bottom, transparent, var(--primary-glow), transparent);
  opacity: 0.4;
}
.session-sidebar.collapsed { margin-left: -280px; opacity: 0; pointer-events: none; }
.session-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.session-header-title { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.session-new-btn {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--primary); color: #000; border: none;
  font-size: 18px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.session-new-btn:hover { opacity: 0.8; }
.session-search-wrap { padding: 8px 10px; }
.session-search {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font-size: 12px;
  box-sizing: border-box;
}
.session-search:focus { border-color: var(--primary); outline: none; }
.session-list { flex: 1; overflow-y: auto; padding: 4px 6px; }
.session-item {
  padding: 10px 10px; border-radius: 8px; cursor: pointer;
  margin-bottom: 2px; transition: background 0.15s;
  display: flex; align-items: center; gap: 4px;
}
.session-item:hover { background: var(--surface); }
.session-item.active { background: var(--primary-dim); border-left: 3px solid var(--primary); }
.session-item-content { flex: 1; min-width: 0; }
.session-item-title {
  font-size: 13px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item-meta {
  font-size: 10px; color: var(--text-dim); margin-top: 3px;
  display: flex; justify-content: space-between; align-items: center;
}
/* Session item actions container */
.session-item-actions {
  display: flex; gap: 2px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.session-item:hover .session-item-actions { opacity: 1; }
.session-rename-btn, .session-delete-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 12px; cursor: pointer; padding: 4px 5px; border-radius: 4px;
  transition: all 0.15s; flex-shrink: 0; line-height: 1;
}
.session-rename-btn:hover { background: rgba(0,212,255,0.15); color: var(--primary); }
.session-delete-btn:hover { background: rgba(255,60,60,0.2); color: #ff4444; }

/* Date group labels */
.session-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-dim);
  padding: 10px 10px 4px; margin-top: 4px;
  opacity: 0.7;
}
.session-group-label:first-child { margin-top: 0; }

/* Session message count badge */
.session-item-count {
  background: var(--surface2); border-radius: 8px;
  padding: 1px 6px; font-size: 10px; font-weight: 600;
  color: var(--text-dim); min-width: 16px; text-align: center;
}
.session-item.active .session-item-count {
  background: rgba(0,212,255,0.15); color: var(--primary);
}

/* Inline rename input */
.session-rename-input {
  width: 100%; background: var(--surface);
  border: 1px solid var(--primary); border-radius: 4px;
  padding: 2px 6px; color: var(--text); font-size: 12px;
  font-family: inherit; outline: none; box-sizing: border-box;
}

/* ========== FOLDER SYSTEM ========== */

/* Folder header bar (New Folder button) */
.session-folder-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.session-folder-bar-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); font-size: 11px; cursor: pointer;
  padding: 4px 8px; transition: all 0.15s; white-space: nowrap;
}
.session-folder-bar-btn:hover { color: var(--primary); border-color: var(--primary); background: rgba(0,212,255,0.05); }
.session-folder-bar-btn .folder-icon { font-size: 13px; }

/* New folder inline form */
.folder-create-form {
  display: none; padding: 8px 10px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-direction: column; gap: 8px;
}
.folder-create-form.visible { display: flex; }
.folder-create-form input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; color: var(--text); font-size: 12px;
  font-family: inherit; outline: none; box-sizing: border-box;
}
.folder-create-form input:focus { border-color: var(--primary); }
.folder-color-picker {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.folder-color-dot {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s;
  flex-shrink: 0;
}
.folder-color-dot:hover { transform: scale(1.15); }
.folder-color-dot.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }
.folder-create-actions {
  display: flex; gap: 6px; justify-content: flex-end;
}
.folder-create-actions button {
  padding: 4px 12px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; transition: opacity 0.15s;
}
.folder-create-actions .folder-save-btn {
  background: var(--primary); color: #000;
}
.folder-create-actions .folder-save-btn:hover { opacity: 0.85; }
.folder-create-actions .folder-cancel-btn {
  background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border);
}
.folder-create-actions .folder-cancel-btn:hover { color: var(--text); }

/* Folder item in sidebar */
.folder-item {
  margin-bottom: 2px; border-radius: 8px; overflow: hidden;
}
.folder-item-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; cursor: pointer; border-radius: 8px;
  transition: background 0.15s; user-select: none;
}
.folder-item-header:hover { background: var(--surface); }
.folder-item-chevron {
  font-size: 10px; color: var(--text-dim); transition: transform 0.2s;
  width: 14px; text-align: center; flex-shrink: 0;
}
.folder-item.expanded .folder-item-chevron { transform: rotate(90deg); }
.folder-item-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.folder-item-name {
  flex: 1; font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.folder-item-count {
  background: var(--surface2); border-radius: 8px;
  padding: 1px 6px; font-size: 10px; font-weight: 600;
  color: var(--text-dim); min-width: 14px; text-align: center;
  flex-shrink: 0;
}
.folder-item-actions {
  display: flex; gap: 2px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.folder-item-header:hover .folder-item-actions { opacity: 1; }
.folder-action-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 11px; cursor: pointer; padding: 2px 4px; border-radius: 4px;
  transition: all 0.15s; line-height: 1;
}
.folder-action-btn:hover { color: var(--primary); background: rgba(0,212,255,0.1); }
.folder-action-btn.delete:hover { color: #ff4444; background: rgba(255,60,60,0.1); }

/* Folder rename input */
.folder-rename-input {
  flex: 1; background: var(--surface); border: 1px solid var(--primary);
  border-radius: 4px; padding: 2px 6px; color: var(--text); font-size: 12px;
  font-family: inherit; outline: none; box-sizing: border-box; min-width: 0;
}

/* Folder contents (collapsible) */
.folder-item-contents {
  display: none; padding-left: 12px;
}
.folder-item.expanded .folder-item-contents { display: block; }
.folder-item-contents .session-item {
  border-left: 2px solid var(--folder-color, var(--text-dim));
  margin-left: 6px; padding-left: 8px;
}

/* Move to folder dropdown on session items */
.session-folder-menu-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 12px; cursor: pointer; padding: 4px 5px; border-radius: 4px;
  transition: all 0.15s; flex-shrink: 0; line-height: 1;
}
.session-folder-menu-btn:hover { background: rgba(0,212,255,0.15); color: var(--primary); }

/* Folder dropdown menu (move to folder) */
.folder-dropdown-menu {
  position: absolute; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; min-width: 160px;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.folder-dropdown-menu-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12px; color: var(--text); transition: background 0.1s;
  white-space: nowrap;
}
.folder-dropdown-menu-item:hover { background: var(--surface2); }
.folder-dropdown-menu-item .fdd-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.folder-dropdown-menu-item.remove-folder { color: var(--text-dim); border-top: 1px solid var(--border); margin-top: 2px; padding-top: 8px; }

/* Folder color picker dropdown for editing */
.folder-color-edit-picker {
  position: absolute; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex; gap: 6px; flex-wrap: wrap; width: 140px;
}

/* Divider between folders and unfoldered sessions */
.folder-divider {
  height: 1px; background: var(--border); margin: 6px 10px;
  opacity: 0.5;
}

/* Session Toggle Button */
.session-toggle {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%); z-index: 10;
  background: var(--surface); border: 1px solid var(--border);
  border-left: none; border-radius: 0 8px 8px 0;
  padding: 8px 4px; cursor: pointer; font-size: 14px;
  color: var(--text-muted); transition: all 0.15s;
  display: none;
}
.session-toggle:hover { color: var(--primary); border-color: var(--primary); }
.session-sidebar.collapsed ~ .session-toggle { display: block; }

/* Wake Word Button */
.chat-wakeword { background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim); }
.chat-wakeword:hover { color: var(--success); border-color: var(--success); }
.chat-wakeword.listening {
  background: rgba(16,185,129,0.1); border-color: var(--success); color: var(--success);
  animation: wake-pulse 2s ease-in-out infinite;
}
@keyframes wake-pulse { 0%,100% { box-shadow:0 0 0 0 rgba(16,185,129,0.3); } 50% { box-shadow:0 0 0 8px rgba(16,185,129,0); } }

/* ========== CHAT PAGE ========== */
.chat-container { display: flex; flex-direction: column; flex: 1; min-width: 0; height: 100%; }
.chat-search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-search-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; color: var(--text);
  font-size: 13px; font-family: inherit; outline: none;
}
.chat-search-input:focus { border-color: var(--primary); }
.chat-search-count { font-size: 11px; color: var(--text-dim); white-space: nowrap; min-width: 60px; }
.chat-search-nav, .chat-search-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 3px 6px; border-radius: 4px;
  font-size: 12px; transition: color 0.15s;
}
.chat-search-nav:hover, .chat-search-close:hover { color: var(--primary); }
.chat-search-mark { background: rgba(255,204,0,0.3); color: var(--text); border-radius: 2px; }
.chat-search-mark.current { background: rgba(255,153,0,0.6); color: #fff; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 8px 0;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-msg { display: flex; gap: 12px; max-width: 80%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.friday { align-self: flex-start; }
.chat-avatar {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 10px; display: flex;
  align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.chat-msg.friday .chat-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 16px var(--primary-glow);
  animation: avatar-glow 3s ease-in-out infinite;
}
@keyframes avatar-glow {
  0%,100% { box-shadow: 0 0 12px rgba(0,212,255,0.2); }
  50% { box-shadow: 0 0 20px rgba(0,212,255,0.35), 0 0 8px rgba(124,58,237,0.2); }
}
.chat-msg.user .chat-avatar { background: var(--surface3); }
.chat-bubble-wrap { display: flex; flex-direction: column; gap: 4px; }
.chat-sender { font-size: 11px; color: var(--text-dim); font-weight: 600; }
.chat-msg.user .chat-sender { text-align: right; }
.chat-bubble {
  padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.6;
  word-wrap: break-word; overflow-wrap: break-word;
}
.chat-msg.friday .chat-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  position: relative;
}
.chat-msg.friday .chat-bubble::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 4px 0 0 16px;
  opacity: 0.5;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(124,58,237,0.15));
  border: 1px solid rgba(0,212,255,0.2);
  border-top-right-radius: 4px;
}
.chat-bubble code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 12px;
}
.chat-bubble pre {
  background: var(--bg); padding: 12px; border-radius: 8px;
  overflow-x: auto; margin: 8px 0; font-size: 12px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  border: 1px solid var(--border);
}
.chat-bubble strong { color: var(--primary); }
.chat-bubble em { color: var(--text-muted); font-style: italic; }
.chat-bubble ul, .chat-bubble ol { padding-left: 20px; margin: 4px 0; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble p { margin: 4px 0; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-time { font-size: 10px; color: var(--text-dim); }
.chat-msg.user .chat-time { text-align: right; }

/* Per-message action buttons */
.chat-actions {
  display: flex; gap: 4px; margin-top: 2px;
  opacity: 0; transition: opacity 0.15s;
}
.chat-bubble-wrap:hover .chat-actions { opacity: 1; }
.chat-msg.user .chat-actions { justify-content: flex-end; }
.chat-action-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 7px;
  font-size: 11px; cursor: pointer; color: var(--text-dim);
  transition: color 0.15s, background 0.15s; line-height: 1.6;
}
.chat-action-btn:hover { color: var(--text); background: var(--surface3); border-color: var(--primary); }
/* Bookmark modal list */
.chat-bm-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.chat-bm-item:last-child { border-bottom: none; }
.chat-bm-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.chat-bm-role { font-size: 11px; font-weight: 700; color: var(--primary); }
.chat-bm-date { font-size: 10px; color: var(--text-dim); flex: 1; }
.chat-bm-del { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 0 4px; transition: color 0.1s; }
.chat-bm-del:hover { color: var(--error); }
.chat-bm-text { font-size: 12px; color: var(--text); line-height: 1.5; white-space: pre-wrap; }

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); opacity: 0.4;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%,100% { opacity:0.3; transform:translateY(0); }
  50% { opacity:1; transform:translateY(-4px); }
}

/* Chat input */
.chat-input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 16px 0 0 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  flex-wrap: wrap;
}
.chat-input {
  flex: 1; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; color: var(--text);
  font-size: 14px; font-family: inherit;
  resize: none; outline: none; line-height: 1.5;
  max-height: 150px; min-height: 44px;
  transition: border-color 0.2s;
}
.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.08), 0 0 20px rgba(0,212,255,0.04);
}
.chat-input::placeholder { color: var(--text-dim); }
.chat-btn {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 12px; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px;
  transition: all 0.15s;
}
.chat-send {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
}
.chat-send::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.chat-send:hover::after { transform: translateX(100%); }
.chat-send:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--primary-glow); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.chat-voice {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted);
}
.chat-voice:hover { color: var(--primary); border-color: var(--primary); }
.chat-voice.recording {
  background: var(--error-dim); border-color: var(--error); color: var(--error);
  animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse { 0%,100% { box-shadow:0 0 0 0 rgba(239,68,68,0.3); } 50% { box-shadow:0 0 0 8px rgba(239,68,68,0); } }
.chat-attach {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 16px;
}
.chat-attach:hover { color: var(--primary); border-color: var(--primary); }
.chat-tts-toggle {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 15px; position: relative;
}
.chat-tts-toggle:hover { color: var(--primary); border-color: var(--primary); }
.chat-tts-toggle.on { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }
.chat-tts-toggle.on::after {
  content: ''; position: absolute; bottom: 4px; right: 4px;
  width: 6px; height: 6px; background: var(--success);
  border-radius: 50%;
}
/* Screen Capture Button */
.chat-screen-share {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 16px;
}
.chat-screen-share:hover { color: var(--accent); border-color: var(--accent); }
.chat-screen-share.capturing {
  background: rgba(124,58,237,0.1); border-color: var(--accent); color: var(--accent);
  animation: screen-pulse 1.2s ease-in-out infinite;
}
@keyframes screen-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(124,58,237,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
}
.chat-image-preview {
  display: none; padding: 8px 0;
  position: relative; max-width: 200px;
}
.chat-image-preview.visible { display: block; }
.chat-image-preview img {
  max-width: 200px; max-height: 150px;
  border-radius: 10px; border: 1px solid var(--border);
}
.chat-image-preview .remove-img {
  position: absolute; top: 12px; right: 4px;
  background: var(--error); color: white;
  border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.chat-image-preview .remove-img:hover { background: #dc2626; }
.chat-input-wrapper {
  flex: 1; display: flex; flex-direction: column;
}

/* ========== MOBILE CHAT ========== */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
    height: calc(100vh - var(--header-h) - 72px - 48px);
    height: calc(100dvh - var(--header-h) - 72px - env(safe-area-inset-bottom, 0px));
  }
  .session-sidebar {
    width: 100%; min-width: 100%; max-height: 40vh;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .session-sidebar.collapsed { margin-left: 0; margin-top: -40vh; }
  .session-toggle { display: block !important; left: auto; right: 8px; top: 8px; transform: none; border-radius: 8px; border: 1px solid var(--border); }
  .chat-container {
    height: calc(100vh - var(--header-h) - 72px - 48px); /* fallback for old browsers */
    height: calc(100dvh - var(--header-h) - 72px - env(safe-area-inset-bottom, 0px) - 16px);
    padding-bottom: 0;
  }
  .chat-input-bar {
    gap: 6px;
    padding: 12px 0 0 0;
    flex-wrap: wrap;
  }
  .chat-input {
    padding: 8px 12px;
    min-height: 44px;
    max-height: 80px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .chat-btn {
    width: 40px; height: 40px; min-width: 40px;
  }
  .chat-input-wrapper { min-width: 100px; }
  .chat-bubble { padding: 10px 14px; font-size: 15px; word-break: break-word; }
  .chat-bubble pre { padding: 8px; font-size: 11px; }
  .chat-avatar { width: 32px; height: 32px; min-width: 32px; font-size: 14px; }
  .chat-image-preview img { max-width: 150px; max-height: 120px; }
  .chat-image-preview .remove-img {
    width: 32px; height: 32px; font-size: 16px;
    top: 8px; right: 8px;
  }
  /* Mobile search bar */
  .chat-search-input { font-size: 16px; padding: 8px 12px; }
  .chat-search-nav, .chat-search-close { min-height: 40px; min-width: 40px; font-size: 14px; }
  /* Mobile session items */
  .session-item-title { font-size: 14px; }
  .session-item-meta { font-size: 12px; }
  /* Mobile typing dots */
  .typing-dot { width: 10px; height: 10px; }
  /* Scroll padding for bottom bar */
  .chat-messages { scroll-padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
}

/* Small phone chat */
@media (max-width: 480px) {
  .chat-msg { max-width: calc(100% - 12px); }
}

/* ========== MODEL SELECTOR ========== */
.chat-model-selector {
  position: relative;
}
.chat-model-btn {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px;
  color: var(--text); cursor: pointer;
  font-size: 12px; white-space: nowrap;
  transition: all 0.2s ease;
}
.chat-model-btn:hover { border-color: var(--primary); background: var(--surface); }
#chat-model-icon { font-size: 14px; }
#chat-model-label { font-weight: 600; }
.chat-model-arrow { font-size: 10px; opacity: 0.6; margin-left: 2px; }
.chat-model-dropdown {
  display: none; position: absolute; bottom: 100%; left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  min-width: 240px; z-index: 1000;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.3);
  margin-bottom: 6px;
}
.chat-model-dropdown.open { display: block; }
.chat-model-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
}
.chat-model-option:hover { background: var(--surface2); }
.chat-model-option.selected { background: var(--primary-glow); }
.model-icon { font-size: 16px; width: 24px; text-align: center; }
.model-name { font-weight: 600; font-size: 13px; color: var(--text); }
.model-desc { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* Model badge in chat messages */
.chat-model-badge {
  display: inline-block;
  font-size: 10px; color: var(--text-dim);
  background: var(--surface2); border-radius: 6px;
  padding: 1px 6px; margin-left: 8px;
  opacity: 0.7; vertical-align: middle;
}
