@keyframes button-press {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.92);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes send-button-press {
  0% {
    transform: scale(1.15);
  }
  25% {
    transform: scale(0.88);
  }
  50% {
    transform: scale(1.05);
  }
  75% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-container {
  /* Fixed sidebar is 300px + gutter; ensure chat uses remaining space */
  max-width: calc(100% - 300px - var(--half));
  margin-right: var(--half);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex-grow: 1;
  min-width: 0;
}

.chat-container .chat-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 32px;
  padding: var(--half);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--tile-elevation-2);
  box-sizing: border-box;
}

.chat-container .chat-assistant-indicator {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.4;
  background: var(--tile-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  user-select: none;
}

.chat-container .chat-content, .chat-container .admin-content {
  display: none;
  height: 100%;
  width: 100%;
}

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

.chat-container .admin-content {
  display: none;
  flex-direction: column;
  padding: var(--one);
  height: 100%;
}

.chat-container .admin-content .admin-textareas {
  display: flex;
  flex-direction: column;
  gap: var(--one);
  flex: 1;
  overflow: hidden;
}

.chat-container .admin-content .admin-textareas .textarea-group {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--half);
}

.chat-container .admin-content .admin-textareas .textarea-group label {
  margin-bottom: var(--half);
  font-weight: 600;
}

.chat-container .admin-content .admin-textareas .textarea-group .admin-textarea {
  resize: none;
  padding: var(--half);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--background-color);
  color: var(--text-color);
  font-family: monospace;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.display-name) {
  flex: 0 0 auto;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.display-name) .admin-textarea {
  height: 24px;
  min-height: 24px;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.welcome-message) {
  flex: 0 0 auto;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.welcome-message) .admin-textarea {
  height: 80px;
  min-height: 80px;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.system-prompt) {
  flex: 1 1 auto;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.system-prompt) .admin-textarea {
  height: 100%;
  min-height: 100px;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.initial-prompt) {
  margin: 0.25rem 0;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.initial-prompt) .initial-prompts-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-container .admin-content .admin-textareas .textarea-group:has(.initial-prompt) .initial-prompts-container .admin-textarea {
  height: 24px;
  min-height: 24px;
  margin: 0;
}

.chat-container .admin-content .admin-textareas .initial-prompts-container .admin-textarea {
  margin: 0;
  padding: var(--half);
}

.chat-container .admin-content .admin-textareas .admin-textarea.display-name {
  height: 24px;
  min-height: 24px;
}

.chat-container .admin-content .admin-textareas .admin-textarea.welcome-message {
  height: 80px;
  min-height: 80px;
}

.chat-container .admin-content .admin-textareas .admin-textarea.system-prompt {
  height: 100%;
}

.chat-container .admin-content .admin-controls {
  margin-top: var(--one);
  display: flex;
  justify-content: flex-end;
}

.chat-container .admin-content .admin-controls button {
  padding: var(--half) var(--one);
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-right: var(--half);
}

.chat-container .admin-content .admin-controls button:hover {
  opacity: 0.9;
}

.chat-container.mode-admin .chat-content {
  display: none;
}

.chat-container.mode-admin .admin-content {
  display: flex;
  box-sizing: border-box;
}

.content-area.sidebar-collapsed .chat-container {
  max-width: 100%;
  margin-right: 0;
}

.chatBox {
  flex: 1;
  max-width: 100%;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-right: var(--one);
  position: relative;
}

.chatBox::-webkit-scrollbar {
  width: 6px;
}

.chatBox::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.chatBox .loading-container, .chatBox .detection-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--one);
  background: var(--tile-bg);
  border-radius: var(--half);
  margin: var(--one) 0;
  opacity: 0.8;
  font-size: 0.9rem;
}

.chatBox .loading-container .loading-icon, .chatBox .detection-container .loading-icon {
  margin-right: var(--half);
  animation: spin 1.5s linear infinite;
}

.chatBox .user-message, .chatBox .ai-message, .chatBox .loading-icon-container {
  margin-bottom: var(--two);
  font-size: 1.1rem;
  line-height: 1.6;
  position: relative;
  padding-right: var(--one);
}

.chatBox .user-message .message-content, .chatBox .ai-message .message-content, .chatBox .loading-icon-container .message-content {
  overflow-x: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chatBox .user-message .message-content pre, .chatBox .ai-message .message-content pre, .chatBox .loading-icon-container .message-content pre {
  overflow-x: visible;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
  background: var(--page-bg);
  padding: var(--half);
  border-radius: 4px;
}

.chatBox .user-message .message-content img, .chatBox .ai-message .message-content img, .chatBox .loading-icon-container .message-content img {
  max-width: 100%;
  height: auto;
}

.chatBox .ai-message {
  align-self: flex-start;
  color: var(--ai-message-text);
  padding: var(--one) 0 var(--one) 0;
  border-radius: 8px;
  background: var(--ai-message-bg);
  margin-bottom: calc(var(--two) + 24px + (var(--half) * 2) + 2px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.chatBox .ai-message.pre-appear {
  opacity: 0;
  transform: translateY(6px);
}

.chatBox .ai-message:not(.pre-appear) {
  opacity: 1;
  transform: translateY(0);
}

.chatBox .user-message {
  align-self: flex-end;
  color: var(--text-color);
  padding: var(--one) var(--two);
  border-radius: 8px;
  background: var(--tile-bg);
  max-width: 75%;
  margin-bottom: calc(var(--two) + 24px + (var(--half) * 2) + 2px);
}

.chatBox .user-message:has(+ .ai-message) {
  margin-bottom: var(--one);
}

.chatBox .user-message:has(+ .loading-icon-container) {
  margin-bottom: var(--one);
}

.chatBox .loading-icon-container {
  align-self: flex-start;
  margin-bottom: var(--one);
}

.chatBox .loading-icon-container .message-content {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.chatBox .loading-icon-container .message-content .loading-icon {
  font-size: 24px;
  opacity: 0.7;
  animation: spin 1.5s linear infinite;
}

.chatForm {
  display: flex;
  flex-direction: column;
  background: var(--tile-bg);
  padding: 10px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  margin-top: 0;
  position: relative;
  z-index: 1;
  gap: 8px;
  min-width: 0;
}

.chatForm .chat-file-pinboard,
.user-message .message-file-pinboard.chat-file-pinboard {
  gap: 8px;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  padding-left: 15px;
  padding-bottom: 8px;
  margin-bottom: 0;
  position: relative;
}

/* Compact mode: show 2 rows of chips and scroll horizontally (no chatbox widening) */
.chatForm .chat-file-pinboard[data-display-mode="compact"],
.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="compact"] {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  grid-template-rows: repeat(2, auto);
  align-items: start;
  flex-wrap: initial;
}

.chatForm .chat-file-pinboard[data-display-mode="compact"] {
  justify-content: start;
}

.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="compact"] {
  justify-content: center;
}

/* Thumbnail mode: force a single row scroller */
.chatForm .chat-file-pinboard[data-display-mode="thumbnail"],
.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="thumbnail"] {
  display: flex;
  flex-wrap: nowrap;
}

.chatForm .chat-file-pinboard:has(.chat-file-chip):not(:empty),
.chatForm .chat-file-pinboard:has(.chat-file-thumbnail-card):not(:empty),
.user-message .message-file-pinboard.chat-file-pinboard:not(:empty) {
  margin-bottom: 0;
  padding-bottom: 14px;
  padding-top: 6px;
  margin-top: 2px;
  position: relative;
}

.chatForm .chat-file-pinboard:has(.chat-file-chip):not(:empty)::after,
.chatForm .chat-file-pinboard:has(.chat-file-thumbnail-card):not(:empty)::after,
.user-message .message-file-pinboard.chat-file-pinboard:not(:empty)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--border-color) 20%,
    var(--border-color) 80%,
    transparent 100%
  );
  opacity: 0.25;
}

.chatForm .chat-file-pinboard {
  display: none;
}

.user-message .message-file-pinboard.chat-file-pinboard {
  display: flex;
  /* Align the attachment cards with the message content (no extra left inset) */
  padding-left: 0;
  margin-bottom: 0;
  padding-bottom: 8px;
  padding-top: 6px;
  margin-top: 2px;
  position: relative;
  justify-content: center;
}

.user-message .message-file-pinboard.chat-file-pinboard.is-scrollable {
  justify-content: flex-start;
}

.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="compact"].is-scrollable {
  justify-content: start;
}

.user-message .message-file-pinboard.chat-file-pinboard:not(:empty)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--border-color) 20%,
    var(--border-color) 80%,
    transparent 100%
  );
  opacity: 0.25;
}

.user-message .message-file-pinboard.chat-file-pinboard:not(:empty) + .message-content {
  margin-top: 0;
  padding-top: 12px;
}

.user-message.editing .message-file-pinboard.chat-file-pinboard:not(:empty) + .message-content {
  margin-top: 0;
  padding-top: 0;
  background: transparent;
  border-radius: 0;
}

.user-message.editing .message-file-pinboard.chat-file-pinboard:not(:empty) + .message-content .edit-textarea {
  margin-top: 12px;
}

.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: none;
}

.message-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--tile-elevation-2);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-color);
  transition: background 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  max-width: 260px;
  min-height: 32px;
}

.message-file-badge[class*="fmt-"] {
  border-left: 3px solid var(--format-color, var(--border-color));
  padding-left: 8px;
}

.message-file-badge:hover {
  background: var(--tile-elevation-3);
  border-color: var(--text-color);
}

.message-file-badge .material-symbols-rounded {
  font-size: 16px;
  color: var(--format-color, var(--muted-text));
  flex-shrink: 0;
}

.message-file-badge.fmt-pdf {
  --format-color: var(--error-color);
}

.message-file-badge.fmt-xlsx,
.message-file-badge.fmt-xls,
.message-file-badge.fmt-csv {
  --format-color: var(--success-color);
}

.message-file-badge.fmt-docx,
.message-file-badge.fmt-doc {
  --format-color: var(--accent-color);
}

.message-file-badge.fmt-md {
  --format-color: var(--accent-color-light);
}

.message-file-badge.fmt-pptx,
.message-file-badge.fmt-ppt {
  --format-color: var(--ppt-color, var(--warning-color));
}

.message-file-badge.fmt-archive {
  --format-color: var(--accent-color-dark);
}

.message-file-badge.fmt-code {
  --format-color: #9c27b0;
}

.message-file-badge.fmt-xml {
  --format-color: #9c27b0;
}

.message-file-badge.fmt-config {
  --format-color: #e65100;
}

.message-file-badge .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chatForm .chat-file-pinboard[data-display-mode="thumbnail"]:has(.chat-file-thumbnail-card):not(:empty),
.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="thumbnail"]:not(:empty) {
  padding-bottom: 12px;
}

.chatForm .chat-file-pinboard:has(.chat-file-chip),
.chatForm .chat-file-pinboard:has(.chat-file-thumbnail-card) {
  display: flex;
}

.chatForm .chat-file-pinboard[data-display-mode="compact"]:has(.chat-file-chip) {
  display: grid;
}

.chatForm .chat-file-chip,
.user-message .message-file-pinboard .chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--tile-elevation-1);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.chatForm .chat-file-chip:hover,
.user-message .message-file-pinboard .chat-file-chip:hover {
  background: var(--tile-elevation-3);
  border-color: var(--primary-color);
}

.chatForm .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip-icon {
  font-size: 18px;
  color: var(--muted-text);
  flex-shrink: 0;
}

.chatForm .chat-file-chip-name,
.user-message .message-file-pinboard .chat-file-chip-name {
  font-size: 13px;
  color: var(--text-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.chatForm .chat-file-chip-status,
.user-message .message-file-pinboard .chat-file-chip-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-text);
  font-size: 18px;
  flex-shrink: 0;
}

.chatForm .chat-file-chip-status.spin,
.user-message .message-file-pinboard .chat-file-chip-status.spin {
  animation: spin 1s linear infinite;
}

.chatForm .chat-file-chip-action,
.user-message .message-file-pinboard .chat-file-chip-action {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
  flex-shrink: 0;
}

.chatForm .chat-file-chip-action:hover,
.user-message .message-file-pinboard .chat-file-chip-action:hover {
  background: var(--hover-bg);
  color: var(--text-color);
  opacity: 1;
}

.chatForm .chat-file-chip-action.danger:hover,
.user-message .message-file-pinboard .chat-file-chip-action.danger:hover {
  background: rgba(var(--error-color-rgb, 229, 57, 53), 0.12);
  color: var(--error-color, #e53935);
}

/* Thumbnail mode styles for file pinboard */
.chatForm .chat-file-pinboard[data-display-mode="thumbnail"],
.user-message .message-file-pinboard.chat-file-pinboard[data-display-mode="thumbnail"] {
  gap: 10px;
  align-items: flex-start;
}

.chatForm .chat-file-thumbnail-card,
.user-message .message-file-pinboard .chat-file-thumbnail-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 120px;
  min-width: 120px;
  background: var(--tile-elevation-1);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.chatForm .chat-file-thumbnail-card:hover,
.user-message .message-file-pinboard .chat-file-thumbnail-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color);
}

.chatForm .chat-file-thumbnail-card:hover .chat-file-thumbnail-actions,
.user-message .message-file-pinboard .chat-file-thumbnail-card:hover .chat-file-thumbnail-actions {
  opacity: 1;
}

.chatForm .chat-file-thumbnail-card:focus-within,
.user-message .message-file-pinboard .chat-file-thumbnail-card:focus-within {
  outline: none;
  box-shadow: none;
}

.chatForm .chat-file-thumbnail-card:has(:focus-visible),
.user-message .message-file-pinboard .chat-file-thumbnail-card:has(:focus-visible) {
  box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb), 0.5);
}
.chatForm .chat-file-thumbnail-card.processing,
.user-message .message-file-pinboard .chat-file-thumbnail-card.processing {
  opacity: 0.7;
}

.chatForm .chat-file-thumbnail-preview,
.user-message .message-file-pinboard .chat-file-thumbnail-preview {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tile-elevation-2);
  overflow: hidden;
  position: relative;
}

.chatForm .chat-file-thumbnail-preview .chat-file-thumbnail-body,
.user-message .message-file-pinboard .chat-file-thumbnail-preview .chat-file-thumbnail-body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chatForm .chat-file-thumbnail-preview .chat-file-format-badge,
.user-message .message-file-pinboard .chat-file-thumbnail-preview .chat-file-format-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 3;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  line-height: 1.2;
  background: var(--format-color, rgba(0, 0, 0, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  pointer-events: none;
  user-select: none;
}

.chatForm .fmt-pdf,
.user-message .message-file-pinboard .fmt-pdf {
  --format-color: var(--error-color);
}

.chatForm .fmt-xlsx,
.chatForm .fmt-xls,
.chatForm .fmt-csv,
.user-message .message-file-pinboard .fmt-xlsx,
.user-message .message-file-pinboard .fmt-xls,
.user-message .message-file-pinboard .fmt-csv {
  --format-color: var(--success-color);
}

.chatForm .fmt-docx,
.chatForm .fmt-doc,
.user-message .message-file-pinboard .fmt-docx,
.user-message .message-file-pinboard .fmt-doc {
  --format-color: var(--accent-color);
}

.chatForm .fmt-md,
.user-message .message-file-pinboard .fmt-md {
  --format-color: var(--accent-color-light);
}

.chatForm .fmt-pptx,
.chatForm .fmt-ppt,
.user-message .message-file-pinboard .fmt-pptx,
.user-message .message-file-pinboard .fmt-ppt {
  --format-color: var(--ppt-color, var(--warning-color));
}

.chatForm .fmt-archive,
.user-message .message-file-pinboard .fmt-archive {
  --format-color: var(--accent-color-dark);
}

.chatForm .fmt-code,
.user-message .message-file-pinboard .fmt-code {
  --format-color: #9c27b0;
}

.chatForm .fmt-xml,
.user-message .message-file-pinboard .fmt-xml {
  --format-color: #9c27b0;
}

.chatForm .fmt-config,
.user-message .message-file-pinboard .fmt-config {
  --format-color: #e65100;
}

/* Compact mode: color the main file icon using the same format color as thumbnail badges */
.chatForm .chat-file-chip.fmt-pdf .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-xlsx .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-xls .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-csv .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-docx .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-doc .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-md .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-pptx .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-ppt .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-archive .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-code .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-config .chat-file-chip-icon,
.chatForm .chat-file-chip.fmt-default .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-pdf .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-xlsx .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-xls .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-csv .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-docx .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-doc .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-md .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-pptx .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-ppt .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-archive .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-code .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-config .chat-file-chip-icon,
.user-message .message-file-pinboard .chat-file-chip.fmt-default .chat-file-chip-icon {
  color: var(--format-color, var(--muted-text));
}

.chatForm .chat-file-thumbnail-preview img,
.user-message .message-file-pinboard .chat-file-thumbnail-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatForm .chat-file-thumbnail-text,
.user-message .message-file-pinboard .chat-file-thumbnail-text {
  width: 100%;
  height: 100%;
  padding: 8px;
  font-size: 10px;
  line-height: 1.25;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
  word-break: break-word;
  opacity: 0.9;
}

.chatForm .chat-file-thumbnail-markdown,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown {
  width: 100%;
  height: 100%;
  padding: 8px;
  font-size: 10px;
  line-height: 1.25;
  color: var(--text-color);
  overflow: hidden;
  word-break: break-word;
  opacity: 0.95;
}

.chatForm .chat-file-thumbnail-markdown > :first-child,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown > :first-child {
  margin-top: 0;
}

.chatForm .chat-file-thumbnail-markdown > :last-child,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown > :last-child {
  margin-bottom: 0;
}

.chatForm .chat-file-thumbnail-markdown p,
.chatForm .chat-file-thumbnail-markdown li,
.chatForm .chat-file-thumbnail-markdown blockquote,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown p,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown li,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown blockquote {
  margin: 0 0 4px;
  font-size: 10px;
  line-height: 1.25;
}

.chatForm .chat-file-thumbnail-markdown h1,
.chatForm .chat-file-thumbnail-markdown h2,
.chatForm .chat-file-thumbnail-markdown h3,
.chatForm .chat-file-thumbnail-markdown h4,
.chatForm .chat-file-thumbnail-markdown h5,
.chatForm .chat-file-thumbnail-markdown h6,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h1,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h2,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h3,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h4,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h5,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown h6 {
  margin: 0 0 4px;
  font-size: 10px;
  line-height: 1.25;
  font-weight: 600;
}

.chatForm .chat-file-thumbnail-markdown ul,
.chatForm .chat-file-thumbnail-markdown ol,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown ul,
.user-message .message-file-pinboard .chat-file-thumbnail-markdown ol {
  margin: 0 0 4px 14px;
  padding: 0;
}

.chatForm .chat-file-thumbnail-code,
.user-message .message-file-pinboard .chat-file-thumbnail-code {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.chatForm .chat-file-thumbnail-code .chat-file-code-preview,
.user-message .message-file-pinboard .chat-file-thumbnail-code .chat-file-code-preview {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 6px 8px;
  font-size: 9px;
  line-height: 1.4;
  overflow: hidden;
  background: var(--code-bg, #1e1e1e);
  color: var(--text-color);
  border: none;
  border-radius: 0;
}

.chatForm .chat-file-thumbnail-code .chat-file-code-preview code,
.user-message .message-file-pinboard .chat-file-thumbnail-code .chat-file-code-preview code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 9px;
  line-height: 1.4;
  color: inherit;
  background: transparent;
  padding: 0;
  border: none;
  display: block;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatForm .chat-file-thumbnail-icon,
.user-message .message-file-pinboard .chat-file-thumbnail-icon {
  font-size: 36px;
  color: var(--muted-text);
  user-select: none;
}

.config-file-thumbnail {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.config-file-thumbnail .config-file-doc {
  font-size: 36px;
  color: var(--muted-text);
  user-select: none;
}

.config-file-thumbnail .config-file-eye {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 14px;
  color: var(--error-color, #F44336);
  background: rgba(var(--error-color-rgb, 244, 67, 54), 0.12);
  border-radius: 50%;
  padding: 3px;
  line-height: 1;
}

.chatForm .chat-file-thumbnail-processing,
.user-message .message-file-pinboard .chat-file-thumbnail-processing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatForm .chat-file-thumbnail-processing .material-symbols-rounded,
.user-message .message-file-pinboard .chat-file-thumbnail-processing .material-symbols-rounded {
  font-size: 24px;
  color: white;
}

.chatForm .chat-file-thumbnail-preview .thumbnail-loading,
.user-message .message-file-pinboard .chat-file-thumbnail-preview .thumbnail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.chatForm .chat-file-thumbnail-preview .thumbnail-loading .material-symbols-rounded,
.user-message .message-file-pinboard .chat-file-thumbnail-preview .thumbnail-loading .material-symbols-rounded {
  font-size: 28px;
  color: var(--muted-text);
}

.chatForm .chat-file-thumbnail-info,
.user-message .message-file-pinboard .chat-file-thumbnail-info {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chatForm .chat-file-thumbnail-name,
.user-message .message-file-pinboard .chat-file-thumbnail-name {
  font-size: 11px;
  color: var(--text-color);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.chatForm .chat-file-thumbnail-actions,
.user-message .message-file-pinboard .chat-file-thumbnail-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.chatForm .chat-file-thumbnail-action,
.user-message .message-file-pinboard .chat-file-thumbnail-action {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  opacity: 1;
}

.chatForm .chat-file-thumbnail-action .material-symbols-rounded,
.user-message .message-file-pinboard .chat-file-thumbnail-action .material-symbols-rounded {
  font-size: 16px;
}

.chatForm .chat-file-thumbnail-action:hover,
.user-message .message-file-pinboard .chat-file-thumbnail-action:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.chatForm .chat-file-thumbnail-action:focus,
.user-message .message-file-pinboard .chat-file-thumbnail-action:focus {
  outline: none;
  outline-offset: 0;
}

.chatForm .chat-file-thumbnail-action:focus-visible,
.user-message .message-file-pinboard .chat-file-thumbnail-action:focus-visible {
  outline: 2px solid rgba(var(--accent-color-rgb), 0.5);
  outline-offset: 2px;
}

.chatForm .chat-file-thumbnail-action.danger:hover,
.user-message .message-file-pinboard .chat-file-thumbnail-action.danger:hover {
  background: var(--error-color);
}

body[color-scheme="dark"] .chat-file-thumbnail-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

body[color-scheme="dark"] .chat-file-thumbnail-action {
  /* Keep strong contrast over light thumbnails (PDF/text previews) even in dark mode */
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

body[color-scheme="dark"] .chat-file-thumbnail-action:hover {
  background: rgba(0, 0, 0, 0.8);
}

@media (max-width: 768px) {
  .chatForm .chat-file-thumbnail-card {
    width: 100px;
    min-width: 100px;
  }
  
  .chatForm .chat-file-thumbnail-preview {
    height: 60px;
  }
  
  .chatForm .chat-file-thumbnail-icon {
    font-size: 28px;
  }
  
  .chatForm .chat-file-thumbnail-info {
    padding: 4px 6px;
  }
  
  .chatForm .chat-file-thumbnail-name {
    font-size: 10px;
  }
}

.chatForm .input-wrapper {
  position: relative;
}

.chatForm .input-wrapper:has(.chat-file-pinboard:not(:empty)) {
  padding-top: 0;
}

.chatForm .input-wrapper:has(.chat-file-pinboard:not(:empty)) .messageInput {
  margin-top: 0;
  padding-top: 12px;
}

.chatForm .messageInput {
  width: 100%;
  padding: 7px 8px 7px 15px;
  font-size: 17px;
  border: none;
  outline: none;
  resize: none;
  height: 38px;
  min-height: 38px;
  max-height: 180px;
  font-family: inherit;
  color: var(--text-color);
  background-color: transparent;
  line-height: 1.4;
  caret-color: var(--text-color);
  caret-shape: bar;
  overflow-y: hidden;
  overflow-x: hidden;
  box-sizing: border-box;
}

.chatForm .messageInput::-webkit-scrollbar {
  width: 4px;
}

.chatForm .messageInput::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.chatForm .messageInput:not(:placeholder-shown) ~ .input-hint {
  opacity: 0;
  transform: translateY(-60%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chatForm .input-hint {
  position: absolute;
  right: 15px;
  bottom: 10px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Hide the hint while the input is focused (even when empty), fade it back in on blur if still empty */
.chatForm .messageInput:focus ~ .input-hint {
  opacity: 0;
  transform: translateY(-60%);
}

.chatForm .chat-button-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 0;
}

.chatForm .voice-status {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--tile-bg);
  min-height: 32px;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.chatForm .voice-status[hidden] {
  display: none;
}

.chatForm .voice-status[data-state="listening"],
.chatForm .voice-status[data-state="capturing"] {
  background: rgba(213, 0, 50, 0.08);
  border-color: rgba(213, 0, 50, 0.24);
  box-shadow: 0 8px 16px rgba(213, 0, 50, 0.06);
}

.chatForm .voice-status[data-state="processing"] {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.chatForm .voice-status .voice-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatForm .voice-status .voice-status-icon {
  font-size: 22px;
  color: var(--primary-color, #d50032);
  animation: voice-soft-pulse 1.6s ease-in-out infinite;
}

.chatForm .voice-status .voice-visualizer {
  display: inline-flex;
  gap: 4px;
  height: 14px;
  align-items: flex-end;
}

.chatForm .voice-status .voice-bar {
  width: 3px;
  border-radius: 12px;
  background: var(--primary-color, #d50032);
  animation: none;
}

.chatForm .voice-status .voice-bar:nth-child(2) {
  animation-delay: 0.1s;
}

.chatForm .voice-status .voice-bar:nth-child(3) {
  animation-delay: 0.2s;
}

.chatForm .voice-status .voice-bar:nth-child(4) {
  animation-delay: 0.3s;
}

.chatForm .voice-status[data-animating="true"] .voice-bar {
  animation: voice-bar 0.9s ease-in-out infinite;
}

.chatForm .voice-status[data-state="processing"] .voice-bar {
  animation: none;
  background: var(--text-muted);
}

.chatForm .voice-status .voice-status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chatForm .voice-status .voice-status-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-color);
  line-height: 1.2;
}

.chatForm .voice-status .voice-status-detail {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

@keyframes voice-soft-pulse {
  0% {
    transform: scale(1);
    opacity: 0.75;
    filter: drop-shadow(0 0 0px rgba(213, 0, 50, 0.15));
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(213, 0, 50, 0.28));
  }
  100% {
    transform: scale(1);
    opacity: 0.75;
    filter: drop-shadow(0 0 0px rgba(213, 0, 50, 0.15));
  }
}

@keyframes voice-bar {
  0% {
    height: 4px;
    opacity: 0.5;
  }
  50% {
    height: 14px;
    opacity: 1;
  }
  100% {
    height: 6px;
    opacity: 0.7;
  }
}

.chatForm .chat-left-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-left: 8px;
}

.chatForm .chat-right-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 8px;
}

.chatForm .chat-right-buttons > * {
  margin: 0;
}

.chatForm .chat-token-usage-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.2s ease;
}

/* Dark mode: keep token gauge needle in neutral grey, independent of gauge color */
body[color-scheme="dark"] .chatForm .chat-token-usage-btn .token-needle path,
body[color-scheme="dark"] .chatForm .chat-token-usage-btn .token-needle circle {
  stroke: #eaecef;
  fill: #afb2b7;
}

body[color-scheme="dark"] .chatForm .chat-token-usage-btn .token-needle .token-needle-tip {
  fill: #afb2b7;
  opacity: 0.9;
}

.chatForm .chat-token-usage-btn:focus,
.chatForm .chat-token-usage-btn:focus-visible,
.chatForm .chat-token-usage-btn:active {
  outline: none;
  box-shadow: none;
}

.chatForm .chat-token-usage-btn:hover {
  opacity: 1;
  background: var(--hover-bg);
  transform: scale(1.08);
}

.chatForm .chat-token-usage-btn svg {
  width: 28px;
  height: 28px;
}

.chatForm button {
  background: none;
  border: none;
  opacity: 0.7;
  font-size: 28px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatForm button:hover {
  opacity: 1;
}

.chatForm .chat-plus-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-color);
  background: transparent;
  border: none;
  font-size: 32px;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.chatForm .chat-plus-btn:focus, .chatForm .chat-plus-btn:focus-visible {
  outline: none;
  box-shadow: none;
}

.chatForm .chat-plus-btn:active {
  box-shadow: none;
  color: var(--primary-color, #d50032);
  transform: scale(0.92);
  animation: button-press 0.3s ease;
}

.chatForm .chat-plus-btn:hover {
  background: var(--hover-bg);
  opacity: 1;
  transform: scale(1.08);
}

.chatForm .chat-plus-btn.active {
  background: var(--hover-bg);
}

.chatForm .chat-tools-btn, .chatForm .chat-reset-btn, .chatForm .chat-submit-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-color);
  background: transparent;
  border: none;
  font-size: 28px;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.chatForm .chat-tools-btn:focus, .chatForm .chat-tools-btn:focus-visible, .chatForm .chat-reset-btn:focus, .chatForm .chat-reset-btn:focus-visible {
  outline: none;
  box-shadow: none;
}

.chatForm .chat-tools-btn:active, .chatForm .chat-reset-btn:active {
  box-shadow: none;
  color: var(--primary-color, #d50032);
  transform: scale(0.92);
  animation: button-press 0.3s ease;
}

.chatForm .chat-tools-btn:hover, .chatForm .chat-reset-btn:hover {
  background: var(--hover-bg);
  opacity: 1;
}

.chatForm .chat-tools-btn.active, .chatForm .chat-reset-btn.active {
  background: var(--hover-bg);
}

.chatForm .chat-reset-btn {
  margin-left: 0;
}

.chatForm .chat-submit-btn {
  transition: all 0.2s ease;
}

.chatForm .chat-submit-btn:hover {
  transform: scale(1.08);
}

.chatForm .chat-submit-btn[data-mode="mic"] {
  opacity: 0.7;
  animation: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn[data-mode="mic"]:hover {
  background: var(--hover-bg);
  opacity: 1;
  transform: scale(1.08);
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn[data-mode="mic"]:focus, .chatForm .chat-submit-btn[data-mode="mic"]:focus-visible, .chatForm .chat-submit-btn[data-mode="mic"]:active {
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn[data-mode="send"] {
  opacity: 1;
  color: var(--primary-color, #d50032) !important;
  animation: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn[data-mode="send"]:hover {
  opacity: 1;
  background: var(--hover-bg);
  color: var(--primary-color, #d50032) !important;
  transform: scale(1.15);
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn[data-mode="send"]:active {
  color: var(--primary-color, #d50032) !important;
  transform: scale(0.92);
  animation: button-press 0.3s ease;
  border: none;
  outline: none;
  box-shadow: none;
}

.chatForm .chat-submit-btn.voice-listening {
  color: #ff4444;
  opacity: 1;
  animation: pulse 1.5s ease-in-out infinite;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.chatForm .chat-submit-btn.voice-listening:hover {
  color: #ff6666;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.chatForm .chat-submit-btn.voice-listening:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.chatForm .chat-plus-btn.active:hover {
  transform: none;
}

.chatForm .chat-tools-btn:hover, .chatForm .chat-reset-btn:hover {
  transform: scale(1.08);
}

.chatForm .chat-model-dropdown-wrapper {
  position: relative;
  display: inline-flex;
  margin-right: 4px;
}

.chatForm .chat-model-btn {
  height: 32px;
  min-width: 60px;
  max-width: 150px;
  padding: 0 8px 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-color);
  background: transparent;
  border: 1px solid var(--border-color);
  opacity: 0.8;
  white-space: nowrap;
  width: auto;
  transition: all 0.2s ease;
}

.chatForm .chat-model-btn .model-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatForm .chat-model-btn .dropdown-arrow {
  font-size: 18px;
  transition: transform 0.2s ease;
}

.chatForm .chat-model-btn[aria-expanded="true"] {
  background: var(--hover-bg);
  opacity: 1;
  border-color: var(--text-color);
}

.chatForm .chat-model-btn[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

.chatForm .chat-model-btn:focus, .chatForm .chat-model-btn:focus-visible {
  outline: none;
  box-shadow: none;
}

.chatForm .chat-model-btn:active {
  box-shadow: none;
  color: var(--primary-color, #d50032);
  border-color: var(--primary-color, #d50032);
  transform: scale(0.96);
  animation: button-press 0.3s ease;
}

.chatForm .chat-model-btn:hover {
  background: var(--hover-bg);
  opacity: 1;
  border-color: var(--text-color);
}

.chatForm .chat-model-btn.active {
  background: var(--hover-bg);
}

.chatForm .chat-model-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--tile-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  padding: 4px;
  overflow: hidden;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.chatForm .chat-model-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chatForm .chat-model-dropdown .chat-model-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.chatForm .chat-model-dropdown .chat-model-item:hover {
  background: #fff;
  color: var(--primary-color, #d50032);
  transform: scale(1.05);
}

.chatForm .chat-model-dropdown .chat-model-item.active {
  background: var(--hover-bg);
  color: var(--primary-color, #d50032);
  font-weight: 600;
}

.chatForm .chat-plus-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--tile-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  padding: 4px;
  overflow: hidden;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.chatForm .chat-plus-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chatForm .chat-plus-menu .chat-plus-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 15px;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.chatForm .chat-plus-menu .chat-plus-item .material-symbols-rounded {
  font-size: 22px;
  opacity: 0.7;
}

.chatForm .chat-plus-menu .chat-plus-item .item-text {
  flex: 1;
}

.chatForm .chat-plus-menu .chat-plus-item:hover {
  background: #fff;
  color: var(--primary-color, #d50032);
  transform: scale(1.03);
}

.chatForm .chat-plus-menu .chat-plus-item:hover .material-symbols-rounded {
  opacity: 1;
}

.message-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
  opacity: 1;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: var(--half);
  background: var(--tile-bg);
  z-index: 10;
}

.user-message .message-actions {
  position: absolute;
  right: 0;
  left: auto;
  top: 100%;
  transform: none;
  margin-top: 2px;
}

.ai-message .message-actions {
  position: absolute;
  left: 0;
  right: auto;
  top: 100%;
  transform: none;
  margin-top: 2px;
}

.message-actions .message-edit-icon, .message-actions .message-quote-icon, .message-actions .message-copy-icon, .message-actions .message-export-icon {
  cursor: pointer;
  opacity: 0.5;
  color: var(--text-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
  width: 24px;
  height: 24px;
  font-size: 22px;
  border-radius: 6px;
}

.message-actions .message-edit-icon:hover, .message-actions .message-quote-icon:hover, .message-actions .message-copy-icon:hover, .message-actions .message-export-icon:hover {
  opacity: 0.9;
  background: var(--hover-bg);
}

.user-message .message-actions {
  opacity: 0;
}

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

.quoted {
  border-left: 3px solid var(--primary-color);
  padding-left: 8px;
}

blockquote {
  margin: 0;
}

.quick-reply-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--half);
}

.quick-reply-container .quick-reply-message {
  display: flex;
  gap: var(--half);
}

.quick-reply-container .quick-reply-message.loading {
  opacity: 1;
}

.quick-reply-container .quick-reply-message.loading .message-content .loading-icon {
  animation: spin 1.5s linear infinite;
}

.quick-reply-container .quick-reply-message .message-edit-icon {
  opacity: 0;
  cursor: pointer;
  font-size: 20px;
}

.quick-reply-container .quick-reply-message:hover .message-edit-icon {
  opacity: 0.3;
}

.quick-reply-container .quick-reply-message:hover .message-edit-icon:hover {
  opacity: 1;
}

.quick-reply-container .quick-reply-message .message-content {
  display: flex;
  align-items: center;
  gap: var(--half);
  cursor: pointer;
  opacity: 0.5;
}

.quick-reply-container .quick-reply-message .message-content:hover {
  opacity: 1;
}

.quick-reply-container .quick-reply-message .message-content .prompt-icon {
  opacity: 0.5;
  font-size: 20px;
}

.quick-reply-container .quick-reply-message .message-content .suggestion-text {
  font-size: 0.9em;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.chatBox .chat-skeleton .ai-message.skeleton {
  background: var(--ai-message-bg);
  border-radius: 8px;
  padding: var(--one) 0;
}

.chatBox .chat-skeleton .ai-message.skeleton .message-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chatBox .chat-skeleton .ai-message.skeleton .message-content .skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.06));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.chatForm.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.user-message.editing {
  background: var(--ai-message-bg);
  max-width: 100%;
  width: 80%;
}

/* Action buttons for file cards in edit mode - match chatbox design */
.user-message.editing .edit-mode-delete-btn,
.user-message.editing .edit-mode-preview-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  opacity: 1;
}

.user-message.editing .edit-mode-delete-btn .material-symbols-rounded,
.user-message.editing .edit-mode-preview-btn .material-symbols-rounded {
  font-size: 16px;
}

.user-message.editing .edit-mode-preview-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.user-message.editing .edit-mode-delete-btn:hover {
  background: var(--error-color);
  transform: scale(1.1);
}

.user-message.editing .edit-mode-delete-btn:focus,
.user-message.editing .edit-mode-preview-btn:focus {
  outline: none;
  outline-offset: 0;
}

.user-message.editing .edit-mode-delete-btn:focus-visible,
.user-message.editing .edit-mode-preview-btn:focus-visible {
  outline: 2px solid rgba(var(--accent-color-rgb), 0.5);
  outline-offset: 2px;
}

/* For thumbnail cards in edit mode */
.user-message.editing .chat-file-thumbnail-card {
  position: relative;
}

.user-message.editing .edit-mode-file-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

/* Hide original action buttons in edit mode to prevent overlap */
.user-message.editing .chat-file-chip-action,
.user-message.editing .chat-file-thumbnail-action {
  display: none !important;
}

/* For chips in edit mode - match chatbox design */
.user-message.editing .chat-file-chip .edit-mode-delete-btn,
.user-message.editing .chat-file-chip .edit-mode-preview-btn {
  position: static;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted-text);
  margin-left: 4px;
  opacity: 0.85;
  flex-shrink: 0;
}

.user-message.editing .chat-file-chip .edit-mode-delete-btn .material-symbols-rounded,
.user-message.editing .chat-file-chip .edit-mode-preview-btn .material-symbols-rounded {
  font-size: 18px;
}

.user-message.editing .chat-file-chip .edit-mode-preview-btn:hover {
  background: var(--tile-elevation-2);
  color: var(--text-color);
  opacity: 1;
}

.user-message.editing .chat-file-chip .edit-mode-delete-btn:hover {
  background: rgba(var(--error-color-rgb, 229, 57, 53), 0.12);
  color: var(--error-color, #e53935);
  opacity: 1;
}

body[color-scheme="dark"] .user-message.editing .edit-mode-delete-btn,
body[color-scheme="dark"] .user-message.editing .edit-mode-preview-btn {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

body[color-scheme="dark"] .user-message.editing .edit-mode-preview-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

body[color-scheme="dark"] .user-message.editing .edit-mode-delete-btn:hover {
  background: var(--error-color);
}

.user-message .edit-textarea {
  width: 100%;
  min-height: 120px;
  max-height: 50vh;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: var(--half);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-color);
  background: var(--background-color);
}

.user-message .edit-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--half);
  margin-top: var(--half);
}

.user-message .edit-save-icon, .user-message .edit-cancel-icon {
  cursor: pointer;
  opacity: 0.7;
}

.user-message .edit-save-icon:hover, .user-message .edit-cancel-icon:hover {
  opacity: 1;
}
