* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #020202;
  color: #f2f2f2;
  font-family: "Ubuntu Mono", monospace;
}

body {
  display: flex;
  flex-direction: column;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hero {
  position: relative;
  border-bottom: 1px solid #303030;
  padding: 1.5rem 2.5rem 1.25rem;
  background: linear-gradient(180deg, rgba(57, 255, 20, 0.12) 0%, rgba(2, 2, 2, 0) 100%);
}

.hero__home {
  position: absolute;
  top: 1.5rem;
  right: 2.5rem;
  color: #9e9e9e;
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.hero__home:hover {
  color: #39ff14;
}

.hero__brand h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: #39ff14;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero__tagline {
  margin: 0.75rem 0 0;
  max-width: 720px;
  color: #d0d0d0;
  font-size: 1rem;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 2.5rem 3rem;
  background: radial-gradient(circle at top left, rgba(57, 255, 20, 0.08), transparent 55%), #000;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
  border: 1px solid #2d2d2d;
  border-radius: 14px;
  background: rgba(4, 4, 4, 0.95);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.65);
}

.controls__buttons {
  display: flex;
  gap: 0.75rem;
}

.control-button {
  background: none;
  border: 1px solid #2a2a2a;
  color: #e6e6e6;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.control-button--primary {
  border-color: #39ff14;
  color: #39ff14;
}

.control-button:hover {
  border-color: #39ff14;
  color: #39ff14;
  background: rgba(57, 255, 20, 0.1);
}

.control-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #2a2a2a;
  color: #777;
  background: none;
}

.controls__note {
  margin: 0;
  color: #9e9e9e;
  font-size: 0.9rem;
}

.pipeline-wrapper {
  position: relative;
  border: 1px solid #2d2d2d;
  border-radius: 14px;
  padding: 2rem;
  background: rgba(4, 4, 4, 0.95);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.pipeline {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  --pipeline-gap: 0rem;
  gap: var(--pipeline-gap);
  overflow: visible;
}

.encoder-group {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.encoder-path {
  display: flex;
  align-items: center;
  gap: 0;
  overflow: visible;
}

.split-connector {
  display: flex;
  align-items: center;
  position: relative;
}

.split-connector__horizontal {
  position: relative;
  width: 60px;
  height: 4px;
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.split-connector__horizontal::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(57, 255, 20, 1) 0 14px, rgba(57, 255, 20, 0.08) 14px 28px);
  background-size: 32px 100%;
  background-position: 0 0;
  opacity: 0;
  will-change: background-position;
  transform: translateZ(0);
}

.app.is-running .split-connector__horizontal::before {
  opacity: 1;
  animation: flow-horizontal 1.2s linear infinite;
}

.split-connector__vertical {
  position: absolute;
  left: 60px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: calc(100% + 28rem);
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.split-connector__vertical::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(180deg, rgba(57, 255, 20, 1) 0 14px, rgba(57, 255, 20, 0.08) 14px 28px);
  background-size: 100% 32px;
  background-position: 0 0;
  opacity: 0;
  will-change: background-position;
  transform: translateZ(0);
}

.app.is-running .split-connector__vertical::before {
  opacity: 1;
  animation: flow-vertical 1.1s linear infinite;
}

.merge-connector {
  display: flex;
  align-items: center;
  position: relative;
}

.merge-connector__vertical {
  position: absolute;
  right: 60px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: calc(100% + 28rem);
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.merge-connector__vertical::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(180deg, rgba(57, 255, 20, 1) 0 14px, rgba(57, 255, 20, 0.08) 14px 28px);
  background-size: 100% 32px;
  background-position: 0 0;
  opacity: 0;
  will-change: background-position;
  transform: translateZ(0);
}

.app.is-running .merge-connector__vertical::before {
  opacity: 1;
  animation: flow-vertical 1.1s linear infinite;
}

.merge-connector__horizontal {
  position: relative;
  width: 60px;
  height: 4px;
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.merge-connector__horizontal::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(57, 255, 20, 1) 0 14px, rgba(57, 255, 20, 0.08) 14px 28px);
  background-size: 32px 100%;
  background-position: 0 0;
  opacity: 0;
  will-change: background-position;
  transform: translateZ(0);
}

.app.is-running .merge-connector__horizontal::before {
  opacity: 1;
  animation: flow-horizontal 1.2s linear infinite;
}

.connection--split-to-encoder {
  flex: 0 0 auto;
  width: 60px;
}

.connection--packager-to-merge {
  flex: 0 0 auto;
  width: 60px;
}

.connection {
  position: relative;
  flex: 1;
  min-width: 60px;
  height: 4px;
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.node {
  position: relative;
  width: 110px;
  min-height: 120px;
  padding: 0.8rem 0.7rem;
  border: 2px solid #2d2d2d;
  border-radius: 12px;
  background: rgba(10, 10, 10, 0.92);
  text-align: center;
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.05);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.node--encoder {
  width: 180px;
  min-height: 280px;
  padding: 0.8rem 0.7rem;
  text-align: left;
}

.node__label {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: rgba(57, 255, 20, 0.2);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-left: 0.3rem;
}

.node h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #39ff14;
}

.node p {
  margin: 0;
  color: #b5b5b5;
  font-size: 0.7rem;
  line-height: 1.4;
}

.node__icon {
  margin: 0.6rem auto;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.node__icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(57, 255, 20, 0.3));
}

.node__video {
  margin: 0.45rem auto 0.6rem;
  width: 80px;
  height: 50px;
  border: 1px solid #39ff14;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #000;
}

.node__video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.node--encoder .node__video {
  margin: 0;
  width: 110px;
  height: 66px;
}

.node--encoder .node__video video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.node--encoder p {
  margin-top: 0.8rem;
  font-size: 0.7rem;
  color: #a9a9a9;
}

.encoder__ladder {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.encoder__rendition {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 0.6rem;
  align-items: center;
}

.encoder__loader {
  width: 32px;
  aspect-ratio: 1;
  --g: conic-gradient(from -90deg at 5.33px 5.33px, #39ff14 90deg, #0000 0);
  background: var(--g), var(--g), var(--g);
  background-size: 50% 50%;
  animation: encoder-loader 1s infinite;
}

.encoder__media {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.encoder__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #39ff14;
}

.encoder__video {
  margin: 0;
  width: 90px;
  height: 54px;
  border: 1px solid #39ff14;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #000;
}

.encoder__video video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

@keyframes encoder-loader {
  0% {
    background-position: 0 0, 5.33px 5.33px, 10.67px 10.67px;
  }
  33% {
    background-position: -16px 0, 5.33px 5.33px, 10.67px 10.67px;
  }
  66% {
    background-position: -16px 0, 5.33px 21.33px, 10.67px 10.67px;
  }
  100% {
    background-position: -16px 0, 5.33px 21.33px, 26.67px 10.67px;
  }
}

.node__domain {
  display: inline-block;
  color: #39ff14;
  font-size: 0.55rem;
  word-break: break-all;
}

.connection {
  position: relative;
  flex: 1;
  min-width: 60px;
  height: 4px;
  border-radius: 4px;
  background: rgba(57, 255, 20, 0.25);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.22);
}

.connection::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(57, 255, 20, 1) 0 14px, rgba(57, 255, 20, 0.08) 14px 28px);
  background-size: 32px 100%;
  background-position: 0 0;
  opacity: 0;
  will-change: background-position;
  transform: translateZ(0);
}

.app.is-running .connection::before {
  opacity: 1;
  animation: flow-horizontal 1.2s linear infinite;
}

@keyframes flow-horizontal {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 32px 0;
  }
}

.node--packager {
  min-height: 280px;
}

.node--cdn {
  width: 160px;
  min-height: 160px;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cdn-loader {
  --s: 25px;
  --g: 5px;
  
  width: calc(3*(1.353*var(--s) + var(--g)));
  display: grid;
  justify-items: end;
  aspect-ratio: 3;
  overflow: hidden;
  --_m: linear-gradient(90deg,#0000,#000 15px calc(100% - 15px),#0000);
  -webkit-mask: var(--_m);
          mask: var(--_m);
  margin: 0.8rem 0;
}

.cdn-loader:before {
  content: "";
  width: 200%;
  background:
    linear-gradient(90deg,#00ff00 50%,#0000 0),
    conic-gradient(from -90deg at var(--s) calc(0.353*var(--s)),
      #fff 135deg,#666 0 270deg,#aaa 0);
  background-blend-mode: multiply;
  --_m:
    linear-gradient(to bottom right,
       #0000 calc(0.25*var(--s)),#000 0 calc(100% - calc(0.25*var(--s)) - 1.414*var(--g)),#0000 0),
    conic-gradient(from -90deg at right var(--g) bottom var(--g),#000 90deg,#0000 0);
  -webkit-mask: var(--_m);
          mask: var(--_m);
  background-size: calc(100%/3) 100%, calc(100%/6) 100%;
  -webkit-mask-size: calc(100%/6) 100%;
          mask-size: calc(100%/6) 100%;
  -webkit-mask-composite: source-in;
          mask-composite: intersect;
  animation: cdn-loader-anim 1s infinite linear;
}

@keyframes cdn-loader-anim {
  to {transform:translate(calc(100%/3))}
}

.loader {
  --block-size: 72px;
  --light-color: rgba(57, 255, 20, 0.2);
  --dot-size: 8px;
  --dot-size-half: calc(var(--dot-size) / 2);
  --dot-size-half-neg: calc(var(--dot-size-half) * -1);
  position: relative;
  display: block;
  width: var(--loader-size, calc(var(--block-size) / 3));
  height: var(--loader-size, calc(var(--block-size) / 3));
  color: #39ff14;
}

.loader::before,
.loader::after {
  content: "";
  position: absolute;
}

.loader--6 {
  --loader-size: calc(var(--block-size) / 3);
  --loader-size-half: calc(var(--loader-size) / 2);
  --loader-size-half-neg: calc(var(--loader-size-half) * -1);
  --anim-duration: 0.6s;
  aspect-ratio: 1 / 1;
  perspective: 50vmin;
  transform-style: preserve-3d;
  transform: rotateX(35deg);
}

.loader--6::before,
.loader--6::after {
  width: 50%;
  aspect-ratio: 1 / 1;
  background-color: currentColor;
  top: 25%;
  left: 25%;
  animation: loader-6 var(--anim-duration) cubic-bezier(0.07, 0.59, 0.56, 0.88) infinite;
  opacity: 0;
}

.loader--6::before {
  --turn-deg: -60deg;
  --x-dist: -25%;
  transform-origin: left calc(var(--loader-size) * -1);
}

.loader--6::after {
  --turn-deg: 60deg;
  --x-dist: 25%;
  transform-origin: right calc(var(--loader-size) * -1);
  animation-delay: calc(var(--anim-duration) / 2 * -1);
}

.packager__loader.loader {
  --block-size: 96px;
  --loader-play-state: paused;
  margin: 1.2rem auto 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(57, 255, 20, 0.15) 0%, rgba(57, 255, 20, 0.04) 70%, transparent 100%);
  filter: drop-shadow(0 0 14px rgba(57, 255, 20, 0.18));
}

.packager__loader.loader,
.packager__loader.loader::before,
.packager__loader.loader::after {
  animation-play-state: var(--loader-play-state);
}

.app.is-running .packager__loader.loader {
  --loader-play-state: running;
}

[data-node="packagerB"] .packager__loader.loader {
  color: #aaa;
  background: radial-gradient(circle, rgba(170, 170, 170, 0.15) 0%, rgba(170, 170, 170, 0.04) 70%, transparent 100%);
  filter: drop-shadow(0 0 14px rgba(170, 170, 170, 0.18));
}

@keyframes loader-6 {
  0% {
    transform: scale(0.3) translateZ(-15vmin) rotateY(calc(var(--turn-deg) * -1));
    opacity: 0;
  }
  20% {
    opacity: 0.85;
  }
  33% {
    transform: scale(1.2) translateZ(5vmin) translateX(var(--x-dist));
    opacity: 1;
  }
  100% {
    transform: scale(1.2) translateZ(5vmin) translateX(var(--x-dist)) rotateY(var(--turn-deg));
    opacity: 0;
  }
}

.legend {
  border: 1px solid #2d2d2d;
  border-radius: 14px;
  padding: 1.5rem 2rem;
  background: rgba(4, 4, 4, 0.95);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.65);
}

.legend h2 {
  margin: 0 0 1rem;
  color: #39ff14;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 1.2rem;
}

.legend ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #b5b5b5;
  font-size: 0.9rem;
}

.legend__swatch {
  display: inline-block;
  width: 22px;
  height: 12px;
  border-radius: 6px;
}

.legend__swatch--flow {
  background: repeating-linear-gradient(90deg, rgba(57, 255, 20, 0.9) 0 10px, rgba(57, 255, 20, 0.15) 10px 20px);
}

.legend__swatch--request {
  background: linear-gradient(90deg, #39ff14, #32b2ff, #ff3fa6);
}

.legend__swatch--segment {
  background: linear-gradient(135deg, rgba(57, 255, 20, 0.45), rgba(57, 255, 20, 0.05));
  border: 1px solid rgba(57, 255, 20, 0.6);
}

@media (max-width: 1200px) {
  .pipeline {
    --pipeline-gap: 0rem;
  }

  .node {
    width: 100px;
    min-height: 120px;
  }

  .node__video {
    width: 70px;
    height: 44px;
  }

  .node--encoder {
    width: 160px;
    min-height: 180px;
  }

  .encoder__rendition {
    grid-template-columns: 28px 1fr;
    gap: 0.5rem;
  }

  .encoder__loader {
    width: 28px;
  }

  .encoder__video,
  .node--encoder .node__video {
    width: 80px;
    height: 48px;
  }

}

@media (max-width: 1024px) {
  .pipeline-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
  }

  .pipeline {
    transform: scale(0.8);
    transform-origin: top left;
    min-width: max-content;
  }

  .node {
    width: 90px;
    min-height: 110px;
    padding: 0.7rem 0.6rem;
  }

  .node h3 {
    font-size: 0.85rem;
  }

  .node--encoder {
    width: 150px;
    min-height: 160px;
  }

  .node--cdn {
    width: 140px;
    min-height: 140px;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 1rem;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls__buttons {
    width: 100%;
    justify-content: flex-start;
  }

  .pipeline-wrapper {
    padding: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .pipeline {
    transform: scale(0.65);
    transform-origin: top left;
    min-width: max-content;
  }

  .hero {
    padding: 1rem 1.5rem;
  }

  .hero__brand h1 {
    font-size: 1.6rem;
  }

  .hero__tagline {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 0.75rem;
  }

  .pipeline-wrapper {
    padding: 0.75rem;
    border-radius: 8px;
  }

  .pipeline {
    transform: scale(0.5);
    transform-origin: top left;
    min-width: max-content;
  }

  .hero {
    padding: 1rem 1.5rem 1rem;
  }

  .hero__brand h1 {
    font-size: 1.5rem;
  }

  .hero__tagline {
    font-size: 0.85rem;
  }

  .hero__home {
    font-size: 0.85rem;
    top: 1rem;
    right: 1.5rem;
  }

  .controls {
    padding: 1rem 1.25rem;
    border-radius: 8px;
  }

  .control-button {
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
  }

  .legend {
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
  }

  .legend h2 {
    font-size: 1rem;
  }

  .legend li {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  .pipeline {
    transform: scale(0.4);
    transform-origin: top left;
    min-width: max-content;
  }

  .hero__brand h1 {
    font-size: 1.25rem;
  }

  .hero__tagline {
    font-size: 0.8rem;
  }
}
