:root {
  color-scheme: light;
  --canvas: #f3f4f6;
  --canvas-dot: #d5dae3;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f7f7f8;
  --surface-hover: #f0f1f4;
  --line: #e0e3e8;
  --line-strong: #cbd0d9;
  --ink: #17191d;
  --muted: #6f7682;
  --subtle: #979eaa;
  --brand: #4057d6;
  --brand-soft: #eaedff;
  --green: #2f9e63;
  --green-soft: #e8f5ed;
  --yellow: #b67b18;
  --yellow-soft: #fbf2df;
  --red: #d94a58;
  --red-soft: #fcebee;
  --violet: #6967d8;
  --shadow-sm: 0 2px 10px rgb(24 35 54 / 8%);
  --shadow-md: 0 14px 40px rgb(24 35 54 / 15%);
  --node-width: 236px;
  --node-height: 148px;
  --file-node-width: 168px;
  --file-node-height: 62px;
  --rail-width: 196px;
  /* Toolbar (48px) plus the canvas tab row (34px). */
  --chrome-top: 82px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; letter-spacing: -.015em; }
h3 { font-size: 13px; }

button, select, input, textarea {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

button {
  min-height: 32px;
  padding: 6px 10px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

button:hover { background: #3349c0; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .graph-viewport:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .42; }
button.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
button.secondary:hover { background: var(--surface-hover); }

input, textarea, select { width: 100%; padding: 7px 8px; }
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }

.workspace, .graph-viewport { width: 100%; height: 100%; }

.graph-viewport {
  position: relative;
  overflow: hidden;
  background-color: var(--canvas);
  background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

.graph-viewport.panning { cursor: grabbing; }

.canvas-toolbar {
  position: absolute;
  z-index: 30;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.toolbar-cluster {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.toolbar-primary { max-width: min(740px, calc(100vw - 410px)); }
.toolbar-run { flex: 0 0 auto; }
.toolbar-divider, .control-divider { width: 1px; height: 26px; flex: none; background: var(--line); }

.brand { display: flex; min-width: 132px; align-items: center; gap: 8px; padding-right: 2px; }
.brand-mark { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 8px; background: var(--brand); color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .03em; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 12px; letter-spacing: -.01em; }
.brand-copy small { color: var(--muted); font-size: 9px; }

.toolbar-field { display: block; min-width: 155px; }
.toolbar-field > span { display: none; }
.toolbar-field select { height: 32px; padding: 4px 28px 4px 8px; border-color: transparent; background-color: var(--surface-muted); font-size: 11px; font-weight: 650; }
.run-field { min-width: 165px; }
.toolbar-action { flex: none; min-width: 66px; }

.project-title { display: grid; min-width: 0; max-width: 210px; padding: 0 6px; line-height: 1.15; }
.project-title strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { display: block; margin-bottom: 2px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.progress { max-width: 145px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.primary-action { min-width: 96px; }
.icon-button, .fit-button, .close-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.icon-button:hover, .fit-button:hover, .close-button:hover { background: var(--surface-hover); color: var(--ink); }
.icon-button { min-width: 32px; padding: 4px 8px; font-size: 17px; line-height: 1; }
.menu-button { color: var(--ink); }
.close-button { min-width: 32px; padding: 2px 8px; font-size: 22px; font-weight: 400; }

.message {
  position: absolute;
  z-index: 35;
  top: 76px;
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 8px 11px;
  border: 1px solid #efc2c8;
  border-radius: 8px;
  background: var(--red-soft);
  box-shadow: var(--shadow-sm);
  color: #a52f3c;
  font-size: 11px;
  user-select: text;
}
.message:empty { display: none; }
.message.ok { border-color: #bce0ca; background: var(--green-soft); color: #247848; }

.graph-empty {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  padding: 100px 30px 30px;
  color: var(--muted);
  text-align: center;
}
.graph-empty[hidden] { display: none; }
.graph-empty strong { color: var(--ink); font-size: 15px; }
.graph-empty > span:not(.empty-mark) { font-size: 12px; }
.empty-mark { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: 4px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--brand); font-size: 27px; }
.graph-empty button { margin-top: 8px; }

.graph-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.edge-layer, .node-layer { position: absolute; inset: 0; overflow: visible; }
.decoration-layer { position: absolute; z-index: 4; inset: 0; overflow: visible; pointer-events: none; }
.edge-layer path.edge { fill: none; stroke: #aeb6c4; stroke-width: 2; marker-end: url(#arrow); pointer-events: none; transition: opacity .15s, stroke .15s, stroke-width .15s; }
.edge-layer path.edge.trigger { stroke-width: 2.35; }
.edge-layer path.edge.feedback { stroke: #b67b18; stroke-dasharray: 7 5; }
.edge-layer path.edge.file-flow { stroke: #6f7fc7; stroke-width: 1.7; }
.edge-layer path.edge.file-flow.planned { stroke-dasharray: 5 5; opacity: .68; }
.edge-layer path.edge.file-flow.missing { stroke: var(--red); stroke-dasharray: 3 4; }
.edge-layer path.edge.flow-active { stroke: var(--brand); stroke-dasharray: 7 5; stroke-width: 2.4; animation: flow-dash 900ms linear infinite; }
.edge-layer path.edge.flow-complete { stroke: var(--green); }
.edge-layer path.edge.flow-ready { stroke: #7688df; }
.edge-layer path.edge.flow-waiting { stroke: var(--yellow); stroke-dasharray: 4 5; }
.edge-layer path.edge.flow-blocked { stroke: var(--red); stroke-dasharray: 3 5; }
@keyframes flow-dash { to { stroke-dashoffset: -24; } }
.edge-layer path.edge.preview { stroke: var(--brand); stroke-dasharray: 5 5; marker-end: none; }
.edge-layer path.edge.related { stroke: var(--brand); stroke-width: 2.5; }
.edge-layer path.edge.dimmed { opacity: .2; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; cursor: pointer; pointer-events: stroke; }
.edge-control { cursor: pointer; pointer-events: all; }
.edge-control rect { fill: rgb(255 255 255 / 96%); stroke: var(--line-strong); stroke-width: 1; }
.edge-control text { fill: var(--muted); font: 700 8px ui-sans-serif, system-ui, sans-serif; pointer-events: none; }
.edge-control.feedback rect { fill: var(--yellow-soft); stroke: #dcc184; }
.edge-control.feedback text { fill: #8b6112; }
.edge-edit-button { position: absolute; z-index: 3; min-width: 48px; min-height: 20px; transform: translate(-50%, -50%); padding: 2px 8px; border-color: var(--line-strong); border-radius: 999px; background: rgb(255 255 255 / 96%); box-shadow: var(--shadow-sm); color: var(--muted); font-size: 8px; cursor: pointer; }
.edge-edit-button:hover { border-color: var(--brand); background: var(--surface); color: var(--brand); }
.edge-edit-button.trigger { border-color: var(--dep-color, var(--line-strong)); color: var(--dep-color, var(--muted)); }
.edge-edit-button.trigger:hover { border-color: var(--dep-color, var(--brand)); background: var(--surface); color: var(--dep-color, var(--brand)); }
.edge-edit-button.feedback { border-color: #dcc184; background: var(--yellow-soft); color: #8b6112; }
.edge-edit-button.feedback:hover { border-color: var(--yellow); color: #78550f; }

.node {
  position: absolute;
  width: var(--node-width);
  height: var(--node-height);
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-raised);
  box-shadow: 0 5px 18px rgb(25 38 58 / 8%);
  color: var(--ink);
  text-align: left;
  cursor: grab;
  touch-action: none;
  transition: box-shadow .15s, border-color .15s, opacity .15s;
}

.node:hover { background: var(--surface); box-shadow: 0 12px 35px rgb(25 38 58 / 12%); }
.node.dragging { cursor: grabbing; box-shadow: var(--shadow-md); transition: none; will-change: left, top; }
.node.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(64 87 214 / 18%), 0 12px 35px rgb(25 38 58 / 12%); }
.node.dimmed { opacity: .35; }
.node.running { border-color: var(--brand); animation: none; }
.node.running .status-dot { animation: running-dot 1.8s ease-in-out infinite; }
@keyframes running-dot { 50% { opacity: .42; } }
.node.succeeded { border-color: #7dc59a; }
.node.failed, .node.cancelled { border-color: #e48d97; }
.node.blocked { border-color: #dcc184; }
.node.needs-attention { border-color: #e3a1a9; }
@keyframes running-node { 50% { box-shadow: 0 0 0 4px rgb(64 87 214 / 10%), 0 12px 35px rgb(25 38 58 / 12%); } }

.file-node {
  position: absolute;
  width: var(--file-node-width);
  height: var(--file-node-height);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 7px;
  padding: 9px 8px;
  border: 1px solid #aeb8cf;
  border-radius: 10px;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  transition: opacity .15s, border-color .15s, box-shadow .15s;
}
.file-node:hover { border-color: var(--brand); box-shadow: 0 9px 24px rgb(25 38 58 / 12%); }
.file-node.dragging { cursor: grabbing; transition: none; }
.file-node.planned { border-style: dashed; background: rgb(255 255 255 / 72%); opacity: .72; }
.file-node.missing { border-color: var(--red); border-style: dashed; background: rgb(252 235 238 / 78%); }
.file-node.stale { border-color: #d7a64d; background: rgb(255 249 233 / 92%); }
.file-node-icon { display: grid; width: 32px; height: 38px; place-items: center; border: 1px solid #b9c3df; border-radius: 7px; background: var(--brand-soft); color: var(--brand); font-size: 9px; font-weight: 800; }
.file-node.planned .file-node-icon { border-style: dashed; background: transparent; }
.file-node.missing .file-node-icon { border-color: #e8a2aa; background: var(--red-soft); color: var(--red); }
.file-node.stale .file-node-icon { border-color: #e2c786; background: var(--yellow-soft); color: #8b6112; }
.file-node-copy { display: grid; min-width: 0; gap: 2px; }
.file-node-copy strong, .file-node-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-node-copy strong { font-size: 10px; }
.file-node-copy small { color: var(--muted); font-size: 8px; }
.file-node-edit { min-width: 20px; min-height: 24px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.file-node-edit:hover { background: var(--surface-hover); color: var(--brand); }
.file-node:hover .connection-handle, .file-node:focus-within .connection-handle { opacity: 1; }

.connection-handle {
  position: absolute;
  z-index: 4;
  top: calc(50% - 7px);
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  opacity: 0;
  cursor: crosshair;
  transition: opacity .12s, transform .12s;
}
.connection-handle.input { left: -7px; background: var(--surface); }
.connection-handle.output { right: -7px; }
.node:hover .connection-handle, .node:focus-within .connection-handle, .graph-viewport.connecting .connection-handle { opacity: 1; }
.connection-handle:hover { transform: scale(1.25); background: var(--brand); }
.graph-viewport.connecting { cursor: crosshair; }
.graph-viewport.connecting .connection-handle.input { transform: scale(1.3); }
.graph-viewport.connecting .connection-valid { outline: 2px solid rgb(64 87 214 / 16%); outline-offset: 3px; }
.graph-viewport.connecting .connection-invalid { opacity: .45; }
.graph-viewport.connecting .connection-hover.connection-valid { outline-color: var(--brand); box-shadow: 0 0 0 6px rgb(64 87 214 / 12%), var(--shadow-sm); opacity: 1; }
.graph-viewport.connecting .connection-hover.connection-invalid { outline: 2px solid rgb(211 73 86 / 55%); opacity: .75; }
.connection-tip { position: fixed; z-index: 70; max-width: 245px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgb(255 255 255 / 97%); box-shadow: var(--shadow-sm); color: var(--muted); font-size: 10px; font-weight: 650; pointer-events: none; }
.connection-tip.valid { border-color: #a8d7ba; color: #247848; }
.connection-tip.invalid { border-color: #ecc0c5; color: #a52f3c; }
.connection-tip[hidden] { display: none; }

.node-header { display: flex; min-height: 43px; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, var(--canvas)); }
.node-heading { display: grid; min-width: 0; gap: 1px; }
.node-actions { display: flex; flex: none; align-items: center; gap: 7px; }
.node-readiness { display: grid; width: 15px; height: 15px; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 9px; font-style: normal; font-weight: 850; }
.node-readiness[hidden] { display: none; }
.node-fork { min-width: 0; min-height: 20px; padding: 2px 7px; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: #475569; font-size: 8px; font-weight: 700; letter-spacing: .02em; }
.node-fork:hover { border-color: var(--brand); background: #eef2ff; color: var(--brand); }
.node-start { display: inline-flex; min-height: 25px; align-items: center; gap: 4px; padding: 3px 7px; border-color: #c8cff5; background: var(--brand-soft); color: var(--brand); font-size: 9px; }
.node-start:hover { border-color: var(--brand); background: var(--brand); color: #fff; }
.node-start span { font-size: 7px; }
.node-title { overflow: hidden; font-size: 12px; font-weight: 720; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.node-agent { overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.node-body { display: grid; min-height: 0; flex: 1; align-content: space-between; gap: 8px; padding: 10px; }
.node-detail { align-self: start; color: #59616d; font-size: 10px; font-weight: 500; }
.node-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.state-label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.node-id { overflow: hidden; color: var(--subtle); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.status-dot, .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--subtle); }
.status-dot.ready, .dot.ready { background: var(--violet); }
.status-dot.queued, .dot.queued, .status-dot.blocked, .dot.blocked { background: var(--yellow); }
.status-dot.running, .dot.running { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.status-dot.awaiting, .dot.awaiting { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.status-dot.succeeded, .dot.succeeded { background: var(--green); }
.status-dot.failed, .dot.failed, .status-dot.cancelled, .dot.cancelled { background: var(--red); }
.status-dot.stalled, .status-dot.slow, .stall-dot { background: #d28a00; box-shadow: 0 0 0 3px #fff3cf; }

.graph-controls {
  position: absolute;
  z-index: 25;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.graph-controls button { min-height: 30px; }
.graph-controls .fit-button { min-width: 42px; font-size: 10px; }
.zoom-value { min-width: 38px; color: var(--muted); font-size: 9px; text-align: center; }
.control-divider { height: 22px; margin: 0 2px; }
/* Right rail: mode, line toggles, and actions. Docked, always visible. */
.canvas-rail {
  position: absolute;
  z-index: 25;
  top: 76px;
  right: 14px;
  bottom: 62px;
  width: var(--rail-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow-sm);
  overflow: hidden auto;
  cursor: default;
  backdrop-filter: blur(12px);
}
.rail-section { display: grid; min-width: 0; gap: 5px; }
.rail-section[hidden] { display: none; }
.rail-line, .rail-action { min-width: 0; }
.rail-section + .rail-section { padding-top: 10px; border-top: 1px solid var(--line); }
.rail-heading { display: flex; align-items: center; justify-content: space-between; color: var(--subtle); font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.rail-modes { grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); }
.rail-mode { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 4px 6px; border-color: transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: 11px; }
.rail-mode:hover { background: var(--surface); color: var(--ink); }
.rail-mode[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--brand); }
.rail-icon { font-size: 10px; }
.rail-line { display: flex; width: 100%; min-height: 28px; align-items: center; gap: 7px; padding: 3px 6px; border-color: transparent; background: transparent; color: var(--ink); text-align: left; font-size: 11px; font-weight: 550; }
.rail-line:hover { background: var(--surface-hover); color: var(--ink); }
.rail-line[aria-pressed="false"] { color: var(--subtle); }
.rail-line[aria-pressed="false"] .rail-swatch { opacity: .3; }
.rail-line .rail-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-swatch { width: 18px; height: 0; flex: none; border-top: 2.5px solid var(--swatch, var(--line-strong)); }
.rail-swatch.dashed { border-top-style: dashed; }
.rail-swatch.dotted { border-top-style: dotted; }
.rail-count { flex: none; min-width: 20px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); text-align: center; font-size: 9px; }
.rail-action { display: flex; width: 100%; min-height: 30px; align-items: center; gap: 7px; padding: 4px 7px; border-color: var(--line); background: var(--surface); color: var(--ink); text-align: left; font-size: 11px; font-weight: 600; }
.rail-action:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.rail-action:disabled { border-color: var(--line); background: var(--surface-muted); color: var(--subtle); }
.rail-action .rail-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-action .rail-icon { width: 14px; color: var(--brand); text-align: center; }
.rail-action:disabled .rail-icon { color: var(--subtle); }
.rail-target { display: grid; gap: 1px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.rail-target span { color: var(--subtle); font-size: 9px; text-transform: uppercase; }
.rail-target strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.rail-proposal { gap: 7px; }
.rail-proposal .readiness-pill { justify-self: start; }
.rail-proposal-summary { color: var(--muted); font-size: 10px; line-height: 1.4; }
.rail-proposal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rail-hint { margin-top: auto; padding-top: 8px; color: var(--subtle); font-size: 9px; line-height: 1.4; }
.canvas-rail .rail-label-only { display: none; }

/* Plan mode shows only files and their links. Nothing here writes to the project. */
.graph-viewport.plan-mode .node, .graph-viewport.plan-mode .edge-edit-button, .graph-viewport.plan-mode .edge-layer path.edge:not(.relation) { display: none; }
.graph-viewport.plan-mode .file-node .connection-handle { display: none; }
body.plan-mode .toolbar-run .run-field, body.plan-mode .toolbar-run .readiness-pill, body.plan-mode #add-task { display: none; }

/* Planning package and automatic task graph on the unified board. */
.package-panel { position: fixed; z-index: 85; top: calc(var(--chrome-top) + 8px); right: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); overflow: auto; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-md); }
.package-panel[hidden], .package-actions[hidden], .orchestrator-panel[hidden] { display: none; }
.package-panel .panel-heading { margin-bottom: 14px; }
.package-panel .field-label { margin: 10px 0; }
.package-summary { margin: 12px 0; color: var(--muted); }
.package-summary p + p { margin-top: 7px; }
.package-task-list { max-height: 45vh; overflow: auto; margin-top: 12px; border-top: 1px solid var(--line); }
.package-task-list > div { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.package-task-list span, .package-task-list small { color: var(--muted); font-size: 11px; }
.package-actions { display: grid; gap: 8px; }
.task-card { position: absolute; width: 230px; min-height: 122px; padding: 0 10px 9px; border: 1px solid var(--line-strong); border-left: 4px solid var(--brand); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); z-index: 5; }
.task-card-head { display: flex; justify-content: space-between; gap: 5px; align-items: start; margin: 0 -10px 7px; padding: 9px 10px 7px; cursor: grab; border-bottom: 1px solid var(--line); }
.task-card-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.task-card-head span { color: var(--muted); font-size: 10px; text-transform: capitalize; white-space: nowrap; }
.task-card > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.task-card-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.task-card-foot button { min-height: 25px; padding: 3px 7px; }
.task-card-foot button:first-child { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.task-card-head.has-stall span { color: #9b6500; }
.stall-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; vertical-align: 1px; }
.stall-line { display: block; max-width: 205px; margin-top: 6px; overflow: hidden; color: #76561a; text-overflow: ellipsis; white-space: nowrap; }
.task-gate { display: block; margin-top: 5px; color: var(--yellow); font-size: 10px; }
.link-layer path.planning-relation { stroke: #8d97ae; stroke-width: 1.5; stroke-dasharray: 4 5; fill: none; }
.link-layer path.trigger-edge { stroke: var(--brand); stroke-width: 2; fill: none; }
.link-layer path.trigger-edge.manual { stroke-dasharray: 7 5; }
.trigger-pill { position: absolute; z-index: 9; pointer-events: auto; }
.trigger-pill button { min-height: 24px; padding: 1px 6px; background: var(--surface); color: var(--brand); border: 1px solid var(--brand); border-radius: 12px; font-size: 10px; }

/* Fixed assistant stays usable while the canvas pans and zooms. */
.orchestrator { position: fixed; z-index: 100; width: 52px; height: 52px; }
.orchestrator-fab { width: 52px; height: 52px; border-radius: 50%; box-shadow: var(--shadow-md); font-size: 24px; touch-action: none; }
.orchestrator-fab::after { content: attr(data-count); position: absolute; right: -5px; top: -6px; min-width: 19px; min-height: 19px; padding: 1px 4px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; line-height: 17px; }
.orchestrator-fab[data-count=""]::after { display: none; }
.orchestrator-panel { position: absolute; right: 0; bottom: 61px; display: flex; flex-direction: column; width: min(370px, calc(100vw - 20px)); height: min(500px, calc(100vh - 90px)); border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden; }
.orchestrator.panel-below .orchestrator-panel { bottom: auto; top: 61px; }
.orchestrator.panel-right .orchestrator-panel { right: auto; left: 0; }
.orchestrator-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.orchestrator-head button { min-height: 25px; padding: 1px 7px; background: transparent; border-color: transparent; color: var(--muted); }
.orchestrator-engine { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.orchestrator-engine select { flex: 1; width: auto; }
.orchestrator-alerts { max-height: 115px; overflow: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.orchestrator-alerts strong { color: var(--yellow); }
.orchestrator-alerts ul { margin: 4px 0 0; padding-left: 16px; }
.orchestrator-content { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 10px; padding: 12px; }
.orchestrator-content p { line-height: 1.45; }
.orchestrator-user { justify-self: end; max-width: 90%; padding: 8px 10px; border-radius: 9px; background: var(--brand-soft); }
.orchestrator-answer { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; }
.orchestrator-actions { display: grid; gap: 6px; margin-top: 10px; }
.orchestrator-actions small { color: var(--muted); }
.orchestrator-actions button { text-align: left; background: var(--surface); border-color: var(--brand); color: var(--brand); }
.orchestrator-plan { display: grid; gap: 8px; margin-top: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.orchestrator-plan-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; padding: 7px; border: 1px solid var(--line); border-radius: 7px; }
.orchestrator-plan-step input { margin-top: 2px; }
.orchestrator-plan-step > span { display: grid; gap: 3px; min-width: 0; }
.orchestrator-plan-detail, .orchestrator-plan-step small { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; }
.orchestrator-plan-step small.is-failing { color: var(--red); }
.orchestrator-plan > button { justify-self: start; }
.orchestrator-plan-result:empty { display: none; }
.orchestrator-content-preview { margin-top: 6px; }
.orchestrator-content-preview pre { max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px; border-radius: 6px; background: var(--surface); font-size: 11px; }
.orchestrator-error { color: var(--red); }
.orchestrator-session { margin: 2px 0 6px; font-size: 11px; line-height: 1.4; color: var(--muted); }
.orchestrator-session.is-continuing { color: var(--brand); }
.orchestrator-working { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 9px; font-size: 12px; color: var(--muted); }
.orchestrator-working-body { flex: 1; min-width: 0; }
.orchestrator-elapsed { font-variant-numeric: tabular-nums; color: var(--ink); }
.orchestrator-hint { display: block; margin-top: 2px; }
.orchestrator-working button { flex: none; font-size: 11px; padding: 2px 8px; }
.orchestrator-spinner { flex: none; width: 10px; height: 10px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: orchestrator-spin 0.8s linear infinite; }
@keyframes orchestrator-spin { to { transform: rotate(360deg); } }
#orchestrator-form { display: grid; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
#orchestrator-form textarea { min-height: 64px; max-height: 120px; }
#orchestrator-form button { justify-self: end; }
.edge-layer path.edge.line-hidden { display: none; }

/* Relation lines are inert planning links between files. */
.edge-layer path.edge.relation { stroke: #8a95b3; stroke-width: 1.5; stroke-dasharray: 2 5; stroke-linecap: round; marker-end: url(#arrow-link); }
.edge-layer path.edge.relation.review { stroke: var(--violet); stroke-dasharray: 1 5; marker-end: url(#arrow-review); }
.edge-layer path.edge.relation.dimmed { opacity: .2; }
.edge-layer path.edge.proposed { stroke-dasharray: 6 5; opacity: .75; }
.edge-layer path.edge.proposed.rejected { opacity: .18; }

/* Review badge and activity on a file node. */
.file-node.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(64 87 214 / 18%), 0 9px 24px rgb(25 38 58 / 12%); }
.file-node.reviewing { border-color: var(--violet); animation: running-node 1.8s ease-in-out infinite; }
.file-node.reviewing .file-node-icon { border-color: #b8b6ec; background: #efeefc; color: var(--violet); }
.file-badge { position: absolute; z-index: 5; top: -9px; right: 22px; min-width: 22px; min-height: 18px; padding: 1px 6px; border: 1px solid; border-radius: 999px; background: var(--surface); font-size: 9px; font-weight: 800; line-height: 1.4; cursor: pointer; }
.file-badge.pass { border-color: #a8d7ba; background: var(--green-soft); color: var(--green); }
.file-badge.warn { border-color: #ead49f; background: var(--yellow-soft); color: var(--yellow); }
.file-badge.fail { border-color: #ecc0c5; background: var(--red-soft); color: var(--red); }
.file-badge:hover { filter: brightness(.96); }
.file-badge[hidden] { display: none; }
.file-gate { position: absolute; z-index: 5; top: -8px; left: 8px; }

/* Proposal overlay: ghost cards until the person applies them. */
.node.ghost { border-style: dashed; border-color: #8f9de8; background: rgb(255 255 255 / 76%); box-shadow: none; cursor: default; }
.node.ghost.rejected { opacity: .32; border-color: var(--line-strong); }
.node.ghost .node-start, .node.ghost .connection-handle, .node.ghost .card-mode-toggle { display: none; }
.ghost-actions { display: flex; gap: 4px; }
.ghost-actions button { min-height: 22px; padding: 2px 7px; font-size: 9px; }
.ghost-gates { display: grid; gap: 2px; margin-top: 4px; color: var(--yellow); font-size: 8px; line-height: 1.3; }
.ghost-gates span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-readiness-pill { display: inline-flex; padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; font-size: 8px; font-weight: 750; text-transform: uppercase; }
.node-readiness-pill.ready { border-color: #a8d7ba; background: var(--green-soft); color: var(--green); }
.node-readiness-pill.blocked, .node-readiness-pill.partial { border-color: #ead49f; background: var(--yellow-soft); color: var(--yellow); }
.node-readiness-pill.unbound { border-color: #ecc0c5; background: var(--red-soft); color: var(--red); }
.file-node.ghost { border-style: dashed; border-color: #8f9de8; background: rgb(255 255 255 / 72%); box-shadow: none; opacity: .85; }

/* File inspector and brief details. */
.gate-list { display: grid; gap: 4px; }
.gate { display: grid; gap: 1px; padding: 6px 8px; border: 1px solid #ead49f; border-radius: 7px; background: var(--yellow-soft); color: #7a5410; font-size: 10px; }
.gate strong { font-size: 9px; text-transform: uppercase; }
.gate.clear { border-color: #a8d7ba; background: var(--green-soft); color: var(--green); }
.review-summary { display: flex; align-items: center; gap: 8px; }
.review-summary .file-badge { position: static; }
.action-editor, .ledger-editor { width: min(620px, 92vw); }
.action-editor textarea { min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.history-button { min-width: 30px; }
.readiness-pill { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 750; white-space: nowrap; }
.readiness-pill.ready { border-color: #a8d7ba; background: var(--green-soft); color: #247848; }
.readiness-pill.attention { border-color: #ecc0c5; background: var(--red-soft); color: #a52f3c; }
.readiness-pill.checking { background: var(--surface-muted); }

.floating-panel {
  position: fixed;
  z-index: 40;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 97%);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  user-select: text;
  backdrop-filter: blur(16px);
}
.floating-panel[hidden] { display: none; }
.resources { top: 14px; bottom: 14px; left: 14px; width: min(340px, calc(100vw - 28px)); padding: 0 14px 16px; transform: translateX(calc(-100% - 24px)); transition: transform 180ms ease; }
.resources.open { transform: translateX(0); }
.inspector { top: 76px; right: calc(var(--rail-width) + 24px); width: min(360px, calc(100vw - var(--rail-width) - 38px)); max-height: calc(100vh - 90px); display: grid; align-content: start; gap: 14px; padding: 14px; }

.sticky-heading { position: sticky; z-index: 2; top: 0; margin: 0 -2px; padding: 14px 2px 11px; background: rgb(255 255 255 / 96%); backdrop-filter: blur(14px); }
.panel-heading, .dialog-heading, .section-heading, .inspector-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.resource-section { display: grid; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line); }
.resource-section:first-of-type { border-top: 0; }
.count { min-width: 25px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); text-align: center; font-size: 10px; }
.agent-list, .resource-list { display: grid; gap: 7px; }
.resource-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); transition: border-color .12s, background .12s; }
.resource-card:hover { border-color: var(--line-strong); background: var(--surface); }
.resource-card.selected { border-color: #aeb8ef; background: var(--brand-soft); }
.resource-copy, .resource-open { display: grid; min-width: 0; gap: 2px; }
.resource-open { min-height: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; color: inherit; text-align: left; }
.resource-open:hover { background: transparent; color: inherit; }
.resource-title { display: flex; min-width: 0; align-items: center; gap: 6px; }
.resource-title strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.resource-copy > span, .resource-open > span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.resource-copy small, .resource-open small { color: var(--subtle); font-size: 9px; font-weight: 550; line-height: 1.35; }
.resource-tag { flex: none; padding: 1px 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; }
.resource-delete { min-height: 26px; padding: 3px 7px; border-color: transparent; background: transparent; color: var(--subtle); font-size: 9px; opacity: 0; transition: opacity .12s, color .12s, background .12s; }
.resource-card:hover .resource-delete, .resource-delete:focus-visible { opacity: 1; }
.resource-delete:hover { border-color: #ecc0c5; background: var(--red-soft); color: var(--red); }
.resource-delete:disabled { opacity: .32; }
.empty { padding: 16px 3px; color: var(--muted); font-size: 11px; font-style: italic; }
.config-section { padding: 4px 0; }
.config-section summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 650; }
.config-section summary small { color: var(--subtle); font-size: 9px; font-weight: 600; }
.form { display: grid; gap: 8px; padding-top: 10px; }
.setup-form { gap: 11px; }
.form-copy { color: var(--muted); font-size: 10px; }
.field-label { gap: 5px; color: #555d69; font-size: 10px; font-weight: 700; }
.field-label[hidden] { display: none; }
.field-help { color: var(--subtle); font-size: 9px; font-weight: 500; line-height: 1.35; }
.choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-field legend { margin-bottom: 5px; color: #555d69; font-size: 10px; font-weight: 700; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.vendor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.vendor-grid .choice-card span { padding-inline: 7px; }
.choice-card { position: relative; display: block; min-width: 0; cursor: pointer; color: inherit; }
.choice-card input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.choice-card span { display: grid; min-height: 55px; align-content: center; gap: 1px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: border-color .12s, background .12s, box-shadow .12s; }
.choice-card strong { font-size: 11px; }
.choice-card small { color: var(--muted); font-size: 9px; font-weight: 500; line-height: 1.3; }
.choice-card input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.choice-card input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.choice-card:has(input:disabled) { cursor: not-allowed; opacity: .45; }
.path-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.path-picker input { overflow: hidden; background: var(--surface-muted); color: #4d5561; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; text-overflow: ellipsis; cursor: pointer; }
.path-picker button { min-width: 70px; }
.inherited-default { display: grid; gap: 2px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.inherited-default strong { color: #555d69; font-size: 10px; }
.inherited-default span { color: var(--muted); font-size: 9px; line-height: 1.35; }
.runtime-note { min-height: 0; color: var(--muted); font-size: 9px; }
.runtime-note:empty { display: none; }
.panel-note { color: var(--muted); font-size: 10px; }

.inspector-heading { display: grid; gap: 6px; }
.status-pill { flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.status-pill.running { border-color: #8f9de8; background: var(--brand-soft); color: var(--brand); }
.status-pill.awaiting, .status-pill.queued { border-color: #ead49f; background: var(--yellow-soft); color: var(--yellow); }
.status-pill.stalled, .status-pill.slow { border-color: #ead49f; background: #fff3cf; color: #9b6500; }
.status-pill.succeeded { border-color: #a8d7ba; background: var(--green-soft); color: var(--green); }
.status-pill.failed, .status-pill.cancelled { border-color: #ecc0c5; background: var(--red-soft); color: var(--red); }
.status-pill.blocked { border-color: #ead49f; background: var(--yellow-soft); color: var(--yellow); }
.meta-grid, .preflight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.meta { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); }
.meta span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.meta strong { display: block; overflow: hidden; margin-top: 2px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.section { display: grid; gap: 7px; }
.terminal-section { min-height: 0; }
.terminal-toolbar { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 6px; }
.terminal-toolbar .node-id { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terminal-state { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.terminal-state i { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; }
.terminal-state.live { color: var(--green); }
.terminal-state.live i { background: var(--green); }
.terminal-follow { min-height: 24px; padding: 3px 7px; border-color: #4b5870; background: #202a3a; color: #d8e0dc; font-size: 9px; }
.terminal-follow:hover { background: #2a374b; color: #fff; }
.terminal-follow[hidden] { display: none; }
.dependency-list { display: flex; flex-wrap: wrap; gap: 5px; }
.dependency { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); color: #59616d; font-size: 10px; }
.prompt { max-height: 150px; overflow: auto; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); color: #4d5561; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; user-select: text; }
.terminal { min-height: 210px; max-height: 42vh; overflow: auto; margin: 0; padding: 11px; border: 1px solid #303949; border-radius: 7px; background: #111827; color: #d8e0dc; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overscroll-behavior: contain; scrollbar-gutter: stable; white-space: pre-wrap; word-break: break-word; user-select: text; }
.terminal:focus-visible { outline: 2px solid #7383dc; outline-offset: 2px; }
.terminal.placeholder { color: #9ca3af; font-style: italic; }
.completion-summary { display: grid; gap: 2px; padding: 10px; border: 1px solid #a8d7ba; border-radius: 8px; background: var(--green-soft); color: var(--green); }
.completion-summary strong { font-size: 11px; }
.completion-summary span { font-size: 9px; line-height: 1.4; }
.readiness-card { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.readiness-card.ready { border-color: #bce0ca; background: var(--green-soft); color: #247848; }
.readiness-card.attention { border-color: #ecc0c5; background: var(--red-soft); color: #9e2f3b; }
.readiness-card > div { display: grid; gap: 2px; }
.readiness-card strong { font-size: 10px; }
.readiness-card span:not(.readiness-icon) { font-size: 9px; line-height: 1.35; }
.readiness-icon { display: grid; width: 22px; height: 22px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 10px; font-weight: 850; }
.markdown-summary { display: grid; gap: 5px; }
.context-overview { margin-bottom: 2px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.context-row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 42px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); }
.context-row.missing, .context-row.stale { border-color: #ecc0c5; background: var(--red-soft); }
.context-row.active { border-color: #aeb8ef; background: var(--brand-soft); }
.context-row.planned { border-style: dashed; }
.context-kind { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.context-copy { display: grid; min-width: 0; gap: 1px; }
.context-copy strong, .context-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-copy strong { font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.context-copy small { color: var(--muted); font-size: 8px; }
.context-preview { min-width: 0; min-height: 24px; padding: 3px 6px; border-color: var(--line-strong); background: var(--surface); color: var(--brand); font-size: 8px; }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.danger { border-color: var(--red); background: var(--red); }
.danger:hover { background: #bf3947; }

dialog { width: min(620px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 100px rgb(23 31 47 / 25%); }
dialog::backdrop { background: rgb(23 31 47 / 28%); }
.dialog-card { display: grid; gap: 15px; padding: 19px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; }
.task-editor { gap: 13px; }
.task-editor.agent-only .task-structure-field { display: none; }
.edge-editor { gap: 13px; }
.quick-file-editor { width: min(480px, 90vw); }
.quick-file-editor > p:not(.task-error) { color: var(--muted); font-size: 11px; line-height: 1.45; }
.edge-editor > p { color: var(--muted); font-size: 11px; }
.split-actions { grid-template-columns: auto 1fr auto auto; }
.split-actions > span { flex: 1; }
.edge-remove { color: var(--red) !important; }
.inline-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.inline-field button { min-width: 88px; }
.dependency-field { display: grid; gap: 5px; }
.dependency-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.dependency-choice { position: relative; display: block; min-width: 0; color: inherit; cursor: pointer; }
.dependency-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dependency-choice span { display: block; overflow: hidden; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); color: #555d69; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dependency-choice input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.dependency-choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.dependency-choice:has(input:disabled) { cursor: not-allowed; opacity: .42; }
.dependency-empty { padding: 9px; border: 1px dashed var(--line-strong); border-radius: 7px; color: var(--muted); font-size: 10px; text-align: center; }
.task-error { padding: 9px; border: 1px solid #ecc0c5; border-radius: 7px; background: var(--red-soft); color: #9e2f3b; font-size: 10px; }
.warning { padding: 9px; border: 1px solid #e6d09c; border-radius: 7px; background: var(--yellow-soft); color: #78550f; font-size: 11px; }
#delete-dialog { width: min(430px, calc(100vw - 30px)); }
.delete-preservation { display: grid; gap: 2px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.delete-preservation strong { font-size: 10px; }
.delete-preservation span { color: var(--muted); font-size: 10px; }
.delete-error { padding: 9px; border: 1px solid #ecc0c5; border-radius: 7px; background: var(--red-soft); color: #9e2f3b; font-size: 10px; }
.directory-card { grid-template-rows: auto auto minmax(180px, 46vh) auto auto; }
.directory-location { display: flex; min-width: 0; align-items: center; gap: 8px; }
.directory-location span { overflow: hidden; color: #555d69; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.directory-list { display: grid; align-content: start; gap: 4px; overflow: auto; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.directory-entry { display: flex; width: 100%; align-items: center; justify-content: flex-start; gap: 8px; padding: 7px 8px; border-color: transparent; background: transparent; color: var(--ink); text-align: left; font-weight: 550; }
.directory-entry:hover { background: var(--surface); color: var(--ink); }
.directory-entry::before { content: "▸"; color: var(--brand); }

@media (hover: none) {
  .resource-delete { opacity: 1; }
}
.directory-loading, .directory-empty { padding: 20px 10px; color: var(--muted); font-size: 10px; text-align: center; }
.directory-note { color: var(--muted); font-size: 9px; }

@media (max-width: 1000px) {
  .brand-copy, .project-title, .progress { display: none; }
  .brand { min-width: auto; }
  .toolbar-primary { max-width: none; }
  .toolbar-field { min-width: 140px; }
  .run-field { min-width: 150px; }
}

@media (max-width: 900px) {
  :root { --rail-width: 46px; }
  .canvas-rail { padding: 6px; gap: 8px; }
  .canvas-rail .rail-label, .canvas-rail .rail-count, .canvas-rail .rail-heading, .canvas-rail .rail-hint, .canvas-rail .rail-target, .canvas-rail .rail-proposal-summary { display: none; }
  .rail-modes { grid-template-columns: 1fr; }
  .rail-line, .rail-action, .rail-mode { justify-content: center; padding: 4px; }
  .rail-proposal-actions { grid-template-columns: 1fr; }
  .inspector { right: 14px; width: min(360px, calc(100vw - 28px)); z-index: 40; }
}

@media (max-width: 700px) {
  .canvas-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-cluster { width: fit-content; max-width: 100%; }
  .toolbar-run { align-self: flex-end; margin-top: -4px; }
  .toolbar-divider, .brand { display: none; }
  .toolbar-field { min-width: 132px; }
  .run-field { min-width: 150px; }
  .inspector { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: min(68vh, 560px); }
  .canvas-rail { top: auto; bottom: 12px; right: 12px; max-height: 42vh; }
  .graph-controls { bottom: 12px; left: 12px; }
  .resources { top: 12px; bottom: 12px; left: 12px; }
  .run-history { top: 115px; right: 12px; bottom: 12px; width: min(430px, calc(100vw - 24px)); }
  .dependency-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .resources, .node { transition: none; animation: none; }
  .edge-layer path.edge.flow-active { animation: none; }
}

/* Workspace files and explicit Markdown contracts. */
.files-panel { position: fixed; top: calc(var(--chrome-top) + 40px); left: 20px; bottom: 24px; width: min(370px, calc(100vw - 40px)); z-index: 30; padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.files-panel[hidden] { display: none; }
.files-panel .dialog-heading { margin: 0; }
.files-panel .inline-field input { min-width: 0; width: 100%; padding: 8px; }
.files-tree { overflow: auto; flex: 1; font-size: 12px; }
.files-tree summary { padding: 6px 0; cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.file-children { margin-left: 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.file-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; color: var(--ink); text-align: left; font-weight: 400; }
.file-row:hover { background: var(--brand-soft); }
.file-row[draggable="true"] { cursor: grab; }
.file-row[draggable="true"]:active { cursor: grabbing; }
.file-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { margin-left: auto; color: var(--muted); white-space: nowrap; }
.md-icon { color: var(--brand); font-size: 9px; font-weight: 700; }
.planned-file-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.planned-file-form button { white-space: nowrap; }
.file-node-editor { width: min(620px, 90vw); }
.markdown-contract { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); }
.markdown-contract textarea { min-height: 64px; font-family: ui-monospace, monospace; font-size: 12px; }
.markdown-contract summary { cursor: pointer; font-size: 12px; color: var(--brand); }
.file-options { max-height: 190px; overflow: auto; overflow-wrap: anywhere; }
.markdown-summary { display: grid; gap: 7px; font-size: 12px; overflow-wrap: anywhere; }
.artifact-preview { text-align: left; }
#file-preview[open] {
  position: fixed;
  z-index: 80;
  inset: 20px;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0;
  display: flex;
}
.file-preview { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; min-height: 0; height: 100%; }
.markdown-heading { min-width: 0; }
.file-preview h2 { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.markdown-viewer-tools { display: flex; flex: none; align-items: center; gap: 8px; }
.markdown-status { max-width: 180px; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.markdown-mode, .markdown-save { min-height: 28px; padding: 2px 11px; border-radius: 999px; font-size: 11px; }
.markdown-rendered, .markdown-raw { min-height: 0; overflow: auto; }
.markdown-rendered { padding: 6px 8px 28px; }
.markdown-rendered > * { max-width: 74ch; }
.markdown-rendered h1, .markdown-rendered h2, .markdown-rendered h3, .markdown-rendered h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.markdown-rendered h1 { font-size: 28px; }
.markdown-rendered h2 { font-size: 22px; white-space: normal; }
.markdown-rendered h3 { font-size: 17px; }
.markdown-rendered p, .markdown-rendered ul, .markdown-rendered ol, .markdown-rendered blockquote { margin: .7em 0; }
.markdown-rendered ul, .markdown-rendered ol { padding-left: 1.3em; }
.markdown-rendered li + li { margin-top: .25em; }
.markdown-rendered blockquote { margin-left: 0; padding-left: 12px; border-left: 3px solid var(--line-strong); color: #3d4450; }
.markdown-rendered a { color: var(--brand); }
.markdown-rendered code { padding: 1px 4px; border-radius: 4px; background: var(--surface-muted); font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-rendered pre { overflow: auto; max-width: none; margin: .9em 0; padding: 14px 16px; border-radius: 8px; background: #111722; color: #dbe4f0; }
.markdown-rendered pre code { padding: 0; background: transparent; color: inherit; font-size: 12.5px; }
.markdown-rendered table { width: 100%; max-width: 74ch; border-collapse: collapse; font-size: 13px; }
.markdown-rendered th, .markdown-rendered td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.markdown-rendered hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--line); }
.markdown-raw { width: 100%; height: 100%; resize: none; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); padding: 16px; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }

.card-mode-toggle { display: flex; padding: 2px 8px; gap: 3px; background: var(--surface-muted); border-bottom: 1px solid var(--line); }
.card-mode-toggle button { min-height: 19px; padding: 1px 8px; font-size: 9px; border: 0; background: transparent; color: var(--muted); border-radius: 4px; }
.card-mode-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.node.cli-card { z-index: 8; display: flex; flex-direction: column; overflow: visible; }
.node.cli-card .node-header { min-height: 38px; padding: 5px 8px; }
.node.cli-card .node-body { display: none; }
.cli-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; padding: 0 8px 8px; background: #111722; border-radius: 0 0 10px 10px; cursor: text; }
.cli-header { display: flex; min-width: 0; min-height: 27px; flex-shrink: 0; align-items: center; gap: 6px; }
.cli-status { min-width: 0; flex: 1; overflow: hidden; padding: 4px 0; color: #94a3b8; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.cli-dimensions { flex: none; color: #718096; font: 8px ui-monospace, SFMono-Regular, Menlo, monospace; }
.cli-tools { display: flex; flex: none; align-items: center; gap: 2px; }
.cli-tools button, .cli-history-actions button, .cli-search button { min-width: 22px; min-height: 20px; padding: 1px 4px; border-color: transparent; background: transparent; color: #94a3b8; font-size: 9px; }
.cli-tools button:hover, .cli-history-actions button:hover, .cli-search button:hover { border-color: #48566e; background: #263349; color: #fff; }
.cli-font-size { min-width: 27px; color: #718096; font: 8px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.cli-search { display: flex; min-height: 30px; flex-shrink: 0; align-items: center; gap: 4px; padding: 3px 0 5px; border-bottom: 1px solid #2c3748; }
.cli-search[hidden] { display: none; }
.cli-search-input { min-width: 80px; height: 24px; flex: 1; padding: 2px 7px; border-color: #48566e; background: #182233; color: #e1e7ef; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.cli-search-result { min-width: 48px; color: #94a3b8; font-size: 8px; text-align: right; }
.cli-history, .cli-history-actions .cli-history-close, .cli-history-actions .cli-history-copy { min-height: 20px; padding: 1px 5px; border-color: #48566e; background: #202a3a; color: #cbd5e1; font-size: 9px; }
.cli-history:hover, .cli-history-actions .cli-history-close:hover, .cli-history-actions .cli-history-copy:hover { background: #2a374b; color: #fff; }
.cli-history[hidden] { display: none; }
.cli-screen { flex: 1; min-height: 0; overflow: hidden; }
.cli-screen .xterm { height: 100%; padding: 0; }
/* The xterm host also carries the legacy .terminal class (the old result
   viewer), whose window-relative max-height and own scrollbar would cap a
   card terminal's height and add a second scrollbar. xterm scrolls itself. */
.cli-screen .terminal { min-height: 0; max-height: none; overflow: hidden; scrollbar-gutter: auto; border: 0; border-radius: 0; }
.cli-screen .xterm-helper-textarea { min-height: 0; border: 0; padding: 0; resize: none; }
.cli-history-panel { position: absolute; z-index: 5; inset: 27px 0 0; display: flex; min-height: 0; flex-direction: column; overflow: hidden; border-radius: 0 0 10px 10px; background: #111722; color: #dbe4f0; }
.cli-panel:has(.cli-search:not([hidden])) .cli-history-panel { top: 57px; }
.cli-history-panel[hidden] { display: none; }
.cli-history-heading { display: flex; min-height: 34px; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 10px; border-bottom: 1px solid #334155; background: #172131; color: #aebcd0; font-size: 9px; }
.cli-history-heading strong { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.cli-history-title, .cli-history-actions, .cli-history-modes { display: flex; min-width: 0; align-items: center; gap: 4px; }
.cli-history-title { gap: 7px; }
.cli-history-summary { overflow: hidden; color: #718096; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.cli-history-actions { flex: none; }
.cli-history-modes { gap: 1px; padding: 1px; border: 1px solid #334155; border-radius: 5px; background: #111722; }
.cli-history-actions .cli-history-modes button { min-height: 17px; padding: 0 5px; border: 0; border-radius: 3px; font-size: 8px; }
.cli-history-actions .cli-history-modes button[aria-pressed="true"] { background: #334155; color: #fff; }
.cli-history-copy:disabled { opacity: .45; }
.cli-history-readable { min-height: 0; flex: 1; overflow: auto; display: grid; align-content: start; gap: 8px; padding: 10px; background: #0e1520; cursor: auto; }
.cli-history-readable[hidden] { display: none; }
.cli-history-entry { padding: 8px 10px; border: 1px solid #273449; border-left: 3px solid #64748b; border-radius: 7px; background: #141d2b; }
.cli-history-entry.is-prompt { border-left-color: #818cf8; background: #171c32; }
.cli-history-entry.is-response { border-left-color: #4ade80; background: #13251f; }
.cli-history-entry.is-error { border-left-color: #fb7185; background: #2b171d; }
.cli-history-entry.is-status { border-left-color: #fbbf24; background: #262214; }
.cli-history-entry.is-session { border-left-color: #a78bfa; background: #1d1930; }
.cli-history-entry.search-match { outline: 2px solid #facc15; outline-offset: 1px; }
.cli-history-entry-label { margin-bottom: 4px; color: #91a1b8; font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.cli-history-entry pre { margin: 0; overflow-wrap: anywhere; color: #e1e7ef; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.cli-history-entry a { color: #93c5fd; text-decoration: underline; text-underline-offset: 2px; }
.cli-history-empty { margin: auto; padding: 24px; color: #718096; font-size: 10px; text-align: center; }
.cli-history-screen { min-height: 0; flex: 1; overflow-x: auto; overflow-y: hidden; padding: 0; background: #111722; }
.cli-history-screen[hidden] { display: none; }
.cli-history-terminal { min-height: 100%; }
.cli-history-terminal .xterm { height: 100%; padding: 0; }
.cli-reconnect { position: absolute; right: 10px; top: 2px; min-height: 22px; font-size: 9px; }
.cli-reconnect[hidden] { display: none; }
.cli-latest { position: absolute; z-index: 4; right: 12px; bottom: 12px; min-height: 24px; padding: 3px 8px; border-color: #48566e; background: #202a3a; color: #d8e0dc; font-size: 9px; box-shadow: 0 3px 10px rgb(0 0 0 / 30%); }
.cli-latest:hover { background: #2a374b; color: #fff; }
.cli-latest[hidden] { display: none; }
.card-resize { position: absolute; right: 0; bottom: 0; border: 0; background: transparent; color: #94a3b8; min-height: 22px; width: 24px; padding: 0; cursor: nwse-resize; z-index: 4; }
.card-resize:hover { background: #263349; }
.cli-panel { color-scheme: dark; }
.node.terminal-focused-card::after { content: 'Terminal focused at full size'; display: grid; min-height: 0; flex: 1; place-items: center; border-radius: 0 0 10px 10px; background: #111722; color: #718096; font-size: 10px; }

.terminal-focus-layer { position: fixed; z-index: 50; inset: 12px; display: flex; min-height: 0; flex-direction: column; overflow: hidden; border: 1px solid #344158; border-radius: 12px; background: #111722; box-shadow: 0 18px 70px rgb(15 23 42 / 45%); color: #e1e7ef; }
.terminal-focus-layer[hidden] { display: none; }
.terminal-focus-heading { display: flex; min-height: 46px; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px 7px 14px; border-bottom: 1px solid #344158; background: #172131; }
.terminal-focus-heading > div { min-width: 0; }
.terminal-focus-heading .eyebrow { color: #7f8da4; }
.terminal-focus-heading strong { display: block; overflow: hidden; color: #e1e7ef; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.terminal-focus-close { min-height: 28px; padding: 3px 9px; border-color: #48566e; background: #202a3a; color: #d8e0dc; font-size: 10px; }
.terminal-focus-close:hover { background: #2a374b; color: #fff; }
.terminal-focus-host { display: flex; min-height: 0; flex: 1; }
.terminal-focus-host .cli-panel { width: 100%; border-radius: 0; padding: 0 10px 10px; }

/* ===== Unified board: agents and Markdown files on one canvas ===== */
body { display: block; }
.topbar { position: fixed; z-index: 30; inset: 0 0 auto 0; height: 48px; display: flex; align-items: center; gap: 3px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tb { flex: none; height: 30px; min-height: 30px; padding: 0 8px; border-color: transparent; background: transparent; color: var(--ink); font-size: 12px; font-weight: 650; white-space: nowrap; }
.tb:hover:not(:disabled) { background: var(--surface-hover); }
.tb.icon { min-width: 30px; padding: 0 6px; color: #59616d; font-size: 16px; line-height: 1; }
.tb.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.tb.primary:hover { background: #3349c0; }
.tb[aria-expanded="true"] { border-color: #c8cff5; background: var(--brand-soft); color: var(--brand); }
.tdiv { flex: none; width: 1px; height: 24px; margin: 0 3px; background: var(--line); }
.spacer { flex: 1; min-width: 8px; }
.zoom-value { min-width: 36px; color: var(--muted); font-size: 10px; text-align: center; }
.project-tabs { position: fixed; z-index: 29; top: 48px; left: 0; right: 0; height: 34px; display: flex; align-items: stretch; gap: 4px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.tab-list { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.project-tab { flex: none; display: flex; align-items: center; max-width: 230px; margin-top: 4px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); }
.project-tab:hover { background: var(--surface-hover); }
.project-tab.current { border-color: var(--line); background: var(--canvas); color: var(--ink); }
.project-tab.fresh { animation: tab-fresh 1.2s ease-in-out 3; }
@keyframes tab-fresh { 50% { background: var(--brand-soft); } }
.project-tab-main { display: flex; align-items: center; gap: 6px; min-width: 0; height: 100%; min-height: 0; padding: 0 4px 0 10px; border: 0; background: transparent; color: inherit; font-size: 11px; font-weight: 650; }
.project-tab-main:hover { background: transparent; }
.tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-count { flex: none; min-width: 16px; padding: 0 5px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 9px; line-height: 15px; text-align: center; }
.tab-count.attention { background: var(--yellow-soft); color: var(--yellow); }
.tab-close { flex: none; width: 20px; min-height: 20px; height: 20px; margin-right: 4px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--subtle); font-size: 13px; line-height: 1; }
.tab-close:hover { background: var(--line); color: var(--ink); }
.tab-add { flex: none; align-self: center; width: 24px; min-height: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 15px; }
.tab-add:hover { background: var(--surface-hover); color: var(--ink); }
.project-tabs .spacer { flex: 1; }
.canvases-toggle { align-self: center; height: 26px; gap: 6px; }
.canvases-toggle .elsewhere { color: var(--green); font-weight: 700; }
.canvases-toggle .elsewhere.attention { color: var(--yellow); }
.status-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.status-dot.working { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.attention { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.canvas-menu { position: fixed; z-index: 95; top: 80px; right: 8px; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 100px); overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-md); }
.canvas-menu[hidden] { display: none; }
.new-project { position: fixed; z-index: 95; top: 80px; left: 8px; display: grid; gap: 6px; width: min(300px, calc(100vw - 16px)); padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-md); }
.new-project[hidden] { display: none; }
.new-project .eyebrow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-project-row { display: flex; gap: 6px; }
.new-project-row input { flex: 1; min-width: 0; }
.new-project small { color: var(--subtle); font-size: 10px; }
.new-project .link { justify-self: start; min-height: 0; padding: 2px 0; border: 0; background: transparent; color: var(--brand); font-size: 11px; }
.canvas-menu .eyebrow { display: block; padding: 6px 8px 4px; }
.canvas-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 9px; width: 100%; min-height: 0; padding: 7px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; }
.canvas-row:hover, .canvas-row.current { background: var(--surface-hover); }
.canvas-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.canvas-row small { grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--subtle); font-size: 10px; font-weight: 400; }
.canvas-row .canvas-state { color: var(--muted); font-size: 10px; white-space: nowrap; }
.canvas-row .canvas-state.working { color: var(--green); }
.canvas-row .canvas-state.attention { color: var(--yellow); }
.canvas-menu .empty { padding: 8px; color: var(--muted); font-size: 11px; }
.line-toggles { display: flex; flex: none; gap: 4px; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; min-height: 26px; padding: 0 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 10px; font-weight: 600; }
.chip:hover { background: var(--surface-hover); }
.chip[aria-pressed="false"] { color: var(--subtle); }
.chip[aria-pressed="false"] .swatch { opacity: .3; }
.swatch { width: 16px; height: 0; border-top: 2.5px solid; }
.chip .count { min-width: 18px; padding: 0 5px; font-size: 9px; }

.explorer { position: fixed; z-index: 20; top: var(--chrome-top); bottom: 0; left: 0; width: 260px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f9f9fb; user-select: none; }
.explorer[hidden] { display: none; }
.explorer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 14px; }
.explorer-actions { display: flex; gap: 2px; }
.xb { min-width: 24px; min-height: 24px; padding: 0 4px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; }
.xb:hover { background: #e8eaef; color: var(--ink); }
.explorer-project { display: grid; gap: 1px; padding: 0 14px 8px; }
.explorer-project strong { overflow: hidden; font-size: 11px; letter-spacing: .02em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.explorer-project code { overflow: hidden; color: var(--subtle); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.explorer-project small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.explorer-filter { padding: 0 10px 8px; }
.explorer-filter input { height: 28px; padding: 4px 8px; font-size: 11px; }
.explorer-tree { flex: 1; min-height: 0; overflow: auto; padding: 0 6px 10px; }
.explorer-foot { margin: 0; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 10px; line-height: 1.4; }
.row { display: flex; align-items: center; gap: 5px; width: 100%; min-height: 26px; padding: 0 6px 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--ink); font-size: 12px; font-weight: 500; text-align: left; cursor: pointer; }
.row:hover { background: #eceef3; color: var(--ink); }
.row.hl { border-color: #c8cff5; background: var(--brand-soft); }
.chev { width: 10px; flex: none; color: var(--subtle); font-size: 9px; text-align: center; }
.ficn { display: inline-grid; flex: none; width: 18px; height: 14px; place-items: center; border-radius: 3px; background: var(--brand-soft); color: var(--brand); font-size: 7px; font-weight: 800; }
.ficn.fold { width: 14px; height: 11px; border-radius: 2px 3px 3px 3px; background: #c9ced9; }
.rname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtag { flex: none; padding: 0 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 8px; font-weight: 750; line-height: 14px; text-transform: uppercase; }
.rtag.read { border-color: #c6cdea; background: #eef0fb; color: #3b4fa0; }
.rtag.write { border-color: #f3c8a8; background: #fdf1e8; color: #a33a09; }
.rtag.readwrite { border-color: #d4c4f7; background: #f3effd; color: #6327c7; }
.rtag.new { border-color: #a8d7ba; background: var(--green-soft); color: #1f6e41; }
.rtag.writing { border-color: #8f9de8; background: var(--brand-soft); color: var(--brand); }

.board { position: fixed; top: var(--chrome-top); bottom: 0; left: 0; right: 0; overflow: hidden; overflow: clip; background-color: var(--canvas); background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px); background-size: 22px 22px; cursor: grab; touch-action: none; user-select: none; }
.watch-warning { position: absolute; z-index: 12; top: 12px; left: 50%; max-width: calc(100% - 28px); padding: 8px 12px; transform: translateX(-50%); border: 1px solid #e4c078; border-radius: 8px; background: #fff8e7; box-shadow: var(--shadow-sm); color: #70490b; font-size: 12px; font-weight: 650; text-align: center; pointer-events: none; }
.watch-warning[hidden] { display: none; }
.board.panning { cursor: grabbing; }
body.explorer-open .board { left: 260px; }
body.resources-open .board { right: 320px; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; will-change: transform; }
.link-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.link-layer path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.link-layer path.read { stroke: #3b5bdb; stroke-width: 2; }
.link-layer path.write { stroke: #c2410c; stroke-width: 2; stroke-dasharray: 6 4; }
.link-layer path.readwrite { stroke: #7c3aed; stroke-width: 2.6; }
.link-layer path.active { stroke-dasharray: 7 5; animation: none; }
.link-arrow { position: absolute; transform: translate(-50%, -50%); font-size: 12px; line-height: 1; pointer-events: none; }
.link-pill { position: absolute; z-index: 3; display: flex; align-items: center; transform: translate(-50%, -50%); overflow: hidden; border: 1px solid; border-radius: 999px; box-shadow: 0 2px 8px rgb(24 35 54 / 10%); pointer-events: auto; }
.link-pill button { min-height: 22px; padding: 1px 8px; border: 0; border-radius: 0; background: transparent; color: inherit; font-size: 10px; font-weight: 750; white-space: nowrap; }
.link-pill button:hover { background: rgb(0 0 0 / 5%); text-decoration: underline; }
.link-pill .link-remove { padding: 1px 6px 1px 2px; color: var(--muted); font-size: 12px; }
.link-pill.read { border-color: #3b5bdb; background: #eef2ff; color: #3b5bdb; }
.link-pill.write { border-color: #c2410c; background: #fff4ec; color: #b13d0a; }
.link-pill.readwrite { border-color: #7c3aed; background: #f5f0ff; color: #6d28d9; }

.node.board-agent { cursor: default; }
.node.board-agent .node-header { cursor: grab; touch-action: none; }
.node.board-agent .node-heading { flex: 1; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; min-height: 0; }
.node-drag-handle { flex: none; color: var(--subtle); cursor: grab; font-size: 13px; line-height: 1; }
.node-header:active .node-drag-handle { cursor: grabbing; }
.node.board-agent .node-heading:hover { background: transparent; }
.node.board-agent .card-mode-toggle { align-items: center; }
.node.board-agent .card-mode-toggle .mini { min-width: 0; min-height: 20px; margin-left: auto; padding: 1px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--brand); font-size: 9px; font-weight: 700; }
.node.board-agent .card-mode-toggle .mini + .mini { margin-left: 0; }
.node.board-agent .card-mode-toggle .mini:hover { border-color: var(--brand); background: var(--brand-soft); }
.node.board-agent .node-body { width: 100%; border: 0; border-radius: 0 0 11px 11px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.node.board-agent .node-body:hover { background: transparent; }
.node-remove { min-width: 22px; min-height: 22px; padding: 0 4px; border-color: transparent; background: transparent; color: var(--subtle); font-size: 14px; line-height: 1; }
.node-remove:hover { border-color: #ecc0c5; background: var(--red-soft); color: var(--red); }
.node-menu { position: relative; z-index: 6; }
.node-menu summary { min-width: 22px; min-height: 22px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 5px; color: var(--subtle); cursor: pointer; font-size: 16px; line-height: 1; list-style: none; }
.node-menu summary::-webkit-details-marker { display: none; }
.node-menu summary:hover, .node-menu[open] summary { border-color: var(--line); background: var(--surface-muted); color: var(--ink); }
.node-menu-panel { position: absolute; top: 26px; right: 0; width: max-content; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-md); color: var(--ink); font-size: 11px; white-space: nowrap; }
.node-menu-panel label { display: block; }
.node-menu input { width: 13px; height: 13px; margin: 0 7px 0 0; vertical-align: -2px; }
.status-dot.ready { background: var(--violet); }
.status-dot.stopped { background: var(--subtle); }

.board-file { position: absolute; z-index: 2; width: var(--file-node-width); height: var(--file-node-height); display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--ink); text-align: left; cursor: pointer; touch-action: none; font-weight: 500; }
.board-file:hover { border-color: var(--brand); background: var(--surface); color: var(--ink); }
.board-file.empty { border-style: dashed; }
.board-file.empty .file-node-icon { border-style: dashed; background: transparent; }
.board-file.hl, .board-file.writing { border-color: var(--brand); }
.board-file.updated { animation: file-updated 1.6s ease-out 1; }
@keyframes file-updated { 0% { box-shadow: 0 0 0 6px rgb(47 158 99 / 30%); } 100% { box-shadow: var(--shadow-sm); } }
.board-file .file-badge { top: -9px; right: 10px; cursor: default; }
.board-file .file-badge.new { border-color: #a8d7ba; background: var(--green-soft); color: #1f6e41; }
.board-file .file-badge.writing { border-color: #8f9de8; background: var(--brand-soft); color: var(--brand); }

.bucket { position: absolute; z-index: 9; width: 250px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); box-shadow: 0 5px 18px rgb(25 38 58 / 8%); overflow: hidden; }
.bucket-head { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 30px; padding: 4px 10px; border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: 11px; font-weight: 650; text-align: left; }
.bucket-head:hover { background: var(--surface-muted); color: var(--ink); }
.diff-list { margin: 0; padding: 4px 0; list-style: none; border-top: 1px solid var(--line); max-height: 220px; overflow: auto; background: var(--surface); }
.diff-list li { display: flex; align-items: center; gap: 6px; padding: 2px 10px; font: 10.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.diff-path { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.plus { color: #1a7f37; font: 600 10.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.minus { color: #cf222e; font: 600 10.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.diff-status { display: inline-grid; width: 15px; height: 15px; flex: none; place-items: center; border-radius: 4px; font: 700 9px ui-sans-serif, system-ui, sans-serif; }
.diff-status.A { background: #dafbe1; color: #1a7f37; }
.diff-status.M { background: #fff8c5; color: #7d4e00; }
.diff-status.D { background: #ffebe9; color: #cf222e; }

.board-empty { position: absolute; z-index: 6; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.board-empty[hidden] { display: none; }
.board-empty.cover { background: var(--canvas); pointer-events: auto; }
.empty-card { display: grid; justify-items: center; gap: 10px; width: 440px; max-width: calc(100% - 40px); padding: 28px 30px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 14px 40px rgb(24 35 54 / 12%); text-align: center; pointer-events: auto; }
.empty-card strong { font-size: 17px; letter-spacing: -.015em; }
.empty-card > span { color: #59616d; font-size: 12px; line-height: 1.5; }
.empty-card small { color: var(--subtle); font-size: 10px; }
.empty-icon { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--brand-soft); color: var(--brand); }
.empty-icon.cli { background: #14161b; color: #7fd6a2; font: 700 16px ui-monospace, SFMono-Regular, Menlo, monospace; }
.recent { display: grid; gap: 4px; width: 100%; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); text-align: left; }
.recent button { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 8px; border-color: transparent; background: transparent; color: var(--ink); font-size: 12px; text-align: left; }
.recent button:hover { background: var(--surface-hover); }
.recent code { flex: 1; color: var(--subtle); font-size: 10px; text-align: right; }

.board .inspector { position: absolute; z-index: 40; top: 14px; right: 14px; left: auto; bottom: auto; width: 320px; max-height: calc(100% - 28px); overflow: auto; overscroll-behavior: contain; touch-action: auto; display: grid; align-content: start; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgb(255 255 255 / 97%); box-shadow: var(--shadow-md); user-select: text; }
.board .inspector[hidden] { display: none; }
.board .message { top: auto; bottom: 18px; white-space: nowrap; }
.board .message:not(.ok) { border-color: #efc2c8; background: var(--red-soft); color: #a52f3c; }

.resources { position: fixed; z-index: 25; top: var(--chrome-top); right: 0; bottom: 0; left: auto; width: 320px; padding: 0 14px 16px; overflow: auto; border-left: 1px solid var(--line); background: var(--surface); transform: none; }
.resources[hidden] { display: none; }
.resources .panel-heading { padding: 12px 0 10px; }
.run-history { top: calc(var(--chrome-top) + 10px); right: 14px; bottom: 14px; width: min(430px, calc(100vw - 28px)); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); align-content: stretch; gap: 11px; padding: 14px; }
.run-history-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.run-history-heading h2 { overflow-wrap: anywhere; }
.history-totals { color: var(--muted); font-size: 10px; line-height: 1.45; }
.history-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.history-filters label { gap: 3px; }
.history-filters select { min-width: 0; height: 30px; padding: 4px 7px; font-size: 10px; }
.run-history-list { display: grid; align-content: start; gap: 7px; min-height: 0; overflow: auto; padding-right: 2px; }
.run-history-row { display: grid; gap: 4px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.run-history-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.run-history-title strong { min-width: 0; overflow-wrap: anywhere; font-size: 11px; }
.run-history-row p { color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.history-state { flex: none; padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; }
.history-state.succeeded { border-color: #a8d7ba; background: var(--green-soft); color: #247848; }
.history-state.failed, .history-state.cancelled { border-color: #ecc0c5; background: var(--red-soft); color: #a52f3c; }
.history-state.blocked { border-color: #ead49f; background: var(--yellow-soft); color: #7a5410; }
.run-history-links { display: flex; flex-wrap: wrap; gap: 5px 10px; padding-top: 2px; }
.run-history-links a, .history-link { width: auto; min-height: 20px; padding: 0; border: 0; background: transparent; color: var(--brand); font-size: 9px; font-weight: 650; text-align: left; text-decoration: underline; }
.run-history-links a:hover, .history-link:hover { background: transparent; color: #3349c0; }

.drag-ghost { position: fixed; z-index: 90; display: flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--brand); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgb(25 38 58 / 18%); color: var(--ink); font-size: 11px; font-weight: 650; pointer-events: none; white-space: nowrap; }
.drag-ghost[hidden] { display: none; }

.seg { display: flex; flex: none; justify-self: start; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.segb { min-height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 650; }
.segb:hover { background: var(--surface); color: var(--ink); }
.segb[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 4px rgb(24 35 54 / 12%); color: var(--brand); }
.check-list { display: grid; gap: 2px; max-height: 300px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; }
.check-list[hidden] { display: none; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 6px; border-radius: 6px; color: var(--ink); font-size: 11px; font-weight: 500; cursor: pointer; }
.check-row:hover { background: var(--surface-hover); }
.check-row input { width: auto; }
.check-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.check-row small { color: var(--subtle); font-size: 10px; }
.form-error { color: var(--red); font-size: 11px; }
.form-error[hidden] { display: none; }
.rename-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.rename-row span { color: var(--subtle); font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.rename { min-width: 80px; height: 30px; padding: 0 6px; border-color: transparent; background: transparent; font: 700 17px ui-sans-serif, system-ui, sans-serif; letter-spacing: -.015em; }
.rename:hover { border-color: var(--line); background: var(--surface-muted); }
.rename:focus { border-color: var(--brand); background: var(--surface); outline: none; box-shadow: 0 0 0 3px rgb(64 87 214 / 15%); }
.file-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 4px 8px; border-color: var(--line); background: var(--surface-muted); color: var(--ink); font-size: 11px; font-weight: 500; text-align: left; }
.file-row:hover { background: var(--surface-hover); color: var(--ink); }
.file-row span:last-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.inspector .diff-list { border: 1px solid var(--line); border-radius: 8px; }
.rec { display: inline-flex; align-items: center; padding: 3px 9px; border: 1px solid #fecaca; border-radius: 999px; background: #fef2f2; color: #b91c1c; font-size: 11px; font-weight: 650; white-space: nowrap; }
#feedback-note { width: 100%; min-height: 120px; resize: vertical; font: inherit; }
.tb[hidden], .rec[hidden] { display: none; }
/* Connection handles: drag from an agent's ● to a file (write), or from a file's ● to an agent (read). */
.port { position: absolute; z-index: 6; width: 14px; height: 14px; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); cursor: crosshair; opacity: .55; transition: opacity .12s, transform .12s; touch-action: none; }
.agent-port { right: -8px; top: 50%; margin-top: -7px; background: #c2410c; }
.file-port { left: -8px; top: 50%; margin-top: -7px; background: #3b5bdb; }
.node:hover .agent-port, .board-file:hover .file-port, .port:hover { opacity: 1; transform: scale(1.2); }
.link-layer path.draft { fill: none; stroke-width: 2.4; stroke-dasharray: 5 4; }
.link-layer path.draft.write { stroke: #c2410c; }
.link-layer path.draft.read { stroke: #3b5bdb; }
.board.link-dragging, .board.link-dragging * { cursor: crosshair !important; }
.file-remove { position: absolute; top: -9px; left: -9px; display: none; width: 20px; height: 20px; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; box-shadow: var(--shadow-sm); }
.board-file:hover .file-remove { display: inline-flex; }
.file-remove:hover { border-color: #dc2626; color: #dc2626; }
.board-file:active { cursor: grabbing; }

/* ---------- Controller: one per agent, owns its reads and writes ---------- */
.controller { --ctrl-accent: #94a3b8; --ctrl-soft: #f1f5f9; position: absolute; z-index: 7; display: flex; flex-direction: column; box-sizing: border-box; border: 1px solid #dfe3ea; border-radius: 16px; background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%); box-shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 8px 24px rgb(15 23 42 / 7%); color: var(--ink); overflow: visible; transition: box-shadow .2s, border-color .2s; }
.controller::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; border-radius: 16px 16px 0 0; background: var(--ctrl-accent); opacity: .9; }
.controller.selected { border-color: var(--ctrl-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ctrl-accent) 22%, transparent), 0 10px 28px rgb(15 23 42 / 10%); }
.controller.st-new { --ctrl-accent: #94a3b8; --ctrl-soft: #f1f5f9; }
.controller.st-scanning, .controller.st-running { --ctrl-accent: #4f6bed; --ctrl-soft: #eef1fe; }
.controller.st-ready, .controller.st-done { --ctrl-accent: #16a34a; --ctrl-soft: #ecfdf3; }
.controller.st-ready { box-shadow: 0 0 0 1px #bbf7d0, 0 10px 28px rgb(22 163 74 / 14%); }
.controller.st-stale, .controller.st-waiting { --ctrl-accent: #d97706; --ctrl-soft: #fffbeb; }
.controller.st-attention { --ctrl-accent: #dc2626; --ctrl-soft: #fef2f2; }
.ctrl-head { display: flex; align-items: center; gap: 8px; padding: 13px 14px 8px; cursor: grab; }
.ctrl-mark { width: 18px; height: 18px; flex: none; border-radius: 6px; background: conic-gradient(from 210deg, #4f6bed, #7c3aed, #16a34a, #4f6bed); box-shadow: inset 0 0 0 3px #fff, 0 0 0 1px #e2e8f0; }
.ctrl-name { font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.ctrl-pill { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; max-width: 132px; padding: 3px 9px; border-radius: 999px; background: var(--ctrl-soft); color: color-mix(in srgb, var(--ctrl-accent) 78%, #0f172a); font-size: 11px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctrl-pill i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--ctrl-accent); }
.controller.st-running .ctrl-pill i, .controller.st-scanning .ctrl-pill i { animation: ctrl-pulse 1.1s ease-in-out infinite; }
@keyframes ctrl-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.ctrl-io { display: grid; gap: 6px; padding: 2px 14px 8px; }
.ctrl-row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.ctrl-key { flex: none; width: 42px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ctrl-key.read { color: #3b5bdb; }
.ctrl-key.write { color: #c2410c; }
.ctrl-chip.both { border-color: #d4c4f7; background: #f5f0ff; color: #6d28d9; }
.ctrl-files { display: flex; flex: 1; gap: 4px; min-width: 0; overflow: hidden; }
.ctrl-chip { max-width: 86px; padding: 2px 7px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctrl-more, .ctrl-none { align-self: center; color: var(--muted); font-size: 11px; }
.ctrl-add { flex: none; width: 22px; height: 22px; min-height: 0; padding: 0; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; }
.ctrl-add:hover { border-style: solid; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.ctrl-checks { display: grid; gap: 7px; margin: 0 10px; padding: 9px 10px; border: 1px solid #edf0f4; border-radius: 11px; background: var(--ctrl-soft); color: var(--ink); text-align: left; cursor: pointer; }
.ctrl-checks:hover { border-color: color-mix(in srgb, var(--ctrl-accent) 45%, #e2e8f0); background: var(--ctrl-soft); color: var(--ink); }
.ctrl-meter { display: flex; gap: 3px; height: 5px; }
.ctrl-meter i { flex: 1; border-radius: 3px; }
.ctrl-meter .ok { background: #22c55e; } .ctrl-meter .fixed { background: #4f6bed; } .ctrl-meter .warn { background: #f59e0b; } .ctrl-meter .error { background: #ef4444; } .ctrl-meter .empty { background: #e2e8f0; }
.ctrl-headline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11.5px; line-height: 1.4; color: #334155; }
.ctrl-actions { display: flex; gap: 6px; margin-top: auto; padding: 10px; }
.ctrl-btn { flex: 1; min-width: 0; display: inline-flex; flex-wrap: nowrap; white-space: nowrap; align-items: center; justify-content: center; gap: 5px; height: 30px; min-height: 0; padding: 0 8px; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 650; }
.ctrl-btn:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; color: var(--ink); }
.ctrl-btn.run { border-color: transparent; background: #e2e8f0; color: #64748b; }
.controller.st-ready .ctrl-btn.run { background: linear-gradient(180deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 4px 12px rgb(22 163 74 / 28%); }
.controller.st-ready .ctrl-btn.run:hover { background: linear-gradient(180deg, #16a34a, #15803d); color: #fff; }
.ctrl-btn:disabled { cursor: not-allowed; opacity: .75; }
.spin { width: 11px; height: 11px; border: 2px solid #c7d2fe; border-top-color: #4f6bed; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controller .agent-port { right: auto; left: 50%; top: auto; bottom: -8px; margin: 0 0 0 -7px; }
.controller .ctrl-in-port { left: -8px; top: 50%; margin-top: -7px; background: #3b5bdb; }
.controller:hover .port { opacity: 1; }
.ctrl-link { position: absolute; z-index: 6; height: 2px; border-radius: 2px; background: repeating-linear-gradient(90deg, #cbd5e1 0 5px, transparent 5px 9px); pointer-events: none; }
.ctrl-link::after { content: ""; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 7px solid #94a3b8; border-right: 0; }
.ctrl-link.st-ready, .ctrl-link.st-done { background: #16a34a; } .ctrl-link.st-ready::after, .ctrl-link.st-done::after { border-left-color: #16a34a; }
.ctrl-link.st-running { background: repeating-linear-gradient(90deg, #4f6bed 0 6px, transparent 6px 10px); background-size: 20px 2px; animation: ctrl-flow .6s linear infinite; }
.ctrl-link.st-running::after { border-left-color: #4f6bed; }
@keyframes ctrl-flow { to { background-position: 20px 0; } }

/* Controller panel (right drawer) */
.board .inspector.controller-panel { width: var(--panel-width, 460px); padding-left: 18px; padding-bottom: 0; }
.panel-resize { position: absolute; top: 0; left: 0; height: 100%; width: 8px; cursor: ew-resize; border-radius: 12px 0 0 12px; }
.panel-resize:hover, .panel-resize:focus-visible { background: linear-gradient(90deg, rgb(79 107 237 / 35%), transparent); outline: none; }
.controller-panel .inspector-actions { position: sticky; bottom: 0; z-index: 1; margin: 0 -14px 0 -18px; padding: 10px 14px 14px 18px; border-top: 1px solid var(--line); background: #fff; }
.ctrl-pill.big { max-width: none; margin-left: 0; }
.ctrl-pill.st-ready, .ctrl-pill.st-done { --ctrl-accent: #16a34a; --ctrl-soft: #ecfdf3; }
.ctrl-pill.st-attention { --ctrl-accent: #dc2626; --ctrl-soft: #fef2f2; }
.ctrl-pill.st-stale, .ctrl-pill.st-waiting { --ctrl-accent: #d97706; --ctrl-soft: #fffbeb; }
.ctrl-pill.st-running, .ctrl-pill.st-scanning { --ctrl-accent: #4f6bed; --ctrl-soft: #eef1fe; }
.ctrl-pill.st-new { --ctrl-accent: #94a3b8; --ctrl-soft: #f1f5f9; }
.ctrl-summary { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: #1e293b; }
.ctrl-engine, .ctrl-last { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }
.warn-text { color: #b45309; }
.check-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.check { display: flex; gap: 9px; padding: 8px 10px; border: 1px solid #eef1f5; border-radius: 10px; background: #fff; }
.check-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #fff; }
.check.lvl-ok .check-icon { background: #22c55e; } .check.lvl-fixed .check-icon { background: #4f6bed; } .check.lvl-warn .check-icon { background: #f59e0b; } .check.lvl-error .check-icon { background: #ef4444; } .check.lvl-info .check-icon { background: #94a3b8; }
.check.lvl-error { border-color: #fecaca; background: #fff7f7; } .check.lvl-warn { border-color: #fde68a; background: #fffdf5; }
.check-copy { display: grid; gap: 3px; min-width: 0; }
.check-copy p, .check-open { margin: 0; font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }
.check-open { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.check-open:hover { text-decoration: underline; }
.check-copy small { color: var(--muted); font-size: 11.5px; }
.controller-panel .check-list { max-height: none; overflow: visible; }
.passed-checks { margin-top: 8px; }
.passed-checks summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 650; }
.check-fix { justify-self: start; height: 24px; min-height: 0; margin-top: 3px; padding: 0 9px; border-radius: 7px; font-size: 11.5px; }
.section-tools { display: inline-flex; gap: 6px; }
.ctrl-prompt { width: 100%; min-height: 150px; box-sizing: border-box; resize: vertical; padding: 10px; border: 1px solid #e2e8f0; border-radius: 10px; background: #0f172a; color: #e2e8f0; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.link-button { min-height: 0; height: auto; padding: 0; border: 0; background: none; color: var(--brand); font-size: 12px; font-weight: 600; }
.run-button { background: linear-gradient(180deg, #22c55e, #16a34a); border-color: transparent; color: #fff; }
.run-button:hover:not(:disabled) { background: linear-gradient(180deg, #16a34a, #15803d); color: #fff; }
.run-button:disabled { background: #e2e8f0; color: #64748b; }
.updated-tick { margin-left: auto; color: #16a34a; font-size: 11px; font-weight: 650; }
#agent-dialog-permission-field.full-access .field-help { color: #b45309; }
#agent-dialog-permission-field.full-access select { border-color: #f59e0b; }
/* After a run, Done is the state to see; running again is a secondary choice. */
.controller.st-done .ctrl-btn.run, .controller.st-waiting .ctrl-btn.run { border: 1px solid #e2e8f0; background: #fff; color: var(--ink); box-shadow: none; }
.controller.st-done .ctrl-pill i { width: auto; height: auto; background: none; }
.controller.st-done .ctrl-pill i::before { content: "✓"; color: #16a34a; font-style: normal; font-weight: 800; }
.controller.st-done .ctrl-checks { border-color: #bbf7d0; }

/* Palette, shortcut map, and progressive orchestrator output. */
.orchestrator-context { min-width: 0; max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 10px; }
.orchestrator-answer-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.orchestrator-step { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.palette-overlay, .shortcuts-overlay { position: fixed; z-index: 500; inset: 0; display: grid; place-items: start center; padding: min(15vh, 120px) 12px 24px; background: rgb(18 24 38 / 42%); backdrop-filter: blur(3px); }
.palette-overlay[hidden], .shortcuts-overlay[hidden] { display: none; }
.palette-modal, .shortcuts-modal { width: min(620px, 100%); max-height: min(620px, 80vh); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-md); }
.palette-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.palette-heading h2 { margin: 2px 0 0; font-size: 17px; }
.palette-search { display: flex; align-items: center; gap: 10px; margin: 12px 14px 8px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--muted); }
.palette-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; box-shadow: none; }
.palette-search input:focus { box-shadow: none; }
.palette-results { min-height: 80px; max-height: min(430px, 58vh); overflow: auto; padding: 4px 8px 8px; }
.palette-option { width: 100%; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; }
.palette-option:hover, .palette-option.is-selected { border-color: var(--line); background: var(--brand-soft); }
.palette-kind { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.palette-copy { min-width: 0; display: grid; gap: 2px; }
.palette-copy strong, .palette-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-copy small { color: var(--muted); font-size: 11px; }
.palette-option kbd, .palette-foot kbd { min-width: 21px; padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); text-align: center; font-size: 10px; }
.palette-empty { padding: 16px 12px; color: var(--muted); font-size: 12px; }
.palette-foot { display: flex; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }
.shortcuts-modal { padding-bottom: 8px; }
.shortcut-list { display: grid; gap: 0; margin: 0; padding: 8px 16px; }
.shortcut-list > div { display: grid; grid-template-columns: minmax(150px, 1fr) 2fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shortcut-list dt { display: flex; gap: 5px; align-items: center; color: var(--ink); }
.shortcut-list dd { margin: 0; color: var(--muted); }
.shortcut-list kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 10px; }
.shortcut-note { margin: 6px 16px 4px; color: var(--muted); font-size: 11px; }

/* Short visible text; details on hover or focus (infoTip, pathLabel). */
.hint { display: inline-grid; place-items: center; width: 13px; height: 13px; margin-left: 2px; border-radius: 50%; color: var(--subtle); font-size: 11px; font-style: normal; font-weight: 600; line-height: 1; vertical-align: -1px; cursor: help; }
.hint:hover, .hint:focus-visible { color: var(--brand); outline: none; }
.path { cursor: help; }
.resource-open .path { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip { position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 16px)); padding: 6px 9px; border-radius: 7px; background: #1f2430; color: #f4f6fa; font-size: 11px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; box-shadow: var(--shadow-sm); pointer-events: none; }
.tip[hidden] { display: none; }

/* Option A v2 result inspector. Board and terminal dimensions stay independent. */
.card-mode-toggle .result-trigger { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 24px; min-height: 24px; min-width: 32px; margin-left: auto; padding: 2px 6px; border: 1px solid #c2ccf3; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 750; white-space: nowrap; }
.card-mode-toggle .result-trigger:hover, .card-mode-toggle .result-trigger[aria-expanded="true"] { background: #dde3ff; border-color: var(--brand); }
.result-alert-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #cc902c; }
.result-inspector, .result-full { position: fixed; z-index: 120; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #cbd2df; border-radius: 12px; background: var(--surface); box-shadow: 0 18px 48px rgb(22 33 58 / 23%); user-select: text; }
.result-inspector { width: 470px; max-width: calc(100vw - 24px); height: min(620px, calc(100dvh - 24px)); }
.result-inspector[hidden], .result-full[hidden], .result-backdrop[hidden] { display: none; }
.result-backdrop { position: fixed; z-index: 119; inset: 0; background: rgb(20 30 50 / 22%); }
.result-head { padding: 17px 18px 13px; border-bottom: 1px solid var(--line); flex: none; }
.result-head-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.result-head .eyebrow { font-size: 10px; }
.result-head h2 { font-size: 17px; margin: 5px 0 4px; }
.result-head p { color: var(--muted); font-size: 11px; }
.result-run-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.result-run-row > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.result-run-row select { width: auto; min-width: 144px; max-width: 180px; padding: 5px; background: #f8fafc; font-size: 11px; font-weight: 750; }
.result-chip { padding: 4px 7px; border-radius: 5px; background: #f2f4f7; color: #556171; font-size: 10px; font-weight: 750; }
.result-chip:empty { display: none; }
.result-chip.hold { background: var(--yellow-soft); color: #875b13; }
.result-chip.done { background: var(--green-soft); color: #26734a; }
.result-chip.failed { background: var(--red-soft); color: #a53943; }
.result-chip.running, .result-chip.queued { background: var(--brand-soft); color: #3652c2; }
.result-banner { padding: 7px 17px; background: #fff6e8; border-bottom: 1px solid #e9d4ad; color: #795315; font-size: 11px; font-weight: 700; flex: none; }
.result-banner[hidden] { display: none; }
.result-tabs { display: flex; gap: 15px; padding: 0 17px; border-bottom: 1px solid var(--line); flex: none; }
.result-tabs button { min-height: 36px; padding: 10px 1px 9px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: #667181; font-size: 11px; }
.result-tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.result-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px 17px; font-size: 12px; }
.result-body h3, .result-detail-main h3 { margin: 0 0 6px; font-size: 13px; }
.result-body p, .result-detail-main p { margin: 0 0 8px; color: #626b79; font-size: 12px; line-height: 1.45; }
.result-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 16px; border-top: 1px solid var(--line); color: #77818e; font-size: 10px; flex: none; }
.result-footer > span { min-width: 0; overflow-wrap: anywhere; }
.result-footer > div { display: flex; gap: 5px; flex: none; }
.result-footer button { min-height: 28px; padding: 5px 8px; border-color: #cad3e5; background: white; color: var(--brand); font-size: 10px; }
.result-link { min-height: 24px; padding: 3px 0; border: 0; background: transparent; color: var(--brand); font-size: 11px; }
.result-link:hover { background: transparent; text-decoration: underline; }
.result-banner-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; }
.result-artifact { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 9px; margin-top: 6px; border-color: var(--line); background: white; color: var(--ink); text-align: left; }
.result-artifact:hover { border-color: #9baded; background: #f8f9ff; }
.result-artifact > span:nth-child(2) { flex: 1; min-width: 0; }
.result-artifact b { display: block; font-size: 11px; }
.result-artifact small { display: block; color: #788492; font-size: 10px; font-weight: 500; }
.result-kind { display: grid; place-items: center; min-width: 41px; height: 28px; background: #eef1ff; color: #3d55b7; border-radius: 5px; font-size: 10px; }
.result-kind.html, .result-kind.image { background: #eaf6f1; color: #17785a; }
.result-kind.markdown { background: #f0f2f5; color: #586573; }
.result-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 135px; padding: 15px; border: 1px dashed #cfd8e5; border-radius: 8px; background: #fafbfc; text-align: center; }
.result-empty p { max-width: 290px; margin: 0; }
.result-skeleton { height: 135px; border-radius: 8px; background: repeating-linear-gradient(#eef1f5 0 12px, transparent 12px 25px); }
.result-item-label { margin-bottom: 10px; }
.result-item-label select { font-size: 12px; }
.result-reference { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #edf0f4; font-size: 11px; }
.result-reference span, .result-reference code { color: #778391; overflow-wrap: anywhere; }
.result-metadata { display: flex; gap: 6px 12px; flex-wrap: wrap; margin: 8px 0 12px; color: #778391; font-size: 10px; overflow-wrap: anywhere; }
.result-metadata code { word-break: break-all; }
.result-code { margin: 7px 0; border: 1px solid #dce2e9; border-radius: 7px; background: #f9fafc; overflow: auto; }
.result-source { padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.result-code-line { padding: 3px 9px; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace; }
.result-code-line.plus { background: #e8f6ee; color: #22764b; }
.result-code-line.minus { background: #fff0ee; color: #a63e43; }
.result-preview { width: 100%; min-height: 270px; height: 300px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.result-image { max-width: 100%; height: auto; }
.result-markdown { overflow-wrap: anywhere; }
.result-markdown pre { overflow: auto; }
.result-full { inset: 24px max(12px, calc((100vw - 1200px) / 2)); }
.result-full-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.result-full-header h2 { font-size: 14px; }
.result-full-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 20px; }
.result-detail-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; }
.result-detail-nav { display: flex; flex-direction: column; gap: 6px; align-self: start; }
.result-detail-nav strong { font-size: 11px; color: var(--muted); }
.result-detail-nav button { text-align: left; background: white; color: var(--muted); border-color: var(--line); }
.result-detail-nav button.active { background: var(--brand-soft); color: var(--brand); }
.result-detail-main { min-width: 0; }
.result-detail-main .result-preview { height: min(65vh, 680px); }
.result-file-nav { display: flex; flex-wrap: wrap; gap: 5px 14px; }
@media (max-width: 699px) {
  .result-inspector { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-width: 100%; height: 77dvh; max-height: 77vh; border-radius: 14px 14px 0 0; }
  .result-head { padding: 13px 14px 10px; }
  .result-tabs { gap: 10px; padding: 0 13px; }
  .result-body { padding: 12px 13px; }
  .result-footer { padding: 9px 12px; flex-wrap: wrap; }
  .result-full { inset: 12px 8px; }
  .result-full-header { padding: 12px; }
  .result-full-body { padding: 12px; }
  .result-detail-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .result-detail-nav { flex-direction: row; flex-wrap: wrap; }
  .result-detail-nav strong { width: 100%; }
}

.file-preview.current-workspace { grid-template-rows: auto auto auto minmax(0, 1fr); }
.current-workspace-meta { padding: 0 2px; margin: 0 0 10px; flex: none; align-content: start; }
.current-workspace-actions { display: flex; gap: 8px; margin-bottom: 10px; flex: none; }
.current-workspace-meta[hidden], .current-workspace-actions[hidden], .current-workspace-actions button[hidden] { display: none; }
.node-menu .menu-item { display: block; width: calc(100% + 12px); min-height: 0; margin: 6px -6px 0; padding: 5px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 11px; font-weight: 500; text-align: left; }
.node-menu .menu-item:hover { background: var(--surface-hover); }
