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

/* Dark mode (default) */
:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --text-primary: #e8e8e8;
  --text-secondary: #888;
  --text-muted: #666;
  --accent: #5D9A9A;
  --accent-hover: #6DAAAA;
  --user-bubble: #3a3a3a;
  --border: #333;
  --color-success: #4CAF50;
  --color-success-bg: rgba(76, 175, 80, 0.15);
  --color-error: #ff6b6b;
  --color-error-bg: rgba(255, 100, 100, 0.2);
  --color-error-bg-hover: rgba(255, 100, 100, 0.3);
}

/* Light mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #888;
    --accent: #4D8A8A;
    --accent-hover: #3D7A7A;
    --user-bubble: #e8e8e8;
    --border: #ddd;
    --color-success: #2e7d32;
    --color-success-bg: rgba(46, 125, 50, 0.12);
    --color-error: #c62828;
    --color-error-bg: rgba(198, 40, 40, 0.15);
    --color-error-bg-hover: rgba(198, 40, 40, 0.25);
    --shadow: rgba(0, 0, 0, 0.1);
    --overlay: rgba(0, 0, 0, 0.3);
  }

  .model-dropdown {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }

  .modal-overlay {
    background: rgba(0, 0, 0, 0.4);
  }

  .send-btn svg {
    stroke: white;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.loading-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Simple model dropdown */
.model-selector {
  position: relative;
}

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

.model-selector-btn:hover {
  background: var(--bg-tertiary);
}

.model-selector-btn svg {
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.model-selector.open .model-selector-btn svg {
  transform: rotate(180deg);
}

.model-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 180px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 50;
  overflow-y: auto;
}

.model-dropdown.hidden {
  display: none;
}

.model-list {
  padding: 6px 0;
}

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

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

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

.model-item .check {
  width: 16px;
  color: var(--accent);
  opacity: 0;
}

.model-item.active .check {
  opacity: 1;
}

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

.header-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

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

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* User message */
.message.user {
  align-self: flex-end;
  max-width: 85%;
  padding: 12px 16px;
  background: var(--user-bubble);
  border-radius: 16px;
  border-bottom-right-radius: 4px;
}

/* Assistant message */
.message.assistant {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message.assistant .bullet {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  margin-top: 8px;
  flex-shrink: 0;
}

.message.assistant .content {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.message.assistant .content p {
  margin-bottom: 8px;
}

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

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

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

.message.assistant .content li {
  margin: 4px 0;
}

.message.assistant .content h3,
.message.assistant .content h4,
.message.assistant .content h5 {
  font-weight: 600;
  margin: 12px 0 8px;
}

.message.assistant .content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
}

/* Streaming cursor */
.message.assistant.streaming .content::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

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

/* Steps section */
.steps-section {
  margin: 12px 0;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.steps-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  padding: 12px 14px;
  transition: background 0.15s;
}

.steps-toggle:hover {
  background: var(--bg-tertiary);
}

.steps-toggle .toggle-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--accent);
}

.steps-toggle .toggle-icon svg {
  width: 14px;
  height: 14px;
}

.steps-toggle .toggle-text {
  flex: 1;
}

.steps-toggle .chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.steps-toggle.expanded .chevron {
  transform: rotate(180deg);
}

.steps-list {
  display: none;
  border-top: 1px solid var(--border);
  padding: 8px 0 16px;
  max-height: 300px;
  overflow-y: auto;
}

.steps-list.visible {
  display: block;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  position: relative;
}

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

/* Timeline connector */
.step-item::before {
  content: '';
  position: absolute;
  left: 23px;
  top: 32px;
  bottom: -10px;
  width: 2px;
  background: var(--border);
}

.step-item:last-child::before {
  display: none;
}

.step-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
  z-index: 1;
}

.step-icon svg {
  width: 12px;
  height: 12px;
}

.step-icon.success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.step-icon.pending {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.step-icon .spinner {
  animation: spin 1s linear infinite;
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-label {
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-result {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-status {
  font-size: 11px;
  color: var(--color-success);
  flex-shrink: 0;
}

/* Tool indicator */
.tool-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  margin: 8px 0;
}

.tool-indicator .indicator-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-indicator .indicator-icon svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

.tool-indicator .sparkle {
  width: 14px;
  height: 14px;
  color: var(--accent);
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

/* Thinking dots animation */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 0;
}

.sparkle-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sparkle-container .sparkle {
  width: 18px;
  height: 18px;
  color: var(--accent);
  animation: spin 2s linear infinite;
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 2px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
}

/* Settings Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: min(480px, calc(100% - 24px));
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.settings-modal {
  width: min(520px, calc(100% - 24px));
}

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

.modal-header .close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-header .close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}

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

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

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

/* Provider cards in settings */
.provider-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.provider-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.provider-card:hover {
  border-color: var(--text-muted);
}

.provider-card.selected {
  border-color: var(--accent);
}

.provider-card.configured {
  position: relative;
}

.provider-card .provider-name {
  font-weight: 500;
  font-size: 13px;
}

.provider-card .check-badge {
  color: var(--accent);
  font-size: 14px;
  margin-left: 4px;
}

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

.provider-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-muted);
}

.provider-status.configured {
  background: rgba(212, 132, 95, 0.2);
  color: var(--accent);
}

.provider-models {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Provider sections in settings */
.provider-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.provider-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.provider-section h4 {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.provider-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.provider-desc a {
  color: var(--accent);
}

.install-cmd {
  display: block;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 12px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  user-select: all;
}

.connected-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-badge.connected {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* API key input */
.api-key-input {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.api-key-input label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.api-key-input input,
.api-key-input select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
}

.api-key-input input:focus,
.api-key-input select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Custom models */
.custom-model-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

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

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

.custom-model-form input::placeholder {
  color: var(--text-muted);
}

.custom-models-list {
  margin-top: 20px;
}

.custom-models-list h4 {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.custom-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.custom-model-item .model-info {
  flex: 1;
  min-width: 0;
}

.custom-model-item .model-name {
  font-weight: 500;
  font-size: 14px;
}

.custom-model-item .model-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-model-item .delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  margin-left: 8px;
}

.custom-model-item .delete-btn:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

.btn-danger {
  background: var(--color-error-bg);
  color: var(--color-error);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Tabs in modal */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: block;
}

.tab-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Input area */
.input-area {
  padding: 12px 16px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.input-container {
  background: var(--bg-tertiary);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.input-container.drag-over {
  border-color: var(--accent);
  background: rgba(93, 154, 154, 0.1);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
}

.input-row .input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 24px;
  max-height: 150px;
  line-height: 1.4;
  padding: 6px 4px;
}

.input-row .input:focus {
  outline: none;
}

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

textarea {
  width: 100%;
  padding: 14px 16px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 24px;
  max-height: 150px;
  line-height: 1.4;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: var(--text-muted);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

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

.toggle-btn.active {
  color: var(--accent);
}

.toggle-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn {
  padding: 8px 16px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: white;
  font-size: 14px;
  font-weight: 500;
}

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

.send-btn:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
  color: var(--text-muted);
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.ask-before-btn {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.ask-before-btn.active {
  color: var(--accent);
}

.ask-before-btn svg {
  width: 18px;
  height: 18px;
}

.stop-btn {
  padding: 8px 16px;
  background: var(--color-error);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: white;
  font-size: 14px;
  font-weight: 500;
}

.stop-btn:hover {
  background: var(--color-error);
}

.stop-btn svg {
  width: 14px;
  height: 14px;
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 40px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state .empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h2 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 14px;
  max-width: 280px;
  margin-bottom: 16px;
}

.empty-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 320px;
}

.example-chip {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.example-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.message.error {
  color: var(--color-error);
  font-size: 14px;
  padding: 8px 0;
}

.message.system {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 0;
  text-align: center;
}

/* Image drop & preview */
.image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.image-preview.hidden {
  display: none;
}

.image-preview-item {
  position: relative;
  display: inline-block;
}

.image-preview-item img {
  max-height: 60px;
  max-width: 120px;
  border-radius: 6px;
  object-fit: cover;
}

.image-preview-item .remove-image-btn,
.remove-image-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--bg-primary);
  border: none;
  color: var(--text-secondary);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-item .remove-image-btn:hover,
.remove-image-btn:hover {
  background: var(--color-error);
  color: white;
}

/* Domain skills section */
.skills-section {
  margin-bottom: 16px;
}

.skills-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.skills-section-title {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-icon {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.skills-list {
  max-height: 250px;
  overflow-y: auto;
}

.skills-list h4 {
  font-size: 12px;
  color: var(--text-muted);
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.skills-list h4:first-child {
  margin-top: 0;
}

/* Domain skills list */
.skill-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.skill-item:hover {
  border-color: var(--text-muted);
}

.skill-item.builtin {
  opacity: 0.7;
  cursor: default;
}

.skill-item .skill-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.skill-item .skill-info {
  flex: 1;
  min-width: 0;
}

.skill-item .skill-domain {
  font-weight: 500;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-item .skill-domain .builtin-badge {
  font-size: 9px;
  padding: 1px 5px;
  background: var(--bg-primary);
  border-radius: 4px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.skill-item .skill-preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.skill-item .skill-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.skill-item .skill-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.skill-item .skill-actions button:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.skill-item .skill-actions button.delete-btn:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* Skill form */
.skill-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
}

.skill-form.hidden {
  display: none;
}

.skill-form input,
.skill-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 10px;
}

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

.skill-form textarea {
  resize: vertical;
  min-height: 100px;
}

.skill-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 500;
  font-size: 14px;
}

.skill-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

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

/* Plan modal */
.plan-section {
  margin-bottom: 16px;
}

.plan-section h4 {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.plan-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
}

.plan-domains li {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  font-size: 13px;
}

.plan-steps {
  padding-left: 20px;
  font-size: 14px;
}

.plan-steps li {
  margin-bottom: 6px;
}

/* Horizontal rule in settings */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Advanced collapsible sections */
.advanced-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.advanced-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  list-style: none;
}

.advanced-section summary::-webkit-details-marker {
  display: none;
}

.advanced-section[open] summary {
  margin-bottom: 4px;
  color: var(--text-primary);
}

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

button:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.model-selector-btn:focus-visible,
.model-item:focus-visible,
.tab:focus-visible,
.example-chip:focus-visible,
.provider-card:focus-visible,
.steps-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.send-btn:focus-visible,
.stop-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
