/* Agent Mesh — Fleet Dashboard (from the Claude Design handoff bundle,
   driven by real network telemetry instead of the prototype simulation). */

html, body { height: 100%; }
body { background: var(--bg-subtle); overflow: hidden; }
* { box-sizing: border-box; }
button { font-family: var(--font-body); }
.hidden { display: none !important; }

.app { display: flex; flex-direction: column; height: 100vh; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar { height: 64px; flex: none; background: var(--bg-default);
  border-bottom: 1px solid var(--border-default); display: flex; align-items: center;
  justify-content: space-between; gap: var(--space-4); padding: 0 var(--space-5); }
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand img { height: 26px; display: block; }
.brand-divider { width: 1px; height: 22px; background: var(--border-default); }
.brand b { font-family: var(--font-display); font-weight: var(--fw-semibold);
  font-size: 16px; color: var(--fg-default); }
.brand-sub { font-size: var(--type-text-xs-size); color: var(--fg-muted); margin-left: var(--space-1); white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.clock { font-size: 12.5px; color: var(--fg-muted); min-width: 62px; text-align: right; }

/* sessions as design-language chips */
.sessions { display: flex; align-items: center; gap: var(--space-2); overflow-x: auto;
  scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px;
  padding: 0 var(--space-3); border: 1px solid var(--border-default); background: var(--bg-default);
  border-radius: var(--radius-full); font-size: 12px; font-weight: var(--fw-medium);
  color: var(--fg-muted); cursor: pointer; white-space: nowrap;
  transition: background var(--duration-fast) ease-out, color var(--duration-fast) ease-out; }
.chip:hover { background: var(--color-gray-100); }
.chip.selected { background: var(--color-blue-900); border-color: var(--color-blue-900); color: var(--color-white); }
.chip .n { font-size: 10.5px; font-weight: var(--fw-semibold); background: var(--color-orange-50);
  color: var(--color-orange-600); border-radius: var(--radius-full); padding: 0 6px; }
.chip.selected .n { background: rgba(255, 255, 255, 0.16); color: var(--color-white); }

/* ── Layout ─────────────────────────────────────────────── */
.main { flex: 1; display: flex; gap: var(--space-4); padding: var(--space-4); min-height: 0; }
.card { background: var(--bg-default); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.map-card { flex: 1; position: relative; overflow: hidden; min-width: 0;
  background-image: radial-gradient(var(--color-gray-200) 1px, transparent 1px);
  background-size: 24px 24px; background-position: 12px 12px; }
.rail { width: 350px; flex: none; display: flex; flex-direction: column; gap: var(--space-4); min-height: 0; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; color: var(--fg-subtle); pointer-events: none; }

/* ── Fleet map ──────────────────────────────────────────── */
.mesh-canvas { position: absolute; inset: 0; }
.mesh-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.edge-base { fill: none; stroke: var(--color-gray-300); stroke-width: 1; stroke-dasharray: 2 6;
  stroke-linecap: round; opacity: 0.6; }
.edge-active { fill: none; stroke: var(--color-orange-300); stroke-width: 1.5; opacity: 0.65; }
.edge-blocked { fill: none; stroke: var(--color-warning-500); stroke-width: 1.5;
  stroke-dasharray: 5 5; animation: dash-march 1.1s linear infinite; }
@keyframes dash-march { to { stroke-dashoffset: -20; } }

/* Collapsed by default into a small "pin"; full card reveals on hover. */
.node { position: absolute; transform: translate(-50%, -50%); z-index: 10; cursor: grab;
  background: none; border: none; padding: 0; width: auto; }
.node.dragging { cursor: grabbing; }
.node:hover { z-index: 100; }          /* expanded card rises above neighbors */
.node.offline { opacity: 0.5; }

.pin { display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-gray-300);
  transition: box-shadow var(--duration-fast) ease-out;
}
.pin-label { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px;
  color: var(--fg-default); max-width: 116px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--bg-default); padding: 1px 7px; border-radius: var(--radius-full); box-shadow: var(--shadow-xs); }
.pin-load { position: absolute; top: -3px; right: 50%; margin-right: -26px;
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: var(--radius-full);
  background: var(--color-orange-500); color: var(--color-white); font-size: 9.5px;
  font-weight: var(--fw-semibold); display: inline-flex; align-items: center; justify-content: center; }
/* identity-collision badge + ring */
.pin-warn { position: absolute; top: -3px; left: 50%; margin-left: 8px;
  width: 16px; height: 16px; border-radius: var(--radius-full);
  background: var(--color-error-500); color: var(--color-white); font-size: 11px; font-weight: var(--fw-bold);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-default); }
.node.collision .pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-error-500) !important; }
.node-collision { font-size: 11px; line-height: 1.4; color: var(--color-error-700);
  background: var(--color-error-50); border: 1px solid var(--color-error-200, rgba(220,38,38,0.25));
  border-radius: var(--radius-md); padding: var(--space-1) var(--space-2); margin-top: var(--space-2); }

/* status ring on the pin avatar */
.node[data-status="online"] .pin .m-avatar,
.node[data-status="ready"] .pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-success-500); }
.node[data-status="busy"] .pin .m-avatar,
.node[data-status="degraded"] .pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-warning-500); }
.node[data-status="stale"] .pin .m-avatar,
.node[data-status="offline"] .pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-gray-300); }
.node.requester .pin .m-avatar {
  box-shadow: 0 0 0 2px var(--bg-default), 0 0 0 4px var(--color-lightblue-500); }

/* full card — hidden until hover/selected, overlays centered on the pin */
.node-detail { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 216px; display: none; flex-direction: column; gap: var(--space-2); text-align: left;
  background: var(--bg-default); border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); padding: var(--space-3); z-index: 100; }
.node:hover .node-detail, .node.selected .node-detail { display: flex; }
.node.requester .node-detail { border-style: dashed; border-color: var(--color-lightblue-500);
  background: var(--color-lightblue-50); }

.node.flash .pin .m-avatar { animation: node-flash 0.9s ease-out; }
@keyframes node-flash {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 0, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(255, 90, 0, 0); }
}
.node-top { display: flex; align-items: center; gap: var(--space-2); }
.node-id { min-width: 0; flex: 1; }
.node-role { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 13px;
  line-height: 1.3; color: var(--fg-default); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-owner { font-size: 11.5px; color: var(--fg-muted); line-height: 1.3; }
.node-load { display: inline-flex; align-items: center; gap: 3px; align-self: flex-start;
  font-size: 10.5px; font-weight: var(--fw-semibold); color: var(--color-gray-600);
  background: var(--color-gray-100); border-radius: var(--radius-full); padding: 2px 7px; }
.node-machine { display: flex; align-items: center; gap: var(--space-1);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle); }
.node-foot { display: flex; flex-direction: column; gap: var(--space-1);
  border-top: 1px solid var(--color-gray-100); padding-top: var(--space-2); }
.node-work { font-size: 11.5px; color: var(--fg-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.node-work.is-idle { color: var(--fg-subtle); font-style: italic; }

.m-avatar { flex: none; border-radius: var(--radius-full); background: var(--color-blue-900);
  color: var(--color-white); display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: var(--fw-semibold); letter-spacing: 0.02em; }
.m-avatar.ghost { background: var(--color-lightblue-500); }

.msg { position: absolute; transform: translate(-50%, -50%); z-index: 20; border: none;
  background: transparent; padding: 0; cursor: pointer; }
.msg-chip { display: flex; align-items: center; gap: 6px; background: var(--bg-default);
  border: 1px solid var(--border-default); box-shadow: var(--shadow-md);
  border-radius: var(--radius-full); padding: 3px 10px 3px 7px; white-space: nowrap;
  font-size: 10.5px; font-weight: var(--fw-medium); color: var(--fg-default);
  font-family: var(--font-mono); }
.msg-dot { width: 9px; height: 9px; border-radius: var(--radius-full); display: inline-block; }

/* ── Pills ──────────────────────────────────────────────── */
.m-pill { display: inline-flex; align-items: center; gap: 5px; height: 20px;
  padding: 0 var(--space-2); border-radius: var(--radius-full); font-size: 11px;
  font-weight: var(--fw-semibold); white-space: nowrap; }
.m-pill .m-dot { width: 6px; height: 6px; border-radius: var(--radius-full); flex: none; }
.st-working { background: var(--color-success-50); color: var(--color-success-700); }
.st-working .m-dot { background: var(--color-success-500); animation: pulse 1.6s ease-in-out infinite; }
.st-idle { background: var(--color-gray-100); color: var(--color-gray-600); }
.st-idle .m-dot { background: var(--color-gray-400); }
.st-blocked { background: var(--color-warning-50); color: var(--color-warning-700); }
.st-blocked .m-dot { background: var(--color-warning-500); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.ts-sent { background: var(--color-orange-50); color: var(--color-orange-600); }
.ts-sent .m-dot { background: var(--color-orange-500); animation: pulse 1.2s ease-in-out infinite; }
.ts-progress { background: var(--color-info-50); color: var(--color-blue-600); }
.ts-progress .m-dot { background: var(--color-blue-500); animation: pulse 1.6s ease-in-out infinite; }
.ts-blocked { background: var(--color-warning-50); color: var(--color-warning-700); }
.ts-blocked .m-dot { background: var(--color-warning-500); animation: pulse 1.1s ease-in-out infinite; }
.ts-returning { background: var(--color-success-50); color: var(--color-success-700); }
.ts-returning .m-dot { background: var(--color-success-500); animation: pulse 1.2s ease-in-out infinite; }
.ts-done { background: var(--color-gray-100); color: var(--color-gray-600); }
.ts-done .m-dot { background: var(--color-success-500); }
.ts-failed { background: var(--color-error-50); color: var(--color-error-700); }
.ts-failed .m-dot { background: var(--color-error-500); }

/* ── Right rail ─────────────────────────────────────────── */
.rail-card { display: flex; flex-direction: column; min-height: 0; max-height: 46%; }
.rail-card.grow { flex: 1; max-height: none; }
.rail-head { display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-gray-100); }
.rail-title { font-family: var(--font-display); font-size: 13.5px; font-weight: var(--fw-semibold);
  margin: 0; color: var(--fg-default); white-space: nowrap; }
.count-badge { font-size: 11px; font-weight: var(--fw-semibold); color: var(--color-orange-600);
  background: var(--color-orange-50); border-radius: var(--radius-full); padding: 1px 8px; }
.rail-action { margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: var(--fw-semibold); letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--fg-muted); background: transparent; border: 1px solid var(--border-default);
  border-radius: var(--radius-full); padding: 2px 9px; cursor: pointer;
  transition: border-color var(--duration-fast) ease-out, color var(--duration-fast) ease-out; }
.rail-action:hover { color: var(--color-orange-600); border-color: var(--color-orange-600); }
.rail-action svg { width: 13px; height: 13px; }
.rail-scroll { overflow-y: auto; min-height: 0; padding: var(--space-3) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  scrollbar-width: thin; scrollbar-color: var(--color-gray-300) transparent; }
.rail-sub { font-size: 10.5px; font-weight: var(--fw-semibold); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-subtle); margin-top: var(--space-2); }
.empty { font-size: 12.5px; color: var(--fg-subtle); margin: var(--space-2) 0; }
#active-tasks, #recent-tasks { display: flex; flex-direction: column; gap: var(--space-2); }

.task-row { background: var(--bg-default); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); cursor: pointer;
  display: flex; flex-direction: column; gap: var(--space-1); text-align: left; width: 100%;
  transition: border-color var(--duration-fast) ease-out, box-shadow var(--duration-fast) ease-out; }
.task-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.task-row.done { opacity: 0.72; }
.task-row-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.task-id { font-size: 11px; color: var(--fg-muted); }
.task-title { font-size: 12.5px; font-weight: var(--fw-medium); color: var(--fg-default);
  line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.m-route { display: inline-flex; align-items: center; gap: var(--space-2); }
.m-route-end { display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  font-weight: var(--fw-medium); color: var(--fg-muted); }

.feed { gap: 0; }
.feed-item { display: flex; align-items: flex-start; gap: var(--space-2); text-align: left;
  background: transparent; border: none; padding: var(--space-2) 0; cursor: pointer; width: 100%;
  border-bottom: 1px solid var(--color-gray-100); }
.feed-item:hover .feed-text { color: var(--fg-strong); }
.feed-ic { flex: none; width: 22px; height: 22px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.tone-accent { background: var(--color-orange-50); color: var(--color-orange-600); }
.tone-success { background: var(--color-success-50); color: var(--color-success-700); }
.tone-warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.tone-info { background: var(--color-lightblue-50); color: var(--color-lightblue-700); }
.tone-muted { background: var(--color-gray-100); color: var(--color-gray-600); }
.tone-error { background: var(--color-error-50); color: var(--color-error-700); }
.feed-text { flex: 1; font-size: 12px; line-height: 1.45; color: var(--fg-default);
  overflow-wrap: anywhere; }
.feed-time { flex: none; font-size: 10.5px; color: var(--fg-subtle); margin-top: 2px; }
.feed-item.feed-msg { cursor: default; }
.m-intent { font-size: 10px; font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--color-lightblue-700); }
.msg-rich { margin-top: 4px; padding: 6px 8px; border-left: 2px solid var(--color-lightblue-300);
  background: var(--color-lightblue-50); border-radius: 4px; font-size: 11.5px; line-height: 1.5; }
.msg-rich p { margin: 0 0 4px; }
.msg-rich ul, .msg-rich ol { margin: 2px 0; padding-left: 18px; }
.msg-rich code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(8,40,59,0.06);
  padding: 0 3px; border-radius: 3px; }
.msg-rich pre { background: rgba(8,40,59,0.06); padding: 6px 8px; border-radius: 4px;
  overflow-x: auto; margin: 4px 0; }
.msg-rich pre code { background: none; padding: 0; }
.msg-rich h3, .msg-rich h4, .msg-rich h5 { font-family: var(--font-display); margin: 4px 0 2px; font-size: 12.5px; }
.msg-rich a { color: var(--color-blue-500); }
.msg-rich table { border-collapse: collapse; margin: 4px 0; }
.msg-rich td, .msg-rich th { border: 1px solid var(--border-default); padding: 2px 6px; }
/* a message row opens its full content in the drawer */
.feed-item.feed-msg.clickable { cursor: pointer; }
.feed-msg.clickable:hover { background: var(--color-gray-50); }
.msg-more { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px;
  font-size: 10px; font-weight: var(--fw-semibold); color: var(--color-lightblue-700);
  text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; vertical-align: middle; }
.feed-msg.clickable:hover .msg-more { opacity: 1; }
.msg-more svg { width: 11px; height: 11px; }

/* message drawer — the maximized view of a coordination message */
.msg-route { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3);
  flex-wrap: wrap; }
.msg-route-end { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  font-weight: var(--fw-medium); color: var(--fg-default); }
.msg-task-link { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-default);
  border-radius: var(--radius-full); padding: 2px 9px; background: var(--bg-default); cursor: pointer;
  font-size: 10.5px; color: var(--fg-muted); font-family: var(--font-mono);
  transition: border-color var(--duration-fast) ease-out, color var(--duration-fast) ease-out; }
.msg-task-link:hover { border-color: var(--color-orange-600); color: var(--color-orange-600); }
.msg-full { font-size: 13.5px; line-height: 1.6; color: var(--fg-default); overflow-wrap: anywhere; }
.msg-full p { margin: 0 0 var(--space-3); }
.msg-full ul, .msg-full ol { margin: var(--space-2) 0; padding-left: 22px; }
.msg-full li { margin: 2px 0; }
.msg-full code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(8,40,59,0.06);
  padding: 1px 4px; border-radius: 3px; }
.msg-full pre { background: rgba(8,40,59,0.06); padding: var(--space-3); border-radius: var(--radius-md);
  overflow-x: auto; margin: var(--space-2) 0; }
.msg-full pre code { background: none; padding: 0; }
.msg-full h3, .msg-full h4, .msg-full h5 { font-family: var(--font-display); margin: var(--space-3) 0 var(--space-1); }
.msg-full a { color: var(--color-blue-500); }
.msg-full blockquote { margin: var(--space-2) 0; padding-left: var(--space-3);
  border-left: 3px solid var(--border-strong); color: var(--fg-muted); }
.msg-full table { border-collapse: collapse; margin: var(--space-2) 0; }
.msg-full td, .msg-full th { border: 1px solid var(--border-default); padding: 4px 8px; }

/* ── Drawers ────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: var(--bg-overlay);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  z-index: var(--z-overlay); animation: fade-in var(--duration-slow) ease-out; }
@keyframes fade-in { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw;
  background: var(--bg-default); box-shadow: var(--shadow-2xl); z-index: var(--z-modal);
  display: flex; flex-direction: column; animation: slide-in var(--duration-slow) ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { padding: var(--space-4) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--border-default); }
.drawer-head-top { display: flex; align-items: center; gap: var(--space-2); }
.drawer-title { font-family: var(--font-display); font-size: 18px; font-weight: var(--fw-semibold);
  line-height: 1.35; margin: var(--space-2) 0 0; color: var(--fg-default); }
.drawer-meta { display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-top: var(--space-2); flex-wrap: wrap; }
.meta-times { display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: 10.5px; color: var(--fg-subtle); }
.agent-head { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }
.agent-head .drawer-title { margin: 0; }
.agent-owner { font-size: 12.5px; color: var(--fg-muted); margin: 2px 0 0; }
.icon-btn.ghost { border: none; background: transparent; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-lg);
  color: var(--fg-muted); cursor: pointer; margin-left: auto; }
.icon-btn.ghost:hover { color: var(--fg-default); background: var(--color-gray-100); }

.drawer-body { flex: 1; overflow-y: auto; min-height: 0; padding: var(--space-4) var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  scrollbar-width: thin; scrollbar-color: var(--color-gray-300) transparent; }

/* thread */
.th-card { border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  padding: var(--space-3); background: var(--bg-default); }
.th-card.th-question { background: var(--color-warning-50); border-color: rgba(245, 158, 11, 0.35); }
.th-card.th-answer { background: var(--color-lightblue-50); border-color: rgba(93, 175, 246, 0.4); }
.th-card.th-response { background: var(--color-success-50); border-color: rgba(0, 125, 0, 0.25); }
.th-card.th-failed { background: var(--color-error-50); border-color: rgba(220, 38, 38, 0.25); }
.th-head { display: flex; align-items: center; gap: var(--space-2); }
.th-sender { font-size: 12px; font-weight: var(--fw-semibold); color: var(--fg-default); }
.th-kind { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px;
  font-weight: var(--fw-semibold); color: var(--fg-muted); background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 1px 8px; }
.th-question .th-kind { color: var(--color-warning-700); border-color: rgba(245, 158, 11, 0.35); }
.th-answer .th-kind { color: var(--color-lightblue-700); border-color: rgba(93, 175, 246, 0.4); }
.th-response .th-kind { color: var(--color-success-700); border-color: rgba(0, 125, 0, 0.25); }
.th-failed .th-kind { color: var(--color-error-700); border-color: rgba(220, 38, 38, 0.25); }
.th-handoff .th-kind { color: var(--color-orange-600); border-color: rgba(255, 90, 0, 0.3); }
.th-time { margin-left: auto; font-size: 10px; color: var(--fg-subtle); }
.th-body { font-size: 13px; line-height: 1.5; margin: var(--space-2) 0 0; color: var(--fg-default);
  overflow-wrap: anywhere; }
.th-status { display: flex; align-items: center; gap: var(--space-2); justify-content: center;
  font-size: 11.5px; color: var(--fg-muted); padding: var(--space-1) 0; }
.th-status svg { color: var(--color-success-500); }

.waiting { display: flex; align-items: center; gap: var(--space-2); font-size: 12px;
  font-weight: var(--fw-medium); color: var(--color-warning-700);
  background: var(--color-warning-50); border: 1px dashed rgba(245, 158, 11, 0.45);
  border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); }
.waiting.neutral { color: var(--fg-muted); background: var(--color-gray-50);
  border-color: var(--border-strong); }
.waiting-dots { display: inline-flex; gap: 3px; }
.waiting-dots span { width: 5px; height: 5px; border-radius: var(--radius-full);
  background: currentColor; animation: wdots 1.2s ease-in-out infinite; }
.waiting-dots span:nth-child(2) { animation-delay: 0.18s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes wdots { 0%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* agent drawer */
.sect-label { font-size: 10.5px; font-weight: var(--fw-semibold); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-subtle); margin-top: var(--space-1); }
.now-card { border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  padding: var(--space-3); background: var(--color-gray-50); }
.now-title { font-size: 13px; font-weight: var(--fw-medium); margin: 0; color: var(--fg-default); }
.inv-row { display: flex; align-items: center; gap: var(--space-2); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); background: var(--bg-default);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color var(--duration-fast) ease-out, box-shadow var(--duration-fast) ease-out; }
.inv-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.inv-dir { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: 10px;
  font-weight: var(--fw-semibold); border-radius: var(--radius-full); padding: 1px 7px; }
.inv-dir.in { background: var(--color-lightblue-50); color: var(--color-lightblue-700); }
.inv-dir.out { background: var(--color-orange-50); color: var(--color-orange-600); }
.inv-title { flex: 1; font-size: 12px; color: var(--fg-default); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }

/* delegation tree (task drawer) */
.sect-label .tree-count { margin-left: var(--space-2); font-size: 10px; letter-spacing: 0;
  text-transform: none; color: var(--fg-subtle); font-weight: var(--fw-medium); }
.tree { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); padding: var(--space-2); background: var(--color-gray-50); }
.tree-row { display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2); cursor: pointer;
  transition: background var(--duration-fast) ease-out, border-color var(--duration-fast) ease-out; }
.tree-row:hover { background: var(--bg-default); border-color: var(--border-default); }
.tree-row.current { background: var(--color-orange-50); border-color: var(--color-orange-600);
  cursor: default; }
.tree-twig { flex: none; width: 12px; color: var(--fg-subtle); font-size: 12px; }
.tree-id { flex: none; font-size: 11px; color: var(--fg-muted); }
.tree-title { flex: 1; font-size: 12px; color: var(--fg-default); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }

/* ── Chat view (a screen SWITCH from the network view, not a modal) ── */
.chat-view { flex: 1; display: flex; min-height: 0; padding: var(--space-4);
  animation: fade-in var(--duration-fast) ease-out; }
.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-default); flex: none; }
.chat-back { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  font-weight: var(--fw-medium); color: var(--fg-muted); background: transparent;
  border: 1px solid var(--border-default); border-radius: var(--radius-full);
  padding: 3px 12px 3px 9px; cursor: pointer;
  transition: border-color var(--duration-fast) ease-out, color var(--duration-fast) ease-out; }
.chat-back:hover { color: var(--color-orange-600); border-color: var(--color-orange-600); }
.chat-title { font-family: var(--font-display); font-size: 16px; font-weight: var(--fw-semibold);
  margin: 0; color: var(--fg-default); }
.chat-filter { margin-left: auto; display: inline-flex; gap: 2px; padding: 2px;
  background: var(--color-gray-100); border-radius: var(--radius-full); }
.chat-filter button { font-size: 11px; font-weight: var(--fw-semibold); color: var(--fg-muted);
  background: transparent; border: none; border-radius: var(--radius-full); padding: 3px 13px;
  cursor: pointer; transition: color var(--duration-fast) ease-out; }
.chat-filter button:hover { color: var(--fg-default); }
.chat-filter button.active { background: var(--bg-default); color: var(--fg-default);
  box-shadow: var(--shadow-sm); }
.chat-layout { flex: 1; display: grid; grid-template-columns: 264px 1fr; min-height: 0; }
.chat-layout.info-open { grid-template-columns: 264px 1fr 308px; }
.chat-infobtn { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  font-weight: var(--fw-medium); color: var(--fg-muted); background: transparent;
  border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 3px 11px;
  cursor: pointer; transition: color var(--duration-fast) ease-out, border-color var(--duration-fast) ease-out; }
.chat-infobtn:hover { color: var(--fg-default); }
.chat-infobtn.active { color: var(--color-orange-600); border-color: var(--color-orange-600);
  background: var(--color-orange-50); }
.chat-infobtn svg { width: 12px; height: 12px; }
/* session inspector */
.chat-info { display: none; border-left: 1px solid var(--border-default); overflow-y: auto;
  padding: var(--space-4); scrollbar-width: thin; scrollbar-color: var(--color-gray-300) transparent; }
.chat-layout.info-open .chat-info { display: block; }
.si-sect { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-subtle); margin: var(--space-3) 0 var(--space-2); }
.si-sect:first-child { margin-top: 0; }
.si-count { margin-left: 4px; color: var(--fg-muted); }
.si-member { display: flex; align-items: center; gap: var(--space-2); padding: 3px 0; }
.si-name { flex: 1; font-size: 12.5px; color: var(--fg-default); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.si-role { flex: none; font-size: 9.5px; font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: 0.03em; border-radius: var(--radius-full); padding: 1px 7px; }
.si-role-owner { color: var(--color-orange-600); background: var(--color-orange-50); }
.si-role-admin { color: var(--color-lightblue-700); background: var(--color-lightblue-50); }
.si-role-member { color: var(--fg-subtle); background: var(--color-gray-100); }
.si-contract { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) 0; }
.si-cname { flex: 1; font-size: 12.5px; color: var(--fg-default); }
.si-status { flex: none; font-size: 9.5px; font-weight: var(--fw-semibold); text-transform: uppercase;
  border-radius: var(--radius-full); padding: 1px 8px; }
.si-status-proposed { color: var(--color-warning-700); background: var(--color-warning-50); }
.si-status-reviewed { color: var(--color-lightblue-700); background: var(--color-lightblue-50); }
.si-status-ratified { color: var(--color-success-700); background: var(--color-success-50); }
.si-note { border-left: 2px solid var(--border-strong); padding: 2px 0 var(--space-2) var(--space-2);
  margin-bottom: var(--space-2); }
.si-note-head { display: flex; align-items: baseline; gap: var(--space-2); font-size: 10.5px;
  color: var(--fg-subtle); margin-bottom: 2px; }
.si-kind { font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--fg-muted); }
.si-kind-decision { color: var(--color-orange-600); }
.si-kind-contract { color: var(--color-success-700); }
.si-kind-limitation { color: var(--color-warning-700); }
.si-by { flex: 1; }
.si-when { flex: none; }
.si-text { font-size: 12.5px; line-height: 1.45; color: var(--fg-default); overflow-wrap: anywhere; }
.si-empty { font-size: 12px; color: var(--fg-subtle); }
.chat-sidebar { border-right: 1px solid var(--border-default); overflow-y: auto; padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
  scrollbar-width: thin; scrollbar-color: var(--color-gray-300) transparent; }
.chat-conv { display: flex; flex-direction: column; gap: 4px; text-align: left; width: 100%;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3); cursor: pointer;
  transition: background var(--duration-fast) ease-out, border-color var(--duration-fast) ease-out; }
.chat-conv:hover { background: var(--color-gray-50); }
.chat-conv.selected { background: var(--color-orange-50); border-color: var(--color-orange-600); }
.chat-conv-top { display: flex; align-items: center; gap: var(--space-2); }
.chat-conv-name { flex: 1; font-size: 13px; font-weight: var(--fw-medium); color: var(--fg-default);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-n { flex: none; font-size: 10.5px; font-weight: var(--fw-semibold); color: var(--color-orange-600);
  background: var(--color-orange-50); border-radius: var(--radius-full); padding: 0 7px; }
.chat-conv-avatars { display: flex; gap: 2px; }
.chat-conv-sub { font-size: 10.5px; color: var(--fg-subtle); }
.chat-stream { overflow-y: auto; padding: var(--space-4) var(--space-5);
  scrollbar-width: thin; scrollbar-color: var(--color-gray-300) transparent; }
.chat-stream-inner { max-width: 900px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; }
.chat-empty { margin-top: var(--space-6, 2rem); text-align: center; color: var(--fg-subtle); font-size: 13px; }

/* a day separator */
.chat-day { display: flex; justify-content: center; margin: var(--space-4) 0 var(--space-2); }
.chat-day span { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: 0.04em;
  color: var(--fg-subtle); background: var(--color-gray-100); border-radius: var(--radius-full);
  padding: 2px 12px; }

/* message bubble — colored per speaker, grouped on consecutive lines */
.chat-bubble { display: flex; align-items: flex-start; gap: var(--space-2);
  max-width: 80%; margin-top: var(--space-4); }
.chat-bubble.grouped { margin-top: 3px; margin-left: 40px; }
.chat-bubble-main { flex: 1; min-width: 0; background: var(--bg-default);
  border: 1px solid var(--border-default); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.chat-bubble-head { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap;
  font-size: 11px; color: var(--fg-muted); margin-bottom: 3px; }
.chat-sender { font-weight: var(--fw-semibold); font-size: 12.5px; }
.chat-to { color: var(--fg-subtle); }
.m-intent + .chat-time, .chat-bubble-head .chat-time { margin-left: auto; }
.chat-time { font-size: 10px; color: var(--fg-subtle); white-space: nowrap; }
.chat-bubble.grouped .chat-time { float: right; margin-left: var(--space-3); }
.chat-text { font-size: 13.5px; line-height: 1.55; color: var(--fg-default); overflow-wrap: anywhere; }
.chat-text p { margin: 0 0 var(--space-2); }
.chat-text p:last-child { margin-bottom: 0; }
.chat-text ul, .chat-text ol { margin: var(--space-1) 0; padding-left: 20px; }
.chat-text code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(8,40,59,0.06);
  padding: 1px 4px; border-radius: 3px; }
.chat-text pre { background: rgba(8,40,59,0.06); padding: var(--space-3); border-radius: var(--radius-md);
  overflow-x: auto; margin: var(--space-2) 0; }
.chat-text pre code { background: none; padding: 0; }
.chat-text a { color: var(--color-blue-500); }
.chat-text h3, .chat-text h4, .chat-text h5 { font-family: var(--font-display); margin: var(--space-2) 0 var(--space-1); }

/* reply context — the "thread line": what this message is replying to */
.chat-reply { display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  margin-bottom: 6px; padding: 3px 10px 3px 7px; cursor: pointer; text-align: left;
  background: var(--color-gray-50); border: 1px solid var(--border-default);
  border-left: 2px solid var(--border-strong); border-radius: var(--radius-md);
  transition: background var(--duration-fast) ease-out; }
.chat-reply:hover { background: var(--color-gray-100); }
.chat-reply svg { flex: none; color: var(--fg-subtle); }
.chat-reply-sender { flex: none; font-size: 11px; font-weight: var(--fw-semibold); }
.chat-reply-snippet { min-width: 0; font-size: 11px; color: var(--fg-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* inline images — capped so a big one can't blow up the layout */
.msg-img, .chat-text img, .msg-full img, .msg-rich img {
  display: block; max-width: 100%; max-height: 360px; width: auto; height: auto;
  margin: var(--space-2) 0; border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--color-gray-50); object-fit: contain; }
.msg-rich img { max-height: 200px; }

/* @-mention chips */
.chat-mentions { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.chat-mention { font-size: 11px; font-weight: var(--fw-semibold); border-radius: var(--radius-full);
  padding: 1px 8px; white-space: nowrap; }
.chat-bubble.flash .chat-bubble-main { animation: chat-flash 1.3s ease-out; }
@keyframes chat-flash {
  0%, 30% { background: var(--color-orange-50); box-shadow: 0 0 0 2px var(--color-orange-600) inset; }
  100% { background: var(--bg-default); box-shadow: none; }
}

/* task event — a slim, de-emphasized timeline marker between bubbles */
.chat-sysnote { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-3) 0; }
.chat-sysnote-rule { flex: 1; height: 1px; background: var(--color-gray-100); }
.chat-sysnote-body { display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 11px; color: var(--fg-subtle); }
.chat-sysnote-body .feed-ic { width: 18px; height: 18px; }
.chat-sysnote-time { color: var(--fg-subtle); opacity: 0.8; }

@media (max-width: 720px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .edge-blocked, .m-dot, .waiting-dots span { animation: none !important; }
  .chat-view { animation: none !important; }
}

/* ── Login gate (hosted dashboard: sign in with a network token) ──────────── */
#login { position: fixed; inset: 0; z-index: var(--z-modal, 1000); display: flex;
  align-items: center; justify-content: center; padding: var(--space-4);
  background: color-mix(in srgb, var(--color-blue-900, #08283B) 55%, transparent);
  backdrop-filter: blur(4px); }
#login .login-card { width: 100%; max-width: 440px; display: flex; flex-direction: column;
  gap: var(--space-3); background: var(--bg-default); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2xl, 0 24px 60px rgba(8,40,59,.35));
  padding: var(--space-6, 28px); }
#login .login-mark { font-family: var(--font-display); font-weight: var(--fw-semibold, 600);
  font-size: 26px; color: var(--fg-default); }
#login .login-sub { margin: 0; font-size: 13.5px; color: var(--fg-muted); line-height: 1.5; }
#login input { height: 42px; padding: 0 var(--space-3); border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 6px); font-size: 13px; font-family: var(--font-mono, monospace);
  color: var(--fg-default); background: var(--bg-subtle); outline: none; }
#login input:focus { border-color: var(--color-orange-500, #FF5A00);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-orange-500, #FF5A00) 22%, transparent); }
#login button { height: 42px; border: none; border-radius: var(--radius-md, 6px); cursor: pointer;
  background: var(--color-orange-500, #FF5A00); color: #fff; font-weight: var(--fw-semibold, 600);
  font-size: 14px; }
#login button:hover { filter: brightness(1.05); }
#login button:disabled { opacity: .6; cursor: default; }
#login .login-err { min-height: 16px; font-size: 12.5px; color: var(--color-red-600, #dc2626); }
@media (prefers-reduced-motion: reduce) { #login { backdrop-filter: none; } }
