@import url("/ui/fonts.css");

:root {
  color-scheme: light;
  --ink: #00283c;
  --ink-2: #1c465c;
  --muted: #5d7382;
  --faint: #8aa0ae;
  --line: #e3ebf0;
  --line-strong: #c5d3dc;
  --paper: #fefefe;
  --card: #fff;
  --fill: #f4f8fb;
  --accent: #0098ec;
  --ok: #1f6b45;
  --bad: #9f1239;
  --run: #0098ec;
  --radius: 2px;
  --radius-sm: 2px;
  --font: "Lato", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  --display: "Cormorant Garamond", "Iowan Old Style", "Songti SC", serif;
}

html, body { overflow-anchor: none; }

body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--paper);
}

.shell { display: flex; min-height: 100vh; }

.side {
  width: 216px;
  flex: 0 0 216px;
  box-sizing: border-box;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 10px 20px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  font-family: var(--display);
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand img {
  width: 22px;
  height: 22px;
  display: block;
}

.side nav { display: flex; flex-direction: column; gap: 2px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  display: block;
  margin-top: 10px;
  padding: 8px 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
}

.side nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 0;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}

.side nav a.sub { padding-left: 24px; }

.side nav a.nav-top { margin-top: 10px; font-weight: 700; }

.side nav a:hover { background: var(--fill); }

.side nav a.active {
  background: #e8f6fd;
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 32px 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar .who { margin-left: auto; }
.topbar #back-task {
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}
.topbar #back-task:hover { color: var(--ink); }
.nav-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 auto;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle:hover {
  color: var(--ink);
  background: var(--fill);
}
.nav-toggle svg { display: block; }
.nav-tip {
  display: none;
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
}
.nav-toggle:hover .nav-tip { display: block; }
body.nav-collapsed .nav-toggle:hover .nav-tip { display: none; }
body.nav-collapsed .side {
  display: none;
  position: fixed;
  left: 8px;
  top: 48px;
  z-index: 40;
  width: 216px;
  flex: none;
  max-height: calc(100vh - 60px);
  overflow: auto;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 40, 60, 0.12);
}
body.nav-collapsed.nav-peek .side { display: block; }
body.nav-collapsed .side nav { flex-direction: column; flex-wrap: nowrap; }

#share-link {
  width: min(360px, 46vw);
  font: 12px/1.4 "Lato", "PingFang SC", sans-serif;
  padding: 6px 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 14px;
}

.badge {
  font-size: 12px;
  line-height: 1.4;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e8f6fd;
  color: var(--ink);
}

main {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 28px 32px 80px;
}

main.narrow { width: 65%; }
main.wide { width: 100%; }

h1 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p { margin: 8px 0; }
p:empty { display: none; }

.lede {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

#status { margin-top: 4px; color: var(--faint); font-size: 12px; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.card > label:first-child,
.compose label { margin-top: 0; }

input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
  background: #fff;
}

textarea {
  min-height: 280px;
  font: 13px/1.55 ui-monospace, "SFMono-Regular", monospace;
}

textarea.key-list {
  min-height: 108px;
  resize: vertical;
}

#system-prompt {
  min-height: 72px;
  height: 72px;
  max-height: 140px;
  resize: vertical;
}

button {
  box-sizing: border-box;
  font: inherit;
  line-height: 1.2;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover { background: var(--fill); }

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

button.primary:hover { background: #0c3d56; }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { background: #fff; }
button.primary:disabled:hover { background: var(--ink); }
button.tiny { padding: 4px 8px; font-size: 12px; border-radius: var(--radius-sm); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { width: auto; flex: 1; min-width: 0; }

.error { color: var(--bad); }
.ok { color: var(--ok); }
.save-line { display: flex; align-items: center; gap: 14px; }
.save-line #message { margin: 0; }

a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

.ticker-field { position: relative; flex: 1; min-width: 0; }
.ticker-field input { width: 100%; }

.composer input {
  height: 52px;
  padding: 0 56px 0 18px;
  border-radius: 26px;
  background: #fff;
  border-color: #e5e5e5;
}

.composer input:focus {
  outline: none;
  border-color: #c8c8c8;
  box-shadow: 0 0 0 1px #c8c8c8;
  background: #fff;
}

.composer .send {
  position: absolute;
  z-index: 2;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}

.composer .send .icon-stop { display: none; }
.composer .send[data-mode="stop"] .icon-send { display: none; }
.composer .send[data-mode="stop"] .icon-stop { display: block; }
.composer .send:hover { background: #0c3d56; }
.composer .send:disabled {
  background: #f4f4f4;
  color: #b5b5b5;
  opacity: 1;
  cursor: default;
}
.composer .send:disabled:hover { background: #f4f4f4; }
.composer .send:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.ticker-picked { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.ticker-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(0, 40, 60, 0.12);
  max-height: 320px;
  overflow: auto;
}
.ticker-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 8px 12px;
  cursor: pointer;
}
.ticker-option.active { background: #e8f6fd; }
.ticker-code { font-weight: 700; white-space: nowrap; }
.ticker-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker-list mark {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  padding: 0;
}
.ticker-empty, .ticker-more {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.stage-block {
  margin-top: 10px;
  padding: 10px 12px 12px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.trace-fold {
  display: flex;
  flex: none;
  gap: 8px;
  margin: 0;
}
html:not(.trace-times-on) .trace-clock {
  display: none;
}
button.tiny.on {
  background: #e8f6fd;
  border-color: var(--accent);
  color: var(--ink);
}
.call-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
}
.call-tools label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-2);
}
.call-tools input,
.call-tools select {
  width: auto;
  padding: 6px 8px;
}
.call-tools input[type="search"] { width: 220px; }
.call-tools input[type="checkbox"] { width: auto; padding: 0; }
button.call-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
  text-align: left;
  background: #fff;
}
button.call-row.failed { border-left: 3px solid var(--bad); }
button.call-row .call-where { font-weight: 600; }
button.call-row .call-where .trace-timing {
  font-weight: 400;
  color: var(--muted);
}
button.call-row.failed .call-where { color: var(--bad); }
button.call-row .call-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 400;
}
.call-note {
  margin: 4px 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.call-body {
  margin: 0 0 8px;
  padding: 4px 12px 12px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-top: 0;
}
.call-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.call-heading h3,
.call-body h3,
.step-detail .call-heading h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
button.call-fold {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  text-align: left;
  background: #fff;
  font-weight: 600;
}
.call-heading button.call-fold {
  width: auto;
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
button.json-copy {
  flex: none;
}
#run-trace .call-body pre,
#run-left .call-body pre,
#run-right .call-body pre { margin-left: 0; }
#run-trace .call-body .json-tree,
#run-left .call-body .json-tree,
#run-right .call-body .json-tree { margin-left: 0; }
.run-line {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.run-audit {
  margin: 16px 0 0;
  min-width: 0;
  scroll-margin-top: 16px;
}
.run-audit[hidden] { display: none; }
.run-audit h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}
.run-audit .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}
.run-audit .audit-more { margin: 8px 0 0; }
.run-audit .audit-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.run-audit .audit-list { margin: 8px 0 12px; }
.run-audit .audit-item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.run-audit .audit-item:last-child { border-bottom: 1px solid var(--line); }
.run-audit .audit-head {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.run-audit .audit-got {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
button.history-job .audit-alert {
  color: var(--bad);
  font-size: 12px;
  font-weight: 400;
}
.queue-box {
  margin: 0 0 16px;
}
.queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}
.queue-head button {
  font-size: 13px;
  font-weight: 400;
  padding: 4px 8px;
}
.queue-line {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin: 0 0 8px;
}
.queue-line .history-job { margin: 0; }
.queue-line .queue-stop {
  flex: none;
  align-self: center;
}
.compose.pick + #run-status:not(:empty) {
  box-sizing: border-box;
  min-height: 40px;
  padding-top: 18px;
  justify-content: center;
  box-shadow: 0 -1px 0 var(--line);
}
.compose.pick + #run-status:not(:empty) .run-head {
  min-height: 0;
  line-height: 1.3;
}
.compose.pick + #run-status:has(.run-title),
.compose.pick + #run-status:has(.run-error),
.compose.pick + #run-status:has(.busy-line) {
  margin-bottom: 16px;
}
.run-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-2);
}
.run-meta,
.run-actions,
.run-head .trace-fold {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.run-meta { flex: 1 1 auto; }
.run-actions { flex: none; margin-left: auto; padding-left: 24px; }
.run-company {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-role,
.run-title,
.run-note,
.run-version,
.run-action,
.run-timing {
  flex: none;
  white-space: nowrap;
}
.run-head .run-timing {
  color: var(--muted);
  white-space: nowrap;
}
.run-title.busy-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.run-head .spinner {
  width: 12px;
  height: 12px;
}
.run-head a,
.run-head button {
  flex: none;
  font: inherit;
  color: inherit;
  line-height: inherit;
  white-space: nowrap;
}
.run-head a { text-underline-offset: 3px; }
.run-head button.tiny {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.run-head button.tiny:hover {
  background: transparent;
  color: var(--accent);
}
.run-head button.tiny.on {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-weight: 700;
}
.pair .run-head { flex-wrap: wrap; }
.pair .run-meta,
.pair .run-actions { flex-wrap: wrap; }
.run-error {
  margin: 0;
  color: var(--bad);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stage-head { font-weight: 600; }
.stage-head.running { color: var(--run); }
.stage-head.done { color: var(--ok); }
.stage-head.failed { color: var(--bad); }
.stage-head.cancelled { color: var(--muted); }

button.stage-head,
button.task {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
button.stage-head .trace-timing,
button.task .trace-timing {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

button.task {
  width: calc(100% - 12px);
  margin: 8px 0 0 12px;
  text-align: left;
  background: #fff;
  border-color: var(--line);
  border-left-width: 3px;
}

button.task:hover { background: var(--fill); }
button.task.running { border-left-color: var(--run); }
button.task.done { border-left-color: var(--ok); }
button.task.failed { border-left-color: var(--bad); }
button.task.cancelled { border-left-color: var(--muted); }
button.task.skipped { border-left-color: var(--muted); color: var(--muted); }

.steps {
  margin: 2px 0 6px 28px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

button.step {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 2px 0 0;
  padding: 5px 4px;
  text-align: left;
  background: transparent;
  border-color: transparent;
  font-weight: 400;
}

button.step:hover { background: transparent; }
button.step .mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}
button.step.running .mark { background: var(--run); }
button.step.done .mark { background: var(--ok); }
button.step.failed .mark { background: var(--bad); }
button.step.cancelled .mark { background: var(--muted); }
button.step .step-title { flex: 1; min-width: 8em; }
button.step .step-state { color: var(--muted); font-size: 12px; }
button.step .trace-timing {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
button.step.failed .step-state { color: var(--bad); }

.step-detail { margin: 0 0 8px 15px; }
.step-detail h3 {
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.step-detail pre { margin-left: 0; }
.json-tree {
  font: 13px/1.5 ui-monospace, "SFMono-Regular", monospace;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 8px 10px 10px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.json-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.json-bar button {
  font: 700 12px/1 var(--font);
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.json-brace { color: var(--muted); }
.json-kids { margin: 0 0 0 16px; }
.json-toggle {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  text-align: left;
  margin: 0;
  padding: 1px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.json-toggle .arrow { color: var(--muted); width: 1em; flex: none; }
.json-key { color: var(--ink-2); font-weight: 700; flex: none; }
.json-preview { color: var(--muted); overflow-wrap: anywhere; }
.json-leaf { margin: 0; padding: 1px 0 1px 1.6em; overflow-wrap: anywhere; }
.json-str { color: var(--bad); }
.json-num, .json-lit { color: var(--ink); }
.json-long {
  white-space: pre-wrap;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bad);
  font: inherit;
}

#run-trace pre:not(.json-long),
#run-left pre:not(.json-long),
#run-right pre:not(.json-long) {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0 0 12px;
  padding: 10px 12px;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 13px/1.5 ui-monospace, "SFMono-Regular", monospace;
}
#run-trace .json-tree,
#run-left .json-tree,
#run-right .json-tree {
  margin: 8px 0 0 12px;
  max-height: 280px;
  overflow: auto;
}
#run-trace .step-detail .json-tree,
#run-left .step-detail .json-tree,
#run-right .step-detail .json-tree,
#run-trace .step-detail pre,
#run-left .step-detail pre,
#run-right .step-detail pre {
  margin-left: 0;
}

.board {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0 8px;
}

.column {
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.column.over { outline: 2px solid var(--ink); outline-offset: 2px; }
.column > input {
  padding: 4px 6px;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
}
.column .row { margin: 0; }
.column > button { width: 100%; }

.arrow {
  width: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 18px;
}

.lane { min-height: 72px; display: flex; flex-direction: column; gap: 8px; }

.node {
  padding: 10px 12px;
  text-align: left;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: grab;
}

.node strong { display: block; }
.node span { color: var(--muted); font-size: 13px; }
.node.report { box-shadow: inset 3px 0 0 var(--run); }
.node.duty-data { box-shadow: inset 3px 0 0 #2a7a62; }
.node.duty-program { box-shadow: inset 3px 0 0 #8a6a2a; }
.node .duty {
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
}
.node.selected { background: #fff; border-color: var(--ink); }
.node.linked { background: #f7fbfe; border-color: #7ec8f0; }
.node .remove {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 20px;
  cursor: pointer;
  z-index: 4;
}
.node:hover .remove,
.node:focus-within .remove { display: block; }
.node .remove:hover { color: var(--bad); }
.node.insert-before { box-shadow: inset 0 2px 0 var(--accent); }
.node.insert-after { box-shadow: inset 0 -2px 0 var(--accent); }

.placeholder { padding: 16px 4px; color: var(--faint); font-size: 13px; text-align: center; }

.add-stage {
  width: 132px;
  flex: 0 0 132px;
  align-self: stretch;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.add-stage:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }

.board { position: relative; gap: 48px; overflow-y: hidden; }
.node { position: relative; }
.port {
  position: absolute;
  right: -7px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: crosshair;
  z-index: 3;
}
#wires {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}
#wires .wire { fill: none; stroke-width: 1.75; pointer-events: stroke; cursor: pointer; }
#wires .faint { stroke: #8aa0ae; stroke-opacity: 0.38; }
#wires .solid { stroke: #0098ec; stroke-opacity: 0.28; }
#wires .dim { stroke-opacity: 0.12; }
#wires .hot { stroke-width: 3.25; stroke-opacity: 0.95; }
#wires .hot.faint { stroke: #3d5a6c; }
#wires .hot.solid { stroke: #0077c2; }
#wires .draft { stroke: var(--accent); stroke-opacity: 0.7; stroke-dasharray: 5 4; stroke-width: 2; pointer-events: none; }
#wires.linking .wire { pointer-events: none; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.split.ledger,
.workbench { grid-template-columns: minmax(0, 65fr) minmax(220px, 35fr); }
#inspector {
  box-sizing: border-box;
  width: calc(65% - 22.4px);
  max-width: 100%;
}

.tools { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.tools label {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}
.tools input { width: auto; }

#choices { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }

label.choice {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
}

label.choice:hover { background: var(--fill); }
label.choice:has(input:checked) { background: #e8f6fd; font-weight: 700; }
label.choice input { width: auto; margin: 0; }

#keys {
  margin-top: 16px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.pick { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.pick label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
  margin: 0;
}
.pick input:not([type="checkbox"]),
.pick select,
.pick button { height: 42px; }
.pick .ticker-field { width: 100%; }
.pick .ticker-picked { flex: 1 1 100%; margin: 0; }
.pick .checkline {
  flex: 1 1 100%;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 0;
  line-height: 1.3;
}
.pick .checkline input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  background: none;
  border: 0;
  border-radius: 0;
}
.pick .option-line {
  box-sizing: border-box;
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  min-width: 0;
  min-height: 40px;
  padding-bottom: 6px;
  line-height: 1.3;
}
.pick .option-line .checkline {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
}
.pick .option-line .checkline span {
  white-space: nowrap;
  line-height: 1.3;
}
.pick .child-pick select {
  width: auto;
  max-width: 11em;
  height: 32px;
  padding: 4px 8px;
  field-sizing: content;
}
.pick .child-pair {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.pick .send {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  transform: none;
  flex: 0 0 auto;
}
.pick .send svg { display: none; }
.pick .stop-label { display: none; }
.pick .send[data-mode="stop"] .send-label { display: none; }
.pick .send[data-mode="stop"] .stop-label { display: inline; }
.pick.locked { opacity: 0.55; pointer-events: none; }

.note { margin: 12px 0; color: var(--muted); font-size: 13px; }

.quote .eyebrow { margin-bottom: 4px; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.price {
  margin: 2px 0 6px;
  font-family: var(--display);
  font-size: 48px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.factors { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.factors span {
  padding: 3px 10px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13px;
}

#out ul, #people { list-style: none; padding: 0; margin: 0; }
#out li, #people li { padding: 12px 0; border-bottom: 1px solid var(--line); }
#out li:last-child, #people li:last-child { border-bottom: 0; padding-bottom: 0; }
#out li:first-child, #people li:first-child { padding-top: 0; }
#people li { display: flex; gap: 8px; align-items: center; }

.tag { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.statement { margin: 0; }

.issued { background: var(--fill); }
.issued strong { font-family: ui-monospace, "SFMono-Regular", monospace; font-size: 15px; }

.workbench {
  display: grid;
  gap: 16px;
  align-items: start;
}
.workbench.tasks {
  grid-template-columns: minmax(200px, 28fr) minmax(0, 72fr);
}
.workbench.tasks > .card { min-width: 0; }
.workbench.tasks .pair { margin-top: 8px; }
.workbench.tasks .pair .run-line {
  align-items: stretch;
}

.task-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
}
.task-filter label { margin: 0; }
.task-filter .ticker-field { flex: none; }

#history, .task-list { max-height: 70vh; overflow: auto; }
.task-more { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.task-line { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.task-line .history-job { margin: 0; }
.task-line a { flex: none; }

button.history-job {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  margin: 0 0 8px;
  text-align: left;
  background: var(--fill);
}

button.history-job.selected { border-color: var(--ink); background: #fff; }
button.history-job .when { color: var(--muted); font-size: 12px; font-weight: 400; white-space: normal; }

.version-line {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  padding: 6px 8px 6px 14px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.version-line.baseline { background: #fff; border-left: 3px solid var(--ink); }
.version-line.child { background: transparent; margin-left: 36px; }
.topology-actions { margin: 16px 0 0; }
#save-message {
  display: inline-flex;
  align-items: center;
  min-height: 1.2em;
}
#save-message .busy-line { margin: 0; }
#save-message .spinner {
  width: 14px;
  height: 14px;
}
.version-line:last-child { margin-bottom: 0; }
.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 12px;
}
.pair > div { min-width: 0; }
.version-line .history-job {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 4px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.version-line .history-job:hover { background: transparent; }
.version-line > .tiny {
  flex: 0 0 auto;
  align-self: center;
  padding: 6px 12px;
  background: #fff;
}

button.stage-head {
  width: 100%;
  margin: 0;
  padding: 2px 0;
  text-align: left;
  background: transparent;
  border-color: transparent;
  font-weight: 600;
}

button.stage-head:hover { background: transparent; }

.confirm {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 40, 60, 0.28);
}

.confirm-card {
  width: min(400px, 100%);
  margin: 0;
  padding: 22px 22px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 40, 60, 0.16);
}
.confirm-card.wide { width: min(560px, 100%); }
.confirm-card .confirm-block { margin: 12px 0 0; }
.confirm-card .confirm-block p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}
.confirm-card .confirm-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 160px;
  overflow: auto;
  font-size: 14px;
}
.confirm-card .confirm-list li { margin: 0 0 2px; }

.confirm-card h2 {
  margin: 0 0 8px;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.confirm-card .row { justify-content: flex-end; margin: 18px 0 0; }

.score-table { width: 100%; border-collapse: collapse; }
.score-table th,
.score-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
.score-table th { color: var(--muted); font-size: 12px; font-weight: 700; }
.score-table .num { text-align: center; font-variant-numeric: tabular-nums; }
.score-table .mark-on { color: var(--ok); font-weight: 700; }
.score-table .mark-off { color: var(--faint); }
.score-table .watch-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.watch-list { overflow-x: auto; }
.watch-list .score-table {
  width: max-content;
  min-width: 100%;
}
.watch-list .score-table th,
.watch-list .score-table td {
  white-space: nowrap;
  padding: 7px 8px;
}
.watch-list .score-table .watch-name {
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-table .chg-up { color: var(--ok); }
.score-table .chg-down { color: var(--bad); }

.watch-status {
  justify-content: space-between;
  margin: 0 0 8px;
}
.watch-status #status { margin: 0; }
.watch-filters {
  margin-top: 10px;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
}
.watch-filters label.inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  min-width: 0;
  flex: 0 0 auto;
}
.watch-filters input,
.watch-filters select,
.watch-filters button {
  height: 38px;
  box-sizing: border-box;
  padding: 0 10px;
  line-height: 36px;
  flex: none;
  width: auto;
}
.watch-filters select { width: 132px; }
.watch-filters #in-universe { width: 124px; }
.watch-filters #query { width: 148px; }
.watch-filters #adhoc-note { width: 128px; }
#adhoc-form.watch-filters { flex-wrap: wrap; }
.watch-filters .ticker-field {
  width: 248px;
  flex: none;
  height: 38px;
}
.watch-filters .ticker-field input {
  width: 100%;
}
.watch-filters .ticker-list {
  min-width: 380px;
  width: max-content;
}
.watch-hint {
  margin: 0 0 2px;
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  align-self: flex-end;
}
.tag {
  display: inline-block;
  margin: 0 4px 0 0;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

[hidden] { display: none !important; }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
}

.busy-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.boot-screen .spinner { width: 18px; height: 18px; }

@keyframes spin { to { transform: rotate(360deg); } }

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.chat-toolbar select { width: 220px; }
.tick-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
input.tick { width: auto; padding: 0; }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  margin-top: 14px;
}
.bubble {
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.user { align-self: flex-end; background: #e8f6fd; }
.bubble.assistant { align-self: flex-start; background: var(--fill); }
.bubble.failed { color: var(--bad); }
.composer { display: flex; gap: 10px; align-items: flex-end; margin-top: 14px; }
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.check-line input { width: auto; margin: 0; }
.composer textarea { min-height: 72px; flex: 1; }
.composer button { flex: 0 0 auto; }

body:has(.compare-main) .shell {
  height: 100vh;
  overflow: hidden;
}
.compare-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 16px;
  overflow: hidden;
}
.compare-toolbar, .compare-legend, .compare-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.compare-legend span, .compare-summary button {
  font-size: 13px;
  color: var(--muted);
}
.compare-summary button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.compare-summary button:hover { color: var(--ink-2); }
.compare-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  flex: 1;
  min-height: 420px;
  border: 1px solid var(--line);
}
.compare-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.compare-pane + .compare-pane { border-left: 1px solid var(--line); }
.compare-pane-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--fill);
  font-size: 13px;
  min-width: 0;
}
.compare-top {
  flex: 0 0 var(--topo-h, 42%);
  min-height: 160px;
  overflow: hidden;
  padding: 8px 8px 0;
  display: flex;
  flex-direction: column;
}
.compare-grip {
  flex: 0 0 7px;
  cursor: ns-resize;
  background: var(--line);
}
.compare-grip:hover { background: var(--line-strong); }
.compare-bottom {
  flex: 1;
  min-height: 140px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: #fff;
}
.compare-bottom iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.compare-empty {
  margin: 0;
  padding: 24px 16px;
  color: var(--muted);
}
.compare-board.board {
  flex: 1;
  min-height: 120px;
  overflow: auto;
}
.compare-board .column > .stage-name {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
}
.compare-board .node { cursor: pointer; }
.compare-board .node.mark-same { opacity: 0.72; }
.compare-board .node.mark-changed { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--bad); }
.compare-board .node.mark-only_left,
.compare-board .node.mark-only_right { border-style: dashed; }
.compare-board .node .mark-label {
  display: inline-block;
  margin-left: 6px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}
.compare-inspect {
  flex: 0 1 auto;
  max-height: 42%;
  overflow: auto;
  margin: 0;
  padding: 8px 4px 10px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  position: relative;
  z-index: 3;
}
.compare-top.has-card .compare-inspect {
  flex: 1 1 46%;
  min-height: 168px;
  max-height: none;
}
.compare-inspect h2 { margin: 0 0 6px; font-size: 15px; }
.compare-inspect h3 { margin: 10px 0 6px; font-size: 13px; }
.compare-inspect table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare-inspect th, .compare-inspect td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
}
.compare-inspect tr.changed td { background: #fff6ea; }
.skill-diff {
  margin: 8px 0 0;
  font: 12px/1.45 ui-monospace, "SFMono-Regular", monospace;
  border: 1px solid var(--line);
  background: #fff;
}
.skill-diff .line { padding: 1px 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.skill-diff .same { color: var(--muted); }
.skill-diff .del { background: #f8e8ec; }
.skill-diff .add { background: #e8f4ee; }
.skill-diff .changed { background: #fff6ea; }
body.compare-topo-only .compare-grip,
body.compare-topo-only .compare-bottom { display: none; }
body.compare-topo-only .compare-top { flex: 1; }
body.compare-report-only .compare-top,
body.compare-report-only .compare-grip { display: none; }
.compare-board svg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}
.compare-board .wire { fill: none; stroke: #0098ec; stroke-width: 1.75; stroke-opacity: 0.28; }
.compare-board .wire.dim { stroke-opacity: 0.12; }
.compare-board .wire.hot { stroke-width: 3.25; stroke-opacity: 0.95; }
.compare-board .wire.mark-only_left,
.compare-board .wire.mark-only_right { stroke-dasharray: 5 4; }

@media (max-width: 800px) {
  main.narrow, #inspector { width: 100%; }
  .split, .split.ledger, #inspector-form .split, .workbench, .workbench.tasks, .pair, .compare-split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .side {
    width: auto;
    flex-basis: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 12px 12px;
  }
  .brand { margin: 0 8px 10px; }
  body.nav-collapsed .side {
    width: 216px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 20px 12px;
  }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .topbar { padding: 0 16px; }
  main { padding: 20px 16px 64px; }
}
