/* ---------- Agent command center (neural ops) ----------
   A committed dark surface: this is mission control, it does not
   follow the dashboard theme. Scoped under .cc so nothing leaks. */

.cc {
  --cc-bg: #05060a;
  --cc-panel: #0a0c13;
  --cc-line: rgba(255, 255, 255, 0.08);
  --cc-ink: #e9ebf2;
  --cc-dim: #8f97ab;
  --cc-faint: #6d7690;
  --cc-live: #4ade80;
  --cc-warn: #fbbf24;
  --cc-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  background: var(--cc-bg);
  color: var(--cc-ink);
  border-radius: 14px;
  border: 1px solid var(--cc-line);
  overflow: hidden;
}
.cc, .cc button { font-family: var(--cc-mono); }

/* page frame: bleed past .main padding a touch on small screens is fine */
#page-agents .cc, #page-agent .cc { min-height: calc(100vh - 120px); display: flex; flex-direction: column; }

/* ---------- HUD chrome ---------- */
.cc-hud {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--cc-line);
  font-size: 11px; letter-spacing: 0.08em; color: var(--cc-dim);
  flex-wrap: wrap;
}
.cc-hud .t { color: var(--cc-ink); font-weight: 700; }
.cc-hud .sep { color: var(--cc-faint); }
.cc-hud .right { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.cc-hud .clock { font-variant-numeric: tabular-nums; color: var(--cc-ink); }
.cc-conn { display: inline-flex; align-items: center; gap: 6px; color: var(--cc-live); }
.cc-conn::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; box-shadow: 0 0 8px currentColor; }

/* ---------- shell: full-width constellation, roster as a slide-in drawer ---------- */
.cc-shell { display: flex; position: relative; flex: 1; min-height: 0; }

.cc-field { position: relative; flex: 1; min-height: 520px; overflow: hidden; }

/* viewfinder corner ticks */
.cc-corner { position: absolute; width: 18px; height: 18px; pointer-events: none; opacity: 0.35; }
.cc-corner.tl { top: 10px; left: 12px; border-top: 1px solid var(--cc-dim); border-left: 1px solid var(--cc-dim); }
.cc-corner.tr { top: 10px; right: 12px; border-top: 1px solid var(--cc-dim); border-right: 1px solid var(--cc-dim); }
.cc-corner.bl { bottom: 10px; left: 12px; border-bottom: 1px solid var(--cc-dim); border-left: 1px solid var(--cc-dim); }
.cc-corner.br { bottom: 10px; right: 12px; border-bottom: 1px solid var(--cc-dim); border-right: 1px solid var(--cc-dim); }
.cc-field canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* corner annotations, like the reel's HUD scribbles */
.cc-note {
  position: absolute; font-size: 10px; letter-spacing: 0.06em; color: var(--cc-faint);
  pointer-events: none; line-height: 1.7; white-space: pre;
}
.cc-note.tl { top: 12px; left: 16px; }
/* bl moved to the top right corner — the live ticker owns the bottom left */
.cc-note.bl { top: 12px; right: 16px; text-align: right; }
.cc-note.br { bottom: 12px; right: 16px; text-align: right; }

/* agent label chips over the canvas */
.cc-chip {
  position: absolute; transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--chip) 13%, rgba(5, 6, 10, 0.82));
  border: 1px solid color-mix(in srgb, var(--chip) 55%, transparent);
  color: var(--chip);
  border-radius: 4px; padding: 4px 8px 5px; cursor: pointer; text-align: left;
  backdrop-filter: blur(2px);
  transition: border-color 140ms ease, box-shadow 180ms var(--ease-out), background-color 140ms ease;
  z-index: 2; max-width: 190px;
}
.cc-chip:hover, .cc-chip:focus-visible {
  border-color: var(--chip);
  box-shadow: 0 0 14px color-mix(in srgb, var(--chip) 45%, transparent);
  background: color-mix(in srgb, var(--chip) 20%, rgba(5, 6, 10, 0.85));
}
.cc-chip:focus-visible { outline: 1px solid var(--chip); outline-offset: 2px; }
.cc-chip.live { animation: cc-chip-glow 2s ease-in-out infinite; }
@keyframes cc-chip-glow {
  0%, 100% { box-shadow: 0 0 5px color-mix(in srgb, var(--chip) 22%, transparent); }
  50% { box-shadow: 0 0 18px color-mix(in srgb, var(--chip) 55%, transparent); }
}
.cc-chip .n { font-size: 11px; font-weight: 700; letter-spacing: 0.11em; white-space: nowrap; }
.cc-chip .s {
  font-size: 10px; color: color-mix(in srgb, var(--chip) 72%, #ffffff);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px;
}
.cc-chip .s .live-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 99px; margin: 0 4px 1px 0;
  background: var(--cc-live); box-shadow: 0 0 6px var(--cc-live);
  animation: cc-blink 1.1s steps(2, start) infinite;
}

/* ---------- roster panel: hidden drawer, slides in from the right ---------- */
.cc-roster {
  position: absolute; top: 0; right: 0; bottom: 0; width: 292px; z-index: 4;
  border-left: 1px solid var(--cc-line); background: rgba(10, 12, 19, 0.94);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; min-height: 0;
  transform: translateX(102%);
  transition: transform 240ms var(--ease-out);
}
.cc-roster.open { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { .cc-roster { transition: none; } }
.cc-roster-head {
  padding: 12px 16px 10px; font-size: 10px; letter-spacing: 0.12em; color: var(--cc-dim);
  border-bottom: 1px solid var(--cc-line); display: flex; justify-content: space-between; align-items: center;
}
.cc-roster-list { overflow-y: auto; flex: 1; padding: 6px 8px; }
.cc-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; border-radius: 4px; text-align: left;
  padding: 7px 9px; cursor: pointer; color: var(--cc-ink);
  transition: background-color 130ms ease;
}
.cc-row:hover, .cc-row:focus-visible { background: rgba(255, 255, 255, 0.05); }
.cc-row:focus-visible { outline: 1px solid var(--cc-dim); outline-offset: -1px; }
.cc-row .ix { color: var(--cc-faint); font-size: 10px; width: 17px; flex-shrink: 0; }
.cc-row .dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; background: var(--chip); box-shadow: 0 0 6px color-mix(in srgb, var(--chip) 70%, transparent); }
.cc-row .nm { font-size: 11px; letter-spacing: 0.05em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-row .st { font-size: 9.5px; letter-spacing: 0.08em; flex-shrink: 0; }
.cc-row .st.live { color: var(--cc-live); animation: cc-blink 1.1s steps(2, start) infinite; }
.cc-row .st.on { color: color-mix(in srgb, var(--cc-live) 65%, var(--cc-dim)); }
.cc-row .st.idle { color: var(--cc-faint); }
.cc-row .st.warn { color: var(--cc-warn); }
.cc-row .st.missed { color: #f87171; }
.cc-status.missed { color: #f87171; border-color: color-mix(in srgb, #f87171 50%, transparent); }
.cc-roster-foot {
  border-top: 1px solid var(--cc-line); padding: 10px 16px; font-size: 10px;
  color: var(--cc-faint); letter-spacing: 0.08em; display: flex; justify-content: space-between; gap: 8px;
}
.cc-cursor { display: inline-block; width: 6px; height: 11px; background: var(--cc-dim); vertical-align: -1px; animation: cc-blink 1s steps(2, start) infinite; }

@keyframes cc-blink { 50% { opacity: 0; } }

/* boot-only typing cursor in the HUD title */
.cc-type-cursor {
  display: inline-block; width: 7px; height: 11px; background: var(--cc-dim);
  vertical-align: -1px; animation: cc-blink 0.8s steps(2, start) infinite;
}

/* ---------- live activity ticker ---------- */
.cc-ticker {
  position: absolute; left: 0; top: 58px; bottom: 10px; z-index: 3;
  width: min(370px, 58%); padding: 4px 16px;
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(5, 6, 10, 0.82) 0%, rgba(5, 6, 10, 0.5) 72%, transparent 100%);
  pointer-events: none;
}
.cc-ticker .ln:nth-child(n + 19) { display: none; }
.cc-ticker .ln {
  font-size: 10.5px; line-height: 1.55; letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: calc(1 - var(--i, 0) * 0.05);
  text-shadow: 0 1px 4px rgba(5, 6, 10, 0.95), 0 0 10px rgba(5, 6, 10, 0.8);
}
.cc-ticker .ln .tm { color: var(--cc-dim); font-variant-numeric: tabular-nums; }
.cc-ticker .ln .ag { color: var(--chip, var(--cc-dim)); font-weight: 700; letter-spacing: 0.06em; }
.cc-ticker .ln .ar { color: var(--cc-faint); }
.cc-ticker .ln .tx { color: var(--cc-ink); }
.cc-ticker .ln.is-empty .tx { color: var(--cc-dim); }
.cc-ticker .ln:first-child { animation: cc-ln-in 220ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes cc-ln-in { from { opacity: 0; transform: translateY(7px); } }

/* ---------- full-bleed mode: command center owns the whole viewport ---------- */
body.cc-full .main { max-width: none; padding: 0; }
body.cc-full .sidebar { display: none; }
body.cc-full #page-agents .cc,
body.cc-full #page-agent .cc { border-radius: 0; border: none; min-height: 100vh; }

/* HUD controls (exit / fullscreen) */
.cc-hud-btn {
  background: none; border: 1px solid var(--cc-line); color: var(--cc-dim); border-radius: 4px;
  font-size: 10px; letter-spacing: 0.1em; padding: 5px 10px; cursor: pointer;
  transition: color 130ms ease, border-color 130ms ease;
}
.cc-hud-btn:hover, .cc-hud-btn:focus-visible { color: var(--cc-ink); border-color: var(--cc-dim); }

/* chips fade during the zoom dive into an agent */
#cc-chips.cc-zooming .cc-chip { opacity: 0 !important; transition: opacity 200ms ease; pointer-events: none; }

/* voice control */
.cc-hud-btn.on { color: var(--cc-live); border-color: color-mix(in srgb, var(--cc-live) 55%, transparent); }
.cc-voice-hud {
  position: fixed; right: 18px; bottom: 16px; z-index: 60;
  background: rgba(5, 6, 10, 0.88); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px; padding: 8px 13px; backdrop-filter: blur(4px);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; color: #e9ebf2; max-width: min(460px, 80vw);
}
.cc-voice-hud .vh-row { display: flex; align-items: center; gap: 9px; }
.cc-voice-hud .vh-say {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: #e9ebf2; white-space: normal; line-height: 1.5; max-height: 5.5em; overflow: hidden;
}
.cc-voice-hud .vh-dot {
  width: 8px; height: 8px; border-radius: 99px; background: #6d7690; flex-shrink: 0;
}
.cc-voice-hud .vh-dot.on { background: #4ade80; box-shadow: 0 0 8px #4ade80; animation: cc-blink 1.3s steps(2, start) infinite; }
.cc-voice-hud .vh-heard { color: #8f97ab; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-voice-hud .vh-act { color: #4ade80; letter-spacing: 0.05em; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .cc-voice-hud .vh-dot.on { animation: none; } }

/* ---------- agent detail page ---------- */
.cc-agent-head {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--cc-line); flex-wrap: wrap;
}
.cc-back {
  background: none; border: 1px solid var(--cc-line); color: var(--cc-dim); border-radius: 4px;
  font-size: 10px; letter-spacing: 0.1em; padding: 6px 10px; cursor: pointer;
  transition: color 130ms ease, border-color 130ms ease;
}
.cc-back:hover, .cc-back:focus-visible { color: var(--cc-ink); border-color: var(--cc-dim); }
.cc-glyph {
  width: 34px; height: 34px; border-radius: 6px; flex-shrink: 0;
  background: color-mix(in srgb, var(--chip) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 55%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--chip) 30%, transparent);
  display: flex; align-items: center; justify-content: center; color: var(--chip);
  font-size: 13px; font-weight: 700;
}
.cc-agent-head h1 { font-size: 16px; letter-spacing: 0.08em; margin: 0; color: var(--cc-ink); font-weight: 700; }
.cc-agent-head .role { font-size: 11px; color: var(--cc-dim); margin-top: 2px; letter-spacing: 0.03em; }
.cc-status {
  margin-left: auto; font-size: 10px; letter-spacing: 0.12em; padding: 5px 11px; border-radius: 3px;
  border: 1px solid var(--cc-line); color: var(--cc-faint);
}
.cc-status.live { color: var(--cc-live); border-color: color-mix(in srgb, var(--cc-live) 50%, transparent); animation: cc-blink 1.4s steps(2, start) infinite; }

.cc-agent-body { display: grid; grid-template-columns: 330px 1fr; gap: 0; flex: 1; min-height: 0; }
.cc-col { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.cc-col.side { border-right: 1px solid var(--cc-line); background: var(--cc-panel); }

.cc-card { border: 1px solid var(--cc-line); border-radius: 6px; padding: 13px 15px; }
.cc-card .hd { font-size: 9.5px; letter-spacing: 0.14em; color: var(--cc-faint); margin-bottom: 9px; }
.cc-card .big { font-size: 13px; line-height: 1.5; color: var(--cc-ink); }
.cc-card .sub { font-size: 10.5px; color: var(--cc-dim); margin-top: 5px; line-height: 1.55; }
.cc-card.now { border-color: color-mix(in srgb, var(--chip) 40%, var(--cc-line)); }
.cc-card.now .hd { color: var(--chip); }

.cc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.cc-stats .v { font-size: 19px; font-weight: 700; color: var(--cc-ink); font-variant-numeric: tabular-nums; }
.cc-stats .v small { font-size: 10px; color: var(--cc-faint); font-weight: 400; }
.cc-stats .l { font-size: 9.5px; letter-spacing: 0.06em; color: var(--cc-dim); margin-top: 1px; }

.cc-runs { display: flex; flex-direction: column; gap: 6px; }
.cc-run { display: flex; gap: 8px; font-size: 10.5px; color: var(--cc-dim); align-items: baseline; }
.cc-run .g { flex-shrink: 0; }
.cc-run .g.done { color: var(--cc-live); }
.cc-run .g.error, .cc-run .g.stale { color: var(--cc-warn); }
.cc-run .g.running { color: var(--cc-live); animation: cc-blink 1.1s steps(2, start) infinite; }
.cc-run .w { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cc-ink); }
.cc-run .t { flex-shrink: 0; color: var(--cc-faint); font-size: 9.5px; }

/* task log */
.cc-log-head { font-size: 9.5px; letter-spacing: 0.14em; color: var(--cc-faint); margin-bottom: 4px; }
.cc-task { border: 1px solid var(--cc-line); border-radius: 6px; overflow: hidden; }
.cc-task > button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; padding: 11px 14px; cursor: pointer; color: var(--cc-ink);
  transition: background-color 130ms ease;
}
.cc-task > button:hover { background: rgba(255, 255, 255, 0.04); }
.cc-task .tt { flex: 1; min-width: 0; font-size: 12px; line-height: 1.45; }
.cc-task .tm { flex-shrink: 0; color: var(--cc-faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.cc-task .flag { flex-shrink: 0; font-size: 9px; letter-spacing: 0.08em; padding: 2.5px 7px; border-radius: 3px; }
.cc-task .flag.pend { color: var(--cc-warn); border: 1px solid color-mix(in srgb, var(--cc-warn) 45%, transparent); }
.cc-task .flag.ok { color: var(--cc-live); border: 1px solid color-mix(in srgb, var(--cc-live) 35%, transparent); }
.cc-task .chev { color: var(--cc-faint); transition: transform 160ms var(--ease-out); }
.cc-task.open .chev { transform: rotate(90deg); }
.cc-task-body { border-top: 1px solid var(--cc-line); padding: 13px 16px; }
.cc-task-body .md { color: #c6ccdb; font-family: system-ui, -apple-system, sans-serif; }
.cc-task-body .md h3, .cc-task-body .md h4 { color: var(--cc-ink); }
.cc-task-body .md code, .cc-task-body .md pre { background: rgba(255, 255, 255, 0.06); border-color: var(--cc-line); }
.cc-task-body .md th, .cc-task-body .md td { border-color: var(--cc-line); }
.cc-task-body .md th { background: rgba(255, 255, 255, 0.04); color: var(--cc-ink); }
.cc-task-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.cc-mini-btn {
  background: none; border: 1px solid var(--cc-line); color: var(--cc-dim); border-radius: 4px;
  font-size: 10px; letter-spacing: 0.08em; padding: 5px 10px; cursor: pointer;
  transition: color 130ms ease, border-color 130ms ease;
}
.cc-mini-btn:hover { color: var(--cc-ink); border-color: var(--cc-dim); }
.cc-empty { color: var(--cc-faint); font-size: 11px; padding: 22px 0; text-align: center; letter-spacing: 0.05em; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .cc-field { min-height: 55vh; }
  .cc-roster { width: min(292px, 86vw); }
  .cc-agent-body { grid-template-columns: 1fr; }
  .cc-col.side { border-right: none; border-bottom: 1px solid var(--cc-line); }
  .cc-ticker { max-width: calc(100% - 32px); }
  .cc-ticker .ln:nth-child(n + 5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-chip .s .live-dot, .cc-row .st.live, .cc-status.live, .cc-cursor,
  .cc-chip.live, .cc-ticker .ln:first-child, .cc-type-cursor { animation: none !important; }
}
