/* Components — buttons, cards, forms, badges, chat, toasts.
   All token references match variables.css; dark mode happens automatically. */

/* === Buttons. Tighter padding, refined active scale. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast),
              border-color var(--duration-fast), transform var(--duration-fast),
              box-shadow var(--duration-fast);
  white-space: nowrap; line-height: 1.4;
  letter-spacing: -0.005em;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn svg { width: 15px; height: 15px; stroke-width: 1.7; }

.btn-primary {
  background: var(--accent); color: var(--text-on-accent);
  box-shadow: 0 1px 1px rgba(0,0,0,0.04), inset 0 -1px 0 rgba(0,0,0,0.08);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--status-error); color: white; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }

.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 10px 22px; font-size: var(--text-sm); }
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-icon svg { width: 14px; height: 14px; }

/* === Cards — flat by default, lift on hover for interactive variants. */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-fast),
              transform    var(--duration-fast),
              box-shadow   var(--duration-fast);
}
.card-interactive:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
}
.card-header h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  color: var(--text-primary);
}
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
}

/* === Form */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  letter-spacing: 0;
}
.form-hint { font-size: 11px; color: var(--text-tertiary); }

.form-input, .form-select {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2386868b' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

/* === Toggle group === */
.toggle-group {
  display: inline-flex;
  background: var(--bg-input);
  border-radius: var(--radius-md); padding: 3px;
}
.toggle-btn {
  padding: 6px 16px; font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.toggle-btn:hover { color: var(--text-primary); }
.toggle-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-button);
}

/* === Upload zone === */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg); padding: var(--space-8);
  text-align: center; cursor: pointer;
  transition: border-color var(--duration-base), background var(--duration-base);
  background: var(--bg-input); position: relative;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone.drag-over { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.upload-zone.has-file { border-color: var(--status-success); border-style: solid; background: rgba(52,199,89,0.06); }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.upload-icon {
  width: 44px; height: 44px; margin: 0 auto var(--space-3);
  color: var(--text-tertiary); transition: color var(--duration-base);
}
.upload-zone:hover .upload-icon { color: var(--accent); }
.upload-zone.has-file .upload-icon { color: var(--status-success); }

.upload-title { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); margin-bottom: 2px; }
.upload-hint { font-size: var(--text-xs); color: var(--text-tertiary); }

.upload-filetag {
  display: inline-flex; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: var(--weight-semibold); letter-spacing: 0.04em;
  background: var(--accent-soft); color: var(--accent);
  margin: var(--space-2) 2px 0;
}

/* === Mode cards — refined. Selected state uses a thin accent border + soft
   accent background and a ring around the icon, instead of recoloring the
   whole icon block. Hover gets a 1px lift. */
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (max-width: 640px) { .mode-grid { grid-template-columns: 1fr; } }

.mode-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
  cursor: pointer;
  transition: border-color var(--duration-fast),
              transform var(--duration-fast),
              background var(--duration-fast);
  background: var(--bg-elevated);
  position: relative;
}
.mode-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.mode-card.selected {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent-soft) 60%, var(--bg-elevated) 40%);
}
.mode-card.selected::after {
  content: ''; position: absolute; top: 14px; right: 14px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M20 6L9 17l-5-5' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.mode-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-input); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.mode-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.mode-card:hover .mode-icon {
  background: var(--bg-active);
  color: var(--text-primary);
}
.mode-card.selected .mode-icon {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.mode-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}
.mode-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* === Status badges === */
.badge-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  background: var(--bg-input);
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); }
.badge-queued    { color: var(--status-warning); }
.badge-queued::before { background: var(--status-warning); }
.badge-running   { color: var(--status-info); }
.badge-running::before { background: var(--status-info); animation: pulse-dot 1.5s infinite; }
.badge-completed { color: var(--status-success); }
.badge-completed::before { background: var(--status-success); }
.badge-failed    { color: var(--status-error); }
.badge-failed::before { background: var(--status-error); }
.badge-cancelled { color: var(--text-tertiary); }
.badge-cancelled::before { background: var(--text-tertiary); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.badge-mode {
  display: inline-flex; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: var(--weight-semibold);
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-input); color: var(--text-secondary);
}
.badge-mode.md     { background: var(--accent-soft); color: var(--accent); }
.badge-mode.mmpbsa { background: rgba(10,132,255,0.12); color: var(--status-info); }
.badge-mode.pmf    { background: rgba(52,199,89,0.12); color: var(--status-success); }
.badge-mode.fep    { background: rgba(255,159,10,0.12); color: var(--status-warning); }

/* === Progress === */
.progress-bar { height: 6px; background: var(--bg-input); border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-emph);
}

/* === Stepper — quieter dots + thinner connecting hairline. The numbered
   circle for the active step uses a filled accent dot rather than a 30px
   filled badge; the inactive states are subtle outlines. Done states use
   the accent (not green) so the colour palette stays disciplined. */
.stepper {
  display: flex; align-items: center; margin-bottom: var(--space-7);
  padding: var(--space-2) 0;
}
.step { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.step-number {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: var(--weight-semibold);
  font-feature-settings: "tnum";
  border: 1px solid var(--border-strong);
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  flex-shrink: 0;
  transition: border-color var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
}
.step.active .step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text-on-accent);
}
.step.done .step-number {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}
.step-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  transition: color var(--duration-fast);
}
.step.active .step-label { color: var(--text-primary); }
.step.done .step-label { color: var(--text-secondary); }
.step-line {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
  margin: 0 var(--space-3);
  transition: background var(--duration-fast);
}
.step-line.done { background: var(--accent); }

/* === Toast === */
.toast-container {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  z-index: var(--z-toast); display: flex; flex-direction: column-reverse;
  gap: var(--space-3); pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-popover);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--space-3);
  pointer-events: auto;
  animation: toast-in var(--duration-slow) var(--ease-emph);
  max-width: 400px;
}
.toast.toast-success { border-left: 3px solid var(--status-success); }
.toast.toast-error   { border-left: 3px solid var(--status-error); }
.toast.toast-warning { border-left: 3px solid var(--status-warning); }
.toast.hiding { animation: toast-out var(--duration-base) var(--ease-standard) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* === Stat card — quieter than v1.
   Old: 40px filled-color icon squares (peak SaaS). New: 28px outlined icon
   with a 4px status dot in the corner. The number is the focal point;
   colour is informational, not decorative. */
.stat-card { padding: var(--space-5); }
.stat-label {
  font-size: 11px; font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);    /* was bold — semibold reads cleaner at this size */
  color: var(--text-primary);
  margin-top: 6px;
  letter-spacing: var(--tracking-tight);
  font-feature-settings: "tnum";          /* tabular figures so 12 and 99 align column */
}
.stat-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }

.stat-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-tertiary);
  flex-shrink: 0;
  position: relative;
}
.stat-icon svg { width: 14px; height: 14px; stroke-width: 1.6; }
/* Variant accents: a 6px dot in the corner instead of filling the icon. */
.stat-icon::after {
  content: ''; position: absolute;
  bottom: -2px; right: -2px;
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
  background: var(--text-tertiary);
}
.stat-icon.blue::after  { background: var(--accent); }
.stat-icon.green::after { background: var(--status-success); }
.stat-icon.amber::after { background: var(--status-warning); }
.stat-icon.red::after   { background: var(--status-error); }
.stat-icon.blue  { color: var(--text-secondary); }
.stat-icon.green { color: var(--text-secondary); }
.stat-icon.amber { color: var(--text-secondary); }
.stat-icon.red   { color: var(--text-secondary); }

/* === Empty state === */
.empty-state { text-align: center; padding: var(--space-12) var(--space-6); color: var(--text-secondary); }
.empty-state svg { width: 56px; height: 56px; margin: 0 auto var(--space-4); color: var(--text-tertiary); stroke-width: 1.5; }
.empty-state h3 { color: var(--text-primary); margin-bottom: var(--space-2); font-size: var(--text-md); }
.empty-state p { font-size: var(--text-sm); max-width: 360px; margin: 0 auto var(--space-6); }

/* === Log viewer === */
.log-viewer {
  background: #0a0a0a; color: #e5e5e7;
  font-family: var(--font-mono); font-size: var(--text-xs);
  padding: var(--space-5); border-radius: var(--radius-lg);
  max-height: 400px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all; line-height: 1.7;
}
[data-theme="dark"] .log-viewer { background: #000; border: 1px solid var(--border-subtle); }

/* === File list === */
.file-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background var(--duration-fast);
}
.file-item:hover { background: var(--bg-hover); }
.file-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.file-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.file-list-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 6px 10px; background: var(--bg-input);
  border-radius: var(--radius-sm); font-size: var(--text-sm);
}
.file-list-item .file-list-name { flex: 1; font-weight: var(--weight-medium); }
.file-list-item .file-list-size { color: var(--text-tertiary); font-size: var(--text-xs); }
.file-list-item .file-list-remove {
  width: 22px; height: 22px;
  color: var(--text-tertiary); cursor: pointer; display: flex;
  align-items: center; justify-content: center; border-radius: 50%;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.file-list-item .file-list-remove:hover { background: rgba(255,59,48,0.12); color: var(--status-error); }
.file-list-item .file-list-remove svg { width: 12px; height: 12px; }

/* === CGenFF notice === */
.cgenff-notice {
  display: flex; gap: var(--space-3); padding: var(--space-4);
  background: rgba(255,159,10,0.08);
  border: 1px solid rgba(255,159,10,0.2);
  border-radius: var(--radius-md); margin-top: var(--space-4);
  font-size: var(--text-xs); color: var(--status-warning);
}
.cgenff-notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* === Loading === */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); padding: var(--space-12); color: var(--text-secondary); font-size: var(--text-sm); }

/* === Chat === */
.chat-container {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-height) - var(--space-8) * 2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-5);
}

.chat-msg { display: flex; gap: var(--space-3); max-width: 88%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.assistant { align-self: flex-start; max-width: 100%; }

.chat-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 11px; font-weight: var(--weight-bold);
}
.chat-msg.user .chat-avatar { background: var(--accent-soft); color: var(--accent); }
.chat-msg.assistant .chat-avatar { background: var(--accent); color: var(--text-on-accent); }

.chat-bubble {
  padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: var(--text-base); line-height: var(--leading-relaxed);
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--accent); color: var(--text-on-accent);
  border-bottom-right-radius: 6px;
}
.chat-msg.assistant .chat-bubble {
  background: var(--bg-input); color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

.chat-bubble p { margin-bottom: 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble code {
  background: rgba(0,0,0,0.08); padding: 1px 6px;
  border-radius: 4px; font-family: var(--font-mono);
  font-size: 0.9em;
}
[data-theme="dark"] .chat-bubble code { background: rgba(255,255,255,0.08); }
.chat-msg.user .chat-bubble code { background: rgba(255,255,255,0.18); }

/* Markdown content rendered by marked. Tighten default margins so paragraphs
   don't add leading whitespace inside the bubble, and give tables / pre code
   the look the rest of the design uses. */
.chat-text > *:first-child { margin-top: 0; }
.chat-text > *:last-child  { margin-bottom: 0; }
.chat-text p { margin: 0 0 0.5em; }
.chat-text p:last-child { margin-bottom: 0; }
.chat-text h1, .chat-text h2, .chat-text h3, .chat-text h4 {
  margin: 0.6em 0 0.3em;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}
.chat-text h1 { font-size: 1.25em; }
.chat-text h2 { font-size: 1.15em; }
.chat-text h3 { font-size: 1.05em; }
.chat-text h4 { font-size: 1em; }
.chat-text ul, .chat-text ol { margin: 0.4em 0; padding-left: 1.4em; }
.chat-text li { margin: 0.15em 0; }
.chat-text strong { font-weight: var(--weight-semibold); }
.chat-text em { font-style: italic; }
.chat-text blockquote {
  margin: 0.5em 0; padding: 0.2em 0.9em;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
}
.chat-text pre {
  margin: 0.6em 0; padding: 12px 14px;
  background: rgba(0,0,0,0.06);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.86em; line-height: 1.55;
}
[data-theme="dark"] .chat-text pre { background: rgba(255,255,255,0.05); }
.chat-msg.user .chat-text pre { background: rgba(255,255,255,0.16); }
.chat-text pre code { background: none; padding: 0; font-size: inherit; }
.chat-text table {
  border-collapse: collapse; margin: 0.6em 0;
  font-size: 0.92em; width: 100%;
}
.chat-text th, .chat-text td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 10px; text-align: left;
}
.chat-text th { font-weight: var(--weight-semibold); color: var(--text-primary); }
.chat-text a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.chat-msg.user .chat-text a { color: white; }
.chat-text hr {
  border: none; border-top: 1px solid var(--border-subtle); margin: 0.8em 0;
}
/* KaTeX inline math should inherit text size; display math gets a touch of breathing room */
.chat-text .katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; }

.chat-typing {
  display: flex; gap: 5px; padding: 12px 16px;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-tertiary); animation: typing 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.chat-suggestions {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  justify-content: center;
}
.chat-suggestion {
  padding: 7px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color var(--duration-fast), color var(--duration-fast),
              background var(--duration-fast);
}
.chat-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.chat-input-area {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex; gap: var(--space-3); align-items: flex-end;
  background: var(--bg-elevated);
}
.chat-input {
  flex: 1; resize: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 11px 16px;
  font-size: var(--text-base);
  outline: none;
  min-height: 44px; max-height: 140px; line-height: var(--leading-snug);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}
.chat-input:focus { border-color: var(--accent); background: var(--bg-elevated); }
.chat-send {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: var(--text-on-accent);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform var(--duration-fast), filter var(--duration-fast);
  flex-shrink: 0;
}
.chat-send:hover:not(:disabled) { filter: brightness(1.05); transform: scale(1.04); }
.chat-send:disabled { opacity: 0.35; cursor: not-allowed; }
.chat-send svg { width: 18px; height: 18px; stroke-width: 1.6; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-12) var(--space-6); text-align: center;
}
/* Refined hero: outlined ring + accent dot. Less SaaS-gradient, more native-app. */
.chat-empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex;
  align-items: center; justify-content: center;
  margin-bottom: var(--space-5);
  background: transparent;
  border: 1px solid var(--border-strong);
  position: relative;
}
.chat-empty-icon::after {
  content: ''; position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
}
.chat-empty-icon svg { width: 24px; height: 24px; color: var(--text-secondary); stroke-width: 1.6; }
.chat-empty h3 {
  font-size: var(--text-xl); font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.chat-empty p { font-size: var(--text-sm); color: var(--text-secondary); max-width: 420px; margin-bottom: var(--space-6); line-height: var(--leading-relaxed); }

/* === Agent tool-call rows (inside assistant chat bubbles) === */
.chat-tool-call {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0; padding: 8px 12px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.chat-tool-call.running { border-color: var(--status-warning); }
.chat-tool-call.ok      { border-color: var(--status-success); }
.chat-tool-call.err     { border-color: var(--status-error); }
.chat-tool-icon { font-weight: var(--weight-bold); flex-shrink: 0; }
.chat-tool-call.ok      .chat-tool-icon { color: var(--status-success); }
.chat-tool-call.err     .chat-tool-icon { color: var(--status-error); }
.chat-tool-call.running .chat-tool-icon { color: var(--status-warning); }
.chat-tool-name { font-weight: var(--weight-medium); color: var(--text-primary); }
.chat-tool-status,
.chat-tool-summary {
  color: var(--text-tertiary); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* === Grid/Flex helpers === */
.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (min-width: 769px) and (max-width: 1024px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
