:root {
  --bg: #05070c;
  --panel: #0c1320;
  --panel-2: #0f1a2a;
  --ink: #f6f8ff;
  --muted: #c5ccde;
  --line: #203149;
  --accent: #34d1ff;
  --warn: #ff9d57;
  --ok: #7cffbf;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Familjen Grotesk', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(255, 89, 137, 0.16) 0%, transparent 42%),
    radial-gradient(circle at 90% 5%, rgba(52, 209, 255, 0.17) 0%, transparent 38%),
    radial-gradient(circle at 50% 100%, rgba(101, 255, 155, 0.09) 0%, transparent 40%),
    var(--bg);
  min-height: 100vh;
}
body:not([data-fonts="ready"]) .page {
  visibility: hidden;
}

.mast {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 9, 16, 0.92);
  backdrop-filter: blur(4px);
}
.mast-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.title {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.title h1 {
  margin: 0;
  font-family: 'Chakra Petch', monospace;
  font-size: 1rem;
  letter-spacing: 0.12em;
}
.title .sub {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: end;
}
.controls label {
  display: grid;
  gap: 0.24rem;
}
.controls label > span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  color: var(--ink);
}
input,
select {
  border: 1px solid #2a3e5e;
  border-radius: 5px;
  background: #0b1525;
  padding: 0.42rem 0.5rem;
}
button {
  border: 1px solid #3a5b84;
  border-radius: 5px;
  background: #101f33;
  padding: 0.43rem 0.62rem;
  cursor: pointer;
}
button:hover,
button:focus-visible {
  background: #16304c;
}

.page {
  width: min(1600px, 98vw);
  margin: 0.8rem auto 1.4rem;
}
.canvas-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(10, 16, 26, 0.95), rgba(8, 12, 20, 0.95));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  position: relative;
}

#atlas-svg {
  display: block;
  width: 100%;
  min-height: 72vh;
  touch-action: none;
}

.grid-underlay line {
  stroke: rgba(130, 156, 196, 0.12);
  stroke-width: 1;
}

.atlas-edge {
  fill: none;
  stroke-width: 2;
  stroke: hsl(var(--hue) 95% 58%);
  opacity: 0.78;
  vector-effect: none;
}
.edge-type-depends-on { stroke: #8be9ff; }
.edge-type-emits-to { stroke: #ff9f6e; }
.edge-type-consumes-from { stroke: #7fffd4; }
.edge-type-wraps { stroke: #f6d365; }
.edge-type-replaces { stroke: #ff78c6; }

.atlas-node {
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), opacity 220ms ease;
}
.atlas-node .node-shape {
  fill: hsl(var(--hue) 76% calc(24% + (7 - min(var(--depth), 6)) * 6%));
  stroke: hsl(var(--hue) 94% calc(64% - min(var(--depth), 6) * 5%));
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.atlas-node .node-shape.inner {
  fill: transparent;
  opacity: 0.9;
}
.node-glyph {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  fill: var(--ink);
  pointer-events: none;
}
.node-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  fill: var(--ink);
  paint-order: stroke;
  stroke: rgba(5, 7, 12, 0.85);
  stroke-width: 3;
  stroke-linejoin: round;
  pointer-events: none;
}

.atlas-node[data-focus="1"] .node-shape {
  filter: drop-shadow(0 0 12px rgba(92, 225, 230, 0.75));
  stroke-width: 3;
}
.atlas-node.parent-focus .node-shape {
  filter: drop-shadow(0 0 7px rgba(255, 210, 63, 0.55));
}

.atlas-node[data-life="pending"] {
  opacity: 0.34;
  animation: pulse-node 0.5s ease-in-out infinite alternate;
}
.atlas-edge[data-life="pending"] {
  opacity: 0.45;
  stroke-dasharray: 7 5;
  animation: march-edge 0.9s linear infinite;
}

.atlas-node[data-life="active"] {
  opacity: 1;
}
.atlas-node[data-life="active"] .node-shape {
  filter: drop-shadow(0 0 9px hsla(var(--hue), 95%, 58%, 0.78));
}
.atlas-edge[data-life="active"] {
  opacity: 0.9;
}

.atlas-node[data-life="inactive"] {
  opacity: 0.18;
  animation: none;
}
.atlas-node[data-life="inactive"] .node-shape {
  filter: saturate(0.25) brightness(0.6);
}
.atlas-edge[data-life="inactive"] {
  opacity: 0.25;
  stroke-dasharray: 4 6;
  animation: none;
}

.stream-dot {
  fill: #f6f8ff;
  opacity: 0.92;
}
.stream-dot.dot-event { fill: #34d1ff; }
.stream-dot.dot-targeted { fill: #ffd23f; }
.stream-dot.dot-agora { fill: #ff78c6; }

#atlas-svg[data-zoom-level="1"] .node-label,
#atlas-svg[data-zoom-level="1"] .stream-dot,
#atlas-svg[data-zoom-level="2"] .stream-dot {
  display: none;
}
#atlas-svg[data-zoom-level="1"] .atlas-edge {
  opacity: 0.45;
}
#atlas-svg[data-zoom-level="2"] .node-label {
  opacity: 0.35;
}

#atlas-svg[data-degrade="1"] .stream-dot {
  display: none;
}
#atlas-svg[data-degrade="2"] .node-label {
  display: none;
}
#atlas-svg[data-degrade="3"] * {
  animation-play-state: paused !important;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  padding: 0.6rem 0.2rem 0;
  align-items: center;
}
.crumb {
  border: 1px solid #2a3e5e;
  border-radius: 999px;
  background: #0c1628;
  color: var(--ink);
  padding: 0.24rem 0.58rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
}
.crumb.empty {
  border-style: dashed;
  color: var(--muted);
}
.crumb-sep {
  color: var(--muted);
}

@keyframes pulse-node {
  from { opacity: 0.22; }
  to { opacity: 0.42; }
}
@keyframes march-edge {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -18; }
}

@media (max-width: 1100px) {
  .controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .mast-top { flex-direction: column; align-items: flex-start; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
