.mesh-wrap {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(7, 11, 18, 0.95) 0%, rgba(15, 23, 42, 0.85) 100%);
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.mesh-wrap-mode-mesh { border-color: rgba(168, 85, 247, 0.25); }
.mesh-wrap-mode-org { border-color: rgba(255, 215, 0, 0.2); }
.mesh-wrap-mode-pulse { border-color: rgba(34, 197, 94, 0.25); }
.mesh-wrap-mode-clusters { border-color: rgba(255, 159, 67, 0.25); }
.mesh-wrap-mode-pyramid { border-color: rgba(0, 229, 255, 0.2); }

.mesh-svg {
  width: 100%;
  min-height: 680px;
  display: block;
}

.mesh-tier-band {
  fill: rgba(148, 163, 184, 0.03);
  stroke: none;
}

.mesh-tier-0 { fill: rgba(0, 229, 255, 0.03); }
.mesh-tier-1 { fill: rgba(168, 85, 247, 0.025); }
.mesh-tier-2 { fill: rgba(34, 197, 94, 0.025); }

.mesh-edge {
  fill: none;
  stroke: rgba(100, 116, 139, 0.2);
  stroke-linecap: round;
  stroke-width: 1.2;
  pointer-events: none;
}

.mesh-edge-report {
  stroke: rgba(0, 229, 255, 0.45);
  stroke-width: 1.5;
}

.mesh-edge-delegate {
  stroke: rgba(255, 215, 0, 0.4);
  stroke-width: 1.3;
  stroke-dasharray: 5 6;
}

.mesh-edge-executive {
  stroke: rgba(255, 159, 67, 0.28);
  stroke-width: 1.1;
}

.mesh-edge-peer {
  stroke: rgba(168, 85, 247, 0.12);
  stroke-width: 0.8;
}

.mesh-edge-peer-live {
  stroke: rgba(192, 132, 252, 0.55);
  stroke-width: 1.4;
}

.mesh-pulse {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 4 100;
  animation: mesh-pulse 2.6s linear infinite;
  pointer-events: none;
}

.mesh-pulse-active.mesh-edge-report { stroke: rgba(0, 229, 255, 0.85); }
.mesh-pulse-active.mesh-edge-delegate { stroke: rgba(255, 215, 0, 0.75); }
.mesh-pulse-active.mesh-edge-peer-live { stroke: rgba(192, 132, 252, 0.9); }

@keyframes mesh-pulse {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -208; }
}

.mesh-node { cursor: pointer; }
.mesh-node text.mesh-label {
  font-size: 13px;
  fill: #f1f5f9;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}
.mesh-label-agent { font-size: 13px; }
.mesh-label-herman { font-size: 14px; fill: #ffd700; }
.mesh-label-exec { font-size: 13px; }
.mesh-node text.mesh-sublabel {
  font-size: 10px;
  fill: #94a3b8;
  text-anchor: middle;
  pointer-events: none;
}
.mesh-sublabel-herman { fill: #cbd5e1; font-size: 10px; }
.mesh-node text.mesh-context {
  font-size: 9.5px;
  fill: #64748b;
  text-anchor: middle;
  pointer-events: none;
}
.mesh-node text.mesh-domain {
  font-size: 8.5px;
  fill: #475569;
  text-anchor: middle;
  pointer-events: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.mesh-node text.mesh-emoji {
  font-size: 14px;
  text-anchor: middle;
  pointer-events: none;
}
.mesh-herman-crown { font-size: 18px; pointer-events: none; }

.mesh-node circle.main {
  fill: #0b1220;
  stroke: rgba(148, 163, 184, 0.55);
  stroke-width: 2;
}

.mesh-node.healthy circle.main { stroke: #22c55e; }
.mesh-node.warn circle.main { stroke: #f59e0b; }
.mesh-node.idle circle.main { stroke: #475569; }
.mesh-node.offline circle.main { stroke: #334155; opacity: 0.65; }

.mesh-agent-live .mesh-pulse-wrap circle.pulse-ring {
  fill: none;
  stroke: rgba(34, 197, 94, 0.45);
  stroke-width: 1.8;
  animation: mesh-agent-pulse 2.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes mesh-agent-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.12); }
}

.mesh-herman circle.main {
  fill: #0f172a;
  stroke: #ffd700;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.35));
}

.mesh-herman.active .mesh-herman-ring circle.ring {
  fill: none;
  stroke: rgba(255, 215, 0, 0.4);
  stroke-width: 2;
  stroke-dasharray: 10 8;
}

.mesh-status-live circle.main { stroke-width: 2.5; }
.mesh-status-ready circle.main { stroke: #64748b; }
.mesh-status-warn circle.main { stroke: #f59e0b; }
.mesh-status-idle circle.main { stroke: #334155; opacity: 0.7; }

.mesh-exec circle.main { stroke-width: 2.5; }
.mesh-ceo circle.main { stroke: #ff9f43; }
.mesh-cto circle.main { stroke: #a855f7; }

/* ——— Communicatie-modus kiezer ——— */
.mesh-mode-section {
  margin-bottom: 1rem;
}

.mesh-mode-section > label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.55rem;
  font-weight: 600;
}

.mesh-mode-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (max-width: 1100px) {
  .mesh-mode-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .mesh-mode-grid { grid-template-columns: repeat(2, 1fr); }
}

.mesh-mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.7rem 0.75rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.7) 0%, rgba(7, 11, 18, 0.9) 100%);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  min-height: 5.5rem;
  color: inherit;
  font: inherit;
  width: 100%;
}

.mesh-mode-card:hover {
  border-color: rgba(148, 163, 184, 0.35);
  transform: translateY(-1px);
}

.mesh-mode-card.is-active {
  border-color: rgba(0, 229, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15), 0 4px 20px rgba(0, 229, 255, 0.08);
  background: linear-gradient(145deg, rgba(0, 229, 255, 0.06) 0%, rgba(7, 11, 18, 0.95) 100%);
}

.mesh-mode-card[data-mode="mesh"].is-active {
  border-color: rgba(168, 85, 247, 0.55);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.15), 0 4px 20px rgba(168, 85, 247, 0.08);
}

.mesh-mode-card[data-mode="org"].is-active {
  border-color: rgba(255, 215, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.12), 0 4px 20px rgba(255, 215, 0, 0.06);
}

.mesh-mode-card[data-mode="pulse"].is-active {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.12), 0 4px 20px rgba(34, 197, 94, 0.08);
}

.mesh-mode-card[data-mode="clusters"].is-active {
  border-color: rgba(255, 159, 67, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 159, 67, 0.12), 0 4px 20px rgba(255, 159, 67, 0.08);
}

.mesh-mode-icon {
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.85;
}

.mesh-mode-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
}

.mesh-mode-sub {
  font-size: 0.68rem;
  color: #64748b;
  line-height: 1.2;
}

.mesh-mode-desc {
  font-size: 0.65rem;
  color: #94a3b8;
  line-height: 1.35;
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mesh-mode-check {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.mesh-mode-card.is-active .mesh-mode-check {
  opacity: 1;
  background: #00e5ff;
  border-color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.mesh-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0.65rem;
}

.mesh-mode-badge {
  margin-right: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: #00e5ff;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.08);
}

.mesh-framework-head { margin-bottom: 0.5rem; }
.mesh-framework-head h2 { margin: 0; }

.mesh-legend {
  display: flex;
  gap: 0.65rem 1rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
  color: #94a3b8;
  font-size: 0.78rem;
}

.mesh-legend span::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 2px;
  margin-right: 0.3rem;
  vertical-align: middle;
  border-radius: 2px;
}

.mesh-legend .leg-report::before { background: #00e5ff; }
.mesh-legend .leg-delegate::before { background: #ffd700; }
.mesh-legend .leg-peer::before { background: #a855f7; }
.mesh-legend .leg-exec::before { background: #ff9f43; }

.mesh-cluster-label {
  font-size: 11px;
  fill: #94a3b8;
  font-weight: 600;
  pointer-events: none;
}

.mesh-agent-cluster-growth circle.main { stroke: rgba(0, 229, 255, 0.7); }
.mesh-agent-cluster-product circle.main { stroke: rgba(168, 85, 247, 0.7); }
.mesh-agent-cluster-ops circle.main { stroke: rgba(34, 197, 94, 0.65); }

.mesh-edge-straight { stroke-dasharray: none; }

/* ——— Terminals grid ——— */
.agents-terminals-intro {
  margin: 0 0 1rem;
  color: #94a3b8;
  font-size: 0.88rem;
}

.agents-terminals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.85rem;
}

.agent-term-window {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  background: #060a10;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.agent-term-window.is-live {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.12);
}

.agent-term-window.is-expanded {
  grid-column: 1 / -1;
  min-height: 320px;
}

.agent-term-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 0.82rem;
}

.agent-term-head .term-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.agent-term-window.is-live .term-dot {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  animation: term-dot-blink 1.8s ease-in-out infinite;
}

@keyframes term-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.agent-term-head strong { color: #f1f5f9; flex: 1; }
.agent-term-head small { color: #64748b; font-size: 0.72rem; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.agent-term-body {
  flex: 1;
  overflow-y: auto;
  max-height: 180px;
  padding: 0.5rem 0.65rem;
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

.agent-term-window.is-expanded .agent-term-body {
  max-height: 280px;
}

.term-line {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  display: flex;
  gap: 0.5rem;
}

.term-ts { color: #64748b; flex-shrink: 0; min-width: 2.5rem; }
.term-msg { color: #cbd5e1; word-break: break-word; }
.term-line.line-handoff .term-msg { color: #c4b5fd; }
.term-line.line-action .term-msg { color: #86efac; }
.term-line.line-command .term-msg { color: #86efac; font-weight: 600; }
.term-line.line-output .term-msg { color: #e2e8f0; }
.term-line.line-error .term-msg { color: #fca5a5; }
.term-line.term-idle .term-msg { color: #64748b; font-style: italic; }
.term-line.term-idle code { color: #94a3b8; font-size: 0.95em; }

.agent-term-foot {
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 14, 20, 0.95);
  padding: 0.45rem 0.55rem;
}

.agent-term-cmd {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.term-prompt {
  color: #22c55e;
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.agent-term-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #f1f5f9;
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
  font-size: 0.72rem;
  outline: none;
  padding: 0.2rem 0;
}

.agent-term-input::placeholder { color: #475569; }
.agent-term-input.is-busy { opacity: 0.55; }

.agent-term-window.is-running .term-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
}

.agent-term-window.is-expanded .agent-term-foot {
  padding: 0.55rem 0.75rem;
}

.agent-term-window.is-expanded .agent-term-input {
  font-size: 0.78rem;
}

.mesh-terminal-focus {
  margin-top: 1rem;
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  background: #060a10;
}

.mesh-terminal-focus .agent-term-body {
  max-height: 240px;
}

.vtab-badge {
  display: inline-flex;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: #f59e0b;
  color: #0a0e14;
  font-size: 0.65rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
}
