.pixel-card:focus-visible {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 18px var(--shadow);
}

.pixel-media-preview {
  background: #06070a;
}

.pixel-media-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.lab-empty-state {
  margin: 16px 0 0;
  padding: 24px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, .12);
  font-size: 11px;
  text-align: center;
}

.lab-empty-state[hidden] {
  display: none;
}

.lab-empty-state[data-state="failed"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.lab-project-dialog {
  width: min(1080px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lab-project-dialog::backdrop {
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(5px);
}

.lab-project-dialog[open] {
  animation: lab-window-in .18s ease-out;
}

@keyframes lab-window-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.lab-window-stack {
  position: relative;
  padding: 0 18px 18px 0;
}

.lab-window-layer {
  position: absolute;
  inset: 0 18px 18px 0;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, black);
  pointer-events: none;
}

.lab-window-layer-back {
  opacity: .34;
  transform: translate(18px, 18px);
}

.lab-window-layer-mid {
  opacity: .66;
  transform: translate(9px, 9px);
}

.lab-project-window {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 1px solid var(--accent);
  color: var(--text);
  background: linear-gradient(135deg, rgba(8, 9, 12, .98), var(--panel));
  box-shadow: 0 0 42px rgba(0, 0, 0, .76), 0 0 24px var(--shadow);
}

.lab-window-bar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 8px 7px 15px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, .28);
  font-size: 10px;
  letter-spacing: .14em;
}

.lab-window-bar > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.lab-window-signal {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.lab-dialog-close {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  letter-spacing: .08em;
}

.lab-dialog-close span:first-child {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.lab-dialog-close:hover,
.lab-dialog-close:focus-visible {
  border-color: var(--accent);
  outline: 0;
  color: var(--bright);
  box-shadow: 0 0 14px var(--shadow);
}

.lab-project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(270px, .58fr);
  min-height: 500px;
}

.lab-gallery {
  min-width: 0;
  padding: clamp(16px, 2.5vw, 28px);
  border-right: 1px solid var(--line);
}

.lab-gallery-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #06070a;
  box-shadow: inset 0 0 32px rgba(0, 0, 0, .58);
}

.lab-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a0a0e;
  isolation: isolate;
}

.lab-media-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #06070a;
}

.lab-media-image[hidden] {
  display: none;
}

.lab-scene::after {
  content: "";
  position: absolute;
  z-index: 10;
  inset: 0;
  opacity: .36;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, .2) 4px);
  pointer-events: none;
}

.lab-scene-layer {
  position: absolute;
  display: block;
}

/* Scarlet Night: moon, layered ground, a small character, and crystal wings. */
.lab-scene--scarlet {
  background: linear-gradient(180deg, #12121d 0 64%, #25131e 64% 72%, #090a0e 72%);
}

.lab-scene--scarlet .lab-scene-layer-a {
  top: 12%;
  right: 15%;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #e9ddcb;
  box-shadow: -17px 0 0 #12121d, 0 0 24px rgba(233, 221, 203, .18);
}

.lab-scene--scarlet .lab-scene-layer-b {
  right: -5%;
  bottom: 0;
  left: -5%;
  height: 35%;
  background: #111219;
  clip-path: polygon(0 34%, 18% 9%, 35% 32%, 58% 5%, 76% 29%, 100% 12%, 100% 100%, 0 100%);
}

.lab-scene--scarlet .lab-scene-layer-c {
  left: 48%;
  bottom: 23%;
  width: 10px;
  height: 31px;
  background: #f1d8b5;
  box-shadow: 0 13px 0 5px #c93d61, 0 24px 0 7px #8a1f3c, 0 0 16px rgba(230, 83, 114, .55);
}

.lab-scene--scarlet .lab-scene-layer-d {
  left: calc(48% - 26px);
  bottom: calc(23% - 1px);
  width: 7px;
  height: 7px;
  background: #f2d25b;
  box-shadow: 15px -12px 0 #5fd2e2, 30px -4px 0 #a783ff, 45px -16px 0 #f08ac9, 58px 2px 0 #66d5e5, 72px -10px 0 #e4ca5a;
  transform: rotate(45deg);
}

.lab-scene--scarlet[data-frame="1"] .lab-scene-layer-a {
  top: 17%;
  right: 48%;
  width: 104px;
  height: 104px;
}

.lab-scene--scarlet[data-frame="1"] .lab-scene-layer-c {
  left: 27%;
  bottom: 20%;
  transform: scale(1.35);
}

.lab-scene--scarlet[data-frame="1"] .lab-scene-layer-d {
  left: calc(27% - 29px);
  bottom: 19%;
  transform: rotate(45deg) scale(1.25);
}

.lab-scene--scarlet[data-frame="2"] {
  background: linear-gradient(180deg, #17101a 0 48%, #27131f 48% 59%, #08090d 59%);
}

.lab-scene--scarlet[data-frame="2"] .lab-scene-layer-a {
  top: 8%;
  right: 7%;
  width: 48px;
  height: 48px;
}

.lab-scene--scarlet[data-frame="2"] .lab-scene-layer-c {
  left: 62%;
  bottom: 31%;
  transform: scale(1.75);
}

.lab-scene--scarlet[data-frame="2"] .lab-scene-layer-d {
  left: calc(62% - 38px);
  bottom: 29%;
  transform: rotate(45deg) scale(1.55);
}

/* Wind Ruins: hillside, distant structure, a scale figure, and wind trails. */
.lab-scene--teal {
  background: linear-gradient(180deg, #10252a 0 58%, #29453d 58%);
}

.lab-scene--teal .lab-scene-layer-a {
  top: 23%;
  right: 9%;
  width: 54%;
  height: 31%;
  background: #87918e;
  box-shadow: -13px 8px 0 #536366, 15px -8px 0 #a4aeaa;
  clip-path: polygon(0 25%, 72% 0, 100% 34%, 84% 100%, 17% 81%);
  transform: rotate(-5deg);
}

.lab-scene--teal .lab-scene-layer-b {
  right: -5%;
  bottom: -2%;
  left: -5%;
  height: 43%;
  background: #365947;
  clip-path: polygon(0 45%, 40% 8%, 100% 47%, 100% 100%, 0 100%);
}

.lab-scene--teal .lab-scene-layer-c {
  left: 19%;
  bottom: 22%;
  width: 5px;
  height: 19px;
  background: #e1caa9;
  box-shadow: 0 9px 0 3px #b52d49;
}

.lab-scene--teal .lab-scene-layer-d {
  top: 16%;
  left: 8%;
  width: 28%;
  height: 1px;
  background: rgba(172, 222, 216, .5);
  box-shadow: 38px 36px 0 rgba(172, 222, 216, .28), -8px 78px 0 rgba(172, 222, 216, .34), 92px 118px 0 rgba(172, 222, 216, .22);
}

.lab-scene--teal[data-frame="1"] .lab-scene-layer-a {
  top: 13%;
  right: 17%;
  width: 67%;
  height: 42%;
  transform: rotate(2deg);
}

.lab-scene--teal[data-frame="1"] .lab-scene-layer-b {
  height: 34%;
  background: #213e37;
}

.lab-scene--teal[data-frame="1"] .lab-scene-layer-c {
  left: 74%;
  bottom: 18%;
}

.lab-scene--teal[data-frame="2"] {
  background: linear-gradient(180deg, #0c1c20 0 64%, #1f3c36 64%);
}

.lab-scene--teal[data-frame="2"] .lab-scene-layer-a {
  top: 29%;
  right: -7%;
  width: 76%;
  height: 24%;
  transform: rotate(-10deg);
}

.lab-scene--teal[data-frame="2"] .lab-scene-layer-c {
  left: 34%;
  bottom: 28%;
  transform: scale(.8);
}

.lab-scene--teal[data-frame="2"] .lab-scene-layer-d {
  top: 10%;
  width: 54%;
  box-shadow: 52px 47px 0 rgba(172, 222, 216, .34), 12px 101px 0 rgba(172, 222, 216, .25), 118px 152px 0 rgba(172, 222, 216, .3);
}

/* Old Terminal: display shell, phosphor text, desk, and status lights. */
.lab-scene--amber {
  background: radial-gradient(circle at 50% 40%, #251807, #0c0905 72%);
}

.lab-scene--amber .lab-scene-layer-a {
  inset: 13% 12% 22%;
  border: 5px solid #8b581e;
  background: #151006;
  box-shadow: inset 0 0 32px rgba(240, 168, 61, .2), 0 0 24px rgba(240, 168, 61, .1);
}

.lab-scene--amber .lab-scene-layer-b {
  top: 27%;
  left: 22%;
  width: 42%;
  height: 3px;
  background: #e2a13c;
  box-shadow: 0 13px 0 #9c6927, 0 26px 0 #9c6927, 0 39px 0 #e2a13c, 54px 52px 0 #6c471c;
}

.lab-scene--amber .lab-scene-layer-c {
  bottom: 13%;
  left: 39%;
  width: 22%;
  height: 7%;
  background: #5d3a13;
  clip-path: polygon(16% 0, 84% 0, 100% 100%, 0 100%);
}

.lab-scene--amber .lab-scene-layer-d {
  right: 16%;
  bottom: 10%;
  width: 7px;
  height: 7px;
  background: #f0a83d;
  box-shadow: -13px 0 0 #6c4415, 0 0 12px rgba(240, 168, 61, .7);
}

.lab-scene--amber[data-frame="1"] .lab-scene-layer-a {
  inset: 8% 19% 18%;
  border-width: 8px;
}

.lab-scene--amber[data-frame="1"] .lab-scene-layer-b {
  top: 22%;
  left: 28%;
  width: 31%;
  box-shadow: 0 18px 0 #e2a13c, 0 36px 0 #9c6927, 0 54px 0 #e2a13c, 72px 72px 0 #6c471c;
}

.lab-scene--amber[data-frame="1"] .lab-scene-layer-c {
  bottom: 9%;
}

.lab-scene--amber[data-frame="2"] {
  background: linear-gradient(180deg, #090704 0 67%, #1b1107 67%);
}

.lab-scene--amber[data-frame="2"] .lab-scene-layer-a {
  inset: 18% 7% 27% 34%;
  transform: rotate(2deg);
}

.lab-scene--amber[data-frame="2"] .lab-scene-layer-b {
  top: 31%;
  left: 42%;
  width: 27%;
}

.lab-scene--amber[data-frame="2"] .lab-scene-layer-c {
  bottom: 13%;
  left: 9%;
  width: 28%;
  height: 12%;
  background: #3d2911;
  transform: skewX(-18deg);
}

.lab-gallery-controls {
  display: grid;
  grid-template-columns: 38px minmax(82px, auto) 38px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.lab-gallery-controls button {
  display: grid;
  width: 38px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.lab-gallery-controls button:hover,
.lab-gallery-controls button:focus-visible {
  border-color: var(--accent);
  outline: 0;
  color: var(--bright);
  box-shadow: 0 0 13px var(--shadow);
}

.lab-gallery-controls button:disabled {
  opacity: .28;
  cursor: default;
  box-shadow: none;
}

.lab-gallery-controls span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-align: center;
}

.lab-media-caption {
  min-height: 1.55em;
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
  text-align: center;
}

.lab-project-info {
  display: flex;
  min-width: 0;
  padding: clamp(24px, 3vw, 40px);
  flex-direction: column;
  justify-content: center;
}

.lab-project-info h2 {
  margin: 5px 0 20px;
  overflow-wrap: anywhere;
  color: var(--bright);
  font-size: clamp(27px, 3.5vw, 46px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lab-project-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.lab-project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 24px;
}

.lab-project-tags span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 10px;
}

.lab-project-position {
  margin: auto 0 0;
  padding-top: 30px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .14em;
}

body.lab-dialog-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .lab-project-dialog {
    overflow-y: auto;
  }

  .lab-project-layout {
    grid-template-columns: 1fr;
  }

  .lab-gallery {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lab-project-info {
    min-height: 300px;
  }
}

@media (max-width: 520px) {
  .lab-project-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .lab-window-stack {
    padding: 0 8px 8px 0;
  }

  .lab-window-layer {
    inset: 0 8px 8px 0;
  }

  .lab-window-layer-back {
    transform: translate(8px, 8px);
  }

  .lab-window-layer-mid {
    display: none;
  }

  .lab-window-bar {
    padding-left: 10px;
  }

  #labWindowLabel,
  #labCloseText {
    display: none;
  }

  .lab-dialog-close {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .lab-gallery {
    padding: 12px;
  }

  .lab-project-info {
    min-height: 260px;
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-project-dialog[open] {
    animation: none;
  }
}
