* {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1e1f22;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #313338;
  --bg-hover: #404249;
  --text-primary: #f2f3f5;
  --text-secondary: #b5bac1;
  --text-muted: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --border: #3f4147;
  --success: #23a559;
  --danger: #da373c;

  /* Safe area insets for iOS */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Light theme */
[data-theme='light'] {
  --bg-primary: #ffffff;
  --bg-secondary: #f2f3f5;
  --bg-tertiary: #e3e5e8;
  --bg-hover: #d5d7db;
  --text-primary: #1e1f22;
  --text-secondary: #4e5058;
  --text-muted: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --border: #d5d7db;
  --success: #23a559;
  --danger: #da373c;
}
[data-theme='light'] .sidebar {
  background-color: #f2f3f5;
}
[data-theme='light'] .chat-header {
  background: #ffffff;
  border-bottom-color: #e3e5e8;
}
[data-theme='light'] .message-input-container {
  background-color: #ffffff;
  border-top-color: #e3e5e8;
}
[data-theme='light'] .message-input {
  background: #e3e5e8;
  color: #1e1f22;
}
[data-theme='light'] .message-input::placeholder {
  color: #80848e;
}
[data-theme='light'] .chat-item.active {
  background: #d5d7db;
}
[data-theme='light'] .message-bubble.assistant {
  background: #e3e5e8;
  color: #1e1f22;
}
[data-theme='light'] .message-bubble.user {
  background: #5865f2;
  color: #ffffff;
}
[data-theme='light'] code {
  background: #e3e5e8;
  color: #1e1f22;
}
[data-theme='light'] pre {
  background: #2b2d31;
  color: #f2f3f5;
}
[data-theme='light'] .sidebar-search-wrapper {
  background: #e3e5e8;
}
[data-theme='light'] .sidebar-search-input {
  color: #1e1f22;
}

/* Theme toggle in footer */
.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  line-height: 1;
}
.theme-toggle-btn:hover {
  background: var(--bg-hover);
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  height: -webkit-fill-available;
  background-color: var(--bg-primary);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  /* Use dvh with fallback for older browsers */
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

/* =================================================================
   LAYOUT
================================================================= */

.container {
  display: flex;
  height: 100%;
  overflow: hidden;
  /* Account for safe areas */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* =================================================================
   SIDEBAR
================================================================= */

.sidebar {
  width: 280px;
  min-width: 280px;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition:
    width 0.3s ease,
    min-width 0.3s ease;
  position: relative;
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  border-right: none !important;
  overflow: hidden !important;
  flex: 0 0 0 !important;
}

.sidebar.collapsed * {
  display: none;
}

/* Expand sidebar button - shows B icon when collapsed */
.sidebar-expand-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 56px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 0;
}

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

body.sidebar-collapsed .sidebar-expand-btn {
  opacity: 1;
  pointer-events: auto;
}

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

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.sidebar-drop-zone {
  flex: 1;
  min-height: 50px;
  transition: background 0.15s ease;
}

.sidebar-drop-zone.drag-over {
  background: rgba(88, 101, 242, 0.1);
  border-top: 2px solid var(--accent);
}

/* Category Selector */
.category-selector {
  padding: 8px 12px;
  margin-bottom: 4px;
}

.category-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.category-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--bg-tertiary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-btn:hover {
  background: var(--bg-secondary);
  transform: scale(1.05);
}

.category-btn.selected {
  border-color: var(--accent);
  background: rgba(88, 101, 242, 0.15);
}

.category-btn-locked {
  opacity: 0.6;
}

.category-slider {
  padding: 12px 16px;
  display: flex;
  justify-content: center;
}

.slider-track {
  position: relative;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  padding: 4px;
  gap: 0;
}

.slider-stop {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
  min-width: 40px;
}

.slider-stop:hover {
  background: rgba(255, 255, 255, 0.1);
}

.slider-stop.active {
  color: white;
}

.slider-thumb {
  position: absolute;
  height: 28px;
  background: var(--accent);
  border-radius: 14px;
  transition: all 0.2s ease;
  z-index: 0;
}

.slider-labels,
.slider-fill,
.slider-emoji {
  display: none;
}

.slider-label {
  display: none;
}

.chat-drop-zone {
  height: 4px;
  transition: all 0.15s ease;
}

.chat-drop-zone.drag-over {
  border-top: 2px solid var(--accent);
  margin-top: -2px;
}

.sidebar-footer {
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent);
  font-size: 18px;
  flex-shrink: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* =================================================================
   PROJECTS & CHATS
================================================================= */

.project {
  margin-bottom: 0;
}

/* Empty projects: neutralize the negative margin from .project-chats */
.project.empty-project .project-chats {
  margin-bottom: 0;
}

.project.empty-project {
  margin-bottom: 4px;
}

.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}

@media (hover: hover) {
  .project-header:hover {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
  }
}

.project-name {
  display: flex;
  align-items: center;
  gap: 4px;
}

.project-chevron {
  transition: transform 0.2s;
  font-size: 10px;
}

.project.collapsed .project-chevron {
  transform: rotate(-90deg);
}

.project-actions {
  display: flex;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

@media (hover: hover) {
  .project-header:hover .project-actions {
    opacity: 1;
  }
}

.project-chats {
  padding-left: 6px;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: -2px;
  margin-bottom: -8px;
  max-height: 5000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.project.collapsed .project-chats {
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px;
  margin: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  user-select: none;
}

@media (hover: hover) {
  .chat-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.chat-item.active {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.chat-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.chat-actions {
  display: flex;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

@media (hover: hover) {
  .chat-item:hover .chat-actions {
    opacity: 1;
  }
}

/* Always show actions on touch devices */
@media (hover: none) {
  .chat-actions {
    opacity: 0.6;
  }
  .project-actions {
    opacity: 0.6;
  }
}

/* Drag and drop */
.chat-item.dragging,
.project.dragging {
  opacity: 0.5;
}

.chat-item.drag-over {
  border-top: 2px solid var(--accent);
  margin-top: -2px;
}

.chat-item.drag-over-bottom {
  border-bottom: 2px solid var(--accent);
  margin-bottom: -2px;
}

.project-header.drag-over {
  background: var(--accent);
  color: white;
  border-radius: 4px;
}

.project.drag-over {
  border-top: 2px solid var(--accent);
  margin-top: -2px;
}

.project.drag-over-bottom {
  border-bottom: 2px solid var(--accent);
  margin-bottom: -2px;
}

.chat-item[draggable='true'],
.project[draggable='true'] {
  cursor: grab;
}

.chat-item[draggable='true']:active,
.project[draggable='true']:active {
  cursor: grabbing;
}

/* Divider row with new chat button */
.sidebar-divider-row {
  display: flex;
  align-items: center;
  margin: 6px 8px;
  gap: 8px;
}

.sidebar-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.new-chat-btn,
.new-project-btn {
  opacity: 0.6;
  font-size: 14px;
  padding: 2px 6px;
}

.new-chat-btn:hover,
.new-project-btn:hover {
  opacity: 1;
}

/* Root level chats */
.root-chats {
  margin-top: 4px;
}

/* =================================================================
   CHAT AREA
================================================================= */

.chat-area {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
}

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

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chat-header .chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  opacity: 1 !important;
}

#toggleSidebarBtn,
#backBtn {
  font-size: 20px;
}

#backBtn {
  font-size: 24px;
  font-weight: bold;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.welcome-message {
  text-align: center;
  margin-top: 100px;
  color: var(--text-secondary);
}

.welcome-message h3 {
  margin-bottom: 8px;
  font-size: 24px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  margin-bottom: 8px;
}

.message:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.message.assistant .message-avatar {
  background-color: var(--success);
}

.message-content {
  overflow: hidden;
  max-width: 100%;
  flex: 1;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

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

.message-time {
  font-size: 12px;
  color: var(--text-muted);
}

.message-text {
  word-break: break-word;
  overflow-wrap: break-word;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-text code {
  background-color: var(--bg-tertiary);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

.message-text pre {
  background-color: var(--bg-tertiary);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
}

/* Message attachments */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.message-attachment.image {
  max-width: 300px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.message-attachment.image img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.2s;
}

.message-attachment.image img:hover {
  opacity: 0.9;
}

.message-attachment.file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 300px;
}

.message-attachment .attachment-icon {
  font-size: 24px;
}

.message-attachment .attachment-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-attachment .attachment-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  border-radius: 16px;
  width: fit-content;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  animation: typing 1.4s infinite;
}

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

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* =================================================================
   MESSAGE INPUT - Discord-style on all devices
================================================================= */

.message-input-container {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.message-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}

.attach-btn {
  display: flex;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 22px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s;
}

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

.input-with-send {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 6px 6px 18px;
  min-height: 44px;
  max-height: 170px;
  transition: border-color 0.2s;
  overflow: hidden;
}

.input-with-send:focus-within {
  border-color: var(--accent);
}

.input-with-send textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 0;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 28px;
  max-height: 150px !important;
  line-height: 1.4;
  overflow-y: auto !important;
}

.input-with-send textarea::placeholder {
  color: var(--text-muted);
}

.input-with-send textarea:focus {
  outline: none;
}

.input-with-send textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#sendBtn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  padding: 0;
  background-color: var(--accent);
  color: white;
  border: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s;
}

#sendBtn:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: scale(1.05);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#sendBtn.stop-mode {
  background-color: var(--danger);
}

#sendBtn.stop-mode:hover {
  background-color: #c0392b;
  transform: scale(1.05);
}

.message-input-container button:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.message-input-container button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =================================================================
   DROP ZONE & FILE PREVIEW
================================================================= */

.drop-zone-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(88, 101, 242, 0.15);
  border: 3px dashed var(--accent);
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}

.drop-zone-overlay.active {
  display: flex;
}

.drop-zone-content {
  text-align: center;
  color: var(--accent);
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.drop-zone-text {
  font-size: 18px;
  font-weight: 600;
}

.file-preview-container {
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 16px 12px 16px;
  flex-shrink: 0;
}

.file-preview-container.has-files {
  display: flex;
}

.file-preview-item {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 200px;
}

.file-preview-item .file-thumbnail {
  width: 100%;
  height: 120px;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-bottom: 1px solid var(--border);
}

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

.file-preview-item .file-info {
  padding: 10px 12px;
}

.file-preview-item .file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

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

/* Action buttons overlay (Discord style) */
.file-preview-item .file-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.file-preview-item:hover .file-actions {
  opacity: 1;
}

.file-preview-item .file-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-primary);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.file-preview-item .file-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.file-preview-item .file-action-btn.remove:hover {
  background: var(--danger);
  color: white;
}

/* =================================================================
   BUTTONS
================================================================= */

.icon-btn {
  padding: 6px 8px;
  background-color: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition:
    background-color 0.2s,
    color 0.2s;
}

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

.icon-btn-small {
  padding: 2px 4px;
  font-size: 12px;
}

.btn-primary {
  padding: 10px 20px;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.btn-secondary {
  padding: 10px 20px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.btn-danger {
  padding: 10px 20px;
  background-color: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* =================================================================
   MODALS
================================================================= */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-secondary);
  padding: 24px;
  border-radius: 8px;
  min-width: 400px;
  max-width: 500px;
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 20px;
  color: var(--text-primary);
}

.modal-content input {
  width: 100%;
  padding: 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 16px;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-category-select {
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-category-select label {
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-category-select select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
}

.modal-category-select select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* =================================================================
   SCROLLBAR
================================================================= */

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

::-webkit-scrollbar-track {
  background-color: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background-color: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--bg-hover);
}

/* =================================================================
   SETTINGS PANEL
================================================================= */

.settings-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.settings-panel.active {
  display: block;
}

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

.settings-container {
  display: flex;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  background-color: var(--bg-primary);
}

.settings-sidebar {
  width: 240px;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  padding: 60px 8px 20px 8px;
  overflow-y: auto;
}

.settings-nav {
  flex: 1;
}

.settings-nav-section {
  margin-bottom: 24px;
}

.settings-nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 8px 4px 8px;
  letter-spacing: 0.5px;
}

.settings-nav-item {
  width: 100%;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.settings-nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.settings-nav-item.active {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.settings-nav-icon {
  font-size: 18px;
}

.settings-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 60px 40px 40px 40px;
}

.settings-panel-content {
  display: none;
}

.settings-panel-content.active {
  display: block;
}

.settings-panel-content h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.settings-description {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.settings-section {
  margin-bottom: 40px;
}

.settings-section h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Stat Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--bg-secondary);
  padding: 24px;
  border-radius: 8px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* Usage Bar */
.usage-bar {
  height: 24px;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

.usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.3s ease;
}

.usage-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Info Rows */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  color: var(--text-primary);
}

/* Memory List */
.memory-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.memory-stat {
  background-color: var(--bg-secondary);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
}

.memory-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
}

.memory-stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.memory-list {
  max-height: 400px;
  overflow-y: auto;
}

.memory-item {
  background-color: var(--bg-secondary);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
}

.memory-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memory-item-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
}

.memory-item-date {
  font-size: 12px;
  color: var(--text-muted);
}

.memory-item-content {
  color: var(--text-primary);
  font-size: 14px;
}

/* Plan Cards */
.plan-card {
  background-color: var(--bg-secondary);
  padding: 24px;
  border-radius: 8px;
  border: 2px solid var(--border);
}

.plan-card.active-plan {
  border-color: var(--accent);
}

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

.plan-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.plan-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.plan-features {
  margin-bottom: 20px;
}

.plan-feature {
  padding: 8px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* Form Elements in Settings */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Toggle Switches */
.toggle-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.toggle-item:last-child {
  border-bottom: none;
}

.toggle-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.toggle-description {
  font-size: 13px;
  color: var(--text-muted);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0.5;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Danger Zone */
.danger-zone {
  background-color: rgba(218, 55, 60, 0.1);
  border: 1px solid var(--danger);
  padding: 20px;
  border-radius: 8px;
}

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* =================================================================
   RESPONSIVE
================================================================= */

@media (max-width: 768px) {
  /* Mobile: 4-Panel Swipeable Layout */

  /* Container becomes horizontal scroll container */
  .container {
    display: flex;
    width: 300vw; /* 3 panels × 100vw */
    height: 100dvh;
    overflow: hidden;
    touch-action: pan-y; /* Allow vertical scroll, but we handle horizontal */
    padding: 0;
  }

  /* Each panel takes full viewport width */
  .swipe-panel {
    width: 100vw;
    min-width: 100vw;
    height: 100dvh;
    flex-shrink: 0;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Panel 1: Sidebar */
  .sidebar {
    border-right: none;
  }

  /* Panel 2: Chat */
  .chat-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Panel 3 & 4: Features & Settings */
  .settings-panel-full {
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Override .panel fixed positioning - swipe panel uses container translateX */
    position: relative !important;
    right: auto !important;
    /* transform: managed by JS */
    box-shadow: none !important;
    z-index: 1 !important;
  }

  .features-panel-full .panel-header,
  .settings-panel-full .panel-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .panel-content-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Important for flex overflow to work */
  }

  /* Hide desktop-only elements on mobile */
  .desktop-only {
    display: none !important;
  }

  /* Hide old navigation buttons on mobile, but keep back arrow */
  #toggleSidebarBtn,
  .sidebar-expand-btn {
    display: none !important;
  }

  #backBtn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 4px 8px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
  }
  #backBtn:active {
    opacity: 1;
  }

  /* Compact model selector on mobile */
  #modelSelector {
    max-width: 100px !important;
    font-size: 11px !important;
    padding: 2px 4px !important;
  }

  .chat-header-left {
    gap: 4px !important;
  }

  .chat-header h2 {
    font-size: 14px !important;
  }
  /* Mobile input adjustments - extra padding for browser toolbar */
  .message-input-container {
    padding: 8px 12px !important;
    padding-bottom: env(safe-area-inset-bottom, 8px) !important;
    background: var(--bg-secondary) !important;
    border-top: none !important;
  }

  .message-input-wrapper {
    align-items: center !important;
  }

  .attach-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    border: none;
  }

  .input-with-send {
    border: none;
    border-radius: 20px;
    padding: 4px 4px 4px 14px;
    min-height: 38px;
  }

  /* Chat area background */
  .chat-area {
    background-color: var(--bg-primary);
  }

  .input-with-send textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    max-height: 120px;
    padding: 6px 0;
  }

  #sendBtn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 14px;
  }

  /* Sidebar footer - safe area handled in tightening block */

  /* Features/Settings panels - safe area padding */
  .features-panel-full .panel-content-scroll,
  .settings-panel-full .panel-content-scroll {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }

  .modal-content {
    min-width: 90%;
    margin: 0 16px;
  }

  .message-input-container textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .messages-container {
    padding-bottom: 20px;
  }

  .settings-container {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
    padding: 20px 12px;
    max-height: 40vh;
  }

  .settings-content {
    padding: 20px 16px;
  }

  .settings-panel-content h1 {
    font-size: 24px;
  }

  .stat-cards,
  .plans-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    min-width: 90%;
    margin: 0 16px;
  }

  /* Mobile: safe area handled above */

  .message-input-container textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Ensure messages container doesn't overflow */
  .messages-container {
    padding-bottom: 20px;
  }

  /* Mobile: Settings Panel */
  .settings-container {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
    padding: 20px 12px;
    max-height: 40vh;
  }

  .settings-content {
    padding: 20px 16px;
  }

  .settings-panel-content h1 {
    font-size: 24px;
  }

  .stat-cards,
  .plans-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  /* Desktop: Traditional 2-column layout - NO swipe panels */
  .container {
    width: 100% !important;
    height: 100vh !important;
    /* transform: managed by JS */
    display: flex !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }

  /* Reset swipe panel styles for desktop */
  .swipe-panel {
    width: auto !important;
    min-width: auto !important;
    flex-shrink: 1 !important;
  }

  .sidebar {
    position: relative;
    width: 280px !important;
    min-width: 280px !important;
    height: 100% !important;
    flex-shrink: 0 !important;
  }

  .chat-area {
    flex: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .chat-area .messages-container {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
  }

  /* HIDE mobile-only settings panel on desktop (uses overlay instead) */
  #settingsFullPanel,
  .settings-panel-full {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
  }

  /* Desktop overlay panels - hidden by default, shown when .active */
  .panel.desktop-only {
    display: flex;
  }

  .panel-overlay.desktop-only {
    display: block;
  }

  /* Desktop: Keep normal input layout */
  .message-input-wrapper {
    display: contents;
  }

  .attach-btn {
    display: flex !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
  }

  .input-with-send {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 12px;
  }

  .message-input-container {
    padding-bottom: 16px !important;
  }

  .message-input-container textarea {
    flex: 1;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    max-height: 150px !important;
    overflow-y: hidden;
  }

  .message-input-container #sendBtn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    font-size: 16px !important;
  }

  /* Desktop sidebar footer - normal padding */
  .sidebar-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Desktop: Show toggle button */
  #toggleSidebarBtn {
    display: flex !important;
    opacity: 0.3;
  }

  #toggleSidebarBtn:hover {
    opacity: 1;
  }

  .sidebar.collapsed ~ .chat-area #toggleSidebarBtn {
    opacity: 1;
  }

  /* Desktop: Never show back button */
  #backBtn {
    display: none !important;
  }

  /* ========================================
     DESKTOP ALIGNMENT: Headers & Footers
     ======================================== */

  /* Match sidebar header height - sidebar uses padding:16px = 32px + ~24px content = ~56px */
  .sidebar-header {
    height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
  }

  /* Chat header already has height:56px, ensure same styling */
  .chat-header {
    height: 56px;
    padding: 0 16px;
    background: transparent; /* Match sidebar header (no special background) */
  }

  /* Match footer heights */
  .sidebar-footer {
    height: 56px;
    padding: 0 12px !important;
    display: flex;
    align-items: center;
    background-color: var(--bg-tertiary) !important;
  }

  .message-input-container {
    min-height: 56px;
    max-height: 180px;
    padding: 0 16px !important;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary) !important; /* Match sidebar footer */
    flex-shrink: 0 !important;
    margin-top: auto;
  }

  /* Fix input layout within the fixed-height container */
  .message-input-wrapper {
    display: flex !important;
    align-items: center;
    width: 100%;
    gap: 12px;
  }

  .input-with-send {
    display: flex !important;
    flex: 1;
    align-items: center;
    gap: 12px;
  }

  .message-input-container textarea {
    flex: 1;
    min-height: 36px;
    max-height: 150px !important;
    padding: 8px 12px;
    resize: none;
    overflow-y: hidden;
  }

  .message-input-container #sendBtn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 50% !important;
    padding: 0 !important;
  }
}

/* =================================================================
   MOBILE: Sidebar Expand Button (Swipe Handle)
================================================================= */

@media (max-width: 768px) {
  /* Show expand button on mobile when in chat view */
  body.mobile-chat-active .sidebar-expand-btn {
    opacity: 1;
    pointer-events: auto;
    left: 0;
    width: 24px;
    height: 80px;
    border-radius: 0 12px 12px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: none;
  }

  .sidebar-expand-btn::after {
    content: '‹';
    font-size: 20px;
    color: var(--text-muted);
  }

  body.mobile-chat-active .sidebar-expand-btn::after {
    content: '‹';
  }
}

/* =================================================================
   PULL TO REFRESH - Peek behind the screen
================================================================= */

.pull-refresh-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  background: linear-gradient(180deg, #0d1117 0%, #161b22 50%, #1a1f26 100%);
  z-index: -1;
  opacity: 0.5;

  transition: opacity 0.2s ease-out;
  overflow: hidden;
  pointer-events: none;
}

/* Grid floor effect */
.pull-refresh-bg::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background:
    linear-gradient(90deg, rgba(88, 101, 242, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(88, 101, 242, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  transform: perspective(200px) rotateX(60deg);
  transform-origin: bottom;
}

.pull-refresh-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

.pull-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pull-refresh-bg.ready .pull-text {
  color: #3fb950;
}

/* Isometric Server Room - Peeking behind the screen */
.server-farm {
  position: relative;
  width: 220px;
  height: 90px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.server-rack {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  transform: perspective(400px) rotateX(5deg);
}

.server {
  width: 32px;
  height: 55px;
  background: linear-gradient(180deg, #484f58 0%, #2d333b 100%);
  border-radius: 4px;
  position: relative;
  box-shadow:
    0 6px 12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* LED status light */
.server::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  height: 5px;
  background: #3fb950;
  border-radius: 2px;
  box-shadow:
    0 0 10px #3fb950,
    0 0 20px rgba(63, 185, 80, 0.3);
  animation: serverBlink 2s ease-in-out infinite;
}

/* Ventilation slots */
.server::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 6px;
  right: 6px;
  bottom: 8px;
  background: repeating-linear-gradient(0deg, #21262d 0px, #21262d 5px, #161b22 5px, #161b22 10px);
  border-radius: 2px;
}

/* Varying server heights */
.server:nth-child(1) {
  height: 50px;
}
.server:nth-child(2) {
  height: 60px;
}
.server:nth-child(3) {
  height: 55px;
}

/* Different blink timing per server */
.server:nth-child(1)::before {
  animation-delay: 0s;
}
.server:nth-child(2)::before {
  animation-delay: 0.7s;
  background: #58a6ff;
  box-shadow:
    0 0 10px #58a6ff,
    0 0 20px rgba(88, 166, 255, 0.3);
}
.server:nth-child(3)::before {
  animation-delay: 1.4s;
}

@keyframes serverBlink {
  0%,
  90%,
  100% {
    opacity: 1;
  }
  95% {
    opacity: 0.3;
  }
}

/* Cute Robots working hard */
.robot {
  position: absolute;
  font-size: 22px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
  animation: robotBounce 1s ease-in-out infinite;
  z-index: 5;
}

.robot-1 {
  bottom: 5px;
  left: 15px;
  animation-delay: 0s;
}

.robot-2 {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: 0.33s;
  font-size: 20px;
}

.robot-3 {
  bottom: 5px;
  right: 15px;
  animation-delay: 0.66s;
}

@keyframes robotBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes robotWork {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-4px) rotate(-10deg);
  }
  75% {
    transform: translateY(-4px) rotate(10deg);
  }
}

.pull-refresh-bg.refreshing .server::before {
  animation: blinkFast 0.15s infinite !important;
}

@keyframes blinkFast {
  0%,
  100% {
    opacity: 1;
    background: #3fb950;
    box-shadow: 0 0 15px #3fb950;
  }
  50% {
    opacity: 1;
    background: #f0883e;
    box-shadow: 0 0 15px #f0883e;
  }
}

.pull-refresh-bg.refreshing .robot {
  animation: robotWork 0.25s ease-in-out infinite !important;
}

.pull-refresh-bg.refreshing .pull-text {
  color: #f0883e;
}

/* =================================================================
   PULL SCENES - Different for each panel
================================================================= */

.pull-scene {
  position: relative;
  width: 220px;
  height: 90px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Scene 1: Files - Creatures organizing folders */
.files-scene .file-cabinet {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.files-scene .drawer {
  width: 40px;
  height: 45px;
  background: linear-gradient(180deg, #8b6914 0%, #5c4a0f 100%);
  border-radius: 4px;
  position: relative;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.files-scene .drawer::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 6px;
  background: #c9a227;
  border-radius: 2px;
}

.files-scene .drawer-1 {
  height: 40px;
}
.files-scene .drawer-2 {
  height: 50px;
}
.files-scene .drawer-3 {
  height: 45px;
}

.files-scene .creature {
  position: absolute;
  font-size: 24px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
  animation: creatureBounce 1s ease-in-out infinite;
}

.files-scene .creature-1 {
  bottom: 5px;
  left: 20px;
  animation-delay: 0s;
}
.files-scene .creature-2 {
  bottom: 5px;
  right: 20px;
  animation-delay: 0.5s;
}

.files-scene .floating-file {
  position: absolute;
  font-size: 16px;
  animation: fileFloat 2s ease-in-out infinite;
}

.files-scene .file-1 {
  top: 10px;
  left: 40px;
  animation-delay: 0s;
}
.files-scene .file-2 {
  top: 5px;
  left: 100px;
  animation-delay: 0.7s;
}
.files-scene .file-3 {
  top: 15px;
  right: 40px;
  animation-delay: 1.4s;
}

@keyframes fileFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-8px) rotate(5deg);
  }
}

@keyframes creatureBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Scene 2: Chat - Creatures chatting */
.chat-scene .chat-creatures {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}

.chat-scene .chatter {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: chatterBounce 1.2s ease-in-out infinite;
}

.chat-scene .chatter-1 {
  animation-delay: 0s;
}
.chat-scene .chatter-2 {
  animation-delay: 0.4s;
}
.chat-scene .chatter-3 {
  animation-delay: 0.8s;
}

.chat-scene .chatter-avatar {
  font-size: 28px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

.chat-scene .speech-bubble {
  font-size: 18px;
  animation: bubblePop 1.5s ease-in-out infinite;
  position: relative;
  top: -5px;
}

.chat-scene .chatter-1 .speech-bubble {
  animation-delay: 0.2s;
}
.chat-scene .chatter-2 .speech-bubble {
  animation-delay: 0.6s;
}
.chat-scene .chatter-3 .speech-bubble {
  animation-delay: 1s;
}

@keyframes chatterBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

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

/* Scene 4: Tools - Creatures with tools */
.tools-scene .workbench {
  width: 120px;
  height: 35px;
  background: linear-gradient(180deg, #4a3728 0%, #2d2118 100%);
  border-radius: 4px;
  position: relative;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.tools-scene .workbench::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -5px;
  right: -5px;
  height: 6px;
  background: linear-gradient(180deg, #5c4632 0%, #3d2d1f 100%);
  border-radius: 2px;
}

.tools-scene .mechanic {
  position: absolute;
  font-size: 26px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
  animation: mechanicWork 0.8s ease-in-out infinite;
}

.tools-scene .mechanic-1 {
  bottom: 5px;
  left: 15px;
  animation-delay: 0s;
}
.tools-scene .mechanic-2 {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: 0.27s;
}
.tools-scene .mechanic-3 {
  bottom: 5px;
  right: 15px;
  animation-delay: 0.54s;
}

.tools-scene .floating-tool {
  position: absolute;
  font-size: 18px;
  animation: toolSpin 2s linear infinite;
}

.tools-scene .tool-1 {
  top: 8px;
  left: 35px;
  animation-delay: 0s;
}
.tools-scene .tool-2 {
  top: 5px;
  left: 50%;
  animation-delay: 0.7s;
  animation-duration: 3s;
}
.tools-scene .tool-3 {
  top: 12px;
  right: 35px;
  animation-delay: 1.4s;
}

@keyframes mechanicWork {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-4px) rotate(-5deg);
  }
  75% {
    transform: translateY(-4px) rotate(5deg);
  }
}

@keyframes toolSpin {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(180deg);
  }
  100% {
    transform: translateY(0) rotate(360deg);
  }
}

/* Refreshing states for all scenes */
.pull-refresh-bg.refreshing .creature,
.pull-refresh-bg.refreshing .chatter,
.pull-refresh-bg.refreshing .mechanic {
  animation-duration: 0.3s !important;
}

.pull-refresh-bg.refreshing .floating-file,
.pull-refresh-bg.refreshing .speech-bubble,
.pull-refresh-bg.refreshing .floating-tool {
  animation-duration: 0.5s !important;
}

/* =================================================================
   CONFETTI CELEBRATION 🎉
================================================================= */

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  animation: confettiFall linear forwards;
  opacity: 0.9;
}

.confetti.square {
  border-radius: 2px;
}

.confetti.circle {
  border-radius: 50%;
  width: 10px;
  height: 10px;
}

.confetti.ribbon {
  width: 8px;
  height: 20px;
  border-radius: 2px;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  25% {
    transform: translateY(25vh) rotate(180deg) scale(0.9);
    opacity: 0.9;
  }
  50% {
    transform: translateY(50vh) rotate(360deg) scale(0.8);
    opacity: 0.8;
  }
  75% {
    transform: translateY(75vh) rotate(540deg) scale(0.7);
    opacity: 0.6;
  }
  100% {
    transform: translateY(110vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* =================================================================
   CHAT CONTEXT MENU
================================================================= */

.chat-context-menu {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 150px;
  padding: 6px;
  z-index: 1000;
  animation: menuFadeIn 0.15s ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger:hover {
  background: rgba(218, 55, 60, 0.15);
}

.context-menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.context-menu-item.disabled:hover {
  background: transparent;
}

.context-menu-item.disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.1s;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin-left: 8px;
  z-index: 10002;
}

.context-menu-item.disabled:hover::after {
  opacity: 1;
}

.context-menu-item.active {
  color: var(--accent);
}

.context-menu-submenu {
  position: relative;
}

.submenu-arrow {
  margin-left: auto;
  opacity: 0.5;
}

.context-submenu-items {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 140px;
  z-index: 10001;
  padding: 4px 0;
}

.context-submenu-items.show {
  display: block;
}

/* Show submenu on hover (desktop) */
.context-menu-submenu:hover > .context-submenu-items {
  display: block;
}

/* Mobile: show submenu below instead of to the right */
@media (max-width: 768px) {
  .context-submenu-items {
    position: relative;
    left: 0;
    margin-top: 4px;
    box-shadow: none;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding-left: 20px;
  }
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* =================================================================
   PINNED CHATS
================================================================= */

.chat-item.pinned {
  background: rgba(88, 101, 242, 0.08);
}

.chat-item.pinned:hover {
  background: rgba(88, 101, 242, 0.15);
}

.pin-icon {
  font-size: 10px;
  margin-right: 2px;
}

/* Chat/Project indicator icons with instant tooltips */
.chat-indicators {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  gap: 2px;
}

.chat-indicator {
  font-size: 10px;
  position: relative;
  cursor: default;
}

.chat-indicator::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 4px;
  z-index: 1000;
}

@media (hover: hover) {
  .chat-indicator:hover::after {
    opacity: 1;
  }
}

.chat-name {
  display: flex;
  align-items: center;
}

.chat-menu-btn {
  opacity: 0.5;
  transition: opacity 0.2s;
}

@media (hover: hover) {
  .chat-item:hover .chat-menu-btn {
    opacity: 1;
  }
}

.chat-item.active .chat-menu-btn {
  opacity: 1;
}

@media (max-width: 768px) {
  .chat-menu-btn {
    opacity: 0.7;
    /* Larger touch target on mobile */
    min-width: 44px;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: -8px;
    padding: 8px;
  }

  .chat-actions {
    opacity: 1 !important;
  }
}

/* ── Usage Banner ─────────────────────────── */
.usage-banner {
  padding: 6px 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  transition: all 0.3s ease;
}
.usage-banner.warning {
  background: rgba(253, 203, 110, 0.1);
  border-top-color: rgba(253, 203, 110, 0.3);
  color: #fdcb6e;
}
.usage-banner.danger {
  background: rgba(225, 112, 85, 0.12);
  border-top-color: rgba(225, 112, 85, 0.3);
  color: #e17055;
}
.usage-banner.critical {
  background: rgba(214, 48, 49, 0.12);
  border-top-color: rgba(214, 48, 49, 0.3);
  color: #d63031;
}
.usage-banner .usage-bar {
  flex: 1;
  max-width: 120px;
  height: 4px;
  background: var(--bg-tertiary, #2a2a3e);
  border-radius: 2px;
  overflow: hidden;
}
.usage-banner .usage-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.usage-banner a {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Sidebar Search */
.sidebar-search-row {
  padding: 8px 12px 4px;
}
.sidebar-search-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary, #2b2d31);
  border-radius: 8px;
  padding: 0 8px;
  gap: 6px;
}
.sidebar-search-icon {
  font-size: 13px;
  opacity: 0.5;
  flex-shrink: 0;
}
.sidebar-search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary, #fff);
  font-size: 13px;
  padding: 7px 0;
  outline: none;
  font-family: inherit;
  min-width: 0;
}
.sidebar-search-input::placeholder {
  color: var(--text-muted, #72767d);
}
.sidebar-search-clear {
  background: none;
  border: none;
  color: var(--text-muted, #72767d);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-search-clear:hover {
  color: var(--text-primary, #fff);
}
.sidebar-search-empty {
  text-align: center;
  color: var(--text-muted, #72767d);
  padding: 24px 12px;
  font-size: 13px;
}
.sidebar-search-section-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #72767d);
  padding: 12px 16px 4px;
  letter-spacing: 0.5px;
}
.search-result-item {
  cursor: pointer;
  justify-content: flex-start !important;
  gap: 6px;
}
.search-result-item:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06));
}

/* User plan badge */
.user-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
}
.user-plan-badge {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  line-height: 1.2;
}
.user-plan-badge.plan-free {
  color: var(--text-muted);
}
.user-plan-badge.plan-starter {
  color: #5b9cf2;
}
.user-plan-badge.plan-pro {
  color: #f5a623;
}
.user-plan-badge.plan-max {
  color: #a855f7;
}
.user-plan-badge.plan-byok {
  color: #23a559;
}
.user-plan-badge.plan-byok_beta {
  color: #23a559;
}
.user-plan-badge.plan-free_beta {
  color: #f5a623;
}

/* Hide wrench and trash on mobile */
@media (max-width: 768px) {
  #chatSettingsBtn,
  #deleteChatBtn {
    display: none;
  }
}

/* =============================================================================
   UNREAD INDICATORS
   ============================================================================= */

/* Unread chat item — bold name + left dot */
.chat-item.has-unread .chat-name-text {
  font-weight: 700;
  color: #fff;
}
.chat-item.has-unread::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
.chat-item {
  position: relative;
}

/* Unread count badge (chat) */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: #5865f2;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

/* Unread count badge (project header) */
.project-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: #5865f2;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

/* ── New Messages Divider (Discord-style) ── */
.new-messages-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  position: relative;
}

.new-messages-divider::before,
.new-messages-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ed4245;
}

.new-messages-divider span {
  font-size: 11px;
  font-weight: 700;
  color: #ed4245;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Autocomplete popup */
#autocomplete-popup {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 4px;
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-color);
  color: white;
}
.autocomplete-item .ac-icon {
  font-size: 16px;
}
.autocomplete-item .ac-name {
  flex: 1;
}
.autocomplete-item .ac-type {
  font-size: 12px;
  color: var(--text-secondary);
}
.autocomplete-item.active .ac-type {
  color: rgba(255, 255, 255, 0.7);
}

/* Reference pills in messages */
.ref-tag {
  background: rgba(88, 101, 242, 0.3);
  color: #8ab4f8;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
}
.ref-tag:hover {
  background: rgba(88, 101, 242, 0.5);
}

/* Reference pills in input */
.ref-pill {
  background: rgba(88, 101, 242, 0.25);
  color: #a5b4fc;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.92em;
  display: inline-block;
  user-select: all;
  cursor: default;
  vertical-align: baseline;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid rgba(88, 101, 242, 0.2);
  transition: background 0.15s;
}
.ref-pill:hover {
  background: rgba(88, 101, 242, 0.4);
}

/* Contenteditable placeholder */
#messageInput:empty:before {
  content: attr(data-placeholder);
  color: var(--text-secondary, #666);
  pointer-events: none;
}

/* Fix send button position with contenteditable */
.input-with-send {
  display: flex !important;
  align-items: flex-end !important;
  position: relative !important;
}
.input-with-send #messageInput {
  flex: 1 !important;
  min-width: 0 !important;
}
.input-with-send #sendBtn {
  flex-shrink: 0 !important;
  position: relative !important;
}

/* Message action buttons (copy, etc) */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.message:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}
/* Always visible on mobile (no hover) */
@media (max-width: 768px) {
  .message-actions {
    opacity: 0.6;
  }
}
.msg-action-btn {
  background: none;
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  color: var(--text-secondary, #888);
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.msg-action-btn:hover {
  color: var(--text-primary, #fff);
  border-color: var(--text-secondary, #666);
}

/* Scroll to bottom button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 90px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary, #2a2a2a);
  color: var(--text-secondary, #aaa);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition:
    opacity 0.2s,
    transform 0.2s;
  opacity: 0.85;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.scroll-to-bottom-btn:hover {
  opacity: 1;
  transform: scale(1.05);
  background: var(--bg-hover, #333);
}
.scroll-to-bottom-btn.visible {
  display: flex;
}
[data-theme='light'] .scroll-to-bottom-btn {
  background: rgba(255, 255, 255, 0.9);
  color: #666;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
[data-theme='light'] .scroll-to-bottom-btn:hover {
  background: rgba(255, 255, 255, 1);
  color: #333;
}

/* Image attachment loading shimmer */
.message-attachment.image {
  position: relative;
  min-height: 60px;
  border-radius: 8px;
  overflow: hidden;
}
.message-attachment.image img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}
.message-attachment.image.img-loading {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-width: 200px;
  min-height: 120px;
}
.message-attachment.image.img-loading img {
  opacity: 0.5;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Warmup/loading animation for VM startup */
.warmup-retry-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  gap: 12px;
  text-align: center;
}
.warmup-spinner {
  width: 48px;
  height: 48px;
  position: relative;
}
.warmup-orbit {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(124, 92, 252, 0.15);
  border-radius: 50%;
  animation: warmup-spin 1.8s linear infinite;
  position: relative;
}
.warmup-dot {
  width: 10px;
  height: 10px;
  background: #7c5cfc;
  border-radius: 50%;
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(124, 92, 252, 0.5);
}
@keyframes warmup-spin {
  to {
    transform: rotate(360deg);
  }
}
.warmup-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.warmup-text strong {
  color: #e0e0e0;
  font-size: 0.95em;
}
.warmup-subtitle {
  color: #888;
  font-size: 0.85em;
}
.warmup-progress {
  width: 120px;
  height: 3px;
  background: rgba(124, 92, 252, 0.15);
  border-radius: 2px;
  overflow: hidden;
}
.warmup-progress-bar {
  height: 100%;
  width: 40%;
  background: #7c5cfc;
  border-radius: 2px;
  animation: warmup-progress 2s ease-in-out infinite;
}
@keyframes warmup-progress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* === Appearance: Font Size & Message Density === */
:root {
  --message-font-size: 15px;
  --message-padding: 8px 0;
  --message-gap: 8px;
}

.message-bubble,
.message-text {
  font-size: var(--message-font-size, 15px) !important;
}

.message {
  padding: var(--message-padding, 8px 0) !important;
}

.messages-container .message + .message {
  margin-top: var(--message-gap, 8px);
}

/* Light theme for settings/features panels */
[data-theme='light'] .panel {
  background: #f2f3f5 !important;
  color: #1e1f22;
}
[data-theme='light'] .ios-group:not(.ios-group-gradient) {
  background: #ffffff !important;
}
[data-theme='light'] .ios-row-title,
[data-theme='light'] .ios-panel-subtitle {
  color: #1e1f22 !important;
}
[data-theme='light'] .ios-section-label {
  color: #6e6e73 !important;
}
[data-theme='light'] .ios-row-value,
[data-theme='light'] .panel-chevron {
  color: #8e8e93 !important;
}
[data-theme='light'] .ios-row {
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

/* ===== Light Theme Fixes ===== */

/* Sidebar: unread chat names — were #fff hardcoded */
[data-theme='light'] .chat-item.has-unread .chat-name-text {
  color: #1e1f22;
}

/* Sidebar: unread dot indicator */
[data-theme='light'] .chat-item.has-unread::before {
  background: #1e1f22;
}

/* Sidebar: chat name text general */
[data-theme='light'] .chat-name-text {
  color: #1e1f22;
}

/* Sidebar: chat preview text */
[data-theme='light'] .chat-preview {
  color: #80848e;
}

/* Sidebar: project headers */
[data-theme='light'] .project-header {
  color: #5c5e66;
}

/* Sidebar: category icons */
[data-theme='light'] .category-icon {
  color: #5c5e66;
}

/* Message action buttons (copy, etc) */
[data-theme='light'] .msg-action-btn {
  border-color: #d5d7db;
  color: #5c5e66;
}
[data-theme='light'] .msg-action-btn:hover {
  color: #1e1f22;
  border-color: #80848e;
}

/* Chat header */
[data-theme='light'] .chat-header {
  color: #1e1f22;
}

/* Message input */
[data-theme='light'] .message-input-container {
  border-top-color: #e3e5e8;
}

/* Sidebar footer */
[data-theme='light'] .sidebar-footer {
  border-top-color: #e3e5e8;
}

/* Sidebar: bottom user info */
[data-theme='light'] .sidebar-footer .user-name {
  color: #1e1f22;
}
[data-theme='light'] .sidebar-footer .user-plan {
  color: #80848e;
}

/* Message timestamps */
[data-theme='light'] .message-time {
  color: #80848e;
}

/* Model selector */
[data-theme='light'] .model-selector,
[data-theme='light'] select {
  background: #e3e5e8;
  color: #1e1f22;
  border-color: #d5d7db;
}

/* === Context Bar (Phase 1 v2) === */
.context-bar {
  height: 3px;
  background: var(--bg-tertiary, #1e1f22);
  position: relative;
  overflow: visible;
  transition: opacity 0.3s;
  flex-shrink: 0;
}
.context-bar.hidden {
  opacity: 0;
  height: 0;
  pointer-events: none;
}
.context-bar .context-bar-fill {
  height: 100%;
  transition:
    width 0.5s ease,
    background-color 0.5s ease;
  border-radius: 0 2px 2px 0;
  min-width: 2px;
}
.context-bar .context-bar-fill.green {
  background: #23a559;
}
.context-bar .context-bar-fill.yellow {
  background: #f0b232;
}
.context-bar .context-bar-fill.red {
  background: #ed4245;
}
.context-bar .context-bar-pct {
  position: absolute;
  right: 8px;
  top: 4px;
  font-size: 10px;
  color: var(--text-muted, #72767d);
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
  background: var(--bg-secondary, #2b2d31);
  padding: 2px 6px;
  border-radius: 3px;
}
.context-bar:hover .context-bar-pct,
.context-bar.show-pct .context-bar-pct {
  opacity: 1;
}

/* === iOS Toggle Switch (Phase 2) === */
.ios-toggle-wrap {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.ios-toggle-wrap input {
  opacity: 0.5;
  width: 0;
  height: 0;
  position: absolute;
}
.ios-toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #636366;
  border-radius: 12px;
  transition: background 0.3s;
}
.ios-toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.ios-toggle-wrap input:checked + .ios-toggle-slider {
  background: #30d158;
}
.ios-toggle-wrap input:checked + .ios-toggle-slider::after {
  transform: translateX(20px);
}

/* === Chat Chains (Phase 4) === */
/* Chain: Option A - Inline Badge */
.chain-badge-a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(74, 158, 255, 0.12);
  color: #4a9eff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 4px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.chain-badge-a:hover {
  background: rgba(74, 158, 255, 0.22);
}
.chain-badge-a.expanded {
  background: rgba(74, 158, 255, 0.22);
}

/* Previous chain items - hidden by default */
.chain-prev-hidden {
  display: none !important;
}
.chain-prev-visible {
  opacity: 0.55;
  padding-left: 28px !important;
  border-left: 2px solid rgba(74, 158, 255, 0.25);
  margin-left: 12px;
}
.chain-prev-visible:hover {
  opacity: 0.8;
}
.chain-prev-visible .chat-name {
  font-size: 13px;
  color: #999;
}

/* Continuation banner */
.continuation-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 8px 16px 16px;
  background: rgba(74, 158, 255, 0.08);
  border: 1px solid rgba(74, 158, 255, 0.2);
  border-radius: 8px;
  font-size: 13px;
  color: #aaa;
}
.continuation-icon {
  font-size: 18px;
}
.continuation-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.continuation-text strong {
  color: #ccc;
  font-size: 13px;
}
.continuation-link {
  color: #4a9eff;
  cursor: pointer;
  font-size: 12px;
}
.continuation-link:hover {
  text-decoration: underline;
}

/* === Chat Styling Update (Mockup v3) === */

/* User messages: right-aligned bubble */
.message.user {
  flex-direction: row-reverse;
}

.message.user .message-avatar {
  display: none;
}

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

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

.message.user .message-text {
  background: var(--accent, #5865f2);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  display: inline-block;
  max-width: 80%;
  white-space: pre-wrap;
}

.message.user .message-text code {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.message.user .message-text pre {
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
}

/* Assistant messages: left-aligned with avatar */
.message.assistant .message-text {
  background: var(--bg-tertiary, #313338);
  padding: 10px 14px;
  border-radius: 4px 16px 16px 16px;
  display: inline-block;
  max-width: 85%;
}

/* Input area: rounded pill style */
.message-input-container {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom, 0px));
  background-color: var(--bg-primary, #1e1f22);
  border-top: 1px solid var(--border, #3f4147);
}

#messageInput {
  border-radius: 20px !important;
  padding: 8px 14px !important;
}

/* Circular attach button */
.attach-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  background: var(--bg-tertiary, #313338) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

/* Send button: circular accent */
#sendBtn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  min-width: 36px !important;
  padding: 0 !important;
}

/* Model selector: pill style */
#modelSelector {
  background: var(--bg-tertiary, #313338) !important;
  border: none !important;
  border-radius: 14px !important;
  padding: 4px 12px !important;
  font-size: 12px !important;
  color: var(--text-secondary, #b5bac1) !important;
  cursor: pointer !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

/* Chat title: cleaner */
.chat-header h2 {
  font-size: 15px;
  font-weight: 600;
}

/* Copy buttons inside messages: subtle */
.message .copy-btn,
.message button[title='Copy'] {
  opacity: 0.5;
  transition: opacity 0.2s;
}
.message:hover .copy-btn,
.message:hover button[title='Copy'] {
  opacity: 0.5;
}
.message:hover .copy-btn:hover,
.message:hover button[title='Copy']:hover {
  opacity: 1;
}

/* Always show chat-actions when chain badge present */
.chat-item .chat-actions:has(.chain-badge-a) {
  opacity: 1 !important;
}

/* Mute indicator */
.mute-indicator {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
}

/* =================================================================
   PWA STANDALONE MODE - Safe area adjustments
   When installed as PWA (Add to Home Screen), content extends behind
   the status bar. Add safe area padding to top-level headers.
================================================================= */
@media (display-mode: standalone) {
  .sidebar-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }

  .chat-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }

  .panel-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px) !important;
  }

  /* Also handle iOS Safari standalone detection (older method) */
}

/* iOS Safari standalone fallback (navigator.standalone) */
@media screen and (max-width: 768px) {
  body.pwa-standalone .sidebar-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }

  body.pwa-standalone .chat-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }

  body.pwa-standalone .panel-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px) !important;
  }
}

/* Body background fills safe area - matches bottom bars */
html,
body {
  background-color: var(--bg-secondary, #2b2d31);
}
[data-theme='light'] body,
[data-theme='light'] html {
  background-color: #f2f3f5;
}

/* =================================================================
   MOBILE LAYOUT TIGHTENING
   Reduce spacing on mobile to maximize content area
================================================================= */
@media (max-width: 768px) {
  /* Compact sidebar header */
  .sidebar-header {
    height: 44px !important;
    padding: 0 12px !important;
  }

  .sidebar-header img {
    height: 22px !important;
  }

  /* Compact category selector */
  .category-selector {
    padding: 4px 12px !important;
    margin-bottom: 2px !important;
  }

  .category-slider {
    padding: 6px 12px !important;
  }

  .slider-track {
    height: 32px !important;
  }

  .slider-stop {
    height: 24px !important;
    min-width: 36px !important;
    font-size: 15px !important;
  }

  .slider-thumb {
    height: 24px !important;
  }

  .category-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
  }

  /* Compact search */
  .sidebar-search-row {
    padding: 4px 12px 4px !important;
  }

  /* Compact chat header */
  .chat-header {
    height: 44px !important;
    padding: 0 12px !important;
  }

  /* Tighter sidebar content */
  .sidebar-content {
    padding: 4px 8px !important;
  }

  /* Compact sidebar footer */
  .sidebar-footer {
    min-height: 48px !important;
    height: auto !important;
    padding: 8px 12px !important;
    padding-bottom: env(safe-area-inset-bottom, 8px) !important;
  }
}

/* PWA standalone: adjust header heights to include safe area */
@media (max-width: 768px) and (display-mode: standalone) {
  .sidebar-header {
    height: calc(44px + env(safe-area-inset-top, 0px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  .chat-header {
    height: calc(44px + env(safe-area-inset-top, 0px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }
}

@media (max-width: 768px) {
  body.pwa-standalone .sidebar-header {
    height: calc(44px + env(safe-area-inset-top, 0px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  body.pwa-standalone .chat-header {
    height: calc(44px + env(safe-area-inset-top, 0px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }
}

/* iOS safe area — bottom fill matches sidebar footer */
@media (display-mode: standalone) {
  html,
  body {
    background-color: var(--bg-tertiary, #313338) !important;
  }
  [data-theme='light'] html,
  [data-theme='light'] body {
    background-color: #e3e5e8 !important;
  }
}

/* ── Markdown rendering styles for assistant messages ── */
.message.assistant .message-text {
  white-space: normal;
}

.message.assistant .message-text p {
  margin: 0 0 8px 0;
}

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

.message.assistant .message-text h1,
.message.assistant .message-text h2,
.message.assistant .message-text h3 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: var(--text-primary);
}

.message.assistant .message-text h1 {
  font-size: 1.3em;
}
.message.assistant .message-text h2 {
  font-size: 1.15em;
}
.message.assistant .message-text h3 {
  font-size: 1.05em;
}

.message.assistant .message-text hr {
  border: none;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  margin: 12px 0;
}

.message.assistant .message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.message.assistant .message-text th,
.message.assistant .message-text td {
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  padding: 6px 10px;
  text-align: left;
}

.message.assistant .message-text th {
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.05));
  font-weight: 600;
}

.message.assistant .message-text tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.message.assistant .message-text blockquote {
  border-left: 3px solid var(--accent-color, #7c5cfc);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
}

.message.assistant .message-text ul,
.message.assistant .message-text ol {
  margin: 4px 0;
  padding-left: 20px;
}

.message.assistant .message-text li {
  margin: 2px 0;
}

.message.assistant .message-text a {
  color: var(--accent-color, #7c5cfc);
  text-decoration: none;
}

.message.assistant .message-text a:hover {
  text-decoration: underline;
}

.message.assistant .message-text strong {
  font-weight: 600;
}

/* Spotify Mini Player — sidebar, above user footer */
.spotify-mini-player {
  display: none;
  flex-direction: column;
  background: rgba(29, 185, 84, 0.08);
  border-top: 1px solid rgba(29, 185, 84, 0.2);
  border-bottom: 1px solid rgba(29, 185, 84, 0.2);
  overflow: hidden;
  flex-shrink: 0;
}
.spotify-mini-player.smp-visible {
  display: flex;
}
.smp-content {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
}
.smp-album-art {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.smp-text {
  flex: 1;
  min-width: 0;
}
.smp-track-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.smp-artist-name {
  font-size: 10px;
  color: var(--text-secondary, #b3b3b3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.smp-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.smp-btn {
  background: none;
  border: none;
  color: var(--text-secondary, #b3b3b3);
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
  line-height: 1;
}
.smp-btn:hover {
  color: var(--text-primary, #fff);
}
.smp-play-btn {
  font-size: 14px;
  color: #fff;
  background: #1db954;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.smp-play-btn:hover {
  background: #1ed760;
  transform: scale(1.05);
}
.smp-progress {
  height: 2px;
  width: 100%;
}
.smp-progress-bar {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
}
.smp-progress-fill {
  height: 100%;
  background: #1db954;
  width: 0;
  transition: width 1s linear;
}

/* ── Auto-Classifier ── */

.classifier-annotation {
  padding: 4px 16px;
  margin: 4px 0;
}

.classifier-annotation-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 159, 10, 0.08);
  border-left: 3px solid #ff9f0a;
  font-size: 12px;
  color: var(--text-secondary, #8e8e93);
}

.classifier-annotation-icon {
  flex-shrink: 0;
}

.classifier-annotation-text {
  flex: 1;
}

.classifier-annotation-text strong {
  color: var(--text-primary, #fff);
}

.classifier-annotation-topic {
  color: var(--text-tertiary, #636366);
  font-style: italic;
}

.classifier-undo-btn {
  background: rgba(255, 159, 10, 0.2);
  border: none;
  color: #ff9f0a;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.classifier-undo-btn:hover {
  background: rgba(255, 159, 10, 0.35);
}

.classifier-confirm {
  padding: 8px 16px;
  margin: 4px 0;
}

.classifier-confirm-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(88, 86, 214, 0.08);
  border-left: 3px solid #5856d6;
  font-size: 13px;
  color: var(--text-secondary, #8e8e93);
  flex-wrap: wrap;
}

.classifier-confirm-inner strong {
  color: var(--text-primary, #fff);
}

.classifier-confirm-buttons {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.classifier-btn {
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.classifier-btn:hover {
  opacity: 0.8;
}

.classifier-btn-yes {
  background: #30d158;
  color: #fff;
}

.classifier-btn-no {
  background: rgba(142, 142, 147, 0.2);
  color: var(--text-secondary, #8e8e93);
}

#auto-categorize-badge {
  animation: badge-fade-in 0.3s ease;
}

@keyframes badge-fade-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

[data-theme='light'] .classifier-annotation-inner {
  background: rgba(255, 159, 10, 0.06);
}

[data-theme='light'] .classifier-annotation-text strong {
  color: var(--text-primary, #1c1c1e);
}

[data-theme='light'] .classifier-confirm-inner {
  background: rgba(88, 86, 214, 0.06);
}

[data-theme='light'] .classifier-confirm-inner strong {
  color: var(--text-primary, #1c1c1e);
}

/* Memory panel scroll fix */
#memory-panel-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Settings list scroll fix — Auto-Categorize was cut off at bottom */
.settings-view-list .panel-content {
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  -webkit-overflow-scrolling: touch;
}

/* Scratchpad chat indicator */
.chat-item.is-scratchpad .chat-name-text::before {
  content: '🗒️ ';
  font-size: 12px;
}
.chat-item.is-scratchpad {
  opacity: 0.75;
  border-left: 2px solid var(--accent-color, #007aff);
}

/* Auto-Categorize Badge */
.auto-categorize-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-secondary, rgba(88, 101, 242, 0.08));
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  font-size: 13px;
  color: var(--accent, #5865f2);
  flex-shrink: 0;
}
.ac-badge-text {
  font-weight: 500;
}
.ac-badge-dismiss {
  background: none;
  border: none;
  color: var(--ios-text-secondary, #98989e);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
}
.ac-badge-dismiss:hover {
  opacity: 1;
  color: var(--text-primary, #fff);
}

/* Budget Exceeded Banner */
.classifier-budget-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: rgba(255, 165, 0, 0.12);
  border-bottom: 1px solid rgba(255, 165, 0, 0.2);
  font-size: 13px;
  color: #ffa500;
  flex-shrink: 0;
}

/* System Messages (classifier annotations in destination chats) */
.system-message {
  display: flex;
  justify-content: center;
  padding: 4px 16px;
  margin: 8px 0;
}
.system-message-content {
  font-size: 12px;
  color: var(--ios-text-secondary, #98989e);
  font-style: italic;
  text-align: center;
  padding: 4px 12px;
  background: var(--surface-secondary, rgba(255, 255, 255, 0.03));
  border-radius: 12px;
}

/* Topic Change Annotation */
.classifier-topic-change {
  padding: 8px 16px;
  margin: 4px 0;
}
.classifier-topic-change-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(88, 101, 242, 0.06);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ios-text-secondary, #98989e);
  border-left: 3px solid var(--accent, #5865f2);
}
.classifier-topic-change-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Pick destination button */
.classifier-btn-pick {
  background: var(--surface-secondary, rgba(255, 255, 255, 0.06));
  color: var(--ios-text, #fff);
  border: 1px solid var(--ios-separator, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.classifier-btn-pick:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.1));
}

/* Move button on annotations */
.classifier-move-btn {
  background: none;
  border: 1px solid var(--ios-separator, rgba(255, 255, 255, 0.1));
  color: var(--ios-text-secondary, #98989e);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 4px;
}
.classifier-move-btn:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.06));
  color: var(--ios-text, #fff);
}

.classifier-pending-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  background: var(--surface-secondary, rgba(255, 255, 255, 0.03));
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  font-size: 12px;
  color: var(--ios-text-secondary, #98989e);
  flex-shrink: 0;
  animation: pulse-opacity 2s ease-in-out infinite;
}
@keyframes pulse-opacity {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* Archived chats section */
.archived-section {
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.archived-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted, #888);
  cursor: pointer;
  user-select: none;
}

.archived-header:hover {
  color: var(--text-primary, #fff);
  background: var(--hover-bg, rgba(255, 255, 255, 0.04));
}

.archived-toggle {
  font-size: 10px;
  transition: transform 0.15s;
}

.archived-list {
  padding-bottom: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.archived-chat {
  opacity: 0.65;
}

.archived-chat:hover {
  opacity: 1;
}
