:root {
  --bg: #08111f;
  --panel: rgba(13, 24, 42, 0.86);
  --panel-2: rgba(18, 32, 55, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8f2ff;
  --muted: #94a8c7;
  --sky: #8fe8ff;
  --blue: #3db4ff;
  --teal: #36e0bf;
  --gold: #ffd166;
  --rose: #ff5c7c;
  --orange: #ff9f5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 40px),
    linear-gradient(150deg, #07101d 0%, #0a1628 48%, #101427 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.arch-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(8, 17, 31, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.arch-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.arch-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 7px;
}

.arch-brand strong,
.arch-brand small {
  display: block;
}

.arch-brand strong {
  font-size: 16px;
  letter-spacing: 0;
}

.arch-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.arch-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.arch-nav a,
.stage-filter,
.flow-filter {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.arch-nav a:hover,
.stage-filter:hover,
.flow-filter:hover {
  border-color: rgba(143, 232, 255, 0.42);
  background: rgba(143, 232, 255, 0.09);
  transform: translateY(-1px);
}

.arch-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  max-width: 1520px;
  margin: 0 auto;
  padding: 42px 24px 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.arch-hero h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(32px, 5vw, 60px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 860px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.hero-stats {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  min-width: 300px;
}

.hero-stats span {
  display: block;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.hero-stats strong {
  display: block;
  color: var(--sky);
  font-size: 22px;
  line-height: 1;
  margin-bottom: 5px;
}

.arch-workbench {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 24px 42px;
}

.arch-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-block,
.detail-panel,
.diagram-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.control-block,
.detail-panel {
  padding: 16px;
}

.control-block h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.stage-filter,
.flow-filter {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.stage-filter.active,
.flow-filter.active {
  color: #04101e;
  border-color: transparent;
  background: linear-gradient(135deg, var(--sky), var(--teal));
}

.detail-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.detail-panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.detail-panel p {
  color: var(--muted);
  line-height: 1.6;
  margin: 12px 0 0;
  font-size: 13px;
}

#detailMeta {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
}

#detailMeta div {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

#detailMeta dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#detailMeta dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 12px;
}

.diagram-shell {
  overflow: auto;
  padding: 14px;
}

.arch-svg {
  display: block;
  min-width: 1120px;
  width: 100%;
  height: auto;
}

.svg-bg {
  fill: url(#pageGlow);
  stroke: rgba(255, 255, 255, 0.12);
}

.lane rect,
.feedback-lane rect {
  fill: rgba(255, 255, 255, 0.035);
  stroke: rgba(255, 255, 255, 0.08);
}

.lane text {
  fill: #8da4c6;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.node {
  cursor: pointer;
  outline: none;
  transition: opacity 0.18s ease, filter 0.18s ease;
}

.node rect {
  fill: rgba(14, 28, 48, 0.96);
  stroke: rgba(143, 232, 255, 0.22);
  stroke-width: 1.4;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.28));
  transition: fill 0.18s ease, stroke 0.18s ease, stroke-width 0.18s ease;
}

.node text {
  pointer-events: none;
  fill: #dfefff;
  font-size: 14px;
  font-weight: 800;
}

.node tspan:first-child {
  fill: #ffffff;
  font-size: 16px;
}

.node tspan:not(:first-child) {
  fill: #9db1cd;
  font-size: 12px;
  font-weight: 700;
}

.edge {
  fill: none;
  stroke: rgba(140, 164, 197, 0.52);
  stroke-width: 2.4;
  marker-end: url(#arrow);
  transition: opacity 0.18s ease, stroke 0.18s ease, stroke-width 0.18s ease;
}

marker path {
  fill: #8ca4c5;
}

.arch-svg.stage-mode .node,
.arch-svg.stage-mode .edge,
.arch-svg.stage-mode .lane {
  opacity: 0.18;
}

.arch-svg.stage-mode .node.stage-active,
.arch-svg.stage-mode .lane.stage-active {
  opacity: 1;
}

.arch-svg.stage-mode .edge.stage-active {
  opacity: 0.72;
}

.arch-svg.flow-mode .node,
.arch-svg.flow-mode .edge {
  opacity: 0.16;
}

.arch-svg.flow-mode .edge.flow-active {
  opacity: 1;
  stroke: var(--gold);
  stroke-width: 4;
}

.arch-svg.flow-mode .node.flow-active {
  opacity: 1;
}

.node.selected rect,
.node.flow-active rect,
.node.stage-active rect {
  stroke: var(--sky);
  stroke-width: 2.6;
}

.node.selected rect {
  fill: rgba(21, 48, 80, 0.98);
}

.edge.related {
  opacity: 1;
  stroke: var(--teal);
  stroke-width: 4;
}

.node.related rect {
  stroke: rgba(54, 224, 191, 0.75);
}

@media (max-width: 980px) {
  .arch-header,
  .arch-hero,
  .arch-workbench {
    padding-left: 16px;
    padding-right: 16px;
  }

  .arch-header,
  .arch-hero,
  .arch-workbench {
    grid-template-columns: 1fr;
  }

  .arch-header {
    align-items: flex-start;
  }

  .arch-workbench {
    display: flex;
    flex-direction: column;
  }

  .arch-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-panel {
    grid-column: 1 / -1;
  }

  .hero-stats {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .arch-nav {
    justify-content: flex-start;
  }

  .arch-controls {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr;
  }

  .diagram-shell {
    padding: 8px;
  }

  .arch-svg {
    min-width: 1040px;
  }
}
