.labs-page {
  --rail-progress: 1;
  --lab-art-ratio: calc(1735 / 1080);
  min-height: 100vh;
  min-height: 100svh;
  background: #000;
}

.lab-page-loader {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(4, 8, 5, 0.94), rgba(0, 0, 0, 0.98)),
    #000;
  transition:
    opacity 420ms ease,
    visibility 420ms ease;
}

body:not(.is-loading) .lab-page-loader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lab-page-loader-card {
  min-width: min(22rem, calc(100vw - 3rem));
  padding: 1rem 1.15rem 1.05rem;
  border: 1px solid rgba(134, 255, 102, 0.22);
  background:
    linear-gradient(180deg, rgba(9, 16, 10, 0.9), rgba(3, 7, 4, 0.96)),
    rgba(0, 0, 0, 0.92);
  box-shadow:
    0 0 0 1px rgba(134, 255, 102, 0.08),
    0 18px 32px rgba(0, 0, 0, 0.34);
}

.lab-page-loader-label,
.lab-page-loader-status {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  letter-spacing: 0.06em;
}

.lab-page-loader-label {
  color: rgba(162, 255, 136, 0.98);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 800;
  text-transform: uppercase;
}

.lab-page-loader-status {
  margin-top: 0.35rem;
  color: rgba(134, 255, 102, 0.72);
  font-size: 0.74rem;
}

.labs-page .subpage-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.labs-page .subpage-header {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 30;
  width: min(86rem, calc(100vw - 2.8rem));
  padding: 1.4rem 0 1.1rem;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  transform: translateX(-50%);
}

.labs-page .subpage-brand,
.labs-page .subpage-nav a {
  color: rgba(134, 255, 102, 0.96);
  text-shadow: 0 0 10px rgba(92, 255, 72, 0.24);
}

.labs-page .subpage-brand {
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.labs-page .subpage-nav a {
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.labs-page .subpage-nav {
  color: rgba(134, 255, 102, 0.62);
}

.labs-page .subpage-nav a[aria-current="page"] {
  color: rgba(162, 255, 136, 1);
}

.labs-main {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
}

.labs-stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

.lab-board {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #050505;
}

.lab-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, calc(var(--viewport-height) * var(--lab-art-ratio)));
  aspect-ratio: 1735 / 1080;
  transform: translate(-50%, -50%);
}

.lab-texture,
.lab-vignette,
.lab-screen-layer {
  position: absolute;
  inset: 0;
}

.lab-texture {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.2)),
    url("../assets/lab-background.png") center center / cover no-repeat;
}

.lab-vignette {
  background:
    radial-gradient(circle at center, transparent 34%, rgba(0, 0, 0, 0.16) 68%, rgba(0, 0, 0, 0.44) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.24));
  pointer-events: none;
}

.lab-screen-layer {
  pointer-events: none;
}

.lab-screen {
  position: absolute;
  left: var(--screen-x);
  top: var(--screen-y);
  width: var(--screen-w);
  height: var(--screen-h);
  overflow: hidden;
  border-radius: var(--screen-radius);
  transform: rotate(var(--screen-tilt));
  transform-origin: center center;
}

.lab-screen-label,
.lab-screen-handle {
  display: none;
}

.lab-screen-project {
  display: block;
  pointer-events: auto;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 24px rgba(0, 0, 0, 0.22);
  transition:
    filter 140ms ease,
    box-shadow 140ms ease;
}

.lab-screen-project:hover,
.lab-screen-project:focus-visible {
  filter: brightness(1.04);
  box-shadow:
    0 0 0 1px rgba(174, 255, 145, 0.28),
    0 0 26px rgba(52, 255, 82, 0.18);
  outline: none;
}

.lab-screen-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.96) contrast(1.05) brightness(0.96);
}

.lab-screen-noise {
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.92) 0 0.038rem, transparent 0.046rem),
    radial-gradient(circle, rgba(255, 255, 255, 0.76) 0 0.032rem, transparent 0.04rem),
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.58) 0 0.18rem, transparent 0.18rem 0.78rem),
    radial-gradient(circle at 76% 64%, rgba(255, 255, 255, 0.42) 0 0.14rem, transparent 0.14rem 0.68rem),
    radial-gradient(circle at 44% 78%, rgba(255, 255, 255, 0.34) 0 0.12rem, transparent 0.12rem 0.62rem),
    linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.24) 22%, transparent 44%, rgba(255, 255, 255, 0.14) 66%, transparent 100%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.24) 0,
      rgba(255, 255, 255, 0.24) 2px,
      rgba(0, 0, 0, 0.14) 2px,
      rgba(0, 0, 0, 0.14) 7px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.14) 0,
      rgba(255, 255, 255, 0.14) 2px,
      transparent 2px,
      transparent 8px
    ),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 3px,
      transparent 3px,
      transparent 18px
    );
  background-size:
    18px 16px,
    26px 22px,
    32% 28%,
    28% 26%,
    24% 24%,
    100% 100%,
    100% 8px,
    10px 100%,
    28px 28px;
  background-position:
    0 0,
    7px 4px,
    0% 0%,
    100% 100%,
    50% 30%,
    0 0,
    0 0,
    0 0,
    0 0;
  mix-blend-mode: screen;
  pointer-events: none;
  will-change: transform, opacity, background-position;
  animation:
    lab-screen-static-shift 72ms steps(4) infinite,
    lab-screen-static-flicker 520ms steps(4) infinite;
}

.lab-screen-project::after,
.lab-screen-static::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 24%, rgba(0, 0, 0, 0.08) 100%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent 3px
    );
  pointer-events: none;
}

@keyframes lab-screen-static-shift {
  0% {
    background-position:
      0 0,
      7px 4px,
      0% 0%,
      100% 100%,
      50% 30%,
      0 0,
      0 0,
      0 0,
      0 0;
    transform: translate3d(0, 0, 0);
  }

  25% {
    background-position:
      3px -2px,
      11px 1px,
      18% -12%,
      82% 90%,
      44% 38%,
      0 -8%,
      0 -2px,
      2px 0,
      -2px 0;
    transform: translate3d(0.28rem, -0.05rem, 0);
  }

  50% {
    background-position:
      -2px 3px,
      4px 7px,
      -12% 22%,
      114% 72%,
      58% 16%,
      0 14%,
      0 3px,
      -3px 0,
      2px 0;
    transform: translate3d(-0.22rem, 0.08rem, 0);
  }

  75% {
    background-position:
      4px 1px,
      13px 6px,
      24% 10%,
      88% 122%,
      38% 52%,
      0 -12%,
      0 -3px,
      4px 0,
      -3px 0;
    transform: translate3d(0.26rem, 0.04rem, 0);
  }

  100% {
    background-position:
      -3px -1px,
      5px 2px,
      -6% -16%,
      108% 84%,
      62% 24%,
      0 8%,
      0 2px,
      -2px 0,
      2px 0;
    transform: translate3d(-0.2rem, -0.04rem, 0);
  }
}

@keyframes lab-screen-static-flicker {
  0%,
  100% {
    opacity: 0.34;
  }

  18% {
    opacity: 0.48;
  }

  38% {
    opacity: 0.4;
  }

  52% {
    opacity: 0.58;
  }

  74% {
    opacity: 0.3;
  }

  82% {
    opacity: 0.52;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-screen-noise {
    animation: none;
  }
}

.lab-screen-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(194, 255, 178, 0.14), transparent 74%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.lab-screen-filler {
  display: block;
  opacity: 0.28;
  pointer-events: none;
}

.lab-screen-static {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(20, 20, 20, 0.26)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      rgba(15, 15, 15, 0.18) 1px,
      rgba(15, 15, 15, 0.18) 3px
    ),
    repeating-linear-gradient(
      180deg,
      rgba(240, 240, 240, 0.18) 0,
      rgba(240, 240, 240, 0.18) 2px,
      rgba(30, 30, 30, 0.18) 2px,
      rgba(30, 30, 30, 0.18) 4px
    );
}

.lab-rail {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 12;
  width: var(--rail-width);
  max-width: calc(100vw - 2rem);
  opacity: 1;
  pointer-events: none;
  transform: none;
  transition: none;
}

.labs-page .rail-statement {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: clamp(2rem, 4vw, 3.45rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.08em;
  text-transform: none;
  color: rgba(134, 255, 102, 0.96);
  text-shadow: 0 0 10px rgba(92, 255, 72, 0.24);
}

@media (max-width: 900px) {
  .lab-rail {
    display: none;
  }
}

.lab-project-block {
  display: grid;
  gap: 0.45rem;
}

.lab-project-nav {
  margin-top: 0;
}

.lab-project-link {
  position: relative;
}

.lab-project-placeholder {
  display: block;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(24, 28, 20, 0.08);
  font-size: 0.96rem;
  color: rgba(95, 103, 112, 0.76);
}

.labs-page.is-tuning .lab-screen-layer {
  pointer-events: auto;
}

.labs-page.is-tuning .lab-screen {
  touch-action: none;
}

.labs-page.is-tuning .lab-screen-project,
.labs-page.is-tuning .lab-screen-filler {
  cursor: move;
}

.labs-page.is-tuning .lab-screen-filler {
  opacity: 0.72;
}

.labs-page.is-tuning .lab-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(145, 255, 128, 0.86);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.labs-page.is-tuning .lab-screen.is-selected::before {
  border-color: rgba(255, 222, 122, 0.98);
}

.labs-page.is-tuning .lab-screen-label,
.labs-page.is-tuning .lab-screen-handle {
  display: block;
}

.labs-page.is-tuning .lab-screen-label {
  position: absolute;
  left: 0.45rem;
  top: 0.45rem;
  z-index: 2;
  padding: 0.22rem 0.42rem;
  background: rgba(8, 12, 9, 0.82);
  color: rgba(169, 255, 151, 0.96);
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.labs-page.is-tuning .lab-screen-handle {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  z-index: 2;
  width: 0.95rem;
  height: 0.95rem;
  border: 1px solid rgba(8, 12, 9, 0.7);
  background: rgba(255, 222, 122, 0.96);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);
  cursor: nwse-resize;
}

.lab-tune-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  width: min(24rem, calc(100vw - 2rem));
  padding: 0.9rem 0.95rem;
  border: 1px solid rgba(148, 255, 133, 0.24);
  background: rgba(5, 10, 6, 0.9);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  color: rgba(182, 255, 169, 0.94);
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
}

.lab-tune-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.lab-tune-head strong,
.lab-tune-head span,
.lab-tune-current,
.lab-tune-note,
.lab-tune-status {
  margin: 0;
}

.lab-tune-head strong {
  font-size: 0.9rem;
}

.lab-tune-head span,
.lab-tune-note,
.lab-tune-status {
  font-size: 0.72rem;
  color: rgba(182, 255, 169, 0.74);
}

.lab-tune-current {
  margin-top: 0.55rem;
  font-size: 0.78rem;
}

.lab-tune-code {
  margin: 0.65rem 0;
  max-height: 14rem;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid rgba(148, 255, 133, 0.16);
  background: rgba(0, 0, 0, 0.26);
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.lab-tune-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.lab-tune-actions button {
  min-height: 2rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(148, 255, 133, 0.24);
  background: rgba(148, 255, 133, 0.08);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lab-tune-actions button:hover,
.lab-tune-actions button:focus-visible {
  background: rgba(148, 255, 133, 0.14);
  outline: none;
}

.lab-tune-status {
  margin-top: 0.55rem;
}

@media (max-width: 900px) {
  .lab-screen {
    left: var(--screen-x-mobile, var(--screen-x));
    top: var(--screen-y-mobile, var(--screen-y));
    width: var(--screen-w-mobile, var(--screen-w));
    height: var(--screen-h-mobile, var(--screen-h));
    border-radius: var(--screen-radius-mobile, var(--screen-radius));
    transform: rotate(var(--screen-tilt-mobile, var(--screen-tilt)));
  }

  .lab-tune-panel {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}

@media (max-width: 720px) {
  .labs-page .subpage-header {
    width: min(86rem, calc(100vw - 2.8rem));
    padding: 1.4rem 0 1.1rem;
  }
}
