/* Execution chain: dense candidate rows grouped into priority tiers.
   Layout/chrome for the routing page lives in routing.css; this file owns the
   chain table, the live event list, the inspector and the destination dialog. */

.arena {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  padding: 38px 14px 14px;
  background:
    linear-gradient(rgb(87 221 255 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(87 221 255 / 4%) 1px, transparent 1px),
    radial-gradient(circle at 45% 0%, rgb(87 221 255 / 7%), transparent 22rem),
    #08131e;
  background-size: 26px 26px, 26px 26px, auto, auto;
}
.grid-glow { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(87 221 255 / 3%), transparent); animation: scan 7s linear infinite; pointer-events: none; }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.arena-inlet { position: absolute; top: 12px; left: 14px; display: flex; align-items: center; gap: 6px; color: var(--quiet); font-size: 8.5px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.arena-inlet span { width: 13px; height: 13px; border: 2px solid var(--cyan); border-radius: 50%; box-shadow: 0 0 14px rgb(87 221 255 / 55%); }
.route-lanes { position: relative; z-index: 2; display: grid; gap: 4px; }

/* ── Stage ───────────────────────────────────────────────── */
.execution-stage { position: relative; display: grid; gap: 7px; padding: 10px; border: 1px solid rgb(58 96 119 / 80%); border-radius: 12px; background: rgb(8 22 34 / 88%); }
.execution-stage.stage-primary { border-color: rgb(87 221 255 / 38%); }
.execution-stage.stage-fallback { border-color: rgb(157 134 255 / 36%); }
.execution-stage.drop-target { border-color: var(--purple); background: rgb(157 134 255 / 9%); }
.stage-bar { display: grid; grid-template-areas: "num id summary actions" "copy copy copy copy"; grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 3px 10px; align-items: center; }
.stage-number { grid-area: num; display: grid; width: 28px; height: 28px; place-items: center; padding: 0; border: 1px solid rgb(87 221 255 / 42%); border-radius: 9px; background: rgb(87 221 255 / 10%); color: var(--cyan); font-size: 12px; font-weight: 950; }
.stage-fallback .stage-number { border-color: rgb(157 134 255 / 48%); background: rgb(157 134 255 / 12%); color: var(--purple); }
.stage-number.draggable { cursor: grab; touch-action: none; }
.stage-number.draggable:active { cursor: grabbing; }
.stage-id { grid-area: id; min-width: 0; }
.stage-id h3 { margin: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.stage-kicker, .stage-summary, .stage-copy { margin: 0; color: var(--quiet); font-size: 9px; line-height: 1.4; }
.stage-kicker { color: var(--purple); font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.stage-primary .stage-kicker { color: var(--cyan); }
.stage-summary { grid-area: summary; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-copy { grid-area: copy; overflow: hidden; padding: 3px 0 0 8px; border-left: 2px solid rgb(87 221 255 / 30%); color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.stage-fallback .stage-copy { border-left-color: rgb(157 134 255 / 38%); }
.stage-actions { grid-area: actions; display: flex; gap: 4px; }
.stage-handoff { display: grid; place-items: center; padding: 3px; color: var(--purple); font-size: 8.5px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.stage-body { display: grid; }

/* ── Priority tier ───────────────────────────────────────── */
.tier { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 6px; padding: 4px 6px 6px; border-radius: 9px; background: rgb(9 24 36 / 45%); transition: background .16s, box-shadow .16s; }
.tier.drop-target { background: rgb(87 221 255 / 10%); box-shadow: inset 0 0 0 1px rgb(87 221 255 / 45%); }
.tier-rail { display: grid; align-content: start; justify-items: center; gap: 3px; padding-top: 3px; border-right: 1px solid rgb(87 221 255 / 14%); }
.tier-tag { color: var(--cyan); font-size: 8.5px; font-weight: 900; letter-spacing: .06em; }
.tier.parallel .tier-rail { border-right: 2px solid rgb(87 221 255 / 40%); }
.tier-flow { color: var(--cyan); font-size: 11px; line-height: 1; opacity: .8; }
.tier-main { min-width: 0; display: grid; gap: 4px; }
.tier-head { display: flex; align-items: center; gap: 8px; min-height: 12px; }
.tier-note { flex: none; color: var(--quiet); font-size: 8.5px; white-space: nowrap; }
.tier.parallel .tier-note { color: var(--cyan); font-weight: 800; }
.tier-add { flex: none; width: 18px; height: 18px; margin-left: auto; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--quiet); font-size: 11px; line-height: 1; opacity: 0; transition: opacity .14s; }
.tier:hover .tier-add, .tier:focus-within .tier-add { opacity: 1; }
.tier-add:hover { border-color: var(--line-hot); color: var(--text); }
.tier-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px; align-items: start; }
.tier.empty { padding: 10px; }

/* How the tier's weights actually split live traffic right now. */
.tier-split { display: flex; flex: 1; gap: 2px; min-width: 0; height: 11px; overflow: hidden; border-radius: 99px; background: rgb(7 16 25 / 80%); }
.split-piece { display: grid; min-width: 0; place-items: center; border-radius: 99px; font-size: 7.5px; font-weight: 900; letter-spacing: .04em; }
.split-piece.cyan { background: rgb(87 221 255 / 30%); color: #cdf3ff; }
.split-piece.mint { background: rgb(88 242 180 / 28%); color: #d3fff0; }
.split-piece.violet { background: rgb(157 134 255 / 32%); color: #e6dfff; }
.split-piece.warn { background: rgb(255 200 87 / 28%); color: #fff1cf; }
.split-piece.excluded { flex: none; padding: 0 7px; background: rgb(93 122 141 / 22%); color: var(--quiet); }
.split-label { overflow: hidden; }
.tier-gap { position: relative; display: grid; height: 12px; place-items: center; }
.tier-gap::before { position: absolute; left: 0; width: 100%; border-top: 1px dashed transparent; content: ''; }
.tier-gap:hover::before, .tier-gap.drop-target::before { border-top-color: rgb(87 221 255 / 45%); }
.gap-add { padding: 0 8px; height: 14px; border: 1px solid transparent; border-radius: 99px; background: var(--bg); color: var(--quiet); font-size: 8.5px; font-weight: 800; opacity: 0; transition: opacity .14s; }
.tier-gap:hover .gap-add, .gap-add:focus-visible { border-color: rgb(87 221 255 / 40%); color: var(--cyan); opacity: 1; }
.tier-gap.drop-target .gap-add { border-color: var(--cyan); color: var(--cyan); opacity: 1; }

/* ── Candidate card ──────────────────────────────────────────
   One component, two layouts. The card asks how much width it was given: a whole
   tier to itself becomes a single dense line, a share of a parallel tier becomes
   a stacked card beside its peers. No viewport breakpoint can know that. */
.cand {
  container-type: inline-size;
  min-width: 0; padding: 4px 6px 4px 2px;
  border: 1px solid var(--line); border-radius: 9px;
  background: linear-gradient(145deg, rgb(22 46 63 / 92%), rgb(12 28 43 / 94%));
  box-shadow: 0 6px 16px rgb(0 0 0 / 22%);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.cand-body {
  display: grid; gap: 3px 6px; align-items: center;
  grid-template-columns: 20px minmax(0, 1fr) 56px 62px;
  grid-template-areas:
    "handle who     who     state"
    "handle model   model   model"
    "handle success latency latency"
    "handle think   weight  actions";
}
.cand-body > .cell.handle { grid-area: handle; align-self: start; }
.cand-body > .cell.who { grid-area: who; }
.cand-body > .cell.model { grid-area: model; }
.cand-body > .cell.success { grid-area: success; text-align: left; }
.cand-body > .cell.latency { grid-area: latency; text-align: left; }
.cand-body > .cell.think { grid-area: think; }
.cand-body > .cell.weight { grid-area: weight; }
.cand-body > .cell.state { grid-area: state; text-align: right; }
.cand-body > .cell.actions { grid-area: actions; }
/* Wide enough for one line: the same cells, laid out as a table row. */
@container (min-width: 560px) {
  .cand-body {
    grid-template-columns: 20px minmax(84px, 1.15fr) minmax(168px, 1.8fr) 58px 58px 98px 44px 110px 92px;
    grid-template-areas: "handle who model success latency think weight state actions";
    gap: 8px; min-height: 22px;
  }
  .cand-body > .cell.success, .cand-body > .cell.latency { text-align: right; }
  .cand-body > .cell.state { text-align: left; }
}
.cand:hover { border-color: rgb(87 221 255 / 34%); box-shadow: 0 8px 20px rgb(0 0 0 / 30%); }
/* Accent edge matching this candidate's segment in the tier's split bar. Declared
   after :hover so hovering never drops the tie between bar and card. */
.cand[class*="tone-"] { border-left-width: 3px; }
.cand.tone-cyan { border-left-color: rgb(87 221 255 / 65%); }
.cand.tone-mint { border-left-color: rgb(88 242 180 / 60%); }
.cand.tone-violet { border-left-color: rgb(157 134 255 / 65%); }
.cand.tone-warn { border-left-color: rgb(255 200 87 / 60%); }
.cand.tone-muted { border-left-color: rgb(93 122 141 / 55%); }
.cand.disabled { opacity: .5; }
.cand.quarantined { border-color: rgb(255 200 87 / 40%); background: linear-gradient(120deg, rgb(56 44 22 / 60%), rgb(16 27 37 / 75%)); }
.cand.selected { border-color: var(--purple); box-shadow: 0 0 0 1px rgb(157 134 255 / 25%); }
.cand[data-route-signal="active"] { border-color: var(--cyan); outline: 2px solid rgb(87 221 255 / 72%); }
.cand[data-route-signal="success"] { border-color: var(--mint); outline: 2px solid rgb(88 242 180 / 72%); }
.cand[data-route-signal="failure"] { border-color: var(--bad); outline: 2px solid rgb(255 99 125 / 78%); }
.cand[data-route-signal] { outline-offset: 1px; }
.route-button[data-route-signal="active"] { border-color: var(--cyan); outline: 2px solid rgb(87 221 255 / 72%); }
.route-button[data-route-signal="success"] { border-color: var(--mint); outline: 2px solid rgb(88 242 180 / 72%); }
.route-button[data-route-signal="failure"] { border-color: var(--bad); outline: 2px solid rgb(255 99 125 / 78%); }
.route-button[data-route-signal] { outline-offset: -2px; }
.cand .cell { overflow: hidden; min-width: 0; text-overflow: ellipsis; white-space: nowrap; }
.cell.handle { display: grid; place-items: center; }
.grip { width: 18px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--quiet); font-size: 11px; line-height: 1; touch-action: none; user-select: none; cursor: grab; }
.grip:hover { color: var(--text); background: var(--surface-2); }
.grip:active { cursor: grabbing; }
.grip:disabled { cursor: not-allowed; opacity: .4; }
.cell.who { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.model { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9.5px; }
/* Shy inline model editor: reads like plain text until hover/focus reveals it. */
.cell.model input {
  width: 100%; min-width: 0; height: 22px; padding: 0 4px;
  border: 1px solid rgb(157 134 255 / 22%); border-radius: 6px; background: rgb(7 16 25 / 35%);
  color: var(--muted); font: 9.5px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cell.model input:hover { border-color: var(--line-hot); background: rgb(7 16 25 / 55%); color: var(--text); }
.cell.model input:focus { border-color: var(--accent); background: rgb(7 16 25 / 70%); color: var(--text); outline: none; }
.cell.num { color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; text-align: right; }
.cell.state { font-size: 9.5px; font-weight: 750; }
.cell.state.ok { color: var(--mint); }
.cell.state.warn { color: var(--warn); }
.cell.state.off { color: var(--quiet); }
.cell.think.none { color: var(--quiet); font-size: 10px; text-align: center; }
.think-select, .move-select { width: 100%; height: 22px; padding: 0 4px; border-radius: 6px; font-size: 9.5px; }
.cell.weight input { width: 100%; height: 22px; padding: 0 4px; border-radius: 6px; font-size: 9.5px; text-align: center; }
.cell.weight.lonely input { color: var(--quiet); opacity: .6; }
.cell.weight.lonely:hover input { opacity: 1; }
.cell.actions { display: flex; gap: 3px; justify-content: flex-end; }
.row-action { width: 21px; height: 21px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: rgb(7 16 25 / 70%); color: var(--muted); font-size: 10px; line-height: 1; opacity: .32; transition: opacity .14s; }
.cand:hover .row-action, .cand:focus-within .row-action, .cand.selected .row-action { opacity: 1; }
.row-action:hover:not(:disabled) { border-color: var(--line-hot); color: var(--text); }
.row-action:disabled { cursor: not-allowed; opacity: .18; }
.cand-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px rgb(88 242 180 / 40%); }
.cand-dot.warn { background: var(--warn); box-shadow: 0 0 8px rgb(255 200 87 / 40%); }
.cand-dot.quiet { background: var(--quiet); box-shadow: none; }
.cand-note, .cand-facts { grid-column: 1 / -1; margin: 0 0 1px 28px; overflow: hidden; font-size: 9px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.cand-note { color: var(--warn); }
.cand-facts { color: var(--quiet); }
.cand-move { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; margin: 1px 0 2px 28px; color: var(--quiet); font-size: 9px; }
.cand-move select { width: auto; min-width: 170px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 9.5px; }

.fallback-controls { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; padding: 10px 12px; border: 1px dashed rgb(157 134 255 / 40%); border-radius: 12px; background: rgb(157 134 255 / 5%); }
.fallback-controls[hidden] { display: none; }
.fallback-controls h3 { margin: 0; font-size: 11.5px; }
.fallback-copy { margin: 3px 0 0; color: var(--quiet); font-size: 9px; line-height: 1.4; }
.fallback-add { display: flex; flex: 0 1 400px; gap: 7px; }
.fallback-add select { min-width: 140px; width: 100%; height: 34px; padding: 0 8px; font-size: 10px; }
.mini-button { display: grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--muted); font-size: 11px; }
.mini-button:hover:not(:disabled) { border-color: var(--line-hot); color: var(--text); }
.mini-button:disabled { cursor: not-allowed; opacity: .35; }

.orb-layer { position: absolute; z-index: 8; inset: 0; overflow: hidden; pointer-events: none; }
.request-orb { position: absolute; display: grid; width: 16px; height: 16px; place-items: center; border: 2px solid #d9f8ff; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 7px #fff, 0 0 20px var(--cyan); color: var(--bg); font-size: 7px; font-weight: 950; transform: translate(-50%, -50%); transition-property: left, top, background, box-shadow, opacity, transform; transition-timing-function: cubic-bezier(.2, .8, .2, 1); }
.request-orb.failover { background: var(--warn); box-shadow: 0 0 7px #fff, 0 0 22px var(--warn); }
.request-orb.error { background: var(--bad); box-shadow: 0 0 7px #fff, 0 0 24px var(--bad); }
.request-orb.complete { background: var(--mint); box-shadow: 0 0 7px #fff, 0 0 20px var(--mint); }
.request-orb.leaving { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }

.arena[data-route-signal="active"] { box-shadow: inset 0 0 0 2px rgb(87 221 255 / 60%), inset 0 0 42px rgb(87 221 255 / 12%); }
.arena[data-route-signal="success"] { box-shadow: inset 0 0 0 2px rgb(88 242 180 / 55%), inset 0 0 38px rgb(88 242 180 / 10%); }
.arena[data-route-signal="failure"] { box-shadow: inset 0 0 0 2px rgb(255 99 125 / 62%), inset 0 0 42px rgb(255 99 125 / 12%); }
.arena[data-route-signal] .arena-inlet { color: var(--text); }
.arena[data-route-signal="active"] .arena-inlet span { background: rgb(87 221 255 / 32%); }
.arena[data-route-signal="success"] .arena-inlet span { border-color: var(--mint); background: rgb(88 242 180 / 30%); }
.arena[data-route-signal="failure"] .arena-inlet span { border-color: var(--bad); background: rgb(255 99 125 / 30%); }

.event-list { height: 280px; margin: 0; padding: 7px; overflow: auto; list-style: none; }
.event-row { display: grid; grid-template-columns: 64px 76px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 8px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: inherit; text-align: left; }
.event-row:hover, .event-row.active { border-color: var(--line); background: var(--panel-2); }
.event-time { color: var(--quiet); font-size: 9px; font-variant-numeric: tabular-nums; }
.event-kind { overflow: hidden; color: var(--cyan); font-size: 9px; font-weight: 900; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.event-kind.error { color: var(--bad); }
.event-kind.failover { color: var(--warn); }
.event-summary { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.event-latency { color: var(--muted); font-size: 9px; }
.follow-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.inspector-body { display: grid; gap: 9px; max-height: 280px; overflow: auto; padding: 13px; }
.intel-card { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.intel-card h3 { margin: 0 0 6px; font-size: 11px; }
.intel-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 9px; margin: 0; font-size: 9px; }
.intel-grid dt { color: var(--quiet); }
.intel-grid dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--muted); }
.reason { color: var(--warn); line-height: 1.5; }

.deployment-dialog { width: min(480px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line-hot); border-radius: 15px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.deployment-dialog::backdrop { background: rgb(0 5 10 / 72%); backdrop-filter: blur(5px); }
.deployment-dialog form { display: grid; gap: 13px; padding: 19px; }
.deployment-dialog header, .deployment-dialog footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.deployment-dialog h2 { margin: 0; }
.deployment-dialog label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 780; }
.deployment-dialog input, .deployment-dialog select { width: 100%; height: 40px; padding: 0 10px; }
.deployment-dialog footer { justify-content: flex-end; margin-top: 5px; }
.dialog-position { margin: 0; padding: 9px 11px; border: 1px solid rgb(87 221 255 / 30%); border-radius: 9px; background: rgb(87 221 255 / 7%); color: var(--muted); font-size: 10px; line-height: 1.45; }
.icon-button { width: 34px; min-height: 34px; padding: 0; font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* No .cand breakpoints: the card's own container query already covers a narrow
   viewport, because a narrow viewport gives the card a narrow container. */
@media (max-width: 900px) {
  .cand-note, .cand-facts, .cand-move { margin-left: 0; }
  .tier { grid-template-columns: 20px minmax(0, 1fr); }
}
