/* The task card: meta, title, the lineage rail (brief → discarded attempts → current attempt),
   the one button, and the tools. Solid amber means durable (the brief); dashed amber means
   disposable (the wake of a dropped diff). */

.card {
  position: relative;
  padding: 13px 14px 12px;
  border-radius: var(--r-card);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: border-color var(--d-hover), box-shadow 0.2s;
  scroll-margin: 90px 24px;
}
.card:hover { border-color: var(--line-2); }
.card:focus-visible { outline-offset: 3px; }
.card.is-highlight { border-color: var(--lamp-line); box-shadow: var(--shadow-card), 0 0 0 3px var(--lamp-wash); }
.card.is-entering { animation: card-in var(--d-enter) var(--ease) both; }
.card.is-settled { animation: tone-glow 1.2s var(--ease); }
.card.is-moved { outline: 2px solid var(--tc); outline-offset: 2px; }
.card[data-compact] { padding-bottom: 10px; }
.card[aria-busy="true"] { cursor: progress; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--t-micro);
  color: var(--text-2);
}
.agent { display: inline-flex; align-items: center; gap: 7px; min-width: 0; flex: 0 1 auto; }
.agent .flag { flex: none; }
.agent-name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attempt-no { font-family: var(--font-mono); color: var(--text-2); white-space: nowrap; flex: none; }
/* With a re-run tag the time is the first thing to go; the name and attempt number stay. */
@container lane (max-width: 330px) {
  .card-time.is-optional { display: none; }
  .rerun-tag { margin-left: auto; }
}
.rerun-tag {
  flex: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--lamp);
  background: var(--lamp-wash);
  border: 1px solid var(--lamp-line);
}
.rerun-tag .ic { width: 11px; height: 11px; stroke-width: 2.2; }
.card-time { margin-left: auto; padding-left: 4px; flex: none; font-family: var(--font-mono); color: var(--text-3); white-space: nowrap; }

.card-title {
  margin: 8px 0 12px;
  font-family: var(--font-display);
  font-size: var(--t-h3);
  font-weight: 620;
  line-height: 1.24;
  letter-spacing: -0.012em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.card[data-compact] .card-title { font-size: 0.96875rem; margin-bottom: 8px; }

/* ------------------------------------------------------------------ lineage rail */

.lineage { position: relative; }
.node {
  --nc: var(--slate);
  position: relative;
  padding: 0 0 14px 24px;
}
.node:last-child { padding-bottom: 0; }
.node::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--nc);
  box-shadow: 0 0 0 3px var(--card);
  z-index: 1;
}
.node:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 14px;
  bottom: -3px;
  width: 1px;
  background: var(--line-2);
}

/* a. The brief: an amber diamond on the rail and a block that reads as a commit. */
.node-brief::before {
  left: 3px;
  top: 12px;
  width: 9px;
  height: 9px;
  border-radius: 1.5px;
  transform: rotate(45deg);
  background: var(--lamp-fill);
  box-shadow: 0 0 0 3px var(--card);
}
.node-brief:not(:last-child)::after { top: 22px; background: linear-gradient(to bottom, var(--lamp-line), var(--line-2)); }

.brief-block {
  display: block;
  width: 100%;
  padding: 7px 10px 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--lamp-line);
  border-left: 3px solid var(--lamp);
  background: var(--lamp-wash);
  text-align: left;
  color: inherit;
  transition: background-color var(--d-hover), border-color var(--d-hover);
}
.brief-block:hover { border-color: var(--lamp); border-left-color: var(--lamp); }
.brief-block[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--lamp-line); }
.bb-top { display: flex; align-items: center; gap: 8px; }
.bb-label {
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--lamp);
  white-space: nowrap;
}
.sha-chip {
  margin-left: auto;
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--lamp-fill);
  color: var(--lamp-ink);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.bb-id {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bb-sum { display: block; margin-top: 2px; font-size: var(--t-micro); color: var(--text-2); line-height: 1.4; overflow-wrap: anywhere; }
.bb-same { color: var(--lamp); font-weight: 600; }

/* b. Earlier attempts: a hollow, struck node, the reason in full contrast, and the wake after it. */
.node-past { --nc: transparent; }
.node-past::before {
  background:
    linear-gradient(135deg, transparent 44%, var(--slate) 44%, var(--slate) 58%, transparent 58%),
    var(--card);
  box-shadow: inset 0 0 0 1.5px var(--slate), 0 0 0 3px var(--card);
}
.node-past:not(:last-child)::after {
  width: 2px;
  left: 6.5px;
  background: repeating-linear-gradient(to bottom, var(--lamp) 0 2px, transparent 2px 6px);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), #000 70%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), #000 70%);
  transform-origin: top;
}
.node-past.is-new:not(:last-child)::after { animation: wake-draw var(--d-draw) var(--ease) 0.1s both; }

.node-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; line-height: 1.35; }
.node-name { font-size: var(--t-label); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text); }
.node-sub { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--text-2); }
.node-sub .sha { font-size: 1em; }
.node-line { margin-top: 3px; font-size: var(--t-micro); color: var(--text-3); line-height: 1.4; }
.node-line.is-mono { font-family: var(--font-mono); font-size: var(--t-mono); }
.node-line .arrow { color: var(--text-3); padding: 0 2px; }
.node-line .hl { color: var(--text-2); }
.node-text { margin-top: 6px; font-size: var(--t-small); color: var(--text); line-height: 1.45; }

.node-past .node-name { color: var(--text-2); }
.past-word { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--text-3); }
.struck {
  color: var(--text-3);
  background-image: linear-gradient(var(--slate), var(--slate));
  background-repeat: no-repeat;
  background-position: 0 56%;
  background-size: 100% 1px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.node-past.is-new .struck { animation: strike-draw var(--d-enter) var(--ease) both; }
.discard-reason {
  margin-top: 6px;
  padding-left: 9px;
  border-left: 2px solid var(--buoy-line);
  font-size: var(--t-small);
  line-height: 1.45;
  color: var(--text);
}
.never-merges { display: block; margin-top: 2px; font-size: var(--t-micro); color: var(--text-2); }
.never-merges .struck { font-family: var(--font-mono); }
.past-tools { display: flex; gap: 2px; margin-top: 4px; margin-left: -6px; }
.wake-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--lamp);
  letter-spacing: 0.02em;
}
.wake-label .ic { width: 12px; height: 12px; stroke-width: 2; }

/* c. The current attempt: a filled node in the card's tone; it pulses only while an agent runs. */
.node-current { --nc: var(--tc); }
.node-current[data-hollow]::before { background: var(--card); box-shadow: inset 0 0 0 2px var(--tc), 0 0 0 3px var(--card); }
.node-current[data-running]::before { animation: node-pulse 2.4s var(--ease) infinite; }
.node-current.is-new { animation: node-in var(--d-enter) var(--ease) 0.3s both; }
.node-current .node-name { color: var(--text); }

/* d. The ghost of the next attempt (Needs re-run only). */
.node-ghost { --nc: transparent; }
.node-ghost::before { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--lamp), 0 0 0 3px var(--card); }
.ghost-text { font-size: var(--t-micro); color: var(--text-2); line-height: 1.45; }
.ghost-text strong { color: var(--lamp); font-weight: 600; }
.node-current:has(+ .node-ghost)::after {
  width: 0;
  left: 7px;
  border-left: 1.5px dashed var(--lamp-line);
  background: none;
}

/* ------------------------------------------------------------------ facts inside the current attempt */

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  font-size: var(--t-micro);
  font-weight: 600;
  color: var(--tc);
  background: var(--tw);
  white-space: nowrap;
}
.pill:not([data-tone]) { --tc: var(--text-2); --tw: var(--slate-wash); }
.pill .ic { width: 13px; height: 13px; stroke-width: 2.1; }
.pill .sha { background: transparent; padding: 0; color: inherit; font-weight: 500; }

.files { margin-top: 10px; display: grid; gap: 3px; }
.file {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto 30px;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  line-height: 1.5;
}
.file-status { color: var(--text-3); font-weight: 600; text-align: center; }
.file-status[data-s="added"] { color: var(--channel); }
.file-status[data-s="deleted"] { color: var(--buoy); }
.file-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); direction: rtl; text-align: left; }
.file-path bdi { direction: ltr; unicode-bidi: isolate; }
.file-add { color: var(--channel); font-variant-numeric: tabular-nums; }
.file-del { color: var(--buoy); font-variant-numeric: tabular-nums; }
.file-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.file-bar i { height: 6px; border-radius: 1px; background: var(--line-2); }
.file-bar i[data-k="a"] { background: var(--channel); }
.file-bar i[data-k="d"] { background: var(--buoy); }
.file.is-outside .file-path { color: var(--lamp); }
.file.is-conflict .file-path { color: var(--buoy); }
.file-flag {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: -1px 0 3px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--tc);
}
.file-flag .ic { width: 12px; height: 12px; }
.files.is-struck .file-path, .files.is-struck .file-add, .files.is-struck .file-del, .files.is-struck .file-status {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--slate);
}
.files.is-struck .file-bar { opacity: 0.35; }

.notes { margin-top: 8px; display: grid; gap: 3px; }
.notes li { display: flex; gap: 6px; font-size: var(--t-micro); color: var(--text-2); line-height: 1.4; }
.notes li .ic { width: 13px; height: 13px; margin-top: 1px; color: var(--tc, var(--lamp)); }
.notes code { color: var(--text); }

.review {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card-2);
  font-size: var(--t-micro);
  line-height: 1.45;
}
.review-head { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.review-verdict { font-weight: 700; letter-spacing: 0.02em; color: var(--tc); }
.review-model { margin-left: auto; font-family: var(--font-mono); font-size: var(--t-label); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.review-note { margin-top: 3px; color: var(--text); font-style: italic; }

.conflict {
  margin-top: 10px;
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--buoy-wash);
  border: 1px solid var(--buoy-line);
}
.conflict-title { display: flex; align-items: baseline; gap: 6px; font-size: var(--t-small); font-weight: 650; color: var(--buoy); }
.conflict-title .ic { width: 14px; height: 14px; stroke-width: 2.2; flex: none; align-self: center; }
.conflict-title .sha { background: transparent; color: inherit; padding: 0; }
.conflict-paths { margin-top: 6px; display: grid; gap: 2px; }
.conflict-paths li { font-family: var(--font-mono); font-size: var(--t-mono); color: var(--text); display: flex; gap: 7px; align-items: center; overflow-wrap: anywhere; }
.conflict-paths li::before { content: ""; width: 5px; height: 5px; border-radius: 1px; background: var(--buoy); transform: rotate(45deg); flex: none; }
.conflict-cause { margin-top: 6px; font-size: var(--t-micro); color: var(--text-2); line-height: 1.45; }

/* The job panel stands in the primary slot while an attempt waits. */
.job {
  position: relative;
  padding: 9px 10px 10px;
  border-radius: var(--r);
  background: var(--moon-wash);
  border: 1px solid var(--moon-line);
  overflow: hidden;
}
.job-row { display: flex; align-items: baseline; gap: 8px; }
.job-what { font-size: var(--t-small); font-weight: 600; color: var(--text); min-width: 0; }
.job-clock { margin-left: auto; font-family: var(--font-mono); font-size: 1.125rem; font-weight: 500; line-height: 1.1; color: var(--moon); font-variant-numeric: tabular-nums; }
.job-meta { margin-top: 3px; font-family: var(--font-mono); font-size: var(--t-micro); color: var(--text-2); line-height: 1.45; }
.job-note { margin-top: 3px; font-size: var(--t-micro); color: var(--text-2); line-height: 1.45; }
.job-note.is-warn { color: var(--lamp); }
.job-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--moon), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: job-sweep 3s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .job-bar { display: none; } }

/* ------------------------------------------------------------------ compact cards (parked, shipped) */

.compact-body { display: grid; gap: 5px; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--t-micro); font-weight: 600; color: var(--text-2); }
.status-line .ic { width: 14px; height: 14px; stroke-width: 2.2; color: var(--tc); }
.card[data-lane="shipped"] .status-line .sha { color: var(--channel); background: var(--channel-wash); }
.compact-text { font-size: var(--t-small); line-height: 1.42; }
.compact-note { font-size: var(--t-micro); color: var(--text-2); line-height: 1.45; }
.mini-files { font-family: var(--font-mono); font-size: var(--t-mono); color: var(--text-3); overflow-wrap: anywhere; }
.history-note { display: inline-flex; align-items: center; gap: 5px; font-size: var(--t-micro); color: var(--lamp); }
.history-note .ic { width: 12px; height: 12px; stroke-width: 2.1; }

/* ------------------------------------------------------------------ the one button, then the tools */

.primary { margin-top: 12px; }
.primary-caption { margin-top: 7px; font-size: var(--t-small); line-height: 1.45; color: var(--text-2); }
.primary-caption .sha { font-size: 0.95em; }
.primary .btn-block .mono { font-weight: 500; }

.confirm {
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--lamp-line);
  background: var(--lamp-wash);
  font-size: var(--t-small);
  color: var(--text);
}
.confirm:focus { outline: none; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; justify-content: flex-end; }

.card-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 7px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--d-hover), background-color var(--d-hover);
}
.toggle .ic { width: 14px; height: 14px; }
.toggle:hover { color: var(--text); background: var(--slate-wash); }
.toggle[aria-pressed="true"], .toggle[aria-expanded="true"] { color: var(--text); background: var(--slate-wash); box-shadow: inset 0 0 0 1px var(--line-2); }
.toggle[aria-disabled="true"] { color: var(--text-3); cursor: not-allowed; background: transparent; }
.toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.secondary .toggle { min-width: 28px; }
.secondary .sec-label { display: none; }
@container lane (min-width: 430px) {
  .secondary .sec-label { display: inline; }
}

.expand { margin-top: 10px; animation: expand-in var(--d-enter) var(--ease); }

.preview-frame { border-radius: 9px; overflow: hidden; border: 1px solid var(--line-2); background: var(--code); }
.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 4px 0 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-3);
}
.preview-bar .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.preview-bar .url bdi { direction: ltr; unicode-bidi: isolate; }
.preview-bar a { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; color: var(--text-2); flex: none; }
.preview-bar a:hover { color: var(--text); background: var(--slate-wash); }
.preview-bar a .ic { width: 13px; height: 13px; }
.preview-box { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--preview-paper); }
.preview-box iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1000px;
  height: 625px;
  border: 0;
  transform: scale(var(--s, 0.3));
  transform-origin: 0 0;
  pointer-events: none;
  background: var(--preview-paper);
}
.preview-caption { margin-top: 6px; font-size: var(--t-micro); color: var(--text-3); }

.brief-detail {
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: var(--t-micro);
  display: grid;
  gap: 9px;
}
.bd-label { font-size: var(--t-label); font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3); margin-bottom: 3px; }
.bd-list { display: grid; gap: 4px; }
.bd-list li { display: flex; gap: 7px; align-items: flex-start; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.bd-list.is-plain li::before { content: "—"; color: var(--text-3); flex: none; }
.bd-list .ic { width: 13px; height: 13px; margin-top: 1px; stroke-width: 2.2; }
.bd-list .ok { color: var(--channel); display: inline-flex; }
.bd-list .bad { color: var(--buoy); display: inline-flex; }
.bd-list .wait { color: var(--moon); display: inline-flex; }
.bd-list .person { color: var(--text-3); display: inline-flex; }
.bd-list code { font-size: 1em; color: var(--text); min-width: 0; }
.bd-tag { margin-left: auto; padding-left: 6px; font-family: var(--font-mono); font-size: var(--t-label); color: var(--text-3); white-space: nowrap; }
.bd-tag[data-tone] { color: var(--tc); }
.bd-file { font-family: var(--font-mono); font-size: var(--t-label); color: var(--text-3); overflow-wrap: anywhere; line-height: 1.5; }

/* Narrow berths (six lanes plus the feed at 1920): drop the per-file bars and tighten the rail
   before anything wraps badly. Paths and shas matter more than decoration. */
@container lane (max-width: 300px) {
  .card { padding: 12px 12px 10px; }
  .node { padding-left: 21px; }
  .node-line.is-mono { font-size: var(--t-micro); }
  .file { grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 6px; font-size: var(--t-micro); }
  .file-bar { display: none; }
  .pill { padding: 0 7px 0 5px; }
  .rerun-tag { padding: 0 5px; }
  .rerun-tag .tag-text { display: none; }
}
@container lane (max-width: 250px) {
  .review-model { display: none; }
  .card-time { display: none; }
}

@media (max-width: 719px) {
  .toggle { height: 44px; padding: 0 10px; }
  .secondary .toggle { min-width: 44px; }
  .primary .btn-block { height: 46px; }
  .confirm-actions .btn { height: 40px; }
}
