:root {
  color-scheme: dark;
  --bg: #091111;
  --surface-1: #0f1a1a;
  --surface-2: #152323;
  --surface-3: #1c2e2e;
  --surface-elevated: #122020;
  --hairline: rgba(218, 238, 232, 0.13);
  --hairline-strong: rgba(218, 238, 232, 0.28);
  --ink: #eef5f2;
  --ink-secondary: #bed0ca;
  --ink-muted: #93aba4;
  --accent: #7ce0b6;
  --accent-dim: rgba(124, 224, 182, 0.14);
  --accent-ink: #071913;
  --route: #f4cf6e;
  --route-dim: rgba(244, 207, 110, 0.16);
  --route-ink: #1a1506;
  --focus: #fff3b9;
  --danger: #f29a82;
  --radius-panel: 14px;
  --radius-control: 10px;
  --radius-pill: 999px;
  --font-sans: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'Consolas', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(ellipse 75% 45% at 15% -10%, rgba(41, 88, 76, 0.34), transparent 70%),
    var(--bg);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 60;
  padding: 0.65rem 1rem;
  color: var(--accent-ink);
  background: var(--focus);
  border-radius: var(--radius-control);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.masthead,
main,
footer {
  width: min(1560px, calc(100% - 2rem));
  margin-inline: auto;
}

/* Header */
.masthead {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(260px, 440px) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--hairline);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: var(--radius-control);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}

.lede {
  margin: 0.15rem 0 0;
  color: var(--ink-secondary);
  font-size: 0.94rem;
  line-height: 1.35;
}

/* Apresentação do portfólio */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.75fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(3rem, 6vw, 6rem) 0;
  border-bottom: 1px solid var(--hairline);
}
.intro-copy { max-width: 780px; }
.intro-kicker, .intro-guide-title {
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 650;
}
.intro h2 {
  margin: 0;
  font-size: clamp(2.2rem, 1.5rem + 3vw, 4.5rem);
  line-height: 1.06;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.intro h2 span { color: var(--accent); }
.intro-lede {
  max-width: 60ch;
  margin: 1.5rem 0 0;
  color: var(--ink-secondary);
  font-size: clamp(1rem, .95rem + .3vw, 1.2rem);
  line-height: 1.7;
}
.intro-actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-top: 2rem; }
.intro-actions a { display: inline-flex; min-height: 48px; align-items: center; gap: .65rem; font-weight: 650; text-decoration: none; }
.intro-primary { padding: .75rem 1.1rem; border-radius: var(--radius-control); color: var(--accent-ink); background: var(--accent); }
.intro-primary:hover { background: var(--ink); }
.intro-secondary { color: var(--ink); }
.intro-secondary:hover { color: var(--accent); text-decoration: underline; }
.intro-guide { padding: 1.5rem; border: 1px solid var(--hairline); border-radius: var(--radius-panel); background: var(--surface-1); }
.intro-guide ol { display: grid; gap: 1rem; margin: 0; padding-left: 1.4rem; color: var(--accent); }
.intro-guide li { padding-left: .3rem; }
.intro-guide li strong, .intro-guide li span { display: block; }
.intro-guide li strong { color: var(--ink); font-size: .95rem; }
.intro-guide li span, .intro-note { color: var(--ink-secondary); font-size: .88rem; }
.intro-note { margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--hairline); }
#explorar-atlas { scroll-margin-top: 1rem; }
@media (max-width: 859px) {
  .intro { grid-template-columns: 1fr; gap: 2rem; padding-block: 2.75rem; }
}

/* Search */
.search-bar {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.search-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.45rem 0 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-control);
}

.search-field:focus-within {
  border-color: var(--accent);
}

.search-icon {
  color: var(--ink-muted);
  flex: 0 0 auto;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0;
}

.search-field input::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

.search-field input:focus {
  outline: none;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.clear-search {
  min-height: 36px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.clear-search:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Snapshot stamp & popover */
.snapshot-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.snapshot-stamp {
  display: grid;
  text-align: right;
  font-size: 0.85rem;
}

.stamp-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.snapshot-stamp time {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.info-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.info-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.info-popover {
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 1rem 1.15rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-panel);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.info-popover p {
  margin: 0;
}

.info-popover p + p {
  margin-top: 0.65rem;
}

.info-popover code,
footer code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--accent);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  padding: 0.85rem 0;
}

.statline-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.35rem;
}

.statline {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--ink-secondary);
  font-size: 0.84rem;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  display: inline-block;
  flex: 0 0 auto;
}

.swatch-channel {
  border-radius: 3px;
  background: var(--accent);
}

.swatch-agent {
  border-radius: 50%;
  border: 2px solid var(--ink-secondary);
  background: var(--surface-3);
}

.swatch-route {
  border-radius: 50%;
  background: var(--route);
}

.swatch-lead {
  border-radius: 2px;
  transform: rotate(45deg) scale(0.85);
  background: var(--route);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
}

.group-switch,
.view-switch,
.zoom-controls {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 2px;
  border-radius: var(--radius-control);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-1);
  gap: 2px;
}

.switch-btn,
.icon-btn,
.zoom-readout,
.control-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.switch-btn {
  padding: 0.35rem 0.8rem;
}

.switch-btn[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.switch-btn[aria-pressed='false']:hover {
  background: var(--surface-2);
}

.control-button {
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-color: var(--hairline-strong);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  line-height: 1.2;
}

.control-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.control-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.zoom-controls .control-button {
  min-height: 38px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  padding: 0.35rem 0.7rem;
}

.zoom-controls .control-button:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.icon-btn {
  min-width: 38px;
  padding: 0.3rem 0.55rem;
  font-size: 1.05rem;
  line-height: 1;
}

.zoom-readout {
  min-width: 54px;
  padding: 0.3rem 0.45rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
}

.icon-btn:hover,
.zoom-readout:hover {
  background: var(--surface-2);
  color: var(--accent);
}

:is(.switch-btn, .icon-btn, .control-button, .hub-select-btn, .hub-expander-btn, .agent-node, .channel-node, .list-agent-btn, .list-channel-btn):active {
  transform: translateY(1px);
}

/* Main Layout */
.atlas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 364px;
  gap: 1rem;
  align-items: start;
}

.network-panel {
  min-width: 0;
}

/* Spatial Graph Stage (camera pan/zoom without native scrollbars) */
.graph-stage {
  position: relative;
  width: 100%;
  min-height: 320px;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-panel);
  background:
    radial-gradient(circle at 24% 18%, rgba(124, 224, 182, 0.06), transparent 46%),
    radial-gradient(circle at 80% 78%, rgba(244, 207, 110, 0.04), transparent 44%),
    radial-gradient(rgba(218, 238, 232, 0.09) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--surface-1);
}

.graph-stage.is-panning {
  cursor: grabbing;
  user-select: none;
}

.graph-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.graph-world.is-animating {
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.graph-stage:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.graph-wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.graph-nodes {
  position: relative;
  z-index: 1;
}

.wire-path {
  fill: none;
  stroke: rgba(182, 201, 195, 0.28);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.wire-path.is-route {
  stroke: var(--route);
  stroke-width: 2.5;
}

.bridge-arc-casing {
  fill: none;
  stroke: var(--surface-1);
  stroke-width: 5.5;
  stroke-linecap: round;
  opacity: 0.9;
}

.bridge-arc {
  fill: none;
  stroke: var(--route);
  stroke-width: 2.1;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  opacity: 0.9;
}

.bridge-dot {
  fill: var(--route);
  stroke: var(--surface-1);
  stroke-width: 2;
}

.stage-hint {
  margin: 0.75rem 0 1.5rem;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

/* Graph Cluster & Nodes */
.cluster {
  position: absolute;
  margin: 0;
}

.hub-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-panel);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  overflow: hidden;
}

.cluster.is-open .hub-card {
  border-color: rgba(124, 224, 182, 0.45);
  background: var(--surface-elevated);
}

.cluster.route-active .hub-card {
  border-color: var(--route);
  box-shadow: inset 0 0 0 1px var(--route);
}

.hub-head {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.25rem;
  padding-right: 0.45rem;
}

.hub-heading {
  display: flex;
  align-self: stretch;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
}

.hub-select-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 72px;
  padding: 0.5rem 0.45rem 0.5rem 0.8rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .hub-card:hover,
  .cluster.is-open .hub-card:hover {
    background: var(--surface-3);
  }
}

.hub-meta {
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  flex: 1 1 auto;
}

.hub-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.hub-title {
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hub-sub-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--ink-secondary);
}

.hub-count {
  font-variant-numeric: tabular-nums;
}

.hub-expander-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 auto;
  border-radius: var(--radius-control);
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.hub-expander-btn:hover:not(:disabled) .hub-expander .ring,
.list-expander-btn:hover:not(:disabled) .hub-expander .ring {
  stroke: var(--accent);
}

.hub-expander-btn:disabled {
  cursor: default;
  opacity: 0.45;
}

/* Circle and +/- mark are ONE svg, so they stay concentric at any zoom or display scaling. */
.hub-expander {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 0;
}

.hub-expander svg {
  display: block;
  width: 30px;
  height: 30px;
  overflow: visible;
}

.hub-expander .ring {
  fill: var(--surface-3);
  stroke: var(--hairline-strong);
  stroke-width: 1;
}

.hub-expander .mark {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
}

.cluster.is-open .hub-expander .ring,
.list-group.is-open .list-expander-btn .hub-expander .ring {
  fill: var(--accent);
  stroke: var(--accent);
}

.cluster.is-open .hub-expander .mark,
.list-group.is-open .list-expander-btn .hub-expander .mark {
  stroke: var(--accent-ink);
}

/* Collapsed mini-avatar strip inside hub */
.hub-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.8rem 0.6rem;
}

.avatar-stack {
  display: flex;
  align-items: center;
  padding-left: 2px;
}

.avatar-stack > * {
  margin-left: -6px;
  border: 2px solid var(--surface-2);
}

.avatar-stack > *:first-child {
  margin-left: 0;
}

.stack-more {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.route-pill,
.archive-badge,
.lead-pill,
.selected-pill,
.neutral-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.48rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}

.route-pill,
.selected-pill,
.lead-pill {
  background: var(--route);
  color: var(--route-ink);
}

.archive-badge,
.neutral-pill {
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  color: var(--ink-secondary);
}

.hub-members {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agent-node,
.channel-node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.agent-node {
  padding: 0.3rem 0.8rem 0.3rem 0.45rem;
  border-radius: var(--radius-pill);
}

.channel-node {
  padding: 0.3rem 0.75rem 0.3rem 0.5rem;
  border-radius: 12px;
}

.agent-node:hover,
.channel-node:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.agent-node.is-selected,
.channel-node.is-selected {
  background: #23281b;
  border-color: var(--route);
  box-shadow: inset 0 0 0 1px var(--route);
}

.node-copy {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
  flex: 1 1 auto;
}

.node-name {
  font-size: 0.87rem;
  font-weight: 560;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--route);
  font-weight: 600;
}

.node-badge-muted {
  color: var(--ink-secondary);
}

.cluster-empty-note {
  position: absolute;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-control);
  border: 1px dashed var(--hairline-strong);
  color: var(--ink-secondary);
  font-size: 0.86rem;
  background: var(--surface-1);
}

/* Avatars */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  user-select: none;
  background: hsl(var(--avatar-hue, 175) 36% 24%);
  color: #f3f9f6;
  font-weight: 700;
  line-height: 1;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

.avatar-agent {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
}

.is-selected .avatar-agent,
.route-active .hub-card .avatar-agent {
  border-color: var(--route);
}

.avatar-channel {
  border-radius: var(--radius-control);
  border: 1px solid rgba(218, 238, 232, 0.24);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px rgba(9, 17, 17, 0.35);
}

.avatar-channel img {
  object-position: center center;
  filter: brightness(0.92) contrast(1.02);
}

.avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 0.68rem;
}

.avatar-md {
  width: 38px;
  height: 38px;
  font-size: 0.85rem;
}

.avatar-hub {
  width: 46px;
  height: 46px;
  font-size: 0.95rem;
}

.avatar-lg {
  width: 68px;
  height: 68px;
  font-size: 1.35rem;
}

mark {
  background: var(--route);
  color: var(--route-ink);
  border-radius: 3px;
  padding: 0 0.14em;
}

/* List / Tree View */
.list-network {
  display: grid;
  gap: 0.85rem;
}

.list-group {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
  overflow: hidden;
}

.list-group.route-active {
  border-color: var(--route);
}

.list-group-head {
  display: flex;
  align-items: center;
  background: var(--surface-2);
}

.list-group-heading {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem;
}

.list-group-select {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 64px;
  padding: 0.7rem 0.55rem 0.7rem 1rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-group-select:hover {
  background: rgba(255, 255, 255, 0.03);
}

.list-group-copy {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
}

.list-group-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.list-group-name {
  font-size: 1.03rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.list-group-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-secondary);
  font-size: 0.86rem;
  min-width: 0;
}

.list-group-role-preview {
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.list-expander-btn {
  display: grid;
  place-items: center;
  width: 52px;
  min-width: 44px;
  min-height: 64px;
  flex: 0 0 auto;
  border: 0;
  border-left: 1px solid var(--hairline);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.list-expander-btn:hover:not(:disabled) {
  background: var(--surface-3);
}

.list-expander-btn:disabled {
  opacity: 0.45;
  cursor: default;
}



.list-group-body {
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--hairline);
}

.list-group-desc {
  margin: 0 0 0.85rem;
  color: var(--ink-secondary);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.list-item-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: stretch;
  gap: 0.6rem;
}

.list-item-grid > li {
  display: flex;
  min-width: 0;
}

.list-agent-btn,
.list-channel-btn {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  width: 100%;
  min-height: 54px;
  padding: 0.5rem 0.72rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-agent-btn:hover,
.list-channel-btn:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.list-agent-btn.is-selected,
.list-channel-btn.is-selected {
  border-color: var(--route);
  box-shadow: inset 0 0 0 1px var(--route);
  background: #23281b;
}

.list-item-copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
  flex: 1 1 auto;
}

.list-item-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.list-item-name {
  font-size: 0.94rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.list-agent-role {
  color: var(--ink-secondary);
  font-size: 0.82rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Detail Panel (Desktop) */
.detail-panel {
  position: sticky;
  top: calc(var(--toolbar-h, 0px) + 0.5rem);
  max-height: calc(100dvh - var(--toolbar-h, 0px) - 1rem);
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 1rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
}

.detail-head h2,
.mobile-sheet-header h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 650;
  color: var(--ink);
}

.details {
  margin-top: 0.85rem;
  padding-bottom: 1.25rem;
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.detail-hero h3 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.detail-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.detail-role {
  margin: 0.3rem 0 0;
  color: var(--ink-secondary);
  font-size: 0.95rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.detail-section-title {
  margin: 0.95rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-channel-list,
.quick-agent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.detail-channel-btn,
.quick-agent-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.detail-channel-btn:hover,
.quick-agent-btn:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.detail-channel-info {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  flex: 1 1 auto;
}

.detail-channel-name {
  font-size: 0.94rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-channel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.detail-intro {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.94rem;
  line-height: 1.5;
}

.empty-state,
.error-state {
  padding: 1.5rem;
  border-radius: var(--radius-panel);
  border: 1px dashed var(--hairline-strong);
  background: var(--surface-1);
  color: var(--ink-secondary);
}

.error-state {
  border-color: var(--danger);
  color: #ffd5c9;
}

.empty-state p,
.error-state p {
  margin: 0 0 0.85rem;
}

/* Mobile Dialog Sheet */
.mobile-sheet {
  width: min(100%, 640px);
  max-width: 100%;
  max-height: 84dvh;
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-bottom: 0;
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  background: var(--surface-1);
  color: var(--ink);
}

.mobile-sheet::backdrop {
  background: rgba(4, 9, 9, 0.72);
}

.mobile-sheet-inner {
  padding: 1rem 1rem 1.35rem;
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hairline);
}

/* Footer */
footer {
  padding: 1.15rem 0 2rem;
  color: var(--ink-secondary);
  font-size: 0.88rem;
}

footer p {
  margin: 0;
}

/* Responsive */
@media (max-width: 1060px) {
  .masthead {
    grid-template-columns: 1fr auto;
  }

  .search-bar {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 859px) {
  .atlas-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    display: none;
  }

  .toolbar-actions {
    width: 100%;
  }

}

@media (max-width: 560px) {
  .masthead,
  main,
  footer {
    width: min(100% - 1.25rem, 1560px);
  }

  .masthead {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .snapshot-meta {
    justify-content: space-between;
  }

  .snapshot-stamp {
    text-align: left;
  }

  .toolbar {
    gap: 0.75rem;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .toolbar-actions > #toggle-all {
    flex: 1 1 auto;
  }

  .list-item-grid {
    grid-template-columns: 1fr;
  }

  .list-group-select {
    padding: 0.7rem 0.45rem 0.7rem 0.75rem;
  }
}

@media (max-width: 420px) {
  .group-switch,
  .view-switch {
    width: 100%;
  }

  .group-switch .switch-btn,
  .view-switch .switch-btn {
    flex: 1 1 0;
    min-height: 44px;
    text-align: center;
  }

  .zoom-controls {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hub-card,
  .agent-node,
  .channel-node,
  .list-agent-btn,
  .list-channel-btn,
  .detail-channel-btn,
  .quick-agent-btn,
  .control-button,
  .switch-btn {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
  }
}

/* Square channel mini-avatars read better side by side than overlapped */
.hub-agent .avatar-stack {
  gap: 4px;
  padding-left: 0;
}

.hub-agent .avatar-stack > * {
  margin-left: 0;
  border-width: 1px;
}

.list-group.is-open .list-group-role-preview {
  display: none;
}

/* The map grows with its content and the page scrolls natively; keep the controls reachable. */
@media (min-width: 860px) {
  .toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  /* Full-bleed band behind the toolbar: it only shows while stuck, so the text keeps the content
     grid alignment instead of sitting glued to the edge of a box. */
  .toolbar::before {
    content: '';
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    left: calc(50% - 50vw);
    width: 100vw;
    background: rgba(9, 17, 17, 0.88);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hairline);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .toolbar.is-stuck::before {
    opacity: 1;
  }
}

body {
  overflow-x: clip;
}

/* Footer: author card */
.footer-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-panel);
  background:
    radial-gradient(ellipse 60% 120% at 0% 0%, rgba(41, 88, 76, 0.3), transparent 70%),
    radial-gradient(rgba(218, 238, 232, 0.07) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--surface-1);
}

.footer-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(124, 224, 182, 0) 55%, var(--route));
  opacity: 0.8;
}

.footer-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr) minmax(0, 0.8fr);
  gap: 1.75rem 2.5rem;
  padding: 1.75rem clamp(1rem, 3vw, 2rem) 1.5rem;
}

.footer-id {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.footer-monogram {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: var(--radius-control);
  border: 1px solid rgba(124, 224, 182, 0.45);
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.footer-name {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.footer-role {
  margin-top: 0.2rem !important;
  color: var(--route);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.footer-pitch {
  margin-top: 1rem !important;
  max-width: 46ch;
  color: var(--ink-secondary);
  font-size: 0.95rem;
  line-height: 1.55;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.15rem;
}

.footer-cta,
.footer-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-control);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.footer-cta {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

.footer-link-btn {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
}

.footer-cta:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.footer-link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.footer-heading {
  margin: 0 0 0.7rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-project p {
  max-width: 42ch;
  color: var(--ink-secondary);
  font-size: 0.93rem;
  line-height: 1.55;
}

.footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.footer-tags li {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.8rem;
}

.footer-nav ul {
  display: grid;
  gap: 0.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}

.footer-nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  padding: 0.95rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--hairline);
  background: rgba(9, 17, 17, 0.55);
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.footer-base .footer-note {
  min-width: 0;
  flex: 1 1 24rem;
  text-align: center;
}

.footer-stack {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
}

@media (max-width: 1060px) {
  .footer-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .footer-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .footer-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-base .footer-note {
    text-align: left;
  }

  .footer-actions > a {
    flex: 1 1 100%;
  }
}

/* Details */
main:focus,
main:focus-visible {
  outline: none;
}

.hub-expander-btn:focus-visible,
.list-expander-btn:focus-visible {
  outline-offset: -3px;
}

/* Copyable prompt templates in the details sheet */
.prompt-hint {
  margin: 0 0 0.6rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.prompt-box {
  margin-bottom: 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  background: var(--surface-2);
}

.prompt-box[open] {
  border-color: var(--hairline-strong);
}

.prompt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.45rem 0.75rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  list-style: none;
}

.prompt-summary::-webkit-details-marker {
  display: none;
}

.prompt-summary:hover {
  color: var(--accent);
}

.prompt-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.prompt-chevron {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 0.2rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}

.prompt-box[open] > .prompt-summary .prompt-chevron {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.prompt-body {
  padding: 0 0.75rem 0.75rem;
}

.prompt-text {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.prompt-status {
  min-height: 1.2em;
  color: var(--accent);
  font-size: 0.82rem;
}

.prompt-box.is-nested {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .prompt-chevron {
    transition: none;
  }
}

/* Mobile: list only (the graph is not readable on small screens). */
@media (max-width: 859px) {
  .view-switch,
  #zoom-controls,
  .graph-stage,
  .stage-hint {
    display: none !important;
  }
}
