/* Agents live — visual view (ui/agents-viz.js). Dark "control room" card so traffic glows; all rules scoped under .av. */
.av {
  --av-bg: #0d1716; --av-card: #13211f; --av-line: #24403b; --av-fg: #e8f3f0; --av-mut: #86a19b;
  --av-blue: #5aa9ff; --av-green: #3ddc97; --av-grey: #a8b8b4; --av-red: #ff5d5d; --av-amber: #ffb547; --av-teal: #2ec4b0;
  display: flex; flex-direction: column; gap: 10px; color: var(--av-fg); font-variant-numeric: tabular-nums;
  background: var(--av-bg); border-radius: 14px; padding: 10px; min-width: 0;
}
.av .hidden { display: none !important; }

/* stats strip */
.av-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
.av-stat { background: var(--av-card); border: 1px solid var(--av-line); border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; min-width: 0; }
.av-stat b { font-size: 20px; line-height: 1.1; font-weight: 700; }
.av-stat span { font-size: 11px; color: var(--av-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-stat i { font-style: normal; font-size: 10.5px; color: var(--av-teal); }
.av-hero { grid-column: span 2; border-color: #2c6b61; background: linear-gradient(135deg, #15332e, var(--av-card)); }
.av-hero b { font-size: 26px; color: var(--av-teal); }
.av-red b { color: var(--av-red); }
.av-amber b { color: var(--av-amber); }
.av-stat.bump b { animation: av-bump .5s ease-out; }
@keyframes av-bump { 0% { transform: translateY(-3px); opacity: .5 } 100% { transform: none; opacity: 1 } }

/* graph */
.av-graph { position: relative; background: radial-gradient(ellipse at 50% 55%, #142a26 0%, var(--av-bg) 70%); border: 1px solid var(--av-line); border-radius: 12px; overflow: hidden; }
.av-svg { display: block; width: 100%; height: auto; }
.av-edge-base { stroke: var(--av-line); stroke-width: 1.4; stroke-dasharray: 3 4; }
.av-edge-heat { stroke: var(--av-teal); stroke-linecap: round; opacity: 0; }
.av-node { cursor: pointer; outline: none; }
.av-node text { text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.av-shape { fill: var(--av-card); stroke: #3b6a62; stroke-width: 1.5; transition: stroke .3s; }
.av-stack { fill: var(--av-card); stroke: #2b4c46; stroke-width: 1.2; }
.av-glyph { fill: var(--av-fg); font-size: 15px; font-weight: 700; }
.av-label { fill: var(--av-fg); font-size: 11.5px; font-weight: 600; }
.av-sub { fill: var(--av-mut); font-size: 9.5px; }
.av-world .av-shape { stroke: #4a5a78; }
.av-human .av-shape { stroke: #8a6a2c; }
.av-gate .av-shape { fill: #1c1b14; stroke: #a08a3a; }
.av-gate .av-glyph { font-size: 12px; fill: #ffd479; }
.av-gate .av-label { font-size: 10px; fill: #e4cf8e; }
.av-node:hover .av-shape, .av-node:focus-visible .av-shape, .av-node.sel .av-shape { stroke: var(--av-teal); stroke-width: 2.5; }
.av-ring { fill: none; stroke: var(--av-teal); stroke-width: 2.5; stroke-dasharray: 30 134; opacity: 0; transform-box: fill-box; transform-origin: center; }
.av-node.thinking .av-ring { opacity: 1; animation: av-spin 1.1s linear infinite; }
.av-node.thinking .av-shape { stroke: var(--av-teal); }
@keyframes av-spin { to { transform: rotate(360deg) } }
.av-node.flash .av-shape { animation: av-flash .7s ease-out; }
@keyframes av-flash { 0% { stroke: var(--flash); stroke-width: 5 } 100% { stroke-width: 1.5 } }
.av-badge rect { fill: var(--av-teal); }
.av-badge text { fill: #062521; font-size: 10.5px; font-weight: 800; }
.av-hub-box { fill: #10201d; stroke: var(--av-teal); stroke-width: 1.5; filter: drop-shadow(0 0 10px rgba(46,196,176,.25)); }
.av-hub-title { fill: var(--av-teal); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.av-page rect { fill: #162a26; transition: fill 1.2s; }
.av-page.hot rect { fill: #2e7d70; transition: none; animation: av-page 1.2s ease-out forwards; }
@keyframes av-page { to { fill: #162a26 } }
.av-page text { text-anchor: start; font-size: 9.5px; fill: var(--av-mut); }
.av-page .av-page-n { text-anchor: end; fill: var(--av-fg); font-family: "JetBrains Mono", ui-monospace, monospace; }
.av-part-label { text-anchor: middle; font-size: 9.5px; font-weight: 700; paint-order: stroke; stroke: var(--av-bg); stroke-width: 3px; }
.av-pulse circle { fill: none; stroke-width: 3; animation: av-pulse 1.4s ease-out forwards; }
.av-pulse text { text-anchor: middle; font-size: 11px; font-weight: 800; letter-spacing: .05em; paint-order: stroke; stroke: var(--av-bg); stroke-width: 3px; animation: av-fade 1.6s ease-in forwards; }
.av-pulse.small text { font-size: 9px; }
@keyframes av-pulse { from { r: 14; opacity: 1 } to { r: 34; opacity: 0 } }
@keyframes av-fade { 0%, 60% { opacity: 1 } 100% { opacity: 0 } }
.av-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 10px 6px; font-size: 10.5px; color: var(--av-mut); }
.av-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.av-latest { border-top: 1px solid var(--av-line); padding: 7px 10px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }

/* node detail */
.av-detail { position: absolute; top: 8px; right: 8px; width: min(280px, calc(100% - 16px)); background: rgba(15, 30, 27, .97); border: 1px solid #2c6b61; border-radius: 12px; padding: 10px 12px; font-size: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.av-d-head { display: flex; align-items: baseline; gap: 8px; }
.av-d-head b { font-size: 14px; }
.av-d-head span { color: var(--av-mut); font-size: 11px; flex: 1; }
.av-d-x { color: var(--av-mut); padding: 2px 4px; background: none; border: 0; cursor: pointer; }
.av-d-counts, .av-d-pages { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0; color: var(--av-mut); font-size: 11px; }
.av-d-counts b, .av-d-pages b { color: var(--av-fg); }
.av-detail ol { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.av-detail li { line-height: 1.35; cursor: help; }
.av-empty { color: var(--av-mut); list-style: none; }

/* timeline */
.av-tl { background: var(--av-card); border: 1px solid var(--av-line); border-radius: 12px; padding: 8px 10px; }
.av-tl-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 11.5px; font-weight: 600; margin-bottom: 6px; }
.av-tl-hint { color: var(--av-mut); font-weight: 400; }
.av-tl-svg { display: block; width: 100%; }
.av-tl-name { fill: var(--av-mut); font-size: 10.5px; }
.av-tl-axis { fill: var(--av-mut); font-size: 9px; }
.av-tl-track { fill: #0f1c1a; }
.av-tl-bar { opacity: .85; }
.av-tl-bar.live { opacity: 1; }
.av-tl-front { fill: var(--av-blue); } .av-tl-pay { fill: var(--av-green); } .av-tl-books { fill: var(--av-grey); } .av-tl-stock { fill: #b48cff; } .av-tl-delivery { fill: #4fb3d9; } .av-tl-care { fill: #e58fb0; }

@media (prefers-reduced-motion: reduce) {
  .av-node.thinking .av-ring { animation: none; stroke-dasharray: none; }
  .av-pulse circle { animation: none; r: 22; opacity: .8; }
  .av-stat.bump b, .av-node.flash .av-shape { animation: none; }
}
.av-node.waiting .av-ring { opacity: 1; stroke: var(--av-amber); stroke-dasharray: none; animation: av-wait 1.6s ease-in-out infinite; }
@keyframes av-wait { 50% { opacity: .25 } }
@media (prefers-reduced-motion: reduce) { .av-node.waiting .av-ring { animation: none; } }
.av { container-type: inline-size; }
@container (max-width: 520px) {
  .av-stats { grid-template-columns: repeat(3, 1fr); }
  .av-hero { grid-column: span 3; flex-direction: row; align-items: baseline; gap: 8px; }
  .av-stat b { font-size: 17px; }
  .av-stat span { white-space: normal; line-height: 1.2; }
  .av-tl-hint { display: none; }
}
/* host page bits (Agents live tab in ui/index.html) */
.agents-viz { margin: 0 10px 12px; }
.link-btn { color: var(--brand, #12857a); font-weight: 600; font-size: 12px; text-decoration: underline; padding: 0 2px; }
/* timeline: measured loop lanes */
.av-tl-name { font-weight: 600; }
.av-tl-live { fill: var(--av-blue); font-weight: 700; font-size: 9.5px; }
.av-tl-grid { stroke: var(--av-line); stroke-dasharray: 2 3; }
.av-tl-now { stroke: var(--av-mut); stroke-width: 1; }
