/* patterns.css — Page-region compositions (.app-shell, .sidebar, ...).
   Filled in by subsequent tasks in the implementation plan.
*/

/* ─── .form-field ──────────────────────────────────────────
   Wraps label + input/textarea + optional helper/error text.
─────────────────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-field__helper {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.form-field__error {
  font-size: var(--text-sm);
  color: var(--danger-fg);
}

/* ─── .app-shell ───────────────────────────────────────────
   Top-level layout: sidebar + chat-pane + workbench.
─────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(var(--app-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--app-grid-line) 1px, transparent 1px),
    var(--app-bg);
  background-size: var(--grid-size) var(--grid-size);
}

/* ─── .sidebar ─────────────────────────────────────────────
   Dark left rail with brand, CTA, and engine list.
─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background:
    linear-gradient(var(--app-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--app-grid-line) 1px, transparent 1px),
    var(--sidebar-bg);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-divider);
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--sidebar-divider);
}
.sidebar__brand {
  color: var(--text-inverted);
}

.sidebar__cta {
  padding: var(--space-3) var(--space-3) var(--space-1);
}
.sidebar__cta .btn { width: 100%; }
.sidebar .btn--ghost {
  border-color: var(--sidebar-divider);
  color: var(--sidebar-text);
}
.sidebar .btn--ghost:hover:not(:disabled) {
  background: var(--sidebar-hover-bg);
  color: var(--text-inverted);
}

.sidebar__group-label {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
}

.sidebar__list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-1) 0;
}

.sidebar__item {
  padding: var(--space-2) var(--space-3);
  margin: 1px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  transition: background var(--duration-fast) var(--ease-standard);
}
.sidebar__item:hover { background: var(--sidebar-hover-bg); }
.sidebar__item--active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar__item-meta {
  font-size: var(--text-xs);
  color: var(--sidebar-text-muted);
}
.sidebar__item--active .sidebar__item-meta {
  color: var(--sidebar-active-text);
  opacity: 0.85;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--sidebar-divider);
  font-size: var(--text-xs);
}
.sidebar__footer-link {
  color: var(--sidebar-text-muted);
  text-decoration: none;
}
.sidebar__footer-link:hover { color: var(--text-inverted); }
.sidebar__footer-legal {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.sidebar__footer-sep { color: var(--sidebar-text-muted); }

.sidebar__signout-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.sidebar__signout-btn:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-inverted);
}

/* Account row in sidebar footer (above feedback links). */
.account-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  margin: 0 calc(-1 * var(--space-1)) var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard);
}
.account-row:hover {
  background: var(--sidebar-hover-bg);
  border-color: var(--sidebar-divider);
  color: var(--sidebar-text);
  text-decoration: none;
}
.account-row__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}
.account-row__avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-inverted);
  background: var(--accent);
  letter-spacing: 0.02em;
}
.account-row__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.account-row__name {
  font-size: var(--text-sm);
  color: var(--text-inverted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-row__email {
  font-size: var(--text-xs);
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-row--empty { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* ─── .workbench ───────────────────────────────────────────
   Right-most pane that hosts dashboard / wizard / upload / grid.
─────────────────────────────────────────────────────────── */
.workbench {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(var(--app-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--app-grid-line) 1px, transparent 1px),
    var(--app-bg);
  background-size: var(--grid-size) var(--grid-size);
  overflow: hidden;
  min-width: 0;
}

#wb-dashboard,
#wb-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#wb-dashboard {
  flex-direction: column;
  padding: var(--space-4);
  gap: var(--space-4);
}

#wb-content {
  padding: var(--space-4);
}

/* ─── .empty-state ─────────────────────────────────────────
   Centered hero with icon, title, subtitle, CTA, and optional hint list.
─────────────────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10);
  color: var(--text-inverted);
}
.empty-state__icon { margin-bottom: var(--space-4); }

.empty-state__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-inverted);
  margin-bottom: var(--space-2);
}
.empty-state__subtitle {
  font-size: var(--text-md);
  color: var(--text-inverted-muted);
  max-width: 420px;
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-8);
}

.empty-state__hints {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: left;
  margin-top: var(--space-8);
}
.empty-state__hint {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-base);
  color: var(--text-inverted-muted);
}
.empty-state__hint-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── .page-header ─────────────────────────────────────────
   Title + status meta. Lives at top of any workbench page.
─────────────────────────────────────────────────────────── */
.page-header {
  padding: var(--space-6) var(--space-8) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}
.page-header__title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: var(--space-1);
}
.page-header__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#wb-dashboard .page-header {
  background: rgba(16, 27, 45, 0.92);
  border-color: var(--app-panel-line);
  box-shadow: none;
}
#wb-dashboard .page-header__title {
  color: var(--text-inverted);
}
#wb-dashboard .page-header__meta {
  color: var(--text-inverted-muted);
}

/* ─── .dash-body ───────────────────────────────────────────
   Scrolling content area below the page-header.
─────────────────────────────────────────────────────────── */
.dash-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.dash-body__section { margin-bottom: var(--space-6); }
.dash-body__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

#wb-dashboard .dash-body__section-label {
  color: var(--text-inverted-muted);
}

#wb-dashboard .form-field__helper {
  color: var(--text-inverted-muted);
}

#wb-dashboard .badge--neutral {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-inverted);
  border-color: var(--app-panel-line);
}

#wb-dashboard .badge--warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-dot);
  border-color: rgba(245, 158, 11, 0.42);
}

#wb-dashboard .badge--success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-dot);
  border-color: rgba(34, 197, 94, 0.42);
}

#wb-dashboard .banner {
  background: rgba(16, 27, 45, 0.88);
  border-color: var(--app-panel-line);
  color: var(--text-inverted);
  box-shadow: none;
}
#wb-dashboard .banner__title {
  color: var(--text-inverted);
}
#wb-dashboard .banner__body {
  color: var(--text-inverted-muted);
}
#wb-dashboard .banner--warning {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.44);
  box-shadow: inset var(--space-1) 0 0 var(--warning-dot);
}
#wb-dashboard .banner--warning .banner__icon {
  color: var(--warning-dot);
}
#wb-dashboard .banner--success {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.36);
  box-shadow: inset var(--space-1) 0 0 var(--success-dot);
}
#wb-dashboard .banner--success .banner__icon {
  color: var(--success-dot);
}

.dash-body__field-tags {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

/* ─── .run-list / .run-list-item ───────────────────────────
   Past-runs list of summary rows.
─────────────────────────────────────────────────────────── */
.run-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.run-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard);
}
.run-list-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.run-list-item__left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.run-list-item__date {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.run-list-item__rows {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.run-list-item__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.run-list--empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: var(--text-base);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

#wb-dashboard .run-list-item {
  background: rgba(16, 27, 45, 0.86);
  border-color: var(--app-panel-line);
  box-shadow: none;
}
#wb-dashboard .run-list-item:hover {
  border-color: rgba(47, 109, 246, 0.62);
  box-shadow: inset 0 0 0 1px rgba(47, 109, 246, 0.28);
}
#wb-dashboard .run-list-item__date {
  color: var(--text-inverted);
}
#wb-dashboard .run-list-item__rows {
  color: var(--text-inverted-muted);
}
#wb-dashboard .run-list--empty {
  background: rgba(16, 27, 45, 0.64);
  border-color: var(--app-panel-line);
  color: var(--text-inverted-muted);
}

#wb-dashboard .dash-section-title {
  color: var(--text-inverted-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#wb-dashboard .run-history-table th,
#wb-dashboard .run-history-table td {
  border-bottom-color: var(--app-panel-line);
}
#wb-dashboard .run-history-table th {
  color: var(--text-inverted-muted);
}
#wb-dashboard .run-history-table td {
  color: var(--text-inverted);
}
#wb-dashboard .run-history-table a {
  color: var(--text-inverted);
}

/* ─── .note-row ────────────────────────────────────────────
   One row in the engine-notes list.
─────────────────────────────────────────────────────────── */
.note-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.note-row__content {
  flex: 1;
  font-size: var(--text-base);
  color: var(--text);
  line-height: var(--leading-base);
}
.note-row__meta {
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.note-row__source {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 1px var(--space-2);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  text-transform: lowercase;
  vertical-align: middle;
  white-space: nowrap;
}

#wb-dashboard .note-row {
  border-bottom-color: var(--app-panel-line);
}
#wb-dashboard .note-row__content {
  color: var(--text-inverted);
}
#wb-dashboard .note-row__meta {
  color: var(--text-inverted-muted);
}
#wb-dashboard .note-row .btn--ghost {
  color: var(--text-inverted-muted);
}
#wb-dashboard .note-row .btn--ghost:hover:not(:disabled) {
  background: var(--sidebar-hover-bg);
  color: var(--text-inverted);
}
#wb-dashboard .note-row__source {
  background: rgba(47, 109, 246, 0.16);
  color: var(--text-inverted);
  border-color: rgba(147, 197, 253, 0.30);
}

#wb-dashboard .notes-list {
  border-top: 1px solid var(--app-panel-line);
  border-bottom: 1px solid var(--app-panel-line);
}

#wb-dashboard .textarea {
  min-height: calc(var(--space-10) + var(--space-2));
  background: rgba(16, 27, 45, 0.86);
  color: var(--text-inverted);
  border-color: var(--app-panel-line);
}
#wb-dashboard .textarea::placeholder {
  color: var(--text-inverted-muted);
}
#wb-dashboard .textarea:focus {
  border-color: var(--accent);
}

#wb-dashboard .btn--primary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-inverted);
  border-color: var(--app-panel-line);
}
#wb-dashboard .btn--primary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(147, 197, 253, 0.34);
}

/* ─── .wizard ──────────────────────────────────────────────
   Centered card-based flow for engine setup.
─────────────────────────────────────────────────────────── */
.wizard {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: transparent;
  overflow-y: auto;
  padding: var(--space-10) var(--space-5);
}

.wizard__card {
  width: 540px;
  max-width: calc(100vw - 300px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.wizard__header {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.wizard__title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
}
.wizard__subtitle {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading-base);
}

.wizard__body { padding: var(--space-5) var(--space-6); }
.wizard__body--list { display: flex; flex-direction: column; gap: var(--space-2); }

.setup-file-list,
#fl-upload {
  max-height: 180px;
  overflow-y: auto;
  margin-top: var(--space-2);
}

.wizard__footer {
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.wizard__footer-actions { display: flex; gap: var(--space-2); }

/* ─── .trust-header ────────────────────────────────────────
   Top of the review screen with title + run stats.
─────────────────────────────────────────────────────────── */
.trust-header {
  padding: var(--space-4) var(--space-6) var(--space-3);
  background: var(--surface-inverted);
  color: var(--text-inverted);
  border: 1px solid var(--app-panel-line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
}
.trust-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.trust-header__title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.trust-header__stats {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-1);
}
.trust-header__stat {
  font-size: var(--text-sm);
  color: var(--text-inverted-muted);
}
.trust-header__stat strong {
  color: var(--text-inverted);
  font-weight: 600;
}
.trust-header__stat--warning {
  color: var(--warning-dot);
}
.trust-header__stat--success {
  color: var(--success-dot);
}
.trust-header__stat--warning strong,
.trust-header__stat--success strong {
  color: currentColor;
}

/* ─── .run-sub-header ──────────────────────────────────────
   Strip below trust-header showing current run filename.
─────────────────────────────────────────────────────────── */
.run-sub-header {
  padding: var(--space-3) var(--space-6);
  background: var(--surface-soft);
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-shrink: 0;
}
.run-sub-header__file {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── .filter-bar ──────────────────────────────────────────
   Row of filter-chips above the grid.
─────────────────────────────────────────────────────────── */
.filter-bar {
  padding: var(--space-2) var(--space-6);
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ─── .review-grid ─────────────────────────────────────────
   Scrollable table for classification rows.
─────────────────────────────────────────────────────────── */
.review-grid {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--surface-soft);
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.review-grid__table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.review-grid__table thead { position: sticky; top: 0; z-index: 10; }
.review-grid__table th {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}
.review-grid__table th:first-child { padding-left: var(--space-6); width: 40px; }

.review-grid__table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  transition: background var(--duration-fast) var(--ease-standard);
}
.review-grid__table tbody tr:hover { background: var(--surface); }

.review-grid__table tbody tr.row--needs-review { background: var(--warning-bg); }
.review-grid__table tbody tr.row--needs-review:hover { background: var(--warning-bg-strong); }
.review-grid__table tbody tr.row--rejected { background: var(--danger-bg); }
.review-grid__table tbody tr.row--edited   { background: var(--accent-soft) !important; }

.review-grid__table td {
  padding: var(--space-2) var(--space-4);
  vertical-align: middle;
}
.review-grid__table td:first-child { padding-left: var(--space-6); }

/* Sticky first 3 columns: checkbox, status, row-index */
.review-grid__table th:nth-child(-n+3),
.review-grid__table td:nth-child(-n+3) {
  position: sticky;
  z-index: 5;
  background: inherit;
}
.review-grid__table th:nth-child(1), .review-grid__table td:nth-child(1) { left: 0; }
.review-grid__table th:nth-child(2), .review-grid__table td:nth-child(2) { left: 40px; }
.review-grid__table th:nth-child(3), .review-grid__table td:nth-child(3) { left: 148px; }
.review-grid__table thead th:nth-child(-n+3) { z-index: 12; background: var(--bg); }

/* Numeric cells: tabular-nums, right-aligned */
.review-grid__table td.field--numeric,
.review-grid__table th.field--numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

/* Editable field cells (the field-value popup-trigger pattern) */
.field-cell { position: relative; min-width: 110px; }
.field-cell__value {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  cursor: pointer;
  min-height: 30px;
  transition: background var(--duration-fast) var(--ease-standard);
}
.field-cell__value:hover { background: var(--action-primary-bg); }

.field-cell__text {
  flex: 1;
  font-size: var(--text-base);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-cell__text--empty { color: var(--text-muted); font-style: italic; }
.field-cell--edited {
  background: var(--accent-soft);
  outline: 1px dashed var(--accent);
  border-radius: var(--radius-xs);
}
.field-evidence-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.field-evidence-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.extracted-cell {
  white-space: nowrap;
}
.extracted-cell .field-evidence-btn {
  margin-left: var(--space-1);
  vertical-align: middle;
}

.engine-kind-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-2);
}
.engine-kind-option {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  cursor: pointer;
}
.engine-kind-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.engine-kind-option--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.engine-kind-option__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.engine-kind-option__title {
  font-weight: 700;
  color: var(--text);
}
.engine-kind-option__desc,
.engine-kind-option__types {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.35;
}

/* ─── .action-bar ──────────────────────────────────────────
   Sticky bottom bar on review screen.
─────────────────────────────────────────────────────────── */
.action-bar {
  padding: var(--space-3) var(--space-6);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-shrink: 0;
}
.action-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-base);
  color: var(--text-secondary);
}
.action-bar__right { display: flex; gap: var(--space-2); }

/* ─── .chat-pane ───────────────────────────────────────────
   Collapsible middle pane between sidebar and workbench.
─────────────────────────────────────────────────────────── */
.chat-pane {
  width: var(--chat-width);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(var(--app-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--app-grid-line) 1px, transparent 1px),
    var(--app-bg-elevated);
  background-size: var(--grid-size) var(--grid-size);
  border-right: 1px solid var(--app-panel-line);
  flex-shrink: 0;
  transition: width var(--duration-slow) var(--ease-standard),
              opacity var(--duration-base) var(--ease-standard);
  overflow: hidden;
}
.chat-pane--collapsed {
  width: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.chat-pane__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--app-panel-line);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.chat-pane__title {
  flex: 1;
  border: none;
  font-size: var(--text-md);
  font-weight: 600;
  font-family: inherit;
  color: var(--text-inverted);
  background: transparent;
  outline: none;
  min-width: 0;
}
.chat-pane__title:disabled { color: var(--text-inverted-muted); cursor: default; }
.chat-pane__title:focus    { color: var(--accent); }

.chat-toggle {
  background: var(--app-bg);
  border: none;
  border-right: 1px solid var(--app-panel-line);
  width: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverted-muted);
  transition: background var(--duration-base) var(--ease-standard),
              color var(--duration-base) var(--ease-standard);
  flex-shrink: 0;
  padding: 0;
}
.chat-toggle:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-inverted);
}

.chat-pane__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-pane__messages > .chat-result-card,
.chat-pane__messages > .run-card,
.chat-pane__messages > .job-card {
  overflow: hidden;
  border: 1px solid var(--app-panel-line);
  border-radius: var(--radius-lg);
  background: rgba(16, 27, 45, 0.86);
  color: var(--text-inverted);
  box-shadow: none;
}
.chat-pane__messages .card-header {
  border-bottom-color: var(--app-panel-line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-inverted);
}
.chat-pane__messages .card-row {
  border-bottom-color: var(--app-panel-line);
}
.chat-pane__messages .card-row .label,
.chat-pane__messages .card-count {
  color: var(--text-inverted-muted);
}
.chat-pane__messages .card-row .value {
  color: var(--text-inverted);
}
.chat-pane__messages .card-actions,
.chat-pane__messages .card-counts {
  border-top-color: var(--app-panel-line);
}
.chat-pane__messages .card-divider {
  border-top: 1px solid var(--app-panel-line);
}

/* ─── .bubble (chat message) ───────────────────────────────
   Variants: --user | --assistant | --tool
─────────────────────────────────────────────────────────── */
.bubble {
  max-width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  word-break: break-word;
}
.bubble--user {
  background: var(--accent);
  color: var(--text-inverted);
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-xs);
}
.bubble--assistant {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-inverted);
  border: 1px solid var(--app-panel-line);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-xs);
}
.bubble--assistant code {
  background: rgba(0, 0, 0, 0.06); /* exception: contrast on light bg */
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
}
.bubble--tool {
  background: transparent;
  align-self: flex-start;
  padding: 3px 0;
}

/* ─── .composer ────────────────────────────────────────────
   Bottom-of-chat input area.
─────────────────────────────────────────────────────────── */
.composer {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--app-panel-line);
  background: rgba(8, 17, 31, 0.82);
  flex-shrink: 0;
}

.composer__row-context,
.composer__file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}
.composer__row-context:empty,
.composer__file-chips:empty { margin-bottom: 0; }

.composer__row-input {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.composer__row-input .textarea {
  min-height: auto;
  resize: none;
  padding: var(--space-2) var(--space-3);
  flex: 1;
  min-width: 0;
}

.composer__chip-remove {
  color: var(--accent-hover);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.composer__chip-remove:hover { color: var(--text); }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sidebar { display: none; }
}
@media (max-width: 800px) {
  .chat-pane { display: none; }
}
