@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #f5f5f0;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f0f0ea;
  --border: #e4e4dc;
  --border-strong: #c8c8bc;
  --text: #1a1a18;
  --text-2: #5c5c56;
  --text-3: #8a8a82;
  --accent: #18794e;
  --accent-light: #e8f5ee;
  --accent-hover: #136636;
  --danger: #c0392b;
  --danger-light: #fdf2f1;
  --warn: #9a5b00;
  --warn-light: #fef9ee;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111110;
  --surface: #1c1c1a;
  --surface-2: #222220;
  --surface-3: #2a2a28;
  --border: #2e2e2c;
  --border-strong: #484844;
  --text: #ededeb;
  --text-2: #a8a8a0;
  --text-3: #6a6a64;
  --accent: #30d17a;
  --accent-light: rgba(48,209,122,0.1);
  --accent-hover: #50e68e;
  --danger: #ff6b6b;
  --danger-light: rgba(255,107,107,0.1);
  --warn: #f0a830;
  --warn-light: rgba(240,168,48,0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  color: var(--text);
  background: var(--bg);
  font: 13.5px/1.5 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Controls ─────────────────────────────────────────────── */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

button:hover { background: var(--surface-3); border-color: var(--border-strong); }
button:active { transform: scale(0.99); }

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
button.ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }

input, select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

select { cursor: pointer; }

/* ── Layout ─────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px 16px;
  gap: 1px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 0 4px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.brand h1 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand p {
  margin: 0;
  font-size: 11px;
  color: var(--text-3);
}

/* ── Nav ─────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.tab {
  justify-content: flex-start;
  text-align: left;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 400;
}

.tab:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.tab.active { background: var(--accent-light); color: var(--accent); border-color: transparent; font-weight: 500; }
.tab.active:hover { background: var(--accent-light); }

/* ── Status / Theme ──────────────────────────────────────────── */

.status-panel {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 4px 0;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: auto;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.status-dot.ok  { background: var(--accent); }
.status-dot.err { background: var(--danger); }

.theme-toggle {
  width: 100%;
  height: 30px;
  font-size: 12px;
  background: transparent;
  border-color: var(--border);
  color: var(--text-3);
  margin-top: 6px;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }

/* ── Workspace ───────────────────────────────────────────────── */

.workspace {
  min-width: 0;
  padding: 32px 36px;
  position: relative;
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 2px;
  opacity: 0;
  background: transparent;
  transition: opacity 0.15s;
}

.loading-bar::before {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  animation: loading-slide 1.1s ease-in-out infinite;
}

.is-loading .loading-bar { opacity: 1; }

@keyframes loading-slide {
  0%   { transform: translateX(-120%); }
  50%  { transform: translateX(100%); }
  100% { transform: translateX(300%); }
}

/* ── Views ───────────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.view-header h2 {
  margin: 0 0 2px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.view-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

.toolbar, .button-row, .inline { display: flex; align-items: center; gap: 8px; }

/* ── Settings ────────────────────────────────────────────────── */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 20px 24px;
  max-width: 860px;
  margin-bottom: 24px;
}

label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.wide { grid-column: 1 / -1; }

.code-block {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font: 12px/1.6 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  min-height: 200px;
  max-width: 860px;
}

/* ── Split / List ────────────────────────────────────────────── */

.split {
  display: flex;
  flex-direction: row;
  gap: 0;
  min-height: calc(100vh - 130px);
  overflow: hidden;
}

.list-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  /* width controlled by JS, default 280px */
  flex-shrink: 0;
  width: 280px;
  min-width: 160px;
  max-width: 520px;
}

.pane-title {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.list { flex: 1; overflow-y: auto; }

.list-item {
  display: block;
  width: 100%;
  height: auto;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.list-item:hover  { background: var(--surface-2); }
.list-item.active { background: var(--accent-light); }
.list-item:last-child { border-bottom: 0; }

.item-title {
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.3;
}

.item-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* ── Detail Pane ─────────────────────────────────────────────── */

.detail-pane {
  min-width: 0;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 130px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  box-shadow: var(--shadow-sm);
}

.detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
}

.title-row { display: flex; align-items: center; gap: 10px; }

.detail-top h3 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#executionMeta { margin: 0; font-size: 12px; color: var(--text-3); }

.marc-controls { display: flex; align-items: center; gap: 8px; }
.marc-controls select { width: auto; }
#marcSelect { max-width: 200px; }

.hidden { display: none !important; }

/* ── Compare Grid ────────────────────────────────────────────── */

.compare-grid {
  display: flex;
  flex-direction: row;
  gap: 0;
  margin-top: 14px;
  height: clamp(280px, 48vh, 560px);
  flex-shrink: 0;
  overflow: hidden;
}

.pdf-panel, .marc-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 180px;
  flex: 1; /* equal split by default; JS overrides with explicit px width */
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  flex-shrink: 0;
}

.panel-header strong { color: var(--text); font-size: 12.5px; }
.panel-header a { font-size: 12px; }

iframe {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 0;
  background: var(--surface-3);
}

.marc-viewer {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #0f1117;
  color: #cdd6e0;
  font: 12px/1.6 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

:root[data-theme="dark"] .marc-viewer { background: #0a0a0a; }

/* ── OCR Summary ─────────────────────────────────────────────── */

.ocr-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-3);
}

.ocr-summary span { display: inline-flex; gap: 5px; overflow-wrap: anywhere; }
.ocr-summary strong { color: var(--text); }

/* ── Line viewer ─────────────────────────────────────────────── */

.code-line {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  min-height: 18px;
  padding: 0 12px 0 0;
  white-space: pre-wrap;
}

.line-no {
  user-select: none;
  color: #4a5260;
  text-align: right;
  padding-right: 14px;
}

.line-text { overflow-wrap: anywhere; }
.code-line.warning { background: rgba(240,168,48,0.12); }
.code-line.error   { background: rgba(255,107,107,0.15); }
.code-line.focused { outline: 1px solid var(--accent); outline-offset: -1px; }

/* ── Validator ───────────────────────────────────────────────── */

.validator-panel {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-height: 120px;
  height: 220px;
  display: flex;
  flex-direction: column;
}

.validator-summary-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.validation-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.summary-chip.error   { background: var(--danger-light); color: var(--danger); }
.summary-chip.warning { background: var(--warn-light);   color: var(--warn); }
.summary-chip.info    { background: var(--surface-3);    color: var(--text-3); }
.summary-chip.ok      { background: var(--accent-light); color: var(--accent); }

.issues {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  flex: 1;
}

.issue {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-light);
  color: var(--warn);
  font-size: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.1s;
}
.issue:hover { border-color: var(--warn); }
.issue.error { background: var(--danger-light); color: var(--danger); }
.issue.error:hover { border-color: var(--danger); }
.issue.info  { background: var(--surface-2); color: var(--text-3); }
.issue.info:hover { border-color: var(--border-strong); }

.issue.error { background: var(--danger-light); color: var(--danger); }
.issue.info  { background: var(--surface-2); color: var(--text-3); }

.external-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* ── Pills ───────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-3);
}

.pill.succeeded { background: var(--accent-light); color: var(--accent); }
.pill.failed, .pill.timed_out, .pill.aborted { background: var(--danger-light); color: var(--danger); }
.pill.running { background: var(--warn-light); color: var(--warn); }
.pill.muted {
  letter-spacing: 0;
  text-transform: none;
}

/* ── Tracking Table ──────────────────────────────────────────── */

.table-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  max-height: calc(100vh - 130px);
  box-shadow: var(--shadow-sm);
}

/* ── Batch tab shell ──────────────────────────────────────── */
.batch-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - 64px - 64px);  /* viewport minus header minus workspace padding */
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ── Left column: compact item list ─────────────────────── */
.batch-list-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.batch-list-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.batch-filter-select {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.batch-item-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.batch-item-row {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.batch-item-row:last-child { border-bottom: none; }
.batch-item-row:hover { background: var(--surface-2); }
.batch-item-row.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.batch-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.batch-item-id {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.batch-item-sub {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
}

/* ── Right column: viewer ────────────────────────────────── */
.batch-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.batch-viewer-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.batch-viewer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 6px;
}

.batch-viewer-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-viewer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.batch-viewer-meta {
  padding: 0 14px 6px;
  color: var(--text-3);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.batch-viewer-tabs {
  display: flex;
  gap: 0;
  padding: 0 14px;
}

.batch-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.batch-tab:hover { color: var(--text); }
.batch-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.batch-records-pane,
.batch-raw-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.batch-raw-pane {
  margin: 0;
  padding: 12px 14px;
  background: #0f1117;
  color: #cdd6e0;
  font: 12px/1.6 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
:root[data-theme="dark"] .batch-raw-pane { background: #0a0a0a; }

.batch-empty {
  padding: 40px 24px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* ── JSONL record cards ──────────────────────────────────── */
.jsonl-card {
  border-bottom: 1px solid var(--border);
}
.jsonl-card:last-child { border-bottom: none; }

.jsonl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.jsonl-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.jsonl-card-id {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jsonl-card-body {
  /* body holds content rows */
}

.jsonl-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
}

.jsonl-meta-link {
  color: var(--accent);
  text-decoration: none;
}
.jsonl-meta-link:hover { text-decoration: underline; }

/* ── Side-by-side image + text layout ────────────────────── */
.jsonl-content-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) 1fr;
  gap: 0;
  min-height: 0;
}

.jsonl-img-col {
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
  background: var(--surface-2);
  min-width: 0;
}

.jsonl-inline-img {
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
  display: block;
}

.jsonl-img-placeholder {
  width: 100%;
  height: 80px;
  background: var(--surface-3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 11px;
}
.jsonl-img-placeholder::after { content: "Loading image…"; }
.jsonl-img-placeholder.img-error::after { content: "Image unavailable"; }

.jsonl-img-standalone {
  padding: 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.jsonl-text-col {
  min-width: 0;
  overflow: hidden;
}

.jsonl-text-block {
  /* full-width text when no image */
}

.jsonl-text-pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 480px;
  overflow: auto;
  background: #0f1117;
  color: #cdd6e0;
  font: 12px/1.6 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
:root[data-theme="dark"] .jsonl-text-pre { background: #0a0a0a; }

.jsonl-parse-errors {
  margin: 10px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-light);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.table-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.table-row:hover { background: var(--surface-2); }
.table-row:last-child { border-bottom: 0; }

/* ── Empty ───────────────────────────────────────────────────── */

.empty { padding: 16px; font-size: 13px; color: var(--text-3); text-align: center; }
.empty.tight { padding: 4px 0; text-align: left; }

/* ── Scrollbars ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Search bar (code viewer) ────────────────────────────────── */

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.viewer-search {
  flex: 1;
  height: 28px;
  font-size: 12px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.viewer-search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-light); }

.execution-search {
  flex: 1;
  min-width: 140px;
  height: 32px;
  font-size: 12.5px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.execution-search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-light); }
.execution-search::placeholder { color: var(--text-3); }

.exec-search-empty {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text-2);
}
.exec-search-empty p { margin: 0; }
.exec-search-action {
  font-size: 12.5px;
  padding: 6px 14px;
}

mark.search-highlight {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-match-count {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  min-width: 56px;
  text-align: right;
}

.viewer-btn {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.viewer-btn:hover { background: var(--surface-3); color: var(--text); }
.viewer-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.search-highlight {
  background: rgba(240, 168, 48, 0.35);
  border-radius: 2px;
}
.search-highlight.current {
  background: rgba(240, 168, 48, 0.75);
  outline: 1px solid var(--warn);
}

/* ── JSON Tree Viewer ────────────────────────────────────────── */

.marc-panel.json-tree-mode .marc-viewer { display: none; }
.marc-panel.json-tree-mode .json-tree-container { display: flex; }

.json-tree-container {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #0f1117;
  padding: 12px;
  flex-direction: column;
}

.jt-node { padding-left: 16px; }
.jt-root { padding-left: 0; }

.jt-toggle {
  cursor: pointer;
  user-select: none;
  color: #6a7f8a;
  font-size: 10px;
  margin-right: 4px;
  display: inline-block;
  width: 12px;
  transition: transform 0.1s;
}
.jt-toggle.open::before { content: "▾"; }
.jt-toggle.closed::before { content: "▸"; }
.jt-toggle.leaf::before { content: ""; }

.jt-key   { color: #a8d8a8; }
.jt-str   { color: #f2b374; }
.jt-num   { color: #b5c9f5; }
.jt-bool  { color: #e392d0; }
.jt-null  { color: #e392d0; font-style: italic; }
.jt-punct { color: #6a7f8a; }

.jt-children { border-left: 1px solid #2a3540; margin-left: 6px; padding-left: 10px; }
.jt-children.collapsed { display: none; }

.jt-row {
  display: flex;
  align-items: baseline;
  gap: 0;
  line-height: 1.7;
  font: 12px/1.7 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: #cdd6e0;
}
.jt-row:hover { background: rgba(255,255,255,0.04); border-radius: 3px; }

/* ── Syntax Highlighting ─────────────────────────────────────── */

.tok-tag    { color: #7ec8e3; }
.tok-attr   { color: #a8d8a8; }
.tok-str    { color: #f2b374; }
.tok-num    { color: #b5c9f5; }
.tok-bool   { color: #e392d0; }
.tok-null   { color: #e392d0; }
.tok-key    { color: #a8d8a8; }
.tok-punct  { color: #6a7f8a; }
.tok-mrk-tag    { color: #7ec8e3; font-weight: 600; }
.tok-mrk-ind    { color: #6a7f8a; }
.tok-mrk-sub    { color: #e392d0; font-weight: 600; }
.tok-mrk-val    { color: #cdd6e0; }

/* ── Process Layout ──────────────────────────────────────────── */

.process-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.process-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.process-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.process-card-header strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.process-card-header p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Drop Zone ────────────────────────────────────────────────── */

.drop-zone {
  position: relative;
  margin: 18px 20px 0;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.drop-zone-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  pointer-events: none;
  text-align: center;
}

.drop-icon {
  width: 36px;
  height: 36px;
  color: var(--text-3);
  margin-bottom: 10px;
}

.drop-label {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--text-2);
}

.drop-browse {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
}

.drop-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-3);
}

.drop-zone-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-2);
  font-size: 13px;
}

.drop-zone-selected svg { color: var(--accent); flex-shrink: 0; }
.drop-zone-selected span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Upload Fields ───────────────────────────────────────────── */

.upload-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  padding: 16px 20px;
}

.upload-fields label > em {
  font-style: normal;
  color: var(--text-3);
}

.process-card-footer {
  padding: 0 20px 18px;
}

.upload-btn {
  width: 100%;
  height: 38px;
  font-size: 13.5px;
  /* Disabled state (no file selected) */
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text-3);
  cursor: not-allowed;
  opacity: 0.7;
}

.upload-btn.ready {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  opacity: 1;
}

.upload-btn.ready:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ── Execution Callout ───────────────────────────────────── */

.execution-callout {
  margin: 16px 20px 0;
  padding: 14px 16px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-light);
  animation: callout-in 0.2s ease;
}

@keyframes callout-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.execution-callout-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.execution-callout-arn {
  font: 12px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 10px;
}

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

.primary-sm {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.primary-sm:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ── Pipeline Timeline ───────────────────────────────────────── */

.pipeline-timeline {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 160px;
}

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

.timeline-step {
  display: flex;
  gap: 14px;
  position: relative;
}

.timeline-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: -4px;
  width: 1px;
  background: var(--border);
}

.tl-dot {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  z-index: 1;
  background: var(--surface-3);
  border: 1.5px solid var(--border-strong);
  color: var(--text-3);
}

.tl-dot.done   { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.tl-dot.active { background: var(--warn-light); border-color: var(--warn); color: var(--warn); animation: tl-pulse 1.2s ease infinite; }
.tl-dot.error  { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

@keyframes tl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.tl-body {
  flex: 1;
  padding-bottom: 16px;
}

.tl-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.tl-meta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.tl-action {
  margin-top: 8px;
}

/* ── Raw toggle ──────────────────────────────────────────────── */

.upload-result-raw {
  border-top: 1px solid var(--border);
  padding: 0;
}

.raw-toggle {
  width: 100%;
  border-radius: 0;
  border-color: transparent;
  height: 36px;
  font-size: 12px;
  color: var(--text-3);
  justify-content: flex-start;
  padding: 0 20px;
}

.upload-result-raw .code-block {
  margin: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  max-height: 240px;
  max-width: none;
  min-height: unset;
}

/* ── Ask ─────────────────────────────────────────────────────── */

.ask-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.4fr);
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 120px);
}

.ask-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}


.answer-panel {
  display: flex;
  flex-direction: column;
}

.answer-box {
  flex: 1;
  padding: 18px 20px;
  white-space: pre-wrap;
  color: var(--text);
  overflow: auto;
}

.answer-box.empty {
  color: var(--text-3);
}

.citations {
  border-top: 1px solid var(--border);
  max-height: 320px;
  overflow: auto;
}

.citation {
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.citation summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  word-break: break-all;
}

.citation p {
  color: var(--text-2);
  margin: 10px 0;
}

.citation pre {
  margin: 0;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-3);
  overflow: auto;
  font: 11px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.muted-text {
  color: var(--text-3);
  font-size: 12px;
}

.muted-text.warn {
  color: var(--warn);
}

/* ── Tracking rows (collapsible) ─────────────────────────────── */

.tracking-row {
  border-bottom: 1px solid var(--border);
}
.tracking-row:last-child { border-bottom: 0; }

.tracking-row-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.1s;
}
.tracking-row-header:hover { background: var(--surface-2); }

.tracking-row-toggle {
  font-size: 11px;
  color: var(--text-3);
  transition: transform 0.15s;
  user-select: none;
  display: inline-block;
}
.tracking-row.open .tracking-row-toggle { transform: rotate(90deg); }

.tracking-row-info { flex: 1; min-width: 0; }

.tracking-row-body {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.tracking-row.open .tracking-row-body { display: block; }

.tracking-row-body pre {
  margin: 0;
  padding: 14px 18px;
  font: 12px/1.6 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 340px;
  overflow-y: auto;
}

/* ── Execution status badge ──────────────────────────────────── */

#executionStatusBadge:not(:empty) {
  display: inline-flex;
}

/* ── Ask / Knowledge Base ────────────────────────────────────── */

.ask-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
  height: calc(100vh - 64px - 2 * 32px);  /* viewport minus header (64px) minus workspace top+bottom padding */
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ── Chat column ── */
.ask-chat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.ask-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}

/* ── Empty / welcome state ── */
.ask-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 32px 32px;
  gap: 32px;
  overflow-y: auto;
}

.ask-welcome {
  text-align: center;
  max-width: 520px;
  width: 100%;
}

.ask-welcome-icon {
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin: 0 auto 16px;
  opacity: 0.85;
  display: block;
}

.ask-welcome h3 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.ask-welcome p {
  margin: 0;
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.65;
}

/* ── Suggestion cards grid ── */
.ask-suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 640px;
}

.ask-suggestion-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  height: auto;
  min-height: 80px;
  width: 100%;
  box-sizing: border-box;
}
.ask-suggestion-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.ask-suggestion-card .card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  white-space: normal;
  display: block;
}
.ask-suggestion-card .card-desc {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.55;
  white-space: normal;
  display: block;
}

/* ── Messages ── */
.ask-msg {
  padding: 20px 24px 0;
  display: flex;
  flex-direction: column;
  animation: msg-in 0.15s ease;
  flex-shrink: 0;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ask-msg + .ask-msg {
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.ask-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.ask-msg-user  .ask-bubble-wrap { align-items: flex-end; }
.ask-msg-assistant .ask-bubble-wrap { align-items: flex-start; }

.ask-role-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.ask-msg-user .ask-role-label {
  text-align: right;
  color: var(--accent);
}

.ask-bubble {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ask-msg-user .ask-bubble {
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
  max-width: 80%;
  min-width: 0;
}
.ask-msg-assistant .ask-bubble {
  padding: 0;
  background: none;
  max-width: 100%;
  width: 100%;
  min-width: 0;
}

.ask-msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.ask-msg-user .ask-msg-actions { justify-content: flex-end; }

.ask-action-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.ask-action-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.ask-action-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.ask-ts {
  font-size: 11px;
  color: var(--text-3);
}

/* ── Typing indicator ── */
.ask-typing-wrap {
  padding: 20px 24px 0;
}
.typing-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 6px 0;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-bounce 1.2s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Input bar ── */
.ask-input-bar {
  flex-shrink: 0;
  padding: 14px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ask-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ask-input {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: 14px/1.45 inherit;
  resize: none;
  overflow-y: auto;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  display: block;
}
.ask-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.ask-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  box-sizing: border-box;
  align-self: flex-end;
}
.ask-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.04);
}
.ask-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.ask-input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  padding: 0 2px;
}

.ask-model-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
}
.ask-model-label::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
  flex-shrink: 0;
}

.ask-meta-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.ask-meta-btn:hover { color: var(--text); background: var(--surface-3); }

/* ── Sidebar ── */
.ask-sidebar {
  min-height: 0;
  overflow-y: auto;
  background: var(--surface-2);
  border-left: 1px solid var(--border);
}

.ask-sidebar-inner {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ask-config-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ask-config-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ask-model-select {
  width: 100%;
  font-size: 13px;
}

.ask-custom-model input { font-size: 12.5px; }

.ask-config-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ask-config-label span { font-size: 12px; color: var(--text-3); }
.ask-config-label input { font-size: 12.5px; }

.ask-kb-status {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}
.ask-kb-status.ok  { color: var(--accent); }
.ask-kb-status.err { color: var(--danger); }

.ask-kb-status-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.kb-stat-label {
  color: var(--text-3);
  flex-shrink: 0;
  white-space: nowrap;
}
.kb-stat-value {
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  font-weight: 500;
}
.kb-stat-value.mono {
  font: 11.5px/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text-2);
}

.kb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kb-status-pill.active   { background: #d1fae5; color: #065f46; }
.kb-status-pill.creating { background: #fef9c3; color: #713f12; }
.kb-status-pill.updating { background: #dbeafe; color: #1e40af; }
.kb-status-pill.deleting { background: #fee2e2; color: #991b1b; }
.kb-status-pill.failed   { background: #fee2e2; color: #991b1b; }
.kb-status-pill.complete { background: #d1fae5; color: #065f46; }
.kb-status-pill.starting { background: #fef9c3; color: #713f12; }
.kb-status-pill.in-progress { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .kb-status-pill.active      { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .kb-status-pill.creating    { background: #422006; color: #fde68a; }
[data-theme="dark"] .kb-status-pill.updating    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .kb-status-pill.failed      { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .kb-status-pill.complete    { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .kb-status-pill.in-progress { background: #1e3a5f; color: #93c5fd; }

.kb-jobs-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.kb-job-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.kb-job-row:last-child { border-bottom: none; }
.kb-job-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.kb-job-ts {
  font-size: 11px;
  color: var(--text-3);
}
.kb-job-stats {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 1px;
}
.kb-stat-added   { color: #059669; }
.kb-stat-updated { color: #2563eb; }
.kb-stat-deleted { color: var(--text-3); }
.kb-stat-failed  { color: var(--danger); font-weight: 600; }
[data-theme="dark"] .kb-stat-added   { color: #34d399; }
[data-theme="dark"] .kb-stat-updated { color: #93c5fd; }
[data-theme="dark"] .kb-stat-failed  { color: #f87171; }

.kb-summary-banner {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.kb-summary-stat {
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kb-summary-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  text-align: center;
}
.kb-summary-lbl {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
  text-align: center;
}

.kb-sync-btn {
  margin-top: 10px;
  width: 100%;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.kb-sync-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.kb-sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ask-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ── Citations ── */
.citation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.citation-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.citation-header:hover { background: var(--surface-2); }

.citation-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.citation-uri {
  font: 11.5px/1.35 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-score {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}

.citation-chevron {
  font-size: 9px;
  color: var(--text-3);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.citation-item.open .citation-chevron { transform: rotate(90deg); }
.citation-item.open .citation-header  { background: var(--accent-light); }

.citation-excerpt {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.65;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: none;
}
.citation-item.open .citation-excerpt { display: block; }

/* ── Resize Splitters ────────────────────────────────────────── */

.resizer {
  flex-shrink: 0;
  background: transparent;
  z-index: 4;
  transition: background 0.15s;
  position: relative;
}

.resizer::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: var(--border-strong);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.resizer:hover::after,
.resizer.dragging::after {
  opacity: 1;
  background: var(--accent);
}

/* Vertical resizer (between horizontal panes) */
.resizer-col {
  width: 10px;
  cursor: col-resize;
  margin: 0 3px;
}
.resizer-col::after {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 40px;
}

/* Horizontal resizer (between vertical panels) */
.resizer-row {
  height: 10px;
  cursor: row-resize;
  width: 100%;
  margin: 3px 0;
}
.resizer-row::after {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 3px;
}

/* prevent text selection while dragging */
body.resizing { user-select: none; cursor: col-resize !important; }
body.resizing-row { user-select: none; cursor: row-resize !important; }

.cost-panel,
.tracking-cost {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  margin: 10px 0 12px;
}

.cost-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 9px;
  white-space: nowrap;
}

.cost-disclosure {
  flex-shrink: 0;
  margin-top: 12px;
  margin-bottom: 16px;
}

.cost-disclosure summary {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: space-between;
  list-style: none;
}

.cost-disclosure summary::-webkit-details-marker { display: none; }

.cost-disclosure summary::before {
  content: "›";
  color: var(--muted);
  font-size: 16px;
  margin-right: 8px;
  transition: transform 0.15s ease;
}

.cost-disclosure[open] summary::before { transform: rotate(90deg); }

.cost-disclosure summary span:first-child {
  margin-right: auto;
}

#executionCostPanelMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.cost-disclosure[open] #executionCostPanelBody {
  margin-top: 10px;
}

.cost-panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.cost-grid > div,
.cost-step {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface);
}

.cost-grid span,
.cost-step span,
.cost-step em {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

.cost-grid strong,
.cost-step strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.cost-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .brand { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
  .tabs { flex-direction: row; flex: 1; gap: 4px; }
  .status-panel { margin-top: 0; margin-left: auto; }
  .theme-toggle { margin-top: 0; width: auto; }
  .workspace { padding: 20px 18px; }

  .split { flex-direction: column; min-height: auto; }
  .split .resizer-col { display: none; }
  .list-pane { width: 100% !important; max-width: none; min-width: 0; }

  .compare-grid { flex-direction: column; height: auto; }
  .compare-grid .resizer-col { display: none; }
  .pdf-panel, .marc-panel { width: 100% !important; min-height: 320px; }

  .settings-grid, .process-layout, .upload-fields { grid-template-columns: 1fr; }
  .batch-shell { grid-template-columns: 1fr; height: auto; }
  .batch-list-col { max-height: 260px; border-right: none; border-bottom: 1px solid var(--border); }
  .cost-grid, .cost-steps { grid-template-columns: 1fr 1fr; }

  .ask-layout { grid-template-columns: 1fr; height: auto; }
  .ask-sidebar { display: none; }
  .ask-empty-state { padding: 24px 16px; }
  .ask-suggestion-grid { grid-template-columns: 1fr; }
}
