:root {
  --ink-0: #090807;
  --ink-1: #0d0c0b;
  --ink-2: #141210;
  --ink-3: #1b1815;
  --ink-4: #26211d;
  --line: #36302a;
  --line-soft: #28231f;
  --paper: #eee7db;
  --paper-dim: #bcb3a5;
  --muted: #8f877c;
  --red: #e65732;
  --red-hot: #ff6b43;
  --red-deep: #7f2818;
  --amber: #d4a66b;
  --green: #72a884;
  --danger: #ff7258;
  --font-display: "Iowan Old Style", "Baskerville", "Songti SC", "STSong", serif;
  --font-body: "Avenir Next Condensed", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SFMono-Regular", "Menlo", "Roboto Mono", monospace;
  --shadow-deep: 0 32px 90px rgba(0, 0, 0, 0.34);
  --radius-sm: 3px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(circle at 80% 6%, rgba(145, 77, 43, 0.08), transparent 28rem),
    linear-gradient(115deg, #0b0a09 0%, #100e0d 48%, #0a0908 100%);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled),
label:has(input:not(:disabled)) {
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: var(--ink-0);
  background: var(--paper);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.grain,
.safelight {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.grain {
  z-index: 20;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.safelight {
  z-index: -1;
  background: radial-gradient(circle at 13% -4%, rgba(230, 87, 50, 0.2), transparent 24rem);
}

.masthead {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 18px clamp(20px, 4vw, 68px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 8, 7, 0.7);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 17px;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border: 1px solid #5b3125;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px var(--ink-1), inset 0 0 0 6px #40271f;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 8px;
  height: 1px;
  background: var(--red);
  content: "";
}

.brand-mark::before {
  left: -4px;
}

.brand-mark::after {
  right: -4px;
}

.brand-mark span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 22px rgba(230, 87, 50, 0.72);
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.brand-lockup h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 2vw, 29px);
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1;
}

.brand-lockup h1 span {
  margin-left: 7px;
  color: var(--paper-dim);
  font-family: var(--font-body);
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  vertical-align: middle;
}

.account-rail {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 4px;
  color: var(--paper-dim);
  font-size: 12px;
}

.account-copy,
.account-data {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-copy {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 9px rgba(212, 166, 107, 0.6);
}

.connection-dot.online {
  background: var(--green);
  box-shadow: 0 0 9px rgba(114, 168, 132, 0.5);
}

.connection-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 9px rgba(255, 114, 88, 0.55);
}

.account-data strong {
  color: var(--paper);
  font-family: var(--font-mono);
  font-weight: 500;
}

.rail-divider {
  width: 1px;
  height: 10px;
  background: var(--line);
}

.global-error {
  position: relative;
  z-index: 25;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin: 16px clamp(20px, 4vw, 68px) 0;
  padding: 13px 14px;
  border: 1px solid rgba(255, 114, 88, 0.36);
  border-left: 3px solid var(--danger);
  background: #1f1210;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}

.error-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 114, 88, 0.45);
  border-radius: 50%;
  color: var(--danger);
  font-family: var(--font-display);
  font-size: 17px;
}

.error-copy strong {
  font-size: 13px;
}

.error-copy p {
  margin: 2px 0 0;
  color: var(--paper-dim);
  font-size: 12px;
}

.error-close {
  width: 34px;
  height: 34px;
  font-size: 20px;
}

main {
  position: relative;
  z-index: 10;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 58px) clamp(16px, 4vw, 68px) 90px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(330px, 425px) minmax(0, 1fr);
  gap: clamp(18px, 2.5vw, 38px);
  align-items: start;
}

.control-panel,
.stage-panel {
  min-width: 0;
}

.control-panel {
  border-top: 1px solid var(--red-deep);
  background: linear-gradient(180deg, rgba(26, 23, 20, 0.92), rgba(16, 14, 13, 0.92));
  box-shadow: var(--shadow-deep);
  animation: rise-in 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.panel-heading,
.stage-toolbar,
.history-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading {
  padding: 24px 25px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading h2,
.stage-toolbar h2,
.history-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.035em;
}

.panel-heading h2 {
  font-size: 22px;
}

.model-stamp {
  flex: 0 0 auto;
  padding: 5px 7px 4px;
  border: 1px solid #503529;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.13em;
  transform: rotate(-1.5deg);
}

.control-block {
  padding: 23px 25px;
  border-bottom: 1px solid var(--line-soft);
}

.control-title-row,
.control-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-title {
  justify-content: flex-start;
}

.control-title label,
.control-title h3 {
  margin: 0;
  color: var(--paper);
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.control-title h3 em {
  margin-left: 5px;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 500;
}

.step-index {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.counter,
.privacy-note {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.privacy-note::before {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  content: "";
  vertical-align: 1px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 158px;
  margin: 14px 0 0;
  padding: 15px 16px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  caret-color: var(--red-hot);
  background:
    linear-gradient(rgba(230, 87, 50, 0.02), rgba(230, 87, 50, 0.02)),
    #100f0e;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:hover {
  border-color: #514940;
}

textarea:focus {
  border-color: #84402d;
  box-shadow: inset 3px 0 0 var(--red-deep), 0 0 0 1px rgba(230, 87, 50, 0.08);
  outline: none;
}

textarea::placeholder {
  color: #635d56;
}

textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-hint,
.field-error {
  margin: 9px 0 0;
  font-size: 10px;
  line-height: 1.55;
}

.field-hint {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

.prompt-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.prompt-presets button,
.text-button {
  padding: 0;
  border: 0;
  color: var(--paper-dim);
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.prompt-presets button {
  padding: 5px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.prompt-presets button::before {
  margin-right: 5px;
  color: var(--red);
  content: "+";
}

.prompt-presets button:hover {
  border-color: #5a4036;
  color: var(--paper);
  background: rgba(230, 87, 50, 0.05);
}

.text-button {
  min-height: 32px;
  text-decoration: underline;
  text-decoration-color: #514840;
  text-underline-offset: 4px;
}

.text-button:hover {
  color: var(--paper);
  text-decoration-color: var(--red);
}

.text-button.danger {
  color: #c97b69;
}

.drop-zone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px dashed #494139;
  border-radius: var(--radius-sm);
  text-align: left;
  background: #100f0e;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--red);
  background: rgba(230, 87, 50, 0.055);
}

.drop-zone.dragging {
  transform: translateY(-2px);
}

.drop-zone.processing {
  pointer-events: none;
  border-style: solid;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid #403832;
  border-radius: 50%;
  color: var(--red);
}

.drop-icon svg,
.result-actions svg,
.history-tools svg,
.history-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.drop-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.drop-copy strong {
  font-size: 12px;
  font-weight: 600;
}

.drop-copy small {
  color: var(--muted);
  font-size: 10px;
}

.drop-meta {
  color: #746d65;
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.55;
  text-align: right;
}

.reference-preview {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 13px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.reference-thumb-wrap {
  position: relative;
  height: 88px;
  padding: 4px;
  border: 1px solid #484039;
  background: #090807;
}

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

.clean-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  padding: 3px 5px;
  color: #0c120e;
  background: var(--green);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.reference-details {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
}

.reference-details strong {
  overflow: hidden;
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-details > span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.inline-actions {
  display: flex;
  gap: 15px;
  margin-top: 6px;
}

.parameter-block > .control-title {
  margin-bottom: 17px;
}

.option-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.option-group + .option-group {
  margin-top: 19px;
}

.option-group legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

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

.segmented input,
.aspect-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 47px;
  flex-direction: column;
  background: #100f0e;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: color 150ms ease, background 150ms ease;
}

.segmented label span small {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 8px;
}

.segmented input:checked + span {
  color: #110b09;
  background: var(--red);
}

.segmented input:checked + span small {
  color: #4e1b10;
}

.segmented input:focus-visible + span,
.aspect-options input:focus-visible + span {
  outline: 2px solid var(--red-hot);
  outline-offset: -3px;
}

.aspect-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.aspect-options label span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #100f0e;
  transition: border-color 150ms ease, background 150ms ease;
}

.aspect-options label:hover span {
  border-color: #554b43;
}

.aspect-options i {
  display: block;
  width: 12px;
  max-height: 17px;
  border: 1px solid #6f675f;
}

.aspect-options .ratio-1-1 { aspect-ratio: 1 / 1; }
.aspect-options .ratio-4-3 { aspect-ratio: 4 / 3; }
.aspect-options .ratio-3-4 { aspect-ratio: 3 / 4; }
.aspect-options .ratio-16-9 { aspect-ratio: 16 / 9; }
.aspect-options .ratio-9-16 { aspect-ratio: 9 / 16; }

.aspect-options b {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
}

.aspect-options input:checked + span {
  border-color: var(--red);
  background: rgba(230, 87, 50, 0.08);
}

.aspect-options input:checked + span i {
  border-color: var(--red-hot);
  background: var(--red-deep);
}

.aspect-options input:checked + span b {
  color: var(--paper);
}

.generate-shell {
  padding: 18px 25px 25px;
}

.request-note {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 9px;
}

.generate-button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 65px;
  padding: 12px 19px;
  border: 1px solid var(--red-hot);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-align: left;
  background: var(--red);
  box-shadow: 0 15px 30px rgba(121, 39, 24, 0.28);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.generate-button::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.14) 49%, transparent 63%);
  content: "";
  transform: translateX(-120%);
  transition: transform 500ms ease;
}

.generate-button:not(:disabled):hover {
  background: var(--red-hot);
  box-shadow: 0 18px 38px rgba(121, 39, 24, 0.42);
  transform: translateY(-2px);
}

.generate-button:not(:disabled):hover::before {
  transform: translateX(120%);
}

.generate-button:disabled {
  border-color: #3e3530;
  color: #6f675f;
  background: #1c1916;
  box-shadow: none;
}

.button-label,
.button-detail {
  position: relative;
  z-index: 1;
  display: block;
}

.button-label {
  color: #160d0a;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.button-detail {
  color: #5a2015;
  font-size: 9px;
}

.generate-button:disabled .button-label,
.generate-button:disabled .button-detail {
  color: inherit;
}

.generate-button svg {
  position: relative;
  z-index: 1;
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 28px;
  height: 16px;
  fill: none;
  stroke: #2d100b;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.generate-button:disabled svg {
  stroke: #625a52;
}

.stage-panel {
  animation: rise-in 620ms 80ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.stage-toolbar {
  min-height: 58px;
  margin-bottom: 13px;
  padding: 0 2px 11px;
  border-bottom: 1px solid var(--line-soft);
}

.stage-toolbar h2,
.history-heading h2 {
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1;
}

.stage-readout {
  display: flex;
  gap: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.stage-readout span:first-child {
  color: var(--amber);
}

.stage-frame {
  position: relative;
  display: grid;
  min-height: clamp(520px, 61vw, 760px);
  place-items: center;
  padding: clamp(24px, 4vw, 55px);
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at center, #1b1815, #0c0b0a 72%);
  background-size: 42px 42px, 42px 42px, auto;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.48), var(--shadow-deep);
}

.stage-frame::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--red-deep), transparent);
  content: "";
}

.crop-mark {
  position: absolute;
  z-index: 3;
  width: 17px;
  height: 17px;
  opacity: 0.58;
}

.crop-mark::before,
.crop-mark::after {
  position: absolute;
  background: var(--paper-dim);
  content: "";
}

.crop-mark::before {
  width: 17px;
  height: 1px;
}

.crop-mark::after {
  width: 1px;
  height: 17px;
}

.crop-mark.top-left { top: 17px; left: 17px; }
.crop-mark.top-right { top: 17px; right: 17px; transform: rotate(90deg); }
.crop-mark.bottom-left { bottom: 17px; left: 17px; transform: rotate(-90deg); }
.crop-mark.bottom-right { right: 17px; bottom: 17px; transform: rotate(180deg); }

.stage-empty,
.stage-busy,
.stage-failed {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 420px;
  text-align: center;
  flex-direction: column;
}

.focus-grid {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 27px;
  border: 1px solid #3b3530;
  border-radius: 50%;
  opacity: 0.9;
}

.focus-grid::before,
.focus-grid::after {
  position: absolute;
  top: 50%;
  left: 50%;
  background: #3b3530;
  content: "";
  transform: translate(-50%, -50%);
}

.focus-grid::before { width: 162px; height: 1px; }
.focus-grid::after { width: 1px; height: 162px; }

.focus-grid span {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: #575049;
  border-style: solid;
}

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

.stage-empty p,
.stage-failed p {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 31px);
  letter-spacing: 0.04em;
}

.stage-empty > span,
.stage-failed strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.stage-busy {
  width: min(440px, 100%);
}

.exposure-sheet {
  position: relative;
  width: min(290px, 76%);
  aspect-ratio: 1 / 1;
  margin-bottom: 30px;
  border: 1px solid #4b3129;
  overflow: hidden;
  background:
    radial-gradient(circle at 46% 43%, rgba(210, 200, 187, 0.08), transparent 28%),
    #120d0b;
  box-shadow: 0 0 70px rgba(153, 49, 25, 0.16);
}

.exposure-sheet::before,
.exposure-sheet::after {
  position: absolute;
  border: 1px solid rgba(230, 87, 50, 0.15);
  border-radius: 50%;
  content: "";
}

.exposure-sheet::before { inset: 21%; }
.exposure-sheet::after { inset: 34%; }

.exposure-scan {
  position: absolute;
  z-index: 2;
  right: 0;
  left: 0;
  height: 32%;
  background: linear-gradient(180deg, transparent, rgba(230, 87, 50, 0.25), transparent);
  animation: exposure-scan 3.4s ease-in-out infinite;
}

.exposure-orbit {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red-hot);
  box-shadow: 0 0 16px var(--red);
  animation: exposure-orbit 4.2s linear infinite;
}

.busy-kicker {
  margin: 0;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stage-busy h3 {
  margin: 6px 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.stage-busy > p:not(.busy-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.stage-busy time {
  margin-top: 13px;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.stage-result {
  position: relative;
  z-index: 2;
  width: min(100%, 920px);
  margin: 0;
  animation: image-develop 800ms ease both;
}

.result-image-wrap {
  display: grid;
  max-height: min(72vh, 640px);
  padding: 8px;
  place-items: center;
  border: 1px solid #595149;
  background: #050505;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
}

.result-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(min(72vh, 640px) - 16px);
  object-fit: contain;
}

.stage-result figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.result-caption-main {
  min-width: 0;
}

.result-caption-main > span {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.result-caption-main p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--paper-dim);
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.solid-action,
.outline-action,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.solid-action {
  gap: 7px;
  color: #160d0a;
  background: var(--paper);
}

.solid-action:hover {
  background: #fffaf1;
  transform: translateY(-1px);
}

.outline-action {
  border-color: var(--line);
  color: var(--paper-dim);
}

.outline-action:hover {
  border-color: #6d5b50;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.03);
}

.outline-action.compact {
  min-height: 34px;
  padding: 5px 10px;
  gap: 5px;
}

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

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  color: var(--muted);
}

.icon-button:hover {
  border-color: #6d5b50;
  color: var(--paper);
}

.icon-button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.stage-failed .failed-mark {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin-bottom: 25px;
  border: 1px solid #60352b;
  border-radius: 50%;
  color: var(--danger);
  font-family: var(--font-display);
  font-size: 43px;
  font-weight: 300;
  box-shadow: 0 0 40px rgba(255, 114, 88, 0.08);
}

.stage-failed .outline-action {
  margin-top: 20px;
}

.job-stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 15px 0 0;
  padding: 0;
  list-style: none;
}

.job-stages li {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  color: #625b54;
}

.job-stages li:not(:last-child)::after {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: 8px;
  left: 21px;
  height: 1px;
  background: var(--line-soft);
  content: "";
}

.job-stages li > span {
  width: 10px;
  height: 10px;
  border: 1px solid #4b443e;
  border-radius: 50%;
  background: var(--ink-1);
}

.job-stages div {
  display: flex;
  width: fit-content;
  padding: 2px 9px 2px 0;
  flex-direction: column;
  background: var(--ink-1);
}

.job-stages b {
  font-size: 9px;
  font-weight: 600;
}

.job-stages small {
  font-size: 8px;
}

.job-stages li.done,
.job-stages li.active {
  color: var(--paper-dim);
}

.job-stages li.done > span {
  border-color: var(--green);
  background: var(--green);
}

.job-stages li.active > span {
  border-color: var(--red-hot);
  background: var(--red);
  box-shadow: 0 0 11px rgba(230, 87, 50, 0.56);
  animation: stage-pulse 1.6s ease-in-out infinite;
}

.job-stages li.active b {
  color: var(--red-hot);
}

.history-section {
  margin-top: clamp(65px, 8vw, 118px);
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  animation: rise-in 620ms 160ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.history-heading {
  margin-bottom: 24px;
}

.history-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  gap: 7px;
  color: var(--muted);
}

.history-loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: loading-dot 1.2s ease-in-out infinite;
}

.history-loading span:nth-child(2) { animation-delay: 140ms; }
.history-loading span:nth-child(3) { animation-delay: 280ms; }
.history-loading p { margin-left: 7px; font-size: 10px; }

.history-empty {
  display: flex;
  align-items: center;
  min-height: 185px;
  padding: 30px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.history-empty span {
  margin-right: 22px;
  color: #292520;
  font-family: var(--font-display);
  font-size: 68px;
  line-height: 1;
}

.history-empty p {
  max-width: 340px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.7vw, 24px);
}

.history-card {
  position: relative;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line-soft);
  background: #12100f;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.history-card::before {
  position: absolute;
  z-index: 2;
  top: -1px;
  left: 12px;
  width: 22px;
  height: 3px;
  background: #3e3731;
  content: "";
}

.history-card:hover,
.history-card.selected {
  border-color: #594840;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
  transform: translateY(-3px);
}

.history-card.selected::before {
  background: var(--red);
}

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

.history-image {
  position: relative;
  display: grid;
  aspect-ratio: 1 / 1;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, transparent 49%, rgba(255, 255, 255, 0.025) 50%, transparent 51%),
    #090807;
}

.history-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 220ms ease, transform 380ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.history-card:hover .history-image img {
  transform: scale(1.025);
}

.history-status-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid #483e37;
  border-radius: 50%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.history-card[data-state="processing"] .history-status-mark,
.history-card[data-state="queued"] .history-status-mark,
.history-card[data-state="saving"] .history-status-mark {
  border-color: var(--red-deep);
  color: var(--red);
  animation: stage-pulse 1.8s ease-in-out infinite;
}

.history-number {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  padding: 3px 5px;
  color: var(--paper-dim);
  background: rgba(9, 8, 7, 0.76);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  backdrop-filter: blur(5px);
}

.history-card-copy {
  padding: 12px 7px 8px;
}

.history-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.04em;
}

.history-card-prompt {
  display: -webkit-box;
  min-height: 38px;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--paper-dim);
  font-family: var(--font-display);
  font-size: 11px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-soft);
}

.history-action {
  min-height: 38px;
  padding: 0 5px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
  background: transparent;
  font-size: 9px;
}

.history-action:last-child {
  border-right: 0;
}

.history-action:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.025);
}

.history-action.danger:hover {
  color: var(--danger);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 30px));
  padding: 0;
  border: 1px solid #55413a;
  border-radius: var(--radius-md);
  color: var(--paper);
  background: #171310;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72);
}

.confirm-dialog::backdrop {
  background: rgba(5, 4, 4, 0.79);
  backdrop-filter: blur(5px);
}

.confirm-dialog form {
  padding: 30px;
}

.dialog-index {
  display: inline-block;
  margin-bottom: 24px;
  padding: 4px 6px;
  border: 1px solid #633a2f;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.confirm-dialog h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 500;
}

.confirm-dialog p {
  margin: 9px 0 26px;
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.danger-fill {
  color: #1d0b08;
  background: var(--danger);
}

.danger-fill:hover {
  background: #ff8c75;
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(18px, env(safe-area-inset-right));
  bottom: var(--safe-bottom);
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 15px;
  border: 1px solid #56483f;
  border-left: 2px solid var(--red);
  color: var(--paper-dim);
  background: rgba(20, 17, 15, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.noscript {
  position: fixed;
  z-index: 200;
  right: 20px;
  bottom: 20px;
  left: 20px;
  padding: 14px;
  border: 1px solid var(--danger);
  color: var(--paper);
  background: #26110e;
  text-align: center;
}

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

@keyframes image-develop {
  0% { opacity: 0; filter: contrast(0.6) brightness(0.25) sepia(0.7); transform: scale(0.985); }
  55% { opacity: 0.82; filter: contrast(0.85) brightness(0.7) sepia(0.3); }
  100% { opacity: 1; filter: none; transform: scale(1); }
}

@keyframes exposure-scan {
  0%, 100% { top: -30%; opacity: 0.3; }
  50% { top: 98%; opacity: 1; }
}

@keyframes exposure-orbit {
  from { transform: translate(-50%, -50%) rotate(0deg) translateX(67px); }
  to { transform: translate(-50%, -50%) rotate(360deg) translateX(67px); }
}

@keyframes stage-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes loading-dot {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 1220px) {
  .workbench {
    grid-template-columns: minmax(320px, 385px) minmax(0, 1fr);
  }

  .stage-frame {
    min-height: 620px;
  }

  .stage-result figcaption {
    grid-template-columns: 1fr;
  }

  .result-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 960px) {
  .masthead {
    min-height: 80px;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .control-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  }

  .panel-heading {
    align-items: flex-start;
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    justify-content: flex-start;
    border-right: 1px solid var(--line-soft);
  }

  .control-panel form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-column: 1 / -1;
  }

  .prompt-block {
    grid-column: 1;
    grid-row: 1 / span 2;
    border-right: 1px solid var(--line-soft);
  }

  .generate-shell {
    grid-column: 1 / -1;
  }

  .stage-panel {
    margin-top: 30px;
  }

  .stage-frame {
    min-height: 680px;
  }
}

@media (max-width: 720px) {
  .masthead {
    align-items: flex-start;
    min-height: 0;
    gap: 12px;
    padding: 17px 18px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-lockup {
    gap: 11px;
  }

  .brand-lockup .eyebrow,
  .brand-lockup h1 span,
  .account-copy,
  .rail-divider,
  #userLabel {
    display: none;
  }

  .brand-lockup h1 {
    font-size: 21px;
    line-height: 36px;
  }

  .account-rail {
    padding-top: 8px;
  }

  .account-data {
    font-size: 10px;
  }

  .global-error {
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin: 12px 12px 0;
  }

  .error-action {
    grid-column: 2;
    justify-self: start;
  }

  .error-close {
    grid-column: 3;
    grid-row: 1;
  }

  main {
    padding: 22px 12px 100px;
  }

  .control-panel {
    display: block;
  }

  .panel-heading {
    align-items: flex-end;
    flex-direction: row;
    border-right: 0;
  }

  .control-panel form {
    display: block;
  }

  .prompt-block {
    border-right: 0;
  }

  .control-block,
  .panel-heading {
    padding-right: 18px;
    padding-left: 18px;
  }

  .generate-shell {
    position: sticky;
    z-index: 15;
    bottom: 0;
    padding: 13px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(14, 12, 11, 0.94);
    backdrop-filter: blur(18px);
  }

  .request-note {
    display: none;
  }

  .generate-button {
    min-height: 58px;
  }

  .stage-panel {
    margin-top: 48px;
  }

  .stage-frame {
    min-height: min(133vw, 600px);
    padding: 35px 21px;
  }

  .job-stages small {
    display: none;
  }

  .job-stages li {
    gap: 5px;
  }

  .job-stages li:not(:last-child)::after {
    right: 3px;
    left: 15px;
  }

  .job-stages div {
    padding-right: 5px;
  }

  .stage-result figcaption {
    gap: 14px;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
  }

  .result-actions .solid-action,
  .result-actions .outline-action {
    width: 100%;
  }

  .history-section {
    margin-top: 76px;
  }

  .history-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-tools {
    width: 100%;
    justify-content: space-between;
  }

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

@media (max-width: 430px) {
  .model-stamp {
    display: none;
  }

  .drop-zone {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .drop-meta {
    display: none;
  }

  .aspect-options {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .aspect-options label span {
    min-height: 50px;
    flex-direction: column;
    gap: 3px;
  }

  .stage-toolbar h2,
  .history-heading h2 {
    font-size: 28px;
  }

  .stage-readout span:last-child {
    display: none;
  }

  .stage-frame {
    min-height: 510px;
  }

  .history-card {
    padding: 5px;
  }

  .history-card-copy {
    padding: 9px 4px 6px;
  }

  .history-card-meta span:last-child {
    display: none;
  }

  .history-action {
    font-size: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
