/* V2 board overrides — sits on top of /styles.css from the v1 board.
 * Only adds what's specific to the pipeline_state-driven layout. */

.v2-tag {
  font-size: 11px;
  font-weight: 600;
  background: #3b82f6;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.05em;
}

.board-v2 .header-left a.btn {
  font-size: 12px;
  padding: 4px 10px;
  margin-left: 8px;
}

/* Tighter columns — 12 of them is a lot */
.v2-board-area {
  gap: 12px;
}

.v2-board-area .column {
  min-width: 240px;
  max-width: 260px;
  flex: 0 0 250px;
}

/* Column kind chrome — gates and terminals get a tinted header bar */
.column[data-kind="gate"] .column-header {
  border-top: 3px solid #f59e0b;
}
.column[data-kind="auto"] .column-header {
  border-top: 3px solid #8b5cf6;
}
.column[data-kind="terminal"] .column-header {
  border-top: 3px solid #6b7280;
  opacity: 0.92;
}

.column-kind-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-left: auto;
  font-weight: 600;
}

/* Drop targets while dragging an awaiting_approval card */
.column-body.drop-approve {
  background: rgba(16, 185, 129, 0.08);
  outline: 2px dashed #10b981;
  outline-offset: -4px;
}
.column-body.drop-reject {
  background: rgba(239, 68, 68, 0.08);
  outline: 2px dashed #ef4444;
  outline-offset: -4px;
}
.column-body.drop-blocked {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Risk tier badge */
.badge-tier {
  font-weight: 700;
  letter-spacing: 0.05em;
}
.badge-tier-1 { background: rgba(16, 185, 129, 0.18); color: #10b981; }
.badge-tier-2 { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }
.badge-tier-3 { background: rgba(239, 68, 68, 0.20); color: #ef4444; }

/* Plan / cost line on the card */
.task-card-plan {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.task-card-plan .plan-segment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-card-plan .plan-warn { color: #f59e0b; }

.cost-bar {
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
}
.cost-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b 70%, #ef4444 100%);
  transition: width 0.2s ease;
}

/* Grade chip */
.grade-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
}
.grade-pass         { background: rgba(16, 185, 129, 0.18); color: #10b981; }
.grade-needs_review { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }
.grade-fail         { background: rgba(239, 68, 68, 0.18);  color: #ef4444; }
.grade-unclear      { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }
.grade-overridden::after {
  content: '⚖';
  margin-left: 2px;
  font-size: 9px;
}

/* Awaiting approval cards — emphasized */
.task-card[data-pipeline-state="awaiting_approval"] {
  border-left: 3px solid #f59e0b;
}

/* Detail modal sections */
.detail-section {
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 0 0 6px;
}
.detail-section pre {
  background: #1e293b;
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.4;
}

.detail-step-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #1e293b;
  font-size: 12px;
}
.detail-step-row .step-status {
  font-size: 14px;
  text-align: center;
}
.detail-step-row .step-meta {
  color: #94a3b8;
  font-size: 11px;
}

/* Agent dialogue thread (Conversation section) */
.dialogue-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dialogue-bubble {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
}
.dialogue-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #334155;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialogue-content {
  background: #1e293b;
  border-radius: 8px;
  padding: 8px 10px;
}
.dialogue-header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.dialogue-actor {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}
.dialogue-time {
  margin-left: auto;
}
.dialogue-text {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.dialogue-tools {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.dialogue-tool-chip {
  display: inline-block;
  padding: 2px 6px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 10px;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
}

.reject-task-summary {
  margin-top: 12px;
  padding: 8px;
  background: #0f172a;
  border-radius: 4px;
  font-size: 12px;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.empty-board {
  text-align: center;
  padding: 60px;
  color: #64748b;
  width: 100%;
}

/* ── Nav between v2 board and skills page ── */
.v2-nav {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
}
.v2-nav .btn {
  font-size: 12px;
  padding: 4px 10px;
}
.v2-nav .btn.active {
  background: #1e293b;
  color: #e2e8f0;
}

/* ── Skills page two-pane layout ── */
.skills-main {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  padding: 16px 24px 24px;
  height: calc(100vh - 140px);
  overflow: hidden;
}

.skills-list {
  background: #0f172a;
  border-radius: 6px;
  overflow-y: auto;
  padding: 8px;
}

.skills-group {
  margin-bottom: 12px;
}
.skills-group-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 8px 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.skills-group-count {
  background: #1e293b;
  border-radius: 8px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
}

.skill-row {
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 4px;
  cursor: pointer;
  border-left: 3px solid transparent;
  background: #1e293b;
  transition: background 0.1s;
}
.skill-row:hover { background: #273449; }
.skill-row.selected { background: #2c3a52; border-left-color: #3b82f6; }

.skill-row-title {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.skill-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: #94a3b8;
}

.shadow-progress {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  padding: 1px 6px;
  border-radius: 4px;
}

.origin-auto { color: #8b5cf6; }
.origin-human { color: #94a3b8; }

.state-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.state-draft      { background: rgba(245, 158, 11, 0.20); color: #f59e0b; }
.state-shadow     { background: rgba(139, 92, 246, 0.20); color: #a78bfa; }
.state-live       { background: rgba(16, 185, 129, 0.20); color: #10b981; }
.state-deprecated { background: rgba(107, 114, 128, 0.25); color: #94a3b8; }

/* ── Skills detail pane ── */
.skills-detail {
  background: #0f172a;
  border-radius: 6px;
  overflow-y: auto;
  padding: 20px 24px;
}

.skill-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e293b;
}
.skill-detail-header h2 {
  margin: 0 0 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 18px;
  color: #e2e8f0;
}
.skill-detail-sub {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.skill-detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.skill-detail-actions .btn {
  font-size: 12px;
  padding: 6px 12px;
}
.skill-detail-actions .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.lifecycle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 12px;
  color: #cbd5e1;
}
.lifecycle-grid code {
  background: #1e293b;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.skill-md-pre {
  background: #020617;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.skill-md-editor {
  width: 100%;
  background: #020617;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 4px;
  border: 1px solid #1e293b;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  line-height: 1.5;
  min-height: 400px;
  max-height: 600px;
  resize: vertical;
  white-space: pre;
  word-break: normal;
  outline: none;
}
.skill-md-editor:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}
.editor-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #94a3b8;
}

.event-row {
  display: grid;
  grid-template-columns: 120px 100px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #1e293b;
  font-size: 11px;
}
.event-time { color: #94a3b8; }
.event-outcome {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.event-drafted             { color: #3b82f6; }
.event-approved_to_shadow  { color: #a78bfa; }
.event-promoted            { color: #10b981; }
.event-rejected            { color: #ef4444; }
.event-failed              { color: #ef4444; }
.event-notes { color: #cbd5e1; }

/* Human feedback bubble — visually distinct from agent bubbles */
.dialogue-bubble-human .dialogue-avatar {
  background: #f59e0b;
  color: #0f172a;
}
.dialogue-bubble-human .dialogue-content {
  background: #1f1d12;
  border-left: 3px solid #f59e0b;
}

/* Send-back-with-feedback section on completed tasks */
/* Message section on the task detail — always-visible chat input.
 * Replaces the older "Send Back" section. Same UX shell handles
 * corrective feedback and conversational follow-ups. */
.message-section { margin-top: 18px; }
.message-input {
  width: 100%;
  padding: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.message-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.message-target-label {
  font-size: 11px;
  color: #94a3b8;
}
.message-target-label select {
  margin-left: 6px;
  background: #0f172a;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
}
.message-hint {
  font-size: 10px;
  color: #64748b;
  font-family: ui-monospace, monospace;
}
.message-controls button {
  margin-left: auto;
  padding: 6px 14px;
  background: #f59e0b;
  color: #0f172a;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.message-controls button:hover:not(:disabled) { background: #fbbf24; }
.message-controls button:disabled { opacity: 0.5; cursor: not-allowed; }
.message-status {
  margin-top: 8px;
  font-size: 11px;
  color: #94a3b8;
  min-height: 14px;
}
.message-queued-badge {
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 4px;
  font-size: 11px;
  color: #c4b5fd;
}

/* Extend-budget surface — appears inline when the task is blocked on
 * a cost-cap halt. The button opens a prompt (v1) to enter a new cap. */
.extend-budget-row {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.extend-budget-info {
  font-size: 11px;
  color: #fca5a5;
  flex: 1 1 auto;
}
.extend-budget-row button {
  padding: 6px 12px;
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
}
.extend-budget-row button:hover { background: rgba(239, 68, 68, 0.15); }

/* ── Task detail: section cards with tint-by-type ────────────────── */
/* Upgrade from flat-stacked sections to card-style segmentation.
 * Each section gets a 1px border, slight bg lift, and a subtle tint
 * by type so the eye can navigate the modal at a glance. */
.detail-section {
  background: #131c2f;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 12px 14px;
}
.detail-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
  margin: 0 0 8px;
  font-weight: 700;
}
.detail-section-overview     { border-left: 3px solid #64748b; }
.detail-section-plan         { border-left: 3px solid #6366f1; }   /* indigo */
.detail-section-steps        { border-left: 3px solid #8b5cf6; }   /* purple */
.detail-section-conversation { border-left: 3px solid #10b981; background: #0f1f1a; }  /* green, slightly stronger */
.detail-section-grade        { border-left: 3px solid #94a3b8; }
.detail-section-grade-pass         { border-left-color: #10b981; }
.detail-section-grade-needs_review { border-left-color: #f59e0b; }
.detail-section-grade-fail         { border-left-color: #ef4444; }
.detail-section-activity     { border-left: 3px solid #475569; }   /* muted */
.detail-section-message      { border-left: 3px solid #f59e0b; }   /* amber action */
.detail-section-actions      { border-left: 3px solid #1e293b; padding: 8px 12px; }

/* Modal title bar — grade + state pills next to title */
.modal-title-grade,
.modal-title-state {
  margin-left: 8px;
  vertical-align: middle;
}
.modal-title-state .state-chip {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #1e293b;
  color: #cbd5e1;
}
.state-chip.state-inbox            { background: rgba(100,116,139,0.18); color: #cbd5e1; }
.state-chip.state-awaiting_approval{ background: rgba(245,158,11,0.18); color: #f59e0b; }
.state-chip.state-planning         { background: rgba(99,102,241,0.18); color: #a5b4fc; }
.state-chip.state-executing        { background: rgba(139,92,246,0.18); color: #c4b5fd; }
.state-chip.state-grading          { background: rgba(34,211,238,0.18); color: #67e8f9; }
.state-chip.state-review           { background: rgba(245,158,11,0.22); color: #fbbf24; }
.state-chip.state-done             { background: rgba(16,185,129,0.18); color: #10b981; }
.state-chip.state-blocked          { background: rgba(239,68,68,0.18);  color: #ef4444; }
.state-chip.state-rejected         { background: rgba(107,114,128,0.18);color: #94a3b8; }

/* Lifecycle action bar */
.lifecycle-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.lifecycle-btn {
  padding: 6px 14px;
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.lifecycle-btn:hover { background: #1e293b; border-color: #475569; }
.lifecycle-accept { border-color: #10b981; color: #10b981; }
.lifecycle-accept:hover { background: rgba(16,185,129,0.12); border-color: #34d399; }
.lifecycle-delete { border-color: #7f1d1d; color: #f87171; }
.lifecycle-delete:hover { background: rgba(239,68,68,0.12); border-color: #ef4444; }

/* Archived banner inside task overview */
.archived-banner {
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(100,116,139,0.18);
  border-radius: 4px;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

/* ── Markdown rendering inside dialogue bubbles + grade feedback ── */
.dialogue-text .md-h1,
.dialogue-text .md-h2,
.dialogue-text .md-h3 {
  margin: 10px 0 6px;
  font-weight: 700;
  color: #e2e8f0;
}
.dialogue-text .md-h1 { font-size: 15px; }
.dialogue-text .md-h2 { font-size: 14px; }
.dialogue-text .md-h3 { font-size: 13px; color: #cbd5e1; }
.dialogue-text p { margin: 6px 0; }
.dialogue-text p:first-child { margin-top: 0; }
.dialogue-text p:last-child  { margin-bottom: 0; }
.dialogue-text .md-list {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.dialogue-text .md-list li { margin: 3px 0; }
.dialogue-text strong { color: #e2e8f0; font-weight: 700; }
.dialogue-text em { color: #cbd5e1; }
.dialogue-text .md-inline-code {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #fbbf24;
}
.dialogue-text .md-code {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 8px 10px;
  margin: 8px 0;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  color: #cbd5e1;
  overflow-x: auto;
  white-space: pre;
}
.dialogue-text a {
  color: #60a5fa;
  text-decoration: underline;
  text-decoration-color: rgba(96,165,250,0.4);
}
.dialogue-text a:hover { text-decoration-color: #60a5fa; }

/* "Show archived" header toggle */
.archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
  margin-left: 12px;
  cursor: pointer;
  user-select: none;
}
.archive-toggle input { cursor: pointer; }

/* Archived cards on the board get a muted treatment */
.task-card[data-archived="true"] {
  opacity: 0.55;
  border-style: dashed;
}

/* Page toolbar — replaces the pre-shell header row. Chrome (sidebar, header,
   identity) is the universal shell from /hub/hub.js. */
.v2-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 0;
}
.v2-toolbar-spacer { flex: 1; }
