:root {
  color-scheme: dark;
  --bg: #1c1b19;
  --surface: #26241f;
  --amber: #e8a33d;
  --blue: #6fa8d8;
  --ivory: #f0eae0;
  --line: #3a362e;
  --text: #f0eae0;
  --text-muted: rgba(240, 234, 224, 0.72);
  --text-soft: rgba(240, 234, 224, 0.68);
  --text-dim: rgba(240, 234, 224, 0.58);
  --button-ink: #1c1b19;
  --accent-label: #e8a33d;
  --accent-line: #e8a33d;
  --focus: #e8a33d;
  --focus-accent: #e8a33d;
  --code-color: #6fa8d8;
  --meter-readout: #e8a33d;
  --indicator-edge: transparent;
  --amber-glow: rgba(232, 163, 61, 0.55);
  --blue-glow: rgba(111, 168, 216, 0.5);
  --grid-line: rgba(58, 54, 46, 0.6);
  --switch-off: rgba(240, 234, 224, 0.4);
  --overlay: rgba(28, 27, 25, 0.88);
  --font-display: "Space Grotesk", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --z-dialog: 40;
  --z-toast: 50;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3efe7;
  --surface: #e8e1d3;
  --amber: #c97c1f;
  --blue: #3f6e96;
  --ivory: #2a2620;
  --line: #d6cdbb;
  --text: #2a2620;
  --text-muted: rgba(42, 38, 32, 0.72);
  --text-soft: rgba(42, 38, 32, 0.68);
  --text-dim: rgba(42, 38, 32, 0.68);
  --button-ink: #2a2620;
  --accent-label: #2a2620;
  --accent-line: #2a2620;
  --focus: #2a2620;
  --focus-accent: #c97c1f;
  --code-color: #2a2620;
  --meter-readout: #2a2620;
  --indicator-edge: #2a2620;
  --amber-glow: rgba(201, 124, 31, 0.32);
  --blue-glow: rgba(63, 110, 150, 0.28);
  --grid-line: rgba(214, 205, 187, 0.75);
  --switch-off: rgba(42, 38, 32, 0.32);
  --overlay: rgba(42, 38, 32, 0.6);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f3efe7;
    --surface: #e8e1d3;
    --amber: #c97c1f;
    --blue: #3f6e96;
    --ivory: #2a2620;
    --line: #d6cdbb;
    --text: #2a2620;
    --text-muted: rgba(42, 38, 32, 0.72);
    --text-soft: rgba(42, 38, 32, 0.68);
    --text-dim: rgba(42, 38, 32, 0.68);
    --button-ink: #2a2620;
    --accent-label: #2a2620;
    --accent-line: #2a2620;
    --focus: #2a2620;
    --focus-accent: #c97c1f;
    --code-color: #2a2620;
    --meter-readout: #2a2620;
    --indicator-edge: #2a2620;
    --amber-glow: rgba(201, 124, 31, 0.32);
    --blue-glow: rgba(63, 110, 150, 0.28);
    --grid-line: rgba(214, 205, 187, 0.75);
    --switch-off: rgba(42, 38, 32, 0.32);
    --overlay: rgba(42, 38, 32, 0.6);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

.disabled {
  pointer-events: none;
  opacity: 0.46;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
summary,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px var(--focus-accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

::selection {
  background: var(--amber);
  color: var(--button-ink);
}

html,
body,
.instrument-bar,
.control-bay,
.development-bay,
.contact-sheet,
.instrument-input,
.prompt-plate,
.reference-item,
.image-stage,
.meter-panel,
.result-actions.stage-toolbar,
.task-card,
.film-strip,
.docs-panel,
.docs-dialog,
.theme-command,
.nav-link,
.lightbox-close,
#toast {
  transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease;
}

.instrument-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(380px, 1.4fr) minmax(250px, 0.8fr);
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand,
.header-readouts,
.header-actions {
  min-width: 0;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ivory);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--amber);
  border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  inset: 4px;
  border: 1px solid var(--amber);
  border-radius: 50%;
  content: "";
}

.brand-mark::after {
  inset: 8px;
  background: var(--amber);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.brand-divider,
.brand-cn {
  color: var(--text-dim);
}

.header-readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-inline: 1px solid var(--line);
}

.readout {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 0 18px;
}

.readout + .readout {
  border-left: 1px solid var(--line);
}

.readout span {
  color: var(--text-dim);
  font-size: 11px;
}

.readout strong {
  overflow: hidden;
  margin-top: 2px;
  color: var(--code-color);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.text-command,
.theme-command,
.icon-command,
.rack-command,
.stage-command {
  border: 0;
  background: transparent;
}

.theme-command {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-muted);
}

.theme-command:hover {
  border-color: var(--amber);
  color: var(--text);
}

.theme-command svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.7;
}

.theme-icon-darkroom {
  display: none;
}

.theme-command[data-resolved-theme="light"] .theme-icon-sun {
  display: none;
}

.theme-command[data-resolved-theme="light"] .theme-icon-darkroom {
  display: block;
}

:root[data-theme="light"] .theme-icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-icon-darkroom {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-icon-sun {
    display: none;
  }

  :root:not([data-theme]) .theme-icon-darkroom {
    display: block;
  }
}

.text-command {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.text-command:hover {
  color: var(--ivory);
}

.text-command svg,
.icon-command svg,
.rack-command svg,
.stage-command svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.7;
}

.connection-state,
.stage-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.state-lamp {
  width: 7px;
  height: 7px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--line);
}

.connection-state.is-connected .state-lamp,
.stage-status.is-ready .state-lamp,
.stage-status.is-complete .state-lamp {
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue-glow);
}

.stage-status.is-working .state-lamp {
  border-color: var(--accent-line);
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}

.connection-state.is-offline .state-lamp,
.stage-status.is-error .state-lamp {
  border-color: var(--ivory);
  background: transparent;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(560px, 1.58fr);
  grid-template-areas:
    "control development"
    "history history";
  max-width: 1720px;
  margin: 0 auto;
  padding: 18px;
  gap: 18px;
}

.control-bay,
.development-bay,
.contact-sheet {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.control-bay {
  grid-area: control;
  padding: 22px;
}

.development-bay {
  grid-area: development;
  padding: 22px;
}

.contact-sheet {
  grid-area: history;
  padding: 20px 22px 22px;
}

.section-heading,
.contact-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-index {
  margin: 0 0 3px;
  color: var(--accent-label);
  font-family: var(--font-mono);
  font-size: 10px;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0;
  text-wrap: balance;
}

h1,
h2 {
  font-size: 21px;
  font-weight: 600;
}

h3 {
  font-size: 15px;
}

.serial-number,
.instrument-value,
.summary-value {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.serial-number {
  padding-top: 5px;
}

.control-group {
  margin-bottom: 22px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.label-row label,
.instrument-control > span,
.range-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.instrument-input,
.prompt-plate,
.instrument-control input,
.instrument-control select,
.stepper {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.instrument-input {
  display: flex;
  align-items: center;
  padding-left: 12px;
}

.instrument-input > svg {
  width: 16px;
  flex: 0 0 auto;
  color: var(--accent-line);
}

.instrument-input input {
  min-width: 0;
  flex: 1;
  height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 12px;
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 12px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

.icon-command {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text-dim);
}

.icon-command:hover {
  color: var(--accent-line);
}

.field-note {
  margin: 7px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.prompt-plate {
  position: relative;
  overflow: hidden;
}

.prompt-plate textarea {
  width: 100%;
  min-height: 156px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 14px 22px 14px 14px;
  color: var(--ivory);
  font-size: 14px;
  line-height: 1.65;
}

.plate-scale {
  position: absolute;
  top: 10px;
  right: 7px;
  bottom: 10px;
  display: flex;
  width: 7px;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.plate-scale span {
  display: block;
  width: 5px;
  border-top: 1px solid var(--line);
}

.plate-scale span:nth-child(4) {
  width: 7px;
  border-color: var(--blue);
}

.reference-rack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.reference-slot {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.reference-slot.is-filled {
  border-color: var(--blue);
}

.reference-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-reference {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ivory);
}

.remove-reference:hover {
  border-color: var(--amber);
  color: var(--accent-line);
}

.remove-reference svg {
  width: 14px;
  height: 14px;
}

.rack-command {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--text-soft);
}

.rack-command:hover,
.reference-rack.is-dragging + .rack-command {
  border-color: var(--blue);
  color: var(--code-color);
}

.primary-settings,
.advanced-grid {
  display: grid;
  gap: 10px;
}

.primary-settings {
  grid-template-columns: 1.35fr 1fr 0.8fr;
  margin-bottom: 14px;
}

.instrument-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.instrument-control input,
.instrument-control select {
  width: 100%;
  height: 44px;
  min-width: 0;
  outline: 0;
  padding: 0 10px;
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 11px;
}

.instrument-control select {
  appearance: auto;
}

.stepper {
  display: grid;
  grid-template-columns: 44px minmax(44px, 1fr) 44px;
  overflow: hidden;
}

.stepper button,
.stepper input {
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--ivory);
  text-align: center;
}

.stepper button {
  color: var(--accent-label);
  font-family: var(--font-mono);
  font-size: 18px;
}

.stepper button:hover {
  background: var(--line);
}

.stepper input {
  width: 100%;
  border-inline: 1px solid var(--line);
  outline: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.advanced-panel,
.development-log {
  border-block: 1px solid var(--line);
}

.advanced-panel {
  margin-bottom: 18px;
}

.advanced-panel summary,
.development-log summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 12px;
}

.advanced-panel summary::-webkit-details-marker,
.development-log summary::-webkit-details-marker {
  display: none;
}

.advanced-panel summary::after,
.development-log summary::after {
  color: var(--accent-label);
  content: "+";
  font-family: var(--font-mono);
  font-size: 15px;
}

.advanced-panel[open] summary::after,
.development-log[open] summary::after {
  content: "−";
}

.advanced-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px 0 16px;
}

.style-control {
  grid-column: 1 / -1;
}

.range-control,
.switch-control {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.range-control {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
}

.range-label {
  display: flex;
  justify-content: space-between;
}

.range-label output {
  color: var(--accent-label);
  font-family: var(--font-mono);
}

input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid var(--accent-line);
  border-radius: 50%;
  background: var(--amber);
}

.switch-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--text);
  font-size: 12px;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  display: flex;
  width: 38px;
  height: 20px;
  flex: 0 0 auto;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.switch-track span {
  width: 12px;
  height: 12px;
  background: var(--switch-off);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), background 180ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: var(--amber);
}

.switch-control input:checked + .switch-track span {
  transform: translateX(18px);
  background: var(--amber);
}

.switch-control input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px var(--focus-accent);
}

.expose-button {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  width: 100%;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--button-ink);
  border-radius: 4px;
  background: var(--amber);
  padding: 0 16px 0 8px;
  color: var(--button-ink);
}

.expose-button:hover {
  box-shadow: inset 0 0 0 2px var(--button-ink);
}

.button-aperture {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--button-ink);
  border-radius: 50%;
}

.button-aperture::before,
.button-aperture::after {
  position: absolute;
  inset: 7px;
  border: 1px solid var(--button-ink);
  border-radius: 50%;
  content: "";
}

.button-aperture::after {
  inset: 14px;
  background: var(--button-ink);
}

.button-label {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.button-state {
  font-family: var(--font-mono);
  font-size: 10px;
}

.expose-button.is-working .button-aperture {
  animation: aperture-turn 900ms linear infinite;
}

.form-error {
  margin: 10px 0 0;
  border: 1px solid var(--amber);
  padding: 10px 12px;
  color: var(--ivory);
  font-size: 12px;
}

.stage-heading {
  align-items: center;
}

.stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 164px;
  min-height: 590px;
  gap: 14px;
}

.image-stage {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  isolation: isolate;
}

.image-stage::before,
.image-stage::after {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  content: "";
}

.image-stage::before {
  top: 50%;
  right: 12px;
  left: 12px;
  border-top: 1px solid var(--grid-line);
}

.image-stage::after {
  top: 12px;
  bottom: 12px;
  left: 50%;
  border-left: 1px solid var(--grid-line);
}

.stage-corners span {
  position: absolute;
  z-index: 8;
  width: 18px;
  height: 18px;
  border-color: var(--blue);
  border-style: solid;
  pointer-events: none;
}

.stage-corners span:nth-child(1) { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.stage-corners span:nth-child(2) { top: 8px; right: 8px; border-width: 1px 1px 0 0; }
.stage-corners span:nth-child(3) { right: 8px; bottom: 8px; border-width: 0 1px 1px 0; }
.stage-corners span:nth-child(4) { bottom: 8px; left: 8px; border-width: 0 0 1px 1px; }

.result-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.26;
  filter: blur(8px);
  transform: scale(1.008);
  transition: filter 760ms cubic-bezier(0.16, 1, 0.3, 1), opacity 760ms cubic-bezier(0.16, 1, 0.3, 1), transform 760ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: filter, opacity, transform;
}

.result-image.is-revealed {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
  will-change: auto;
}

.image-stage.is-developed {
  animation: developed-border-pulse 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.empty-stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px;
  text-align: center;
}

.empty-stage strong {
  margin-top: 20px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.empty-stage p {
  max-width: 46ch;
  margin: 8px auto 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.aperture-large {
  position: relative;
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.aperture-large::before,
.aperture-large::after {
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 50%;
  content: "";
}

.aperture-large::before { inset: 16px; }
.aperture-large::after { inset: 34px; border-color: var(--amber); }

.stage-toolbar {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 12;
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  padding: 4px;
}

.stage-toolbar[hidden] {
  display: none;
}

.stage-command {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 1;
  color: var(--text-muted);
  font-size: 11px;
}

.stage-command:hover {
  background: var(--line);
  color: var(--ivory);
}

.meter-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  padding: 14px;
}

.meter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
}

.vu-meter {
  position: relative;
  height: 150px;
  margin-top: 14px;
  overflow: hidden;
}

.meter-arc {
  position: absolute;
  right: 7px;
  bottom: -54px;
  left: 7px;
  height: 124px;
  border: 1px solid var(--line);
  border-radius: 50% 50% 0 0;
}

.meter-scale span {
  position: absolute;
  top: calc(98px - sin((var(--tick) / 100) * 3.14159) * 68px);
  left: calc(50% - cos((var(--tick) / 100) * 3.14159) * 58px);
  transform: translate(-50%, -50%);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.meter-needle {
  position: absolute;
  bottom: 10px;
  left: calc(50% - 1px);
  width: 2px;
  height: 104px;
  transform: rotate(-58deg);
  transform-origin: 50% calc(100% - 2px);
  background: var(--amber);
  box-shadow: 0 0 0 1px var(--indicator-edge), 0 0 7px var(--amber-glow);
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.meter-pivot {
  position: absolute;
  bottom: 4px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--amber);
}

.meter-number {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: var(--meter-readout);
  font-family: var(--font-mono);
  font-size: 34px;
  line-height: 1;
}

.meter-number small {
  margin: 0 0 3px 3px;
  color: var(--text-dim);
  font-size: 10px;
}

.stage-data {
  margin: 22px 0 0;
}

.stage-data div {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.stage-data dt,
.stage-data dd {
  min-width: 0;
  margin: 0;
  font-size: 10px;
}

.stage-data dt {
  color: var(--text-dim);
}

.stage-data dd {
  overflow: hidden;
  color: var(--code-color);
  font-family: var(--font-mono);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 4px;
  margin-top: auto;
  overflow: hidden;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
  background: var(--amber);
  box-shadow: inset 0 1px 0 var(--indicator-edge), inset 0 -1px 0 var(--indicator-edge);
  transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1);
}

.development-log {
  margin-top: 14px;
}

.development-log ol {
  display: grid;
  margin: 0;
  padding: 4px 0 16px 24px;
  gap: 8px;
}

.development-log li {
  padding-left: 4px;
  color: var(--text-soft);
  font-size: 12px;
}

.development-log li::marker {
  color: var(--code-color);
  font-family: var(--font-mono);
}

.contact-heading {
  align-items: flex-end;
  margin-bottom: 14px;
}

.history-summary {
  display: flex;
  align-items: center;
  gap: 18px;
}

.film-strip {
  display: flex;
  min-height: 184px;
  gap: 9px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 13px 12px 16px;
  border-block: 10px solid var(--bg);
  scrollbar-color: var(--line) var(--bg);
  scrollbar-width: thin;
}

.film-frame {
  position: relative;
  width: 160px;
  flex: 0 0 160px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.film-frame::before,
.film-frame::after {
  position: absolute;
  right: 6px;
  left: 6px;
  z-index: 4;
  height: 4px;
  background: var(--surface);
  content: "";
}

.film-frame::before { top: -8px; }
.film-frame::after { bottom: -8px; }

.film-frame:hover,
.film-frame:focus-within {
  transform: translateY(-3px) rotate(-0.35deg) scale(1.015);
  border-color: var(--amber);
}

.film-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--surface);
}

.film-image-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.film-meta {
  min-width: 0;
  padding: 7px;
}

.film-meta strong,
.film-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.film-meta strong {
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
}

.film-meta span {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 9px;
}

.film-actions {
  position: absolute;
  inset: 4px 4px auto;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.film-frame:hover .film-actions,
.film-frame:focus-within .film-actions {
  opacity: 1;
}

.film-action {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ivory);
}

.film-action:hover {
  border-color: var(--amber);
  color: var(--accent-line);
}

.film-action svg {
  width: 14px;
  height: 14px;
}

.history-empty {
  display: flex;
  min-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.history-empty svg {
  width: 18px;
  color: var(--blue);
}

.docs-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 22px;
  color: var(--ivory);
  z-index: var(--z-dialog);
}

.docs-dialog::backdrop {
  background: var(--overlay);
}

.docs-content {
  display: grid;
  gap: 0;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.docs-content section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.docs-content p {
  max-width: 65ch;
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: var(--z-toast);
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
}

.toast {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 12px 14px;
  color: var(--ivory);
  font-size: 12px;
  animation: toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.toast.is-error {
  border-color: var(--amber);
}

@keyframes aperture-turn {
  to { transform: rotate(360deg); }
}

@keyframes developed-border-pulse {
  0%, 100% {
    border-color: var(--line);
    box-shadow: inset 0 0 0 0 transparent;
  }
  34% {
    border-color: var(--amber);
    box-shadow: inset 0 0 0 1px var(--amber), inset 0 0 10px var(--amber-glow);
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1120px) {
  .instrument-bar {
    grid-template-columns: 1fr auto;
  }

  .header-readouts {
    display: none;
  }

  .header-actions {
    border-left: 1px solid var(--line);
  }

  .workbench {
    grid-template-columns: minmax(320px, 0.86fr) minmax(480px, 1.4fr);
  }

  .stage-layout {
    grid-template-columns: minmax(0, 1fr) 142px;
  }
}

@media (max-width: 900px) {
  .instrument-bar {
    position: static;
  }

  .workbench {
    grid-template-columns: 1fr;
    grid-template-areas:
      "control"
      "development"
      "history";
  }

  .stage-layout {
    min-height: 520px;
  }

  .image-stage {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .instrument-bar {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .brand {
    min-height: 62px;
    padding: 0 16px;
  }

  .header-actions {
    min-height: 50px;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding: 0 16px;
  }

  .workbench {
    padding: 10px;
    gap: 10px;
  }

  .control-bay,
  .development-bay,
  .contact-sheet {
    padding: 16px;
  }

  .primary-settings {
    grid-template-columns: 1fr 1fr;
  }

  .quantity-control {
    grid-column: 1 / -1;
  }

  .stage-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .image-stage {
    min-height: 440px;
  }

  .meter-panel {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 14px;
  }

  .meter-title,
  .progress-track {
    grid-column: 1 / -1;
  }

  .vu-meter {
    height: 115px;
    margin: 0;
  }

  .meter-needle {
    height: 80px;
  }

  .meter-number {
    display: none;
  }

  .stage-data {
    margin: 0;
  }

  .stage-toolbar {
    flex-wrap: wrap;
  }

  .stage-command {
    min-width: calc(50% - 4px);
  }

  .film-frame {
    width: 148px;
    flex-basis: 148px;
  }

  .film-actions {
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .brand-divider,
  .brand-cn {
    display: none;
  }

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

  .advanced-grid,
  .primary-settings {
    grid-template-columns: 1fr;
  }

  .quantity-control,
  .style-control {
    grid-column: auto;
  }

  .image-stage {
    min-height: 390px;
  }

  .stage-command {
    min-width: 100%;
  }
}

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

  .result-image {
    filter: none;
    transform: none;
    transition: opacity 180ms ease-out !important;
  }

  .image-stage.is-developed {
    animation: none;
    border-color: var(--amber);
  }
}

/* Remote image-web compatibility layer: keep the existing queue contract while using the darkroom surface. */
.stage-copy {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.reference-rack:empty::before {
  display: block;
  grid-column: 1 / -1;
  padding: 8px 0;
  color: var(--text-dim);
  content: "点击上方装载参考片，或直接粘贴图片";
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.reference-item {
  position: relative;
  height: auto;
  min-height: 76px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
}

.reference-item img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 76px;
  object-fit: cover;
}

.reference-item button {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ivory);
  box-shadow: none;
  font-size: 16px;
}

.reference-item button:hover {
  border-color: var(--amber);
  color: var(--accent-line);
}

.loading-art {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface);
  padding: 42px;
}

.loading-outline {
  position: absolute;
  inset: 24px;
  border: 1px solid var(--line);
  opacity: 0.72;
}

.loading-outline span {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--blue);
  border-style: solid;
}

.loading-outline span:nth-child(1) { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.loading-outline span:nth-child(2) { top: -1px; right: -1px; border-width: 1px 1px 0 0; }
.loading-outline span:nth-child(3) { right: -1px; bottom: -1px; border-width: 0 1px 1px 0; }
.loading-outline span:nth-child(4) { bottom: -1px; left: -1px; border-width: 0 0 1px 1px; }

.developing-progress {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100% - 48px));
}

.developing-progress-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.developing-progress-head > span {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.developing-progress-number {
  min-width: 4ch;
  color: var(--meter-readout);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.developing-progress-track {
  display: block;
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--indicator-edge);
  background: var(--line);
}

.developing-progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--develop-progress, 0));
  transform-origin: left center;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
  transition: transform 520ms cubic-bezier(0.25, 1, 0.5, 1);
}

.developing-progress p {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.task-queue {
  display: grid;
  gap: 8px;
  padding: 2px 0 14px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  padding: 10px;
  color: var(--ivory);
  text-align: left;
}

.task-view {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  text-align: left;
}

.task-card.active,
.task-card.done {
  border-color: var(--blue);
}

.task-card.error,
.task-card.cancelled {
  border-color: var(--amber);
}

.task-title,
.task-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title {
  color: var(--ivory);
  font-size: 12px;
  font-weight: 500;
}

.task-subtitle {
  margin-top: 3px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.task-progress {
  grid-column: 1 / -1;
  display: block;
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

.task-progress span {
  display: block;
  height: 100%;
  background: var(--amber);
  box-shadow: inset 0 1px 0 var(--indicator-edge), inset 0 -1px 0 var(--indicator-edge);
}

.task-cancel {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--accent-label);
}

.result-actions.stage-toolbar {
  position: static;
  inset: auto;
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  padding: 4px;
}

.result-actions.stage-toolbar .stage-command {
  position: static;
  min-height: 44px;
}

.meter-scale {
  position: absolute;
  inset: 0;
}

.meter-scale span {
  position: absolute;
  top: auto;
  left: auto;
  transform: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.meter-scale span:nth-child(1) { bottom: 24px; left: 2px; }
.meter-scale span:nth-child(2) { top: 58px; left: 18px; }
.meter-scale span:nth-child(3) { top: 35px; left: 44px; }
.meter-scale span:nth-child(4) { top: 35px; right: 44px; }
.meter-scale span:nth-child(5) { top: 58px; right: 18px; }
.meter-scale span:nth-child(6) { right: 2px; bottom: 24px; }

.history-item {
  position: relative;
  display: block;
  width: 160px;
  min-width: 160px;
  height: auto;
  flex: 0 0 160px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  padding: 0;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), border-color 180ms ease;
}

.history-item:hover,
.history-item:focus-within {
  transform: translateY(-3px) rotate(-0.35deg) scale(1.015);
  border-color: var(--amber);
}

.history-preview {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  text-align: left;
}

.history-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--surface);
}

.history-caption {
  position: static;
  display: block;
  overflow: hidden;
  padding: 7px;
  background: transparent;
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.history-item:hover .history-actions,
.history-item:focus-within .history-actions {
  opacity: 1;
}

.history-actions button {
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ivory);
  box-shadow: none;
  font-size: 10px;
}

.history-actions button:hover {
  border-color: var(--amber);
  color: var(--accent-label);
}

#toast {
  right: 18px;
  bottom: 18px;
  left: auto;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ivory);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.image-lightbox.show {
  opacity: 1;
  pointer-events: auto;
}

.image-lightbox img {
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  background: var(--surface);
  object-fit: contain;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ivory);
}

.image-stage.is-developing > .empty-state,
.image-stage.is-revealing > .empty-state {
  display: none !important;
}

@media (max-width: 900px) {
  .header-readouts { display: none; }
  .instrument-bar { grid-template-columns: 1fr auto; }
}

@media (max-width: 640px) {
  .instrument-bar { grid-template-columns: 1fr; }
  .history-item { width: 148px; min-width: 148px; flex-basis: 148px; }
  .history-actions { opacity: 1; }
}

/* Shared documentation page */
.docs-shell {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.docs-topbar,
.topbar {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.topbar .brand {
  padding: 0;
}

.topbar .brand > div:last-child {
  min-width: 0;
}

.topbar .brand h1 {
  font-size: 19px;
}

.topbar .brand p {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--ivory);
  font-size: 12px;
  text-decoration: none;
}

.nav-link:hover {
  border-color: var(--amber);
  color: var(--accent-label);
}

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

.docs-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 22px;
}

.docs-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.docs-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-label);
  font-family: var(--font-mono);
  font-size: 10px;
}

.docs-panel h2 {
  font-size: 20px;
}

.docs-panel p,
.docs-copy {
  max-width: 70ch;
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.docs-panel a {
  color: var(--code-color);
  text-decoration-color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.quick-grid,
.settings-list,
.step-list,
.note-grid {
  margin-top: 16px;
}

.quick-grid {
  display: grid;
  gap: 8px;
}

.quick-card,
.setting-row,
.note-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.quick-card {
  display: block;
  padding: 11px 12px;
  text-decoration: none;
}

.quick-card span,
.setting-row span,
.note-card span {
  color: var(--text-dim);
  font-size: 11px;
}

.quick-card strong,
.note-card strong {
  display: block;
  margin-top: 3px;
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.docs-section-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-list {
  display: grid;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 0;
  border-width: 0 0 1px;
  padding: 11px 0;
}

code {
  color: var(--code-color);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.step-list {
  display: grid;
  padding-left: 22px;
  gap: 12px;
}

.step-list li {
  padding-left: 4px;
  color: var(--accent-label);
}

.step-list strong,
.step-list span {
  display: block;
}

.step-list strong {
  color: var(--ivory);
  font-size: 13px;
}

.step-list span {
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 12px;
}

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

.note-card {
  padding: 12px;
}

.note-card strong {
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 12px;
}

.note-card span {
  display: block;
  margin-top: 4px;
}

@media (max-width: 760px) {
  .docs-shell { width: min(100% - 20px, 680px); padding-top: 12px; }
  .docs-topbar, .topbar { align-items: flex-start; flex-direction: column; padding-bottom: 12px; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-hero { grid-column: auto; grid-template-columns: 1fr; }
  .note-grid { grid-template-columns: 1fr; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 4px; }
}
