/* ================================================================
   NEOBRUTALIST DESIGN OVERRIDES
   ================================================================ */
:root {
  --bg: #f7f5f0;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888888;
  --border: #1a1a1a;
  --border-width: 2px;

  --table-color: #3b82f6;
  --table-bg: #dbeafe;
  --md-color: #8b5cf6;
  --md-bg: #ede9fe;
  --chart-color: #f97316;
  --chart-bg: #fff7ed;
  --kv-color: #f59e0b;
  --kv-bg: #fef3c7;
  --form-color: #ec4899;
  --form-bg: #fce7f3;
  --decision-color: #ef4444;
  --decision-bg: #fee2e2;
  --image-color: #06b6d4;
  --image-bg: #cffafe;
  --section-color: #1a1a1a;
  --agent-color: #6b7280;
  --agent-bg: #f3f4f6;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --error: #dc2626;
  --highlight: #dab6fc;

  --shadow: 4px 4px 0 var(--border);
  --shadow-sm: 2px 2px 0 var(--border);
  --shadow-pressed: 1px 1px 0 var(--border);

  --font-head: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', Menlo, Consolas, monospace;

  --radius: 0px;
  /* Legacy aliases retained for existing rules */
  --bg-card: var(--card-bg);
  --bg-header: #ece8dc;
  --accent: var(--table-color);
  --accent-hover: #2563eb;
  --font: var(--font-body);
  --mono: var(--font-mono);
}

[data-theme="dark"] {
  --bg: #000000;
  --card-bg: #1a1a1a;
  --text: #f5f5f5;
  --text-muted: #a0a0a0;
  --border: #b0b0b0;

  --table-bg: #1e3a5f;
  --md-bg: #2d1f5e;
  --chart-bg: #431407;
  --kv-bg: #3d2e0a;
  --form-bg: #3d1a2e;
  --decision-bg: #3d1a1a;
  --image-bg: #0a3d4a;
  --agent-bg: #374151;

  --shadow: 4px 4px 0 var(--border);
  --shadow-sm: 2px 2px 0 var(--border);
  --shadow-pressed: 1px 1px 0 var(--border);

  --highlight: #352050;
  --success-bg: #14412e;
  --bg-card: var(--card-bg);
  --bg-header: #333333;
  --accent: var(--table-color);
  --accent-hover: #60a5fa;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

.header {
  background: var(--card-bg);
  border-bottom: 3px solid var(--border);
  padding: 10px 0;
}

body {
  padding-top: 51px;
  padding-bottom: 33px;
}

.header-inner {
  max-width: 1040px;
  padding: 0 24px;
}

.header h1 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.btn,
.study-dropdown-trigger,
.export-dropdown-panel,
.study-dropdown-panel,
.table-search,
.table-pager button,
.export-btn,
.response-btn,
.confirm-actions button,
.row-detail-close,
.form-field select,
.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-select-trigger,
.form-date-trigger,
.form-select-panel,
.form-calendar-panel,
.form-calendar-nav-btn,
.response-message-input,
.annotation-textarea {
  border-radius: var(--radius);
}

.btn,
.study-dropdown-trigger {
  padding: 6px 14px;
  border: var(--border-width) solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:hover,
.study-dropdown-trigger:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
  border-color: var(--border);
  background: var(--card-bg);
}

.btn:active,
.study-dropdown-trigger:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Override base.css 28px — neo uses 2px borders + 6px padding,
   so buttons need 32px to fit content without clipping. */
.header-actions .btn,
.header-actions .btn-icon {
  height: 32px;
}

.btn-icon {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-head);
  font-size: 13px;
  transition: transform 0.1s, box-shadow 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
  background: var(--card-bg);
  color: var(--text);
}

.study-dropdown-panel,
.export-dropdown-panel {
  background: var(--card-bg);
  border: var(--border-width) solid var(--border);
  box-shadow: var(--shadow);
}

.study-dropdown-all:hover,
.study-dropdown-entry:hover,
.export-dropdown-item:hover {
  background: var(--highlight);
}

.study-dropdown-all,
.study-dropdown-entry,
.study-dropdown-group-label,
.study-entry-meta,
.study-meta-detail {
  font-family: var(--font-head);
}

.study-metadata-bar {
  font-family: var(--font-head);
  width: 100%;
  max-width: 1040px;
  padding: 28px 24px 0;
}

.study-meta-label {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.study-separator {
  font-family: var(--font-head);
  font-size: 22px;
  letter-spacing: -0.3px;
  padding: 32px 0 8px;
}

.study-meta-edit-input {
  font-family: var(--font-mono);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.card-title-edit-input {
  font-family: var(--font-mono);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.feed {
  max-width: 1040px;
}

.card {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}

.card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--border);
}

.card-header {
  padding: 10px 14px;
  border-bottom: var(--border-width) solid var(--border);
  background: var(--card-bg);
  gap: 10px;
}

.card-header[data-type="table"] { background: var(--table-bg); }
.card-header[data-type="markdown"] { background: var(--md-bg); }
.card-header[data-type="plotly"] { background: var(--chart-bg); }
.card-header[data-type="image"] { background: var(--image-bg); }
.card-header[data-type="keyvalue"] { background: var(--kv-bg); }
.card-header[data-type="form"] { background: var(--form-bg); }
.card-header[data-type="decision"] { background: var(--decision-bg); }
.card-header[data-type="agent"] { background: var(--agent-bg); }

.card-type-icon {
  width: 28px;
  height: 28px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.card-type-icon[data-type="table"] { background: var(--table-color); color: #fff; }
.card-type-icon[data-type="markdown"] { background: var(--md-color); color: #fff; }
.card-type-icon[data-type="plotly"] { background: var(--chart-color); color: #fff; }
.card-type-icon[data-type="image"] { background: var(--image-color); color: #fff; }
.card-type-icon[data-type="keyvalue"] { background: var(--kv-color); color: #fff; }
.card-type-icon[data-type="form"] { background: var(--form-color); color: #fff; }
.card-type-icon[data-type="decision"] { background: var(--decision-color); color: #fff; }
.card-type-icon[data-type="agent"] { background: var(--agent-color); color: #fff; }

.card-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
}

.card-collapse-btn,
.card-action-btn {
  color: var(--text-muted);
}

.card-action-btn:hover,
.card-collapse-btn:hover {
  color: var(--text);
  background: transparent;
}

.card-body {
  padding: 16px;
}

.card-provenance {
  padding: 6px 14px;
  border-top: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
  font-family: var(--font-mono);
  font-size: 10px;
  gap: 12px;
}

.table-toolbar {
  padding: 8px 0 0;
  margin-bottom: 8px;
}

.table-wrapper table {
  font-family: var(--font-mono);
  border: var(--border-width) solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
}

.table-wrapper th {
  padding: 8px 14px;
  border-bottom: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-weight: 700;
  background: var(--table-bg);
}

.table-wrapper th:hover {
  background: var(--table-bg);
}

.table-wrapper td {
  padding: 6px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 20%, transparent);
}

.table-wrapper tr:hover td {
  background: var(--table-bg);
}

.table-info {
  padding: 10px 14px;
  border-top: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-size: 12px;
}

.table-pager button,
.export-btn {
  border: var(--border-width) solid var(--border);
  background: var(--card-bg);
  font-family: var(--font-head);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
}

.table-pager button:hover,
.export-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
  background: var(--card-bg);
  color: var(--text);
}

.table-search,
.response-message-input,
.form-field select,
.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-select-trigger,
.form-date-trigger,
.annotation-textarea {
  border: var(--border-width) solid var(--border);
  background: var(--card-bg);
  font-family: var(--font-mono);
  box-shadow: var(--shadow-sm);
}

.table-search:focus,
.response-message-input:focus,
.form-field select:focus,
.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus,
.form-field input[type="date"]:focus,
.form-select-trigger:focus-visible,
.form-date-trigger:focus-visible,
.annotation-textarea:focus {
  box-shadow: var(--shadow-pressed);
  border-color: var(--border);
}

.type-badge {
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--card-bg);
}

.markdown-body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: var(--font-head);
  font-weight: 700;
}

.markdown-body code {
  font-family: var(--font-mono);
  background: var(--md-bg);
  border: 1px solid color-mix(in srgb, var(--border) 20%, transparent);
}

.markdown-body pre {
  background: var(--bg);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.kv-key {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
}

.kv-value {
  font-family: var(--font-mono);
}

.section-divider {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
}

.section-divider::before,
.section-divider::after {
  height: 3px;
  background: var(--border);
}

.chart-loading {
  font-family: var(--font-head);
}

.chart-loading::before {
  border: var(--border-width) solid var(--border);
  border-top-color: var(--chart-color);
}

.image-container img {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card.waiting {
  border-color: var(--decision-color);
}

.card.responded {
  border-color: var(--border);
}

.card.responded .card-header {
  background: var(--success-bg);
}

.card.responded .card-type-icon {
  background: var(--success);
  color: #fff;
}

@keyframes subtlePulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--decision-color) 25%, transparent), var(--shadow); }
}

.card-response-ui {
  border-top: var(--border-width) solid var(--border);
  background: var(--decision-bg);
}

.response-prompt {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
}

.response-btn {
  border: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
}

.response-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
}

.response-btn-confirm {
  background: var(--text);
  border-color: var(--border);
  color: var(--card-bg);
}

.response-btn-confirm:hover {
  background: var(--text);
  border-color: var(--border);
}

.response-btn-skip {
  background: var(--card-bg);
  color: var(--text-muted);
}

.form-field-label {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
}

.form-toggle-track {
  border-radius: 0;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s, transform 0.1s, box-shadow 0.1s;
}

.form-toggle-track::after {
  border-radius: 0;
}

.form-toggle-switch:hover .form-toggle-track {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
}

.form-toggle-switch:active .form-toggle-track {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.form-slider-row input[type="range"],
.form-range-slider-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  background: var(--card-bg);
  border: var(--border-width) solid var(--border);
  border-radius: 0;
}

.form-slider-row input[type="range"]::-webkit-slider-thumb,
.form-range-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.form-slider-row input[type="range"]::-webkit-slider-thumb:hover,
.form-range-slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
}

.form-slider-row input[type="range"]::-moz-range-track,
.form-range-slider-row input[type="range"]::-moz-range-track {
  height: 12px;
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  background: var(--card-bg);
}

.form-slider-row input[type="range"]::-moz-range-thumb,
.form-range-slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.form-frozen-item .frozen-label {
  font-family: var(--font-head);
}

.form-frozen-item .frozen-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.row-detail-panel {
  background: var(--card-bg);
  border-left: 3px solid var(--border);
  box-shadow: -4px 0 0 var(--border);
}

.row-detail-header {
  border-bottom: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
}

.row-detail-close {
  background: none;
  border: var(--border-width) solid var(--border);
  box-shadow: var(--shadow-sm);
}

.row-detail-close:hover {
  background: none;
  box-shadow: var(--shadow-pressed);
}

.confirm-dialog {
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--border);
  font-family: var(--font-body);
}

.confirm-dialog h3 {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
}

.confirm-actions button {
  border: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.confirm-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--border);
}

.footer {
  background: var(--card-bg);
  border-top: 3px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
}

.footer-inner {
  max-width: 1040px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border: var(--border-width) solid var(--border);
  border-radius: 0;
}

.copy-toast {
  background: var(--text);
  color: var(--card-bg);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-head);
  font-weight: 600;
}

.empty-state {
  font-family: var(--font-head);
}

.empty-state code {
  font-family: var(--font-mono);
  background: var(--card-bg);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 4px 12px;
}

.selection-badge {
  border-radius: var(--radius);
  border: var(--border-width) solid var(--border);
  background: var(--highlight);
  color: var(--text);
  font-family: var(--font-head);
}

.table-wrapper th.select-col,
.table-wrapper td.select-col {
  padding: 6px 4px;
}

.form-multiselect-option input[type="checkbox"],
.form-check-row input[type="checkbox"],
.table-wrapper td.select-col input[type="checkbox"],
.table-wrapper th.select-col input[type="checkbox"] {
  border-radius: 0;
}

/* Undo snackbar */
.undo-snackbar {
  background: var(--text);
  color: var(--card-bg);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font-head);
  font-weight: 600;
}

.undo-snackbar-btn {
  font-family: var(--font-head);
  background: none;
  border: var(--border-width) solid currentColor;
  color: var(--card-bg);
  padding: 2px 12px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.undo-snackbar-btn:hover {
  background: var(--card-bg);
  color: var(--text);
}

/* Card animations — override hover transform during animation */
.card.card-deleting,
.card.card-restoring,
.card.card-dismissing,
.card.card-undismissing {
  box-shadow: var(--shadow);
}

.card.card-deleting:hover,
.card.card-restoring:hover,
.card.card-dismissing:hover,
.card.card-undismissing:hover {
  transform: none;
}

/* TOC overrides */
.toc-panel {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card-bg);
}

.toc-section-header {
  font-family: var(--font-head);
  font-weight: 700;
}

.toc-entry {
  font-family: var(--font-head);
}

.toc-entry:hover {
  background: var(--highlight);
}

.toc-entry.toc-active {
  background: var(--highlight);
  border-left: 3px solid var(--accent);
}

.toc-type-badge {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
}

.toc-jump-latest {
  font-family: var(--font-head);
  font-weight: 600;
  border-top: var(--border-width) solid var(--border);
}

.toc-empty {
  font-family: var(--font-head);
}

@media (max-width: 720px) {
  .form-date-range-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-date-range-sep {
    align-self: flex-start;
    margin: -2px 0 2px;
  }

  .form-calendar-panel {
    width: min(320px, calc(100vw - 32px));
  }
}

/* Action palette */
.action-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}

.action-palette {
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--border);
  width: min(420px, calc(100vw - 32px));
  max-height: 60vh;
  overflow-y: auto;
}

.action-palette-header {
  padding: 12px 16px;
  border-bottom: var(--border-width) solid var(--border);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.action-palette-header kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.action-palette-list {
  padding: 4px 0;
}

.action-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.action-palette-item:hover,
.action-palette-item.active {
  background: var(--highlight);
}

.action-palette-item .action-icon {
  width: 24px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.action-palette-item .action-label {
  flex: 1;
}

.action-palette-item .action-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.action-palette-sep {
  height: 1px;
  background: color-mix(in srgb, var(--border) 30%, transparent);
  margin: 4px 16px;
}

/* Actions button in header */
#actions-btn {
  font-family: var(--font-head);
  font-weight: 600;
}

/* ================================================================
   AGENT CARD STYLES
   ================================================================ */

/* Agent status dot in header */
.agent-status-dot {
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.agent-status-dot.running {
  width: 8px;
  height: 8px;
  background: var(--chart-color);
  border: var(--border-width) solid var(--border);
  animation: agentPulse 1.5s ease-in-out infinite;
  animation-delay: -1500s;
}

.agent-status-dot.completed {
  color: var(--success);
}

.agent-status-dot.failed {
  color: var(--error);
}

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

/* Agent config form */
.agent-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-config-row-full {
  flex-direction: column;
  align-items: stretch;
}

.agent-config-label {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  width: 100px;
  flex-shrink: 0;
  color: var(--text);
}

.agent-config-row-full .agent-config-label {
  width: auto;
}

.agent-config-select,
.agent-config-input {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.agent-config-select {
  min-width: 120px;
}

.agent-config-input {
  width: 100px;
}

.agent-config-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.agent-perms-badge {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  color: var(--card-bg);
  background: var(--warning);
  padding: 2px 8px;
  border: var(--border-width) solid var(--border);
  box-shadow: var(--shadow-sm);
}

.agent-config-textarea {
  width: 100%;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  resize: vertical;
}

.agent-config-textarea:focus {
  box-shadow: var(--shadow-pressed);
  outline: none;
}

/* Advanced toggle */
.agent-advanced-toggle {
  font-family: var(--font-head);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.agent-advanced-toggle summary {
  padding: 4px 0;
  user-select: none;
  list-style: none;
  position: relative;
  padding-left: 16px;
  transition: color 0.15s;
}

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

.agent-advanced-toggle summary::before {
  content: '\25b6';
  position: absolute;
  left: 0;
  font-size: 9px;
  transition: transform 0.15s;
}

.agent-advanced-toggle[open] summary::before {
  transform: rotate(90deg);
}

.agent-advanced-toggle summary:hover {
  color: var(--text);
}

.agent-prompt-preview {
  background: var(--bg);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 8px;
  color: var(--text);
}

/* Bottom bar */
.agent-bottom-bar {
  display: flex;
  justify-content: center;
  padding: 12px 16px;
  border-top: var(--border-width) solid var(--border);
  background: var(--card-bg);
}

.agent-run-btn {
  min-width: 140px;
  transition: opacity 0.2s, transform 0.1s;
}

.agent-run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Metadata strip (running state) */
.agent-meta-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
  font-family: var(--font-head);
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.agent-model-badge {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border: var(--border-width) solid var(--border);
  background: var(--agent-bg);
  color: var(--text);
  white-space: nowrap;
}

.agent-header-badge {
  margin-left: 2px;
}

/* Usage info in completed bottom bar (left-aligned) */
.agent-bottom-usage {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.agent-perms-badge-sm {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border: var(--border-width) solid var(--border);
  background: var(--warning);
  color: var(--card-bg);
  white-space: nowrap;
}

.agent-tools-list {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Terminal box */
.agent-terminal {
  background: #1a1a1a;
  border: var(--border-width) solid var(--border);
  max-height: 200px;
  overflow-y: auto;
  padding: 12px 14px;
  position: relative;
}

.agent-terminal.expanded {
  max-height: none;
}

.agent-terminal-compact {
  max-height: 80px;
  overflow: hidden;
  position: relative;
}

.agent-terminal-compact::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, rgba(26, 26, 26, 0), #1a1a1a);
  pointer-events: none;
}

.agent-terminal-compact.expanded::after {
  display: none;
}

.agent-terminal-content {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #e0e0e0;
}

.agent-terminal-content.markdown-body {
  color: #e0e0e0;
}

.agent-terminal-content h1,
.agent-terminal-content h2,
.agent-terminal-content h3 {
  color: #f5f5f5;
  border-bottom: none;
  font-size: 13px;
  margin-top: 12px;
}

.agent-terminal-content p {
  margin: 4px 0;
}

.agent-terminal-content code {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e0e0e0;
}

.agent-terminal-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.agent-terminal-content a {
  color: #93c5fd;
}

.agent-terminal-content ul,
.agent-terminal-content ol {
  padding-left: 20px;
  margin: 4px 0;
}

/* Dark mode terminal adjustments */
[data-theme="dark"] .agent-terminal {
  background: #0a0a0a;
  border-color: #444;
}

[data-theme="dark"] .agent-terminal-compact::after {
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0), #0a0a0a);
}

[data-theme="dark"] .agent-terminal-content {
  color: #d0d0d0;
}

/* Alive strip in running agent terminal — pulsing dot + thinking message */
.agent-alive-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.agent-alive-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  background: var(--chart-color);
  border: var(--border-width) solid var(--border);
  animation: agentPulse 1.5s ease-in-out infinite;
  animation-delay: -1500s;
}

.agent-alive-msg {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #888;
}

/* Usage info in alive strip (right-aligned) */
.agent-alive-usage {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #666;
  white-space: nowrap;
}

/* Inactivity indicator */
.agent-inactivity-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #666;
}

/* Status reason badge in header (cancelled/failed/timed out) */
.agent-reason-badge {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border: var(--border-width) solid var(--error);
  background: var(--decision-bg);
  color: var(--error);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* Cancel button */
.agent-cancel-btn {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--error);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s, color 0.15s;
}

.agent-cancel-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
  background: var(--error);
  color: var(--card-bg);
}

/* Expand/collapse toggle */
.agent-expand-btn {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
}

.agent-expand-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-pressed);
  color: var(--text);
}

/* Bottom bar updates for running/completed */
.agent-bottom-bar-running {
  justify-content: flex-end;
  gap: 8px;
}

.agent-bottom-bar-completed {
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.agent-bottom-bar-completed:has(.agent-bottom-usage) {
  justify-content: space-between;
}
