:root {
  color-scheme: dark;
  --bg: #050604;
  --ink: #f8faf2;
  --muted: #a8afa2;
  --line: rgba(248, 250, 242, 0.18);
  --line-strong: rgba(248, 250, 242, 0.34);
  --acid: #c8ff46;
  --cyan: #55e1d6;
  --coral: #ff6e5b;
  --gold: #ffd275;
  --font: "Avenir Next", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(118deg, rgba(85, 225, 214, 0.12), transparent 33%),
    linear-gradient(246deg, rgba(255, 110, 91, 0.13), transparent 38%),
    linear-gradient(180deg, rgba(136, 169, 255, 0.09), transparent 44%),
    #050604;
  color: var(--ink);
  font-family: var(--font);
}

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

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.lab-shell {
  min-height: 100vh;
  padding: 18px 20px 38px;
}

.lab-topbar[data-site-header] .site-topbar__nav { display: grid !important; flex: 1 1 auto; justify-items: end; overflow: visible; }

.lab-topbar[data-site-header] .site-secondary-links[data-image-proof-section-nav] { display: flex !important; flex-wrap: wrap; justify-content: flex-end; gap: 8px; overflow-x: auto; }

.lab-topbar[data-site-header] .site-secondary-links[data-image-proof-section-nav] a { display: inline-flex; min-height: 44px !important; align-items: center; justify-content: center; border-color: rgba(85, 225, 214, 0.44) !important; padding: 0 12px; color: var(--ink) !important; background: rgba(5, 6, 4, 0.76) !important; }

.lab-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.45fr);
  gap: 16px;
  min-height: calc(100vh - 118px);
}

.image-stage {
  display: grid;
  grid-template-rows: minmax(500px, 1fr) 138px;
  gap: 12px;
  min-width: 0;
}

.primary-frame,
.result-tile,
.command-rail,
.proof-band,
.source-notes,
.backend-receipt {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248, 250, 242, 0.045), transparent),
    rgba(13, 16, 13, 0.82);
}

.primary-frame {
  position: relative;
  overflow: hidden;
  min-height: 500px;
  margin: 0;
  border-color: rgba(248, 250, 242, 0.22);
  box-shadow:
    0 34px 110px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(248, 250, 242, 0.1);
}

.primary-frame img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 500px;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.04);
}

.primary-frame::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(5, 6, 4, 0) 46%, rgba(5, 6, 4, 0.84) 100%),
    linear-gradient(90deg, rgba(5, 6, 4, 0.38), transparent 36%),
    linear-gradient(130deg, rgba(85, 225, 214, 0.12), transparent 42%),
    linear-gradient(310deg, rgba(255, 110, 91, 0.1), transparent 44%);
  pointer-events: none;
}

.primary-frame figcaption {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  z-index: 1;
  display: grid;
  gap: 7px;
  max-width: 640px;
}

.frame-kicker,
.rail-kicker {
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.primary-frame strong {
  font-size: clamp(2.35rem, 4.2vw, 4.25rem);
  line-height: 0.95;
  text-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}

.primary-frame span {
  max-width: 540px;
  color: rgba(248, 250, 242, 0.78);
  font-size: 1rem;
  line-height: 1.35;
}

.result-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.result-tile {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(248, 250, 242, 0.06);
}

.result-tile img {
  display: block;
  width: 100%;
  height: 136px;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.04);
}

.result-tile:hover,
.result-tile:focus-visible {
  border-color: rgba(85, 225, 214, 0.46);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.3);
}

.result-tile span {
  position: absolute;
  bottom: 8px;
  left: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 6px;
  border: 1px solid rgba(248, 250, 242, 0.24);
  border-radius: 4px;
  background: rgba(5, 6, 4, 0.76);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.command-rail {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
  min-width: 0;
  align-self: stretch;
  padding: 18px;
  border-color: rgba(248, 250, 242, 0.2);
  background:
    linear-gradient(145deg, rgba(85, 225, 214, 0.1), transparent 36%),
    linear-gradient(315deg, rgba(255, 110, 91, 0.09), transparent 44%),
    rgba(9, 12, 10, 0.86);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(248, 250, 242, 0.08);
  backdrop-filter: blur(18px) saturate(1.08);
}

.rail-heading {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.75rem, 4.45vw, 4.1rem);
  line-height: 0.9;
}

#backend-status {
  min-height: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.32;
}

[data-backend="running"] #backend-status {
  color: var(--cyan);
}

[data-backend="ready"] #backend-status {
  color: var(--acid);
}

[data-backend="blocked"] #backend-status {
  color: var(--coral);
}

.generate-form {
  display: grid;
  gap: 12px;
}

.generate-form > label,
.setting-label {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
}

textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(248, 250, 242, 0.035), transparent),
    #080a08;
  color: var(--ink);
}

textarea {
  min-height: 154px;
  margin-top: 8px;
  padding: 13px;
  line-height: 1.45;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.setting-picker {
  position: relative;
  display: grid;
  gap: 7px;
  min-width: 0;
}

.picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 46px;
  border: 1px solid rgba(248, 250, 242, 0.28);
  border-radius: 6px;
  padding: 0 13px;
  background:
    linear-gradient(180deg, rgba(248, 250, 242, 0.07), transparent),
    rgba(5, 6, 4, 0.86);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(248, 250, 242, 0.06);
}

.picker-button:hover {
  border-color: rgba(85, 225, 214, 0.58);
  background:
    linear-gradient(180deg, rgba(85, 225, 214, 0.12), transparent),
    #090d0b;
}

.picker-button:focus-visible,
.picker-option:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.picker-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: rgba(248, 250, 242, 0.82);
  transform: rotate(45deg) translateY(-2px);
}

.setting-picker[data-open="true"] .picker-button {
  border-color: rgba(85, 225, 214, 0.92);
  box-shadow:
    0 0 0 3px rgba(85, 225, 214, 0.16),
    inset 0 1px 0 rgba(248, 250, 242, 0.1);
}

.setting-picker[data-open="true"] .picker-chevron {
  transform: rotate(225deg) translate(-2px, -1px);
}

.picker-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  max-height: 154px;
  overflow-y: auto;
  border: 1px solid rgba(85, 225, 214, 0.48);
  border-radius: 8px;
  padding: 5px;
  background:
    linear-gradient(180deg, rgba(22, 28, 24, 0.98), rgba(8, 10, 8, 0.98)),
    #080a08;
  backdrop-filter: blur(18px);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(200, 255, 70, 0.04),
    inset 0 1px 0 rgba(248, 250, 242, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

.setting-picker[data-open="true"] .picker-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-radius: 6px;
  padding: 0 10px;
  color: rgba(248, 250, 242, 0.84);
  font-size: 0.84rem;
  font-weight: 760;
  cursor: pointer;
}

.picker-option::after {
  width: 7px;
  height: 12px;
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
  content: "";
  transform: rotate(45deg) translateY(-1px);
}

.picker-option:hover,
.picker-option:focus-visible {
  background: rgba(85, 225, 214, 0.12);
  color: var(--ink);
}

.picker-option[aria-selected="true"] {
  background:
    linear-gradient(90deg, rgba(200, 255, 70, 0.2), rgba(85, 225, 214, 0.08)),
    rgba(200, 255, 70, 0.1);
  color: var(--acid);
}

.picker-option[aria-selected="true"]::after {
  border-color: var(--acid);
}

.run-button,
.export-button {
  min-height: 48px;
  border: 1px solid rgba(200, 255, 70, 0.78);
  border-radius: 6px;
  background: #dfff58;
  color: #11150d;
  font-weight: 950;
  box-shadow: 0 18px 52px rgba(200, 255, 70, 0.14);
}

.export-button {
  display: inline-grid;
  width: 52px;
  min-height: 52px;
  place-items: center;
  padding: 0;
}

.export-button span {
  width: 18px;
  height: 18px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
}

.export-button span::after {
  display: block;
  width: 18px;
  height: 3px;
  margin-top: 18px;
  margin-left: 3px;
  background: currentColor;
  content: "";
  transform: rotate(-45deg);
}

.run-button:hover,
.export-button:hover {
  box-shadow: 0 24px 64px rgba(85, 225, 214, 0.18);
}

.sample-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sample-button {
  position: relative;
  overflow: hidden;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #080a08;
  color: var(--ink);
}

.sample-button img {
  display: block;
  width: 100%;
  height: 78px;
  object-fit: cover;
  opacity: 0.74;
}

.sample-button:hover,
.sample-button:focus-visible {
  border-color: rgba(85, 225, 214, 0.42);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

.sample-button[aria-pressed="true"] {
  border-color: var(--acid);
}

.sample-button[aria-pressed="true"] img {
  opacity: 1;
}

.sample-button span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backend-receipt {
  align-self: end;
  padding: 14px;
  border-color: rgba(248, 250, 242, 0.17);
  background:
    linear-gradient(145deg, rgba(136, 169, 255, 0.08), transparent 36%),
    rgba(5, 6, 4, 0.74);
}

.backend-receipt dl {
  display: grid;
  gap: 9px;
  margin: 0 0 12px;
}

.backend-receipt div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(248, 250, 242, 0.1);
  padding-bottom: 8px;
}

.backend-receipt dt,
.backend-receipt dd {
  margin: 0;
  font-size: 0.82rem;
}

.backend-receipt dt {
  color: var(--gold);
  font-weight: 850;
}

.backend-receipt dd {
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}

.backend-receipt p {
  display: grid;
  gap: 4px;
  min-height: 20px;
  margin-top: 10px;
  color: var(--cyan);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.backend-receipt p strong {
  color: var(--acid);
  font-size: 0.78rem;
}

.backend-receipt p span {
  color: rgba(248, 250, 242, 0.78);
}

.backend-receipt p a {
  justify-self: start;
  border-bottom: 1px solid rgba(85, 225, 214, 0.58);
  color: var(--ink);
  font-weight: 850;
}

.proof-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border-color: rgba(248, 250, 242, 0.14);
}

.proof-band article {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: rgba(248, 250, 242, 0.035);
}

.proof-band strong {
  color: var(--acid);
  font-size: 0.86rem;
}

.proof-band span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.source-notes {
  margin-top: 14px;
  padding: 14px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 850;
}

.source-notes details[open] {
  display: grid;
  gap: 10px;
}

.source-notes a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin: 10px 10px 0 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 0.9rem;
}

@media (max-width: 1080px) {
  .lab-workbench {
    grid-template-columns: 1fr;
  }

  .command-rail {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.72fr);
    align-items: start;
  }

  .rail-heading,
  .backend-receipt {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .lab-shell {
    padding: 12px;
  }

  .lab-topbar[data-site-header] .site-secondary-links[data-image-proof-section-nav] { flex-wrap: nowrap; justify-content: flex-start; }

  .lab-topbar[data-site-header] .site-secondary-links[data-image-proof-section-nav] a { flex: 0 0 auto; }

  .image-stage {
    display: contents;
  }

  .primary-frame {
    order: 1;
    height: clamp(220px, 28vh, 280px);
    min-height: 220px;
  }

  .primary-frame img {
    height: 100%;
    min-height: 0;
  }

  .primary-frame strong {
    font-size: 2.15rem;
  }

  .command-rail {
    order: 2;
    gap: 10px;
    padding: 14px;
  }

  .result-strip {
    order: 3;
  }

  .result-strip,
  .proof-band,
  .command-rail {
    grid-template-columns: 1fr;
  }

  .picker-menu {
    position: static;
    max-height: 0;
    border-width: 0;
    padding: 0 5px;
    opacity: 1;
    transform: none;
  }

  .setting-picker[data-open="true"] .picker-menu {
    max-height: 154px;
    border-width: 1px;
    padding: 5px;
  }

  h1 {
    font-size: 2.1rem;
  }

  textarea {
    height: 112px;
    min-height: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
