/* VMS 중심 연결 구조: 입력 장비 → VMS → 출력 채널, AI는 VMS 확장 모듈 */
#video-diagram .diagram {
  grid-template-columns: minmax(270px, 1.25fr) 64px minmax(180px, .8fr) 64px minmax(360px, 1.35fr) 84px minmax(250px, 1.1fr);
}

#video-diagram .input-groups {
  position: relative;
  grid-column: 1;
  overflow: visible;
}

#video-diagram .core-stack {
  grid-column: 5;
  align-self: start;
}

#video-diagram .output-flow {
  grid-column: 6;
}

#video-diagram .outputs {
  grid-column: 7;
  align-self: start;
  margin-top: 150px;
}

#video-diagram .mobile-network-card {
  grid-column: 3;
  align-self: end;
}

#video-diagram .group-box {
  position: relative;
}

/* 시설·이동형 CCTV 각각에서 VMS로 향하는 직접 화살표 */
#video-diagram .fixed-cctv::after {
  content: "";
  position: absolute;
  z-index: 2;
  right: -380px;
  top: 50%;
  width: 368px;
  border-top: 2px solid var(--red);
}

#video-diagram .fixed-cctv::before {
  content: "";
  position: absolute;
  z-index: 2;
  right: -380px;
  top: calc(50% - 5px);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--red);
}

/* 라우터는 이동형 CCTV 카드의 우측에 위치하는 전용 통신 장비입니다. */
#video-diagram .mobile-router-card {
  position: absolute;
  z-index: 4;
  right: -166px;
  bottom: 105px;
  width: 150px;
  padding: 10px 8px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 7px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(26,42,67,.07);
}

#video-diagram .mobile-router-card .router-symbol {
  width: 42px;
  height: 44px;
  margin: 0;
  transform: scale(.7);
  transform-origin: center;
}

#video-diagram .mobile-router-card strong,
#video-diagram .mobile-router-card span {
  display: block;
}

#video-diagram .mobile-router-card strong { font-size: 12px; }
#video-diagram .mobile-router-card span { color: var(--muted); font-size: 10px; line-height: 1.4; }

/* 이동형 CCTV 카드 안의 LTE/5G 라우터 → 통신망 → VMS 흐름 */
#video-diagram .mobile-network-card::before {
  content: "";
  position: absolute;
  width: 112px;
  left: -112px;
  top: 50%;
  border-top: 2px solid var(--red);
}

#video-diagram .mobile-network-card {
  position: relative;
}

/* 통신망에서 VMS로 올라가는 연결선 */
#video-diagram .mobile-network-card::after {
  content: "";
  position: absolute;
  right: -132px;
  top: -96px;
  width: 118px;
  height: 104px;
  border-top: 2px solid var(--red);
  border-right: 2px solid var(--red);
}

/* 출력 화살표는 AI가 아닌 VMS 카드의 높이에 맞춥니다. */
#video-diagram .output-flow {
  align-self: start;
  margin-top: 160px;
  display: none;
}

/* VMS에서 각 활용 채널로 향하는 개별 대각선 연결 */
#video-diagram .output-card::before {
  left: -120px;
  width: 112px;
  border-top: 2px solid #78c9e1;
  transform-origin: right center;
}

#video-diagram .output-card::after {
  left: -10px;
  border-left-color: #78c9e1;
}

/* 통합관제센터는 VMS의 위쪽 방향, 모바일·API는 아래쪽 방향으로 연결 */
#video-diagram .output-card:nth-child(1)::before {
  transform: translateY(-50%) rotate(-20deg);
}

#video-diagram .output-card:nth-child(2)::before {
  transform: translateY(-50%) rotate(12deg);
}

#video-diagram .output-card:nth-child(3)::before {
  transform: translateY(-50%) rotate(28deg);
}

@media (max-width: 1220px) {
  #video-diagram .core-stack,
  #video-diagram .outputs {
    grid-column: 1 / -1;
  }

  #video-diagram .mobile-network-card {
    grid-column: 1 / -1;
  }

  #video-diagram .outputs {
    margin-top: 0;
  }

  #video-diagram .mobile-router-card {
    position: static;
    width: 100%;
    margin-top: 12px;
  }

  #video-diagram .output-flow {
    grid-column: 1 / -1;
  }

  #video-diagram .output-card::before,
  #video-diagram .output-card::after {
    display: none;
  }

  #video-diagram .fixed-cctv::before,
  #video-diagram .fixed-cctv::after,
  #video-diagram .mobile-network-card::before,
  #video-diagram .mobile-network-card::after {
    display: none;
  }

  #video-diagram .output-flow {
    margin-top: 0;
  }
}
