:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --text: #2f2f2f;
  --muted: #585858;
  --border: #dfdede;
  --accent: #007ec3;
  --ok: #33937c;
  --warn: #c89c00;
  --bad: #d03056;
  --code-bg: #eff1f4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --panel: #1f2329;
    --text: #e6e8eb;
    --muted: #a3a8ae;
    --border: #343a42;
    --accent: #68b4dd;
    --ok: #76cdae;
    --warn: #f5c724;
    --bad: #f28ca5;
    --code-bg: #262b32;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: var(--accent); }
.top {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.top h1 { font-size: 16px; margin: 0; }
.top h1 a { color: var(--text); text-decoration: none; }
#who { margin-left: auto; font-size: 12px; }
main { max-width: 1600px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 6px 12px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button.ghost { background: transparent; color: var(--accent); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--code-bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; border: 1px solid currentColor; }
.s-ok, .s-done { color: var(--ok); }
.s-decline, .s-declined, .s-needs_info, .s-escalated, .s-running { color: var(--warn); }
.s-failed { color: var(--bad); }
.steps span { margin-right: 4px; }
pre {
  background: var(--code-bg); padding: 12px; border-radius: 6px; overflow-x: auto;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; max-height: 70vh;
}
.wrap { white-space: pre-wrap; word-break: break-word; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 16px 0 4px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
.links a { margin-right: 16px; }
.error { color: var(--bad); }

/* ---------- nav ---------- */
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 4px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.tabs a.active { background: var(--code-bg); color: var(--text); font-weight: 600; }

/* ---------- board ---------- */
.strip { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; padding: 12px 16px; }
.strip b { font-size: 18px; font-variant-numeric: tabular-nums; }
.strip .warn b { color: var(--warn); }
#poll-status { margin-left: auto; font-size: 12px; }
.board { display: flex; flex-direction: column; gap: 16px; }
.lane { display: grid; gap: 10px; }
.steps-lane { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px 22px; }
.lane.ends { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 16px; border-top: 2px dashed var(--border); align-items: start; }
.col {
  min-height: 160px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.steps-lane .col { min-height: 220px; padding: 12px; border-radius: 10px; }
.steps-lane .col header { font-size: 16px; }
.steps-lane .cards { flex: 1; }
.empty { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12px; opacity: 0.7; }
.col-stats { font-size: 12px; border-top: 1px solid var(--border); padding-top: 6px; }
.col.end { min-height: 0; }
.col.end .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* Arrows between steps, left to right on each row; row 1 ends pointing down. */
.steps-lane .col:not(.finished-tile)::after {
  content: "›"; position: absolute; right: -16px; top: 12px; color: var(--muted); font-weight: 700; font-size: 18px;
}
.steps-lane .col:nth-child(5)::after { content: "↓"; right: 50%; top: auto; bottom: -20px; }
.steps-lane .col:nth-child(9)::after { content: "›"; }
.finished-tile { cursor: pointer; background: var(--code-bg); }
.finished-tile:hover { border-color: var(--accent); }
.tally { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tally li { display: flex; justify-content: space-between; }
.tally b { font-size: 18px; font-variant-numeric: tabular-nums; }
.col.busy { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.col header { display: flex; justify-content: space-between; font-weight: 600; }
.col .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.col.busy .count { color: var(--accent); }
.col-sub { font-size: 11px; margin-top: -4px; }
.cards { display: flex; flex-direction: column; gap: 6px; }
.card {
  display: block; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); text-decoration: none; font-size: 12px;
}
a.card:hover { border-color: var(--accent); }
.card.live { border-color: var(--accent); }
.card-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 4px; align-items: center; }
.card-top strong { white-space: nowrap; }
.card-line { margin-top: 2px; font-variant-numeric: tabular-nums; }
.more { font-size: 12px; }
.tag { font-size: 10px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }
.tag.live { color: var(--accent); border-color: var(--accent); }
.phase { font-weight: 600; }
.ph-working { color: var(--ok); }
.ph-waiting { color: var(--warn); }
.ph-lambda { color: var(--muted); }

/* ---------- run page ---------- */
.run-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.run-grid > .panel { margin-bottom: 16px; min-width: 0; }
.path { list-style: none; margin: 0; padding: 0; }
.node a {
  display: grid; grid-template-columns: 16px 1fr auto; column-gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 6px; color: var(--text); text-decoration: none; position: relative;
}
.node a:hover { background: var(--code-bg); }
.node.selected a { background: var(--code-bg); box-shadow: inset 3px 0 0 var(--accent); }
.node:not(:last-child) a::before {
  content: ""; position: absolute; left: 15px; top: 22px; bottom: -8px; width: 2px; background: var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); background: var(--panel); z-index: 1; }
.node-name { font-weight: 600; }
.node-time { font-variant-numeric: tabular-nums; font-size: 12px; }
.node-status { grid-column: 2; font-size: 12px; color: var(--muted); }
.node-notes { grid-column: 2 / 4; font-size: 11px; }
.st-ok .dot, .st-done .dot { border-color: var(--ok); background: var(--ok); }
.st-decline .dot, .st-needs_info .dot, .st-escalated .dot, .st-aborted .dot, .st-timed_out .dot { border-color: var(--warn); background: var(--warn); }
.st-failed .dot { border-color: var(--bad); background: var(--bad); }
.st-running .dot { border-color: var(--accent); background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.st-running .node-status { color: var(--accent); font-weight: 600; }
.st-notreached { opacity: 0.45; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.2s ease-in-out infinite; vertical-align: middle;
}
@keyframes pulse { 50% { opacity: 0.3; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .st-running .dot, .live-dot { animation: none; } }
.s-running { color: var(--accent); }
.s-stopped, .s-aborted, .s-timed_out { color: var(--warn); }
.activity {
  list-style: none; margin: 0; padding: 0; max-height: 65vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
}
.act { display: grid; grid-template-columns: 72px 56px 1fr; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 12px; }
.act:last-child { border-bottom: 0; }
.act-time { font-variant-numeric: tabular-nums; }
.act-kind { color: var(--muted); }
.act-text { white-space: pre-wrap; word-break: break-word; }
.act-tool .act-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.act-error { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.act-error .act-kind { color: var(--bad); }
.act-note .act-text { font-style: italic; }
.act-result { font-weight: 600; }

@media (max-width: 900px) {
  .run-grid { grid-template-columns: 1fr; }
  .steps-lane { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps-lane .col::after { display: none; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  dl { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
  .steps-lane, .lane.ends { grid-template-columns: 1fr; }
  .col, .steps-lane .col { min-height: 0; }
  .steps-lane .col::after { display: none; }
  .act { grid-template-columns: 1fr; gap: 0; }
}
