:root {
  --paper: #f4e8cc;
  --paper-light: #fff8e7;
  --paper-deep: #e7d5ae;
  --ink: #1d3557;
  --ink-soft: #526477;
  --red: #ef5b3f;
  --red-dark: #b93c2d;
  --mint: #72c7a5;
  --mint-dark: #2c8067;
  --corn: #f2c14e;
  --sky: #7eafd1;
  --black: #14202c;
  --white: #fffdf5;
  --border: 2px solid var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --font-display: "Arial Black", "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", "Microsoft YaHei UI", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(29, 53, 87, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 53, 87, 0.045) 1px, transparent 1px);
  background-size: 16px 16px;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="radio"],
input[type="file"],
summary,
label:has(input[type="file"]) {
  cursor: pointer;
}

button {
  border-radius: 0;
}

a {
  color: inherit;
}

::selection {
  background: var(--red);
  color: var(--white);
}

:focus-visible {
  outline: 3px solid var(--corn);
  outline-offset: 3px;
}

.skip-link {
  background: var(--ink);
  color: var(--white);
  left: 8px;
  padding: 10px 14px;
  position: fixed;
  top: -60px;
  z-index: 1000;
}

.skip-link:focus {
  top: 8px;
}

.topbar {
  align-items: stretch;
  background: var(--paper-light);
  border-bottom: 3px solid var(--ink);
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto minmax(300px, 1fr);
  min-height: 76px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  padding: 10px 20px;
  text-decoration: none;
}

.brand-mark {
  background: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--red);
  display: grid;
  flex: 0 0 auto;
  gap: 2px;
  grid-template-columns: repeat(3, 8px);
  height: 38px;
  padding: 4px;
  width: 38px;
}

.brand-mark i {
  background: var(--paper-light);
  display: block;
}

.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4),
.brand-mark i:nth-child(6),
.brand-mark i:nth-child(8) {
  background: var(--red);
}

.brand-mark i:nth-child(5) {
  background: var(--corn);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 1.5vw, 1.45rem);
  letter-spacing: -0.04em;
}

.brand-copy small {
  color: var(--red-dark);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

.machine-strip {
  border-left: var(--border);
  border-right: var(--border);
  display: flex;
}

.machine-cell {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 86px;
  padding: 9px 14px;
}

.machine-cell + .machine-cell {
  border-left: 1px dashed var(--ink-soft);
}

.machine-cell small,
.machine-cell strong {
  display: block;
  line-height: 1.1;
}

.machine-cell small {
  color: var(--ink-soft);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.machine-cell strong {
  font-size: 0.86rem;
  margin-top: 4px;
}

.led {
  background: var(--corn);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  height: 11px;
  width: 11px;
}

.led.is-online {
  background: var(--mint);
  animation: led-pulse 2.2s steps(2, end) infinite;
}

.led.is-offline {
  background: var(--red);
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 10px 18px;
}

.pixel-button {
  align-items: center;
  background: var(--paper-light);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 900;
  gap: 7px;
  justify-content: center;
  letter-spacing: 0.04em;
  min-height: 36px;
  padding: 7px 11px;
  text-decoration: none;
  transition: transform 80ms steps(2, end), box-shadow 80ms steps(2, end), background 120ms;
}

.pixel-button:hover:not(:disabled) {
  background: var(--corn);
}

.pixel-button:active:not(:disabled) {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(2px, 2px);
}

.pixel-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.45;
}

.pixel-button.quiet {
  box-shadow: none;
}

.pixel-button.language {
  background: var(--ink);
  color: var(--paper-light);
  min-width: 90px;
}

.pixel-button.language .language-active {
  color: var(--corn);
}

.pixel-button.ink {
  background: var(--ink);
  color: var(--white);
}

.pixel-button.danger {
  color: var(--red-dark);
}

.pixel-button.full {
  width: 100%;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(520px, 1fr) minmax(290px, 340px);
  margin: 0 auto;
  max-width: 1900px;
  min-height: calc(100vh - 106px);
}

.control-column,
.stage-column,
.queue-column {
  min-width: 0;
  padding: 22px;
}

.control-column {
  background-color: rgba(255, 248, 231, 0.7);
  border-right: 3px solid var(--ink);
}

.stage-column {
  padding: 24px 28px 38px;
}

.queue-column {
  background-color: rgba(231, 213, 174, 0.72);
  border-left: 3px solid var(--ink);
}

.panel-label {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-label > span {
  align-items: center;
  background: var(--red);
  border: var(--border);
  color: var(--white);
  display: flex;
  font-family: var(--font-display);
  font-size: 0.74rem;
  height: 28px;
  justify-content: center;
  width: 31px;
}

.panel-label h1,
.panel-label h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.01em;
  margin: 0;
}

.panel-label.inline {
  margin: 0;
}

.key-console {
  background: var(--ink);
  border: 2px solid var(--black);
  box-shadow: 5px 5px 0 var(--red);
  color: var(--white);
  margin: 0 5px 22px 0;
  padding: 13px;
}

.key-console > label,
.field-heading,
.form-block legend {
  align-items: center;
  display: flex;
  font-size: 0.67rem;
  font-weight: 900;
  justify-content: space-between;
  letter-spacing: 0.07em;
}

.mini-link {
  background: none;
  border: 0;
  color: var(--corn);
  font-size: 0.6rem;
  padding: 0;
  text-decoration: underline;
}

.key-input-wrap {
  align-items: center;
  background: var(--black);
  border: 1px solid var(--sky);
  display: grid;
  gap: 5px;
  grid-template-columns: auto 1fr auto;
  margin-top: 9px;
  min-height: 39px;
  padding: 4px 8px;
}

.key-input-wrap > span:first-child {
  color: var(--mint);
  font-weight: 900;
}

.key-input-wrap input {
  background: transparent;
  border: 0;
  color: var(--white);
  min-width: 0;
  outline: 0;
  padding: 7px 0;
  width: 100%;
}

.key-input-wrap input::placeholder {
  color: #91a0ad;
}

.key-state {
  color: var(--corn);
  font-weight: 900;
}

.key-state.is-valid {
  color: var(--mint);
}

.key-state.is-invalid {
  color: var(--red);
}

.key-console p,
.field-hint {
  color: #c4ccd3;
  font-size: 0.62rem;
  line-height: 1.45;
  margin: 8px 0 0;
}

.form-block {
  border: 0;
  border-top: 2px dashed rgba(29, 53, 87, 0.45);
  margin: 0;
  padding: 18px 0 20px;
}

.form-block legend {
  padding: 0;
  width: 100%;
}

.form-block legend em,
.field-heading em {
  color: var(--red-dark);
  font-size: 0.56rem;
  font-style: normal;
}

.mode-tabs {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 12px;
}

.mode-tabs input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.mode-tabs span {
  align-items: center;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  display: flex;
  font-size: 0.67rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
}

.mode-tabs input:checked + span {
  background: var(--red);
  box-shadow: inset 0 -4px 0 var(--red-dark);
  color: var(--white);
}

.mode-tabs input:focus-visible + span {
  outline: 3px solid var(--corn);
  outline-offset: 2px;
}

.mode-block .field-hint {
  color: var(--ink-soft);
}

.prompt-block textarea,
.advanced-inner textarea,
.advanced-inner input,
.field-grid input,
.field-grid select,
.full-field input {
  background: var(--paper-light);
  border: var(--border);
  border-radius: 0;
  width: 100%;
}

.prompt-block textarea {
  box-shadow: inset 4px 4px 0 rgba(29, 53, 87, 0.09);
  line-height: 1.5;
  margin-top: 10px;
  min-height: 168px;
  padding: 12px;
  resize: vertical;
}

.prompt-block textarea::placeholder,
.advanced-inner textarea::placeholder,
.full-field input::placeholder {
  color: #7e857f;
}

.prompt-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.prompt-chip {
  background: transparent;
  border: 1px solid var(--ink);
  font-size: 0.58rem;
  font-weight: 900;
  padding: 5px 7px;
}

.prompt-chip:hover {
  background: var(--corn);
}

.prompt-chip.dice {
  margin-left: auto;
}

.frame-pair {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.drop-slot {
  align-items: center;
  background-color: var(--paper-light);
  background-image: radial-gradient(var(--paper-deep) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 2px dashed var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 105px;
  overflow: hidden;
  padding: 10px;
  position: relative;
  text-align: center;
}

.drop-slot:hover,
.drop-slot.is-dragging {
  background-color: #fff0cb;
  border-style: solid;
}

.drop-slot.has-file {
  background-color: #d7efdf;
  border-style: solid;
}

.drop-slot input,
.reference-row input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.drop-icon {
  color: var(--red);
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1;
  margin-bottom: 7px;
}

.drop-slot strong {
  font-size: 0.62rem;
}

.drop-slot small {
  color: var(--ink-soft);
  font-size: 0.52rem;
  margin-top: 4px;
}

.drop-slot .file-name {
  background: var(--ink);
  bottom: 0;
  color: var(--white);
  display: none;
  font-size: 0.52rem;
  left: 0;
  overflow: hidden;
  padding: 4px;
  position: absolute;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.drop-slot.has-file .file-name {
  display: block;
}

.reference-deck {
  border: 1px solid var(--ink);
  margin-top: 10px;
}

.reference-row {
  align-items: center;
  background: rgba(255, 248, 231, 0.66);
  display: grid;
  gap: 9px;
  grid-template-columns: 53px 1fr auto;
  min-height: 55px;
  padding: 7px 9px;
  position: relative;
}

.reference-row + .reference-row {
  border-top: 1px solid var(--ink);
}

.reference-row:hover {
  background: var(--paper-light);
}

.reference-row.has-file {
  background: #d7efdf;
}

.ref-code {
  background: var(--ink);
  color: var(--corn);
  font-size: 0.56rem;
  font-weight: 900;
  padding: 7px 4px;
  text-align: center;
}

.reference-row strong,
.reference-row small {
  display: block;
}

.reference-row strong {
  font-size: 0.62rem;
}

.reference-row small {
  color: var(--ink-soft);
  font-size: 0.54rem;
  margin-top: 3px;
}

.reference-row output {
  bottom: 2px;
  color: var(--mint-dark);
  font-size: 0.52rem;
  font-weight: 900;
  position: absolute;
  right: 31px;
}

.add-ref {
  color: var(--red);
  font-size: 1.3rem;
  font-weight: 900;
}

.preset-cards {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
}

.preset-card {
  align-items: flex-start;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 82px;
  padding: 9px;
  text-align: left;
}

.preset-card:hover {
  transform: translateY(-2px);
}

.preset-card.is-active {
  background: var(--corn);
  box-shadow: var(--shadow-sm);
}

.preset-card strong {
  font-size: 0.59rem;
  margin-top: 7px;
}

.preset-card small {
  font-size: 0.48rem;
  margin-top: 3px;
  white-space: nowrap;
}

.preset-bars {
  align-items: flex-end;
  display: flex;
  gap: 2px;
  height: 18px;
}

.preset-bars i {
  background: var(--red);
  display: block;
  height: 5px;
  width: 5px;
}

.preset-bars i:nth-child(2) { height: 9px; }
.preset-bars i:nth-child(3) { height: 13px; }
.preset-bars i:nth-child(4) { height: 16px; }
.preset-bars i:nth-child(5) { height: 18px; }

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 11px;
}

.field-grid.two {
  grid-template-columns: 1fr 1fr;
}

.field-grid label,
.full-field {
  display: block;
  min-width: 0;
}

.field-grid label > span,
.full-field > span {
  display: block;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.field-grid input,
.field-grid select,
.advanced-inner input,
.advanced-inner select,
.full-field input,
.advanced-inner textarea {
  min-height: 38px;
  padding: 7px 9px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 16px,
    calc(100% - 8px) 16px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  padding-right: 25px !important;
}

.unit-input {
  align-items: center;
  display: grid;
  grid-template-columns: 1fr auto;
}

.unit-input input {
  grid-column: 1 / 3;
  grid-row: 1;
  padding-right: 29px;
}

.unit-input b {
  grid-column: 2;
  grid-row: 1;
  padding-right: 9px;
}

.range-field {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 34px;
}

.range-field input[type="range"] {
  accent-color: var(--red);
  border: 0;
  min-height: 38px;
  padding: 0;
}

.range-field output {
  align-items: center;
  background: var(--ink);
  color: var(--white);
  display: flex;
  font-size: 0.65rem;
  height: 28px;
  justify-content: center;
}

.is-hidden {
  display: none !important;
}

.frame-readout {
  align-items: center;
  background: var(--paper-deep);
  border: 1px dashed var(--ink);
  display: flex;
  font-size: 0.58rem;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 11px;
  padding: 7px 9px;
}

.frame-readout span:first-child {
  margin-right: auto;
}

.frame-readout strong {
  color: var(--red-dark);
  font-size: 0.78rem;
}

.advanced-block {
  border: var(--border);
  margin: 0 0 18px;
}

.advanced-block summary {
  align-items: center;
  background: var(--paper-deep);
  display: flex;
  font-size: 0.68rem;
  font-weight: 900;
  justify-content: space-between;
  list-style: none;
  padding: 11px;
}

.advanced-block summary::-webkit-details-marker {
  display: none;
}

.advanced-block summary::after {
  content: "+";
  color: var(--red);
  font-size: 1rem;
}

.advanced-block[open] summary::after {
  content: "−";
}

.advanced-block summary small {
  color: var(--ink-soft);
  font-size: 0.55rem;
  font-weight: 500;
  margin-left: auto;
  margin-right: 10px;
}

.advanced-inner {
  background: rgba(255, 248, 231, 0.65);
  border-top: 1px solid var(--ink);
  padding: 12px;
}

.advanced-inner .full-field + .field-grid,
.advanced-inner .field-grid + .full-field,
.advanced-inner .full-field + .full-field {
  margin-top: 12px;
}

.submit-dock {
  align-items: stretch;
  display: grid;
  gap: 9px;
  grid-template-columns: 88px 1fr;
  margin-bottom: 10px;
}

.estimate-block {
  align-items: center;
  background: var(--paper-deep);
  border: var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7px;
  text-align: center;
}

.estimate-block span {
  font-size: 0.49rem;
  font-weight: 900;
}

.estimate-block strong {
  color: var(--red-dark);
  font-size: 0.69rem;
  margin-top: 4px;
}

.render-button {
  align-items: center;
  background: var(--red);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  color: var(--white);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  min-height: 62px;
  padding: 8px 12px;
  text-align: left;
  transition: transform 80ms steps(2), box-shadow 80ms steps(2);
  width: 100%;
}

.render-button:hover {
  background: #ff6848;
}

.render-button:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(4px, 4px);
}

.render-button:disabled {
  cursor: wait;
  filter: grayscale(0.75);
}

.render-button-icon {
  align-items: center;
  background: var(--corn);
  border: 2px solid var(--ink);
  color: var(--ink);
  display: flex;
  height: 31px;
  justify-content: center;
  width: 31px;
}

.render-button strong,
.render-button small {
  display: block;
}

.render-button strong {
  font-family: var(--font-display);
  font-size: 0.79rem;
}

.render-button small {
  font-size: 0.49rem;
  margin-top: 3px;
}

.stage-header,
.queue-head,
.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.stage-coordinates {
  color: var(--ink-soft);
  display: flex;
  font-size: 0.58rem;
  gap: 15px;
}

.video-stage {
  aspect-ratio: 16 / 9;
  background-color: var(--black);
  background-image: radial-gradient(#26384a 1px, transparent 1px);
  background-size: 8px 8px;
  border: 4px solid var(--ink);
  box-shadow: 9px 9px 0 var(--red);
  color: var(--white);
  margin: 19px 9px 0 0;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

.video-stage::before,
.video-stage::after {
  border: 2px solid var(--paper-light);
  content: "";
  height: 13px;
  position: absolute;
  top: 12px;
  width: 13px;
  z-index: 5;
}

.video-stage::before {
  border-bottom: 0;
  border-right: 0;
  left: 12px;
}

.video-stage::after {
  border-bottom: 0;
  border-left: 0;
  right: 12px;
}

.stage-rulers {
  color: #7f909e;
  display: flex;
  font-size: 0.48rem;
  justify-content: space-around;
  left: 12%;
  position: absolute;
  right: 12%;
  top: 10px;
  z-index: 4;
}

.empty-stage {
  align-items: center;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  left: 0;
  padding: 40px;
  position: absolute;
  right: 0;
  text-align: center;
  top: 0;
}

.empty-stage p {
  color: var(--corn);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  margin: 14px 0 7px;
}

.empty-stage h3 {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.7vw, 1.55rem);
  line-height: 1.2;
  margin: 0;
  max-width: 560px;
}

.empty-stage small {
  color: #aeb9c1;
  line-height: 1.45;
  margin-top: 10px;
  max-width: 500px;
}

.pixel-reel {
  border: 3px solid var(--paper-light);
  display: grid;
  gap: 8px;
  grid-template-columns: 8px 28px 8px;
  grid-template-rows: 8px 22px 8px;
  padding: 6px;
  position: relative;
}

.pixel-reel span {
  background: var(--red);
  display: block;
}

.pixel-reel span:nth-child(2) { grid-column: 3; }
.pixel-reel span:nth-child(3) { grid-column: 1; grid-row: 3; }
.pixel-reel span:nth-child(4) { grid-column: 3; grid-row: 3; }
.pixel-reel i {
  align-items: center;
  background: var(--corn);
  color: var(--ink);
  display: flex;
  font-style: normal;
  grid-column: 2;
  grid-row: 1 / 4;
  justify-content: center;
}

#video-player {
  background: #000;
  display: none;
  height: 100%;
  inset: 0;
  object-fit: contain;
  position: absolute;
  width: 100%;
}

#video-player.is-visible {
  display: block;
}

.render-overlay {
  align-items: center;
  background: rgba(20, 32, 44, 0.88);
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  left: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 3;
}

.render-overlay[hidden] {
  display: none;
}

.overlay-scan {
  background: var(--mint);
  box-shadow: 0 0 0 1px var(--mint);
  height: 2px;
  left: 8%;
  opacity: 0.75;
  position: absolute;
  right: 8%;
  top: 16%;
  animation: scan-stage 2.3s steps(12, end) infinite alternate;
}

.render-state {
  background: var(--red);
  border: 2px solid var(--white);
  font-size: 0.62rem;
  font-weight: 900;
  padding: 5px 9px;
}

.render-overlay strong {
  color: var(--corn);
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 6vw, 5.5rem);
  line-height: 1;
  margin: 15px 0 8px;
  text-shadow: 5px 5px 0 var(--red-dark);
}

.render-overlay p {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  margin: 0;
}

.stage-meta {
  background: var(--paper-light);
  bottom: 9px;
  color: var(--ink);
  display: flex;
  font-size: 0.51rem;
  font-weight: 900;
  gap: 9px;
  left: 9px;
  padding: 5px 7px;
  position: absolute;
  z-index: 6;
}

.telemetry {
  background: var(--paper-light);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  margin-top: 22px;
  padding: 14px;
}

.telemetry-top {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 130px 110px;
}

.telemetry-top > div {
  min-width: 0;
}

.telemetry-top span,
.telemetry-top strong {
  display: block;
}

.telemetry-top span {
  color: var(--ink-soft);
  font-size: 0.51rem;
  font-weight: 900;
}

.telemetry-top strong {
  font-size: 0.72rem;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pixel-progress {
  display: grid;
  gap: 3px;
  grid-template-columns: repeat(20, 1fr);
  margin: 13px 0;
}

.pixel-progress i {
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  height: 13px;
}

.pixel-progress i.is-filled {
  background: var(--red);
}

.pixel-progress i.is-head {
  background: var(--corn);
  animation: head-blink 0.8s steps(2, end) infinite;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.recent-section {
  margin-top: 34px;
}

.section-heading {
  border-bottom: var(--border);
  padding-bottom: 8px;
}

.section-heading h2 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin: 0;
}

.section-heading span {
  background: var(--ink);
  color: var(--corn);
  font-size: 0.62rem;
  padding: 4px 7px;
}

.recent-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 15px;
}

.recent-card {
  background: var(--paper-light);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}

.recent-card button {
  background: var(--black);
  border: 0;
  color: var(--white);
  display: block;
  height: 120px;
  padding: 0;
  position: relative;
  width: 100%;
}

.recent-card button::before {
  background-image: radial-gradient(#34495c 1px, transparent 1px);
  background-size: 7px 7px;
  content: "";
  inset: 0;
  position: absolute;
}

.recent-card button span {
  align-items: center;
  background: var(--red);
  border: 2px solid var(--white);
  display: flex;
  font-size: 1rem;
  height: 36px;
  justify-content: center;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  z-index: 2;
}

.recent-card div {
  padding: 9px;
}

.recent-card strong,
.recent-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-card strong {
  font-size: 0.59rem;
}

.recent-card small {
  color: var(--ink-soft);
  font-size: 0.5rem;
  margin-top: 4px;
}

.recent-empty {
  border: 2px dashed rgba(29, 53, 87, 0.45);
  color: var(--ink-soft);
  font-size: 0.67rem;
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
}

.live-badge {
  align-items: center;
  background: var(--ink);
  color: var(--white);
  display: flex;
  font-size: 0.55rem;
  font-weight: 900;
  gap: 6px;
  padding: 5px 7px;
}

.live-badge i {
  background: var(--mint);
  height: 7px;
  width: 7px;
  animation: led-pulse 1.4s steps(2, end) infinite;
}

.queue-machine {
  background: var(--ink);
  border: 3px solid var(--black);
  box-shadow: 6px 6px 0 var(--red);
  color: var(--white);
  margin: 18px 6px 22px 0;
  padding: 12px;
}

.queue-digits {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(3, 1fr);
}

.queue-digits div {
  background: var(--black);
  border: 1px solid #526b80;
  padding: 8px;
  text-align: center;
}

.queue-digits span,
.queue-digits strong {
  display: block;
}

.queue-digits span {
  color: #9fb0bd;
  font-size: 0.48rem;
  font-weight: 900;
}

.queue-digits strong {
  color: var(--corn);
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin-top: 4px;
}

.throughput-line {
  display: flex;
  font-size: 0.49rem;
  justify-content: space-between;
  margin-top: 9px;
}

.throughput-line strong {
  color: var(--mint);
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.queue-empty {
  border: 2px dashed rgba(29, 53, 87, 0.48);
  color: var(--ink-soft);
  padding: 28px 12px;
  text-align: center;
}

.queue-empty span {
  color: var(--red);
  letter-spacing: 5px;
}

.queue-empty p {
  font-size: 0.65rem;
  margin: 10px 0 0;
}

.queue-card {
  background: var(--paper-light);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  position: relative;
}

.queue-card.is-running {
  border-color: var(--red-dark);
  box-shadow: 3px 3px 0 var(--red);
}

.queue-card-top {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: 29px 1fr auto;
}

.queue-number {
  align-items: center;
  background: var(--ink);
  color: var(--corn);
  display: flex;
  font-size: 0.59rem;
  font-weight: 900;
  height: 27px;
  justify-content: center;
}

.queue-card strong,
.queue-card small {
  display: block;
}

.queue-card-title {
  font-size: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-card-sub {
  color: var(--ink-soft);
  font-size: 0.49rem;
  margin-top: 3px;
}

.status-tag {
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  font-size: 0.48rem;
  font-weight: 900;
  padding: 4px;
}

.status-tag.running { background: var(--red); color: var(--white); }
.status-tag.completed { background: var(--mint); }
.status-tag.failed { background: var(--red-dark); color: var(--white); }
.status-tag.cancelled { background: #a7a7a7; }

.mini-progress {
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  height: 7px;
  margin-top: 9px;
}

.mini-progress i {
  background: var(--red);
  display: block;
  height: 100%;
  max-width: 100%;
  width: 0;
}

.queue-card-foot {
  align-items: center;
  color: var(--ink-soft);
  display: flex;
  font-size: 0.49rem;
  justify-content: space-between;
  margin-top: 7px;
}

.queue-card-foot button {
  background: transparent;
  border: 0;
  color: var(--red-dark);
  font-size: 0.5rem;
  font-weight: 900;
  padding: 0;
}

.queue-note,
.api-teaser {
  border: var(--border);
  margin-top: 24px;
  padding: 12px;
}

.queue-note {
  background: var(--corn);
  display: grid;
  gap: 10px;
  grid-template-columns: 25px 1fr;
}

.note-pin {
  align-items: center;
  background: var(--red);
  border: 1px solid var(--ink);
  color: var(--white);
  display: flex;
  font-family: var(--font-display);
  height: 25px;
  justify-content: center;
}

.queue-note strong,
.api-teaser strong {
  font-size: 0.61rem;
}

.queue-note p,
.api-teaser p {
  font-size: 0.56rem;
  line-height: 1.5;
  margin: 6px 0 0;
}

.api-teaser {
  background: var(--paper-light);
  box-shadow: var(--shadow-sm);
}

.api-teaser > div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.api-teaser > div > span {
  background: var(--ink);
  color: var(--mint);
  padding: 5px;
}

.api-teaser .pixel-button {
  margin-top: 12px;
}

.footer-ticker {
  align-items: center;
  background: var(--ink);
  color: var(--paper-light);
  display: flex;
  font-size: 0.52rem;
  font-weight: 900;
  gap: 15px;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 30px;
  overflow: hidden;
  white-space: nowrap;
}

.footer-ticker i {
  background: var(--red);
  height: 7px;
  transform: rotate(45deg);
  width: 7px;
}

.api-dialog {
  background: transparent;
  border: 0;
  color: var(--ink);
  max-height: 92vh;
  max-width: 900px;
  padding: 0;
  width: min(900px, calc(100vw - 28px));
}

.api-dialog::backdrop {
  background: rgba(20, 32, 44, 0.77);
  background-image: radial-gradient(rgba(244, 232, 204, 0.2) 1px, transparent 1px);
  background-size: 8px 8px;
}

.dialog-shell {
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 9px 9px 0 var(--red);
  max-height: 88vh;
  overflow: auto;
}

.dialog-shell > header {
  align-items: center;
  background: var(--ink);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
}

.dialog-shell > header > div {
  align-items: center;
  display: flex;
  gap: 10px;
}

.dialog-shell h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0;
}

.dialog-code {
  background: var(--red);
  border: 1px solid var(--white);
  font-size: 0.55rem;
  padding: 5px;
}

.dialog-close {
  background: var(--paper-light);
  border: 2px solid var(--paper-light);
  color: var(--ink);
  font-size: 1.2rem;
  height: 30px;
  line-height: 1;
  width: 30px;
}

.dialog-content {
  padding: 20px;
}

.dialog-content > p {
  font-size: 0.72rem;
  line-height: 1.6;
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 18px 0 0;
}

.code-tabs button {
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  font-size: 0.59rem;
  font-weight: 900;
  padding: 8px 10px;
}

.code-tabs button.is-active {
  background: var(--red);
  color: var(--white);
}

.code-pane {
  background: var(--black);
  border: 2px solid var(--ink);
  color: #dce9e4;
  min-height: 250px;
}

.code-pane[hidden] {
  display: none;
}

.code-toolbar {
  align-items: center;
  background: #263848;
  border-bottom: 1px solid #526b80;
  display: flex;
  font-size: 0.55rem;
  justify-content: space-between;
  padding: 7px 10px;
}

.code-toolbar button {
  background: var(--mint);
  border: 1px solid var(--white);
  color: var(--ink);
  font-size: 0.52rem;
  font-weight: 900;
  padding: 4px 7px;
}

pre {
  font-size: 0.7rem;
  line-height: 1.65;
  margin: 0;
  overflow: auto;
  padding: 16px;
  tab-size: 2;
}

.code-pane > p {
  color: #a9bac5;
  font-size: 0.62rem;
  line-height: 1.5;
  padding: 0 16px 16px;
}

.parameter-table {
  background: var(--paper-light);
  color: var(--ink);
  overflow: auto;
}

.parameter-table table {
  border-collapse: collapse;
  font-size: 0.64rem;
  width: 100%;
}

.parameter-table th,
.parameter-table td {
  border: 1px solid var(--ink);
  padding: 8px;
  text-align: left;
}

.parameter-table th {
  background: var(--corn);
}

.api-links {
  align-items: center;
  display: flex;
  font-size: 0.58rem;
  font-weight: 900;
  justify-content: space-between;
  margin-top: 13px;
}

.api-links a {
  color: var(--red-dark);
}

.toast-stack {
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  width: min(360px, calc(100vw - 36px));
  z-index: 1000;
}

.toast {
  background: var(--paper-light);
  border: var(--border);
  box-shadow: var(--shadow);
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1.45;
  padding: 11px 13px;
  pointer-events: auto;
  animation: toast-in 180ms steps(3, end);
}

.toast.error {
  background: var(--red);
  color: var(--white);
}

.toast.success {
  background: var(--mint);
}

@keyframes led-pulse {
  50% { opacity: 0.42; }
}

@keyframes scan-stage {
  from { top: 14%; }
  to { top: 84%; }
}

@keyframes head-blink {
  50% { background: var(--red); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(12px, 12px); }
  to { opacity: 1; transform: translate(0, 0); }
}

@media (max-width: 1320px) {
  .workbench {
    grid-template-columns: minmax(320px, 370px) minmax(480px, 1fr);
  }

  .queue-column {
    border-left: 0;
    border-top: 3px solid var(--ink);
    grid-column: 1 / -1;
  }

  .queue-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .queue-note,
  .api-teaser {
    display: inline-grid;
    margin-right: 16px;
    vertical-align: top;
    width: calc(50% - 11px);
  }
}

@media (max-width: 940px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .machine-strip {
    border-left: 0;
    border-right: 0;
    border-top: var(--border);
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }

  .top-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .workbench {
    display: block;
  }

  .control-column {
    border-bottom: 3px solid var(--ink);
    border-right: 0;
  }

  .control-column form {
    margin: 0 auto;
    max-width: 650px;
  }

  .stage-column {
    min-height: 700px;
  }

  .queue-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  html {
    font-size: 14px;
  }

  .topbar {
    position: static;
  }

  .brand {
    padding: 9px 11px;
  }

  .brand-copy small {
    display: none;
  }

  .brand-mark {
    transform: scale(0.86);
  }

  .top-actions {
    gap: 5px;
    padding: 8px;
  }

  .top-actions .pixel-button.quiet span:last-child {
    display: none;
  }

  .pixel-button.language {
    min-width: 72px;
  }

  .machine-cell {
    min-width: auto;
    padding: 8px 10px;
  }

  .control-column,
  .stage-column,
  .queue-column {
    padding: 17px 13px 25px;
  }

  .field-grid.two,
  .frame-pair,
  .preset-cards {
    grid-template-columns: 1fr;
  }

  .preset-cards {
    gap: 6px;
  }

  .preset-card {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: 36px 1fr auto;
    min-height: 52px;
  }

  .preset-card strong,
  .preset-card small {
    margin: 0;
  }

  .submit-dock {
    grid-template-columns: 1fr;
  }

  .estimate-block {
    flex-direction: row;
    gap: 8px;
  }

  .video-stage {
    aspect-ratio: 4 / 3;
    min-height: 0;
  }

  .empty-stage {
    padding: 25px;
  }

  .telemetry-top {
    grid-template-columns: 1fr 1fr;
  }

  .telemetry-top > div:first-child {
    grid-column: 1 / -1;
  }

  .recent-grid,
  .queue-list {
    grid-template-columns: 1fr;
  }

  .queue-note,
  .api-teaser {
    display: grid;
    margin-right: 0;
    width: 100%;
  }

  .footer-ticker {
    justify-content: flex-start;
    overflow-x: auto;
    padding: 0 12px;
  }

  .dialog-content {
    padding: 13px;
  }

  .api-links {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
