:root {
  --bg: #e9e5d9;
  --surface: #fbfaf6;
  --surface-2: #f1eee5;
  --ink: #171916;
  --muted: #66706a;
  --line: #d8d2c4;
  --line-strong: #b9b09e;
  --green: #0d6f5a;
  --green-dark: #084337;
  --rust: #b95232;
  --gold: #cf9e2b;
  --on-gold: #171916;
  --blueprint: #23313a;
  --panel-bg: rgba(251, 250, 246, 0.94);
  --soft-fill: rgba(241, 238, 229, 0.72);
  --body-glow-1: rgba(13, 111, 90, 0.035);
  --body-glow-2: rgba(207, 158, 43, 0.05);
  --body-grid-1: rgba(23, 25, 22, 0.045);
  --body-grid-2: rgba(23, 25, 22, 0.04);
  --stage-grid-1: rgba(35, 49, 58, 0.05);
  --stage-grid-2: rgba(35, 49, 58, 0.05);
  --stage-generating-grid-1: rgba(105, 217, 183, 0.08);
  --stage-generating-grid-2: rgba(226, 184, 76, 0.06);
  --brand-bg: #171916;
  --brand-fg: #cf9e2b;
  --badge-bg: #171916;
  --badge-fg: #fbfaf6;
  --primary-action-bg: #171916;
  --primary-action-fg: #ffffff;
  --selected-bg: #171916;
  --selected-fg: #fbfaf6;
  --dialog-backdrop: rgba(23, 25, 22, 0.34);
  --disabled-bg: #76766e;
  --shadow: 0 20px 50px rgba(27, 30, 26, 0.12);
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
}

html[data-theme="dark"] {
  --bg: #07090d;
  --surface: #10141b;
  --surface-2: #151b24;
  --ink: #f4f7fb;
  --muted: #9aa7b8;
  --line: #2a3442;
  --line-strong: #43536a;
  --green: #60e7c8;
  --green-dark: #12a785;
  --rust: #ff8c6b;
  --gold: #f0c868;
  --on-gold: #071017;
  --blueprint: #9cc8e8;
  --panel-bg: rgba(12, 16, 23, 0.93);
  --soft-fill: rgba(20, 26, 35, 0.82);
  --body-glow-1: rgba(96, 231, 200, 0.13);
  --body-glow-2: rgba(240, 200, 104, 0.08);
  --body-grid-1: rgba(148, 166, 190, 0.052);
  --body-grid-2: rgba(148, 166, 190, 0.038);
  --stage-grid-1: rgba(126, 151, 181, 0.055);
  --stage-grid-2: rgba(126, 151, 181, 0.04);
  --stage-generating-grid-1: rgba(96, 231, 200, 0.1);
  --stage-generating-grid-2: rgba(240, 200, 104, 0.055);
  --brand-bg: #03060a;
  --brand-fg: #f0c868;
  --badge-bg: #060a10;
  --badge-fg: #f4f7fb;
  --primary-action-bg: #0f8068;
  --primary-action-fg: #ffffff;
  --selected-bg: #0f8068;
  --selected-fg: #ffffff;
  --dialog-backdrop: rgba(1, 4, 8, 0.72);
  --disabled-bg: #313946;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #07090d;
    --surface: #10141b;
    --surface-2: #151b24;
    --ink: #f4f7fb;
    --muted: #9aa7b8;
    --line: #2a3442;
    --line-strong: #43536a;
    --green: #60e7c8;
    --green-dark: #12a785;
    --rust: #ff8c6b;
    --gold: #f0c868;
    --on-gold: #071017;
    --blueprint: #9cc8e8;
    --panel-bg: rgba(12, 16, 23, 0.93);
    --soft-fill: rgba(20, 26, 35, 0.82);
    --body-glow-1: rgba(96, 231, 200, 0.13);
    --body-glow-2: rgba(240, 200, 104, 0.08);
    --body-grid-1: rgba(148, 166, 190, 0.052);
    --body-grid-2: rgba(148, 166, 190, 0.038);
    --stage-grid-1: rgba(126, 151, 181, 0.055);
    --stage-grid-2: rgba(126, 151, 181, 0.04);
    --stage-generating-grid-1: rgba(96, 231, 200, 0.1);
    --stage-generating-grid-2: rgba(240, 200, 104, 0.055);
    --brand-bg: #03060a;
    --brand-fg: #f0c868;
    --badge-bg: #060a10;
    --badge-fg: #f4f7fb;
    --primary-action-bg: #0f8068;
    --primary-action-fg: #ffffff;
    --selected-bg: #0f8068;
    --selected-fg: #ffffff;
    --dialog-backdrop: rgba(1, 4, 8, 0.72);
    --disabled-bg: #313946;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html,
body {
  min-height: 100%;
}

html[data-theme="dark"] body,
html:not([data-theme="light"]) body {
  color-scheme: light dark;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% -12%, var(--body-glow-1), transparent 34%),
    radial-gradient(circle at 86% -8%, var(--body-glow-2), transparent 30%),
    linear-gradient(90deg, var(--body-grid-1) 1px, transparent 1px),
    linear-gradient(0deg, var(--body-grid-2) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
  font-family: ui-sans-serif, "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.studio-shell {
  width: min(1680px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0;
}

.studio-top {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  padding: 4px;
  box-shadow: 0 10px 24px rgba(23, 25, 22, 0.05);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--brand-bg);
  color: var(--brand-fg);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.brand-lockup p,
.kicker {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  letter-spacing: 0;
}

.system-pill,
.mini-state,
.job-chip,
.user-pill,
.auth-button,
.history-open,
.task-open,
.theme-toggle {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.history-open,
.task-open,
.auth-button,
.theme-toggle {
  gap: 8px;
  cursor: pointer;
}

.user-pill {
  gap: 7px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 74%, transparent);
}

.user-pill span {
  line-height: 1;
}

.auth-button {
  min-width: 64px;
  justify-content: center;
  border-color: color-mix(in srgb, var(--green) 34%, var(--line));
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.auth-button:hover {
  border-color: color-mix(in srgb, var(--green) 58%, var(--line));
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  transform: translateY(-1px);
}

.history-open b,
.task-open b,
.theme-toggle b {
  min-width: 20px;
  min-height: 20px;
  display: grid;
  place-items: center;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 11px;
}

.theme-toggle {
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  background: var(--surface);
  padding-right: 6px;
}

.theme-toggle span {
  color: var(--muted);
}

.theme-toggle b {
  min-width: 34px;
  padding: 0 8px;
  background: var(--badge-bg);
  color: var(--badge-fg);
}

.system-pill {
  position: relative;
  gap: 7px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.system-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--muted);
}

.system-pill.ok {
  border-color: color-mix(in srgb, var(--green) 28%, transparent);
  background: color-mix(in srgb, var(--green) 9%, var(--surface));
  color: var(--green);
}

.system-pill.ok::before {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
}

.system-pill.bad {
  border-color: color-mix(in srgb, var(--rust) 35%, transparent);
  background: color-mix(in srgb, var(--rust) 9%, var(--surface));
  color: var(--rust);
}

.system-pill.bad::before {
  background: var(--rust);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rust) 16%, transparent);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(460px, 560px) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: stretch;
  height: calc(100vh - 100px);
}

.input-console,
.render-console {
  min-height: 0;
  height: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.input-console {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.workflow-switcher {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.workflow-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
}

.workflow-select-row strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
  line-height: 1.2;
}

.workflow-select-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workflow-picker-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--primary-action-bg);
  background: var(--primary-action-bg);
  color: var(--primary-action-fg);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.workflow-picker-button span {
  display: inline-flex;
  margin-top: 0;
  color: #fff;
}

.workflow-picker-button b {
  min-width: 24px;
  min-height: 24px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 12px;
}

.panel-title,
.section-row,
.render-toolbar,
.render-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.toolbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.panel-title {
  margin-bottom: var(--space-3);
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-title b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 13px;
}

.workflow-list {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
}

.workflow-card {
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.workflow-card:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--green);
}

.workflow-card.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-bg);
}

.workflow-card.ghost {
  cursor: not-allowed;
  opacity: 0.48;
}

.workflow-card span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}

.workflow-card span .icon {
  width: 13px;
  height: 13px;
}

.workflow-card strong {
  font-size: 14px;
  line-height: 1.25;
}

.workflow-card small {
  color: inherit;
  opacity: 0.68;
  font-size: 11px;
  line-height: 1.35;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: var(--dialog-backdrop);
  opacity: 0;
  transition: opacity 120ms ease;
}

.dialog-backdrop.open {
  opacity: 1;
}

.dialog-backdrop[hidden] {
  display: none;
}

.workflow-dialog,
.history-dialog,
.tasks-dialog,
.auth-dialog {
  width: min(760px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 72px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(8px);
  transition: transform 120ms ease;
}

.dialog-backdrop.open .workflow-dialog,
.dialog-backdrop.open .history-dialog,
.dialog-backdrop.open .tasks-dialog,
.dialog-backdrop.open .auth-dialog {
  transform: translateY(0);
}

.workflow-dialog {
  grid-template-rows: auto auto 1fr;
}

.workflow-dialog header,
.history-dialog header,
.tasks-dialog header,
.auth-dialog header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.workflow-dialog h2,
.history-dialog h2,
.tasks-dialog h2,
.auth-dialog h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.workflow-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.workflow-tabs button {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.workflow-tabs button:last-child {
  border-right: 0;
}

.workflow-tabs button.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
}

.dialog-close,
.clear-history {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.workflow-dialog .workflow-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: auto;
  padding: var(--space-4);
}

.workflow-dialog .workflow-card {
  min-height: 118px;
}

.auth-dialog {
  width: min(480px, calc(100vw - 36px));
  grid-template-rows: auto auto 1fr;
}

.auth-dialog.compact {
  grid-template-rows: auto 1fr;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.auth-tabs button {
  min-height: 46px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.auth-tabs button:last-child {
  border-right: 0;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--ink);
}

.auth-form {
  display: none;
  gap: var(--space-3);
  padding: var(--space-4);
}

.auth-form.active {
  display: grid;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: var(--space-2);
  align-items: end;
}

.code-button,
.auth-submit {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--primary-action-bg);
  background: var(--primary-action-bg);
  color: var(--primary-action-fg);
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

.code-button:disabled,
.auth-submit:disabled {
  cursor: not-allowed;
  border-color: var(--disabled-bg);
  background: var(--disabled-bg);
}

.auth-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-error {
  display: none;
  border: 1px solid color-mix(in srgb, var(--rust) 42%, var(--line));
  background: color-mix(in srgb, var(--rust) 12%, var(--surface));
  color: var(--rust);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.auth-error.show {
  display: block;
}

.job-form {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
}

.input-section {
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.section-row {
  margin-bottom: var(--space-3);
}

.section-row h2,
.render-toolbar h2 {
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.upload-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.upload-stack.is-empty {
  grid-template-columns: 1fr;
}

.upload-empty {
  min-height: 118px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  background: var(--soft-fill);
  padding: var(--space-4);
}

.upload-empty strong {
  font-size: 15px;
}

.upload-empty span {
  color: var(--muted);
  font-size: 13px;
}

.upload-card {
  position: relative;
  min-height: 110px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 12px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.upload-card:hover {
  border-color: var(--green);
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
}

.upload-card.priority {
  border-color: rgba(207, 158, 43, 0.9);
}

.upload-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-index {
  color: var(--rust);
  font-size: 11px;
  font-weight: 900;
}

.upload-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.upload-icon .icon {
  width: 15px;
  height: 15px;
}

.upload-copy {
  display: grid;
  gap: 2px;
}

.upload-copy strong {
  font-size: 15px;
}

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

.upload-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 160ms ease;
}

.upload-card.has-image img {
  opacity: 1;
}

.upload-card.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(5, 8, 7, 0.72), transparent 70%);
}

.upload-card.has-image .upload-index,
.upload-card.has-image .upload-icon,
.upload-card.has-image .upload-copy {
  position: relative;
  z-index: 1;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.upload-card.has-image .upload-icon {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22);
}

.upload-card.has-image small {
  color: rgba(255, 255, 255, 0.8);
}

.field-label,
.text-field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.control-block {
  margin-bottom: var(--space-3);
}

.menu-block {
  position: relative;
}

.control-block.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.control-block.split .control-block {
  margin-bottom: 0;
}

.control-block.split > div {
  position: relative;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.choice {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.choice:hover {
  border-color: var(--green);
}

.choice.active {
  color: #fff;
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.choice-row.compact .choice {
  flex: 1;
  min-width: 82px;
  padding: 0 10px;
}

.select-trigger {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.select-trigger b {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.select-trigger b .icon {
  width: 14px;
  height: 14px;
}

.menu-popover {
  display: none;
  position: absolute;
  z-index: 30;
  width: min(310px, calc(100vw - 40px));
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.menu-popover.open {
  display: grid;
}

.menu-popover button {
  border: 0;
  background: transparent;
  padding: 10px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.menu-popover button:hover {
  background: var(--surface-2);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.metric-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label unit"
    "input unit";
  gap: 2px 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px;
}

.metric-card span {
  grid-area: label;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.metric-card input {
  grid-area: input;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  outline: none;
}

.metric-card b {
  grid-area: unit;
  align-self: end;
  color: var(--green);
  font-size: 12px;
}

.advanced-section {
  padding: 0;
}

.advanced-toggle {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: var(--surface-2);
  padding: 0 var(--space-4);
  font-weight: 900;
  cursor: pointer;
}

.advanced-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.advanced-panel {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
}

.advanced-panel[hidden] {
  display: none;
}

.text-field input,
.text-field textarea {
  width: 100%;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  padding: 12px;
  outline: none;
}

.text-field textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.52;
}

.text-field.prompt-field textarea {
  min-height: 156px;
}

#coreParameters,
#advancedFields {
  display: grid;
  gap: var(--space-3);
}

#coreParameters > .control-block,
#advancedFields > .text-field,
#advancedFields > .control-block {
  margin-bottom: 0;
}

.text-field input:focus,
.text-field textarea:focus {
  border-color: var(--green);
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
}

.run-button {
  position: sticky;
  bottom: 0;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--badge-bg);
  color: var(--badge-fg);
  padding: 0 var(--space-4);
  font-size: 18px;
  font-weight: 950;
  cursor: pointer;
}

.run-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.run-label em {
  font-style: normal;
}

.run-button b {
  display: grid;
  min-width: 54px;
  min-height: 36px;
  place-items: center;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 13px;
}

.run-button:disabled {
  cursor: not-allowed;
  background: var(--disabled-bg);
}

.render-console {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  overflow: hidden;
  background: var(--panel-bg);
}

.render-toolbar {
  min-height: 78px;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--line);
}

.render-stage {
  position: relative;
  display: grid;
  height: 520px;
  min-height: 520px;
  place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(circle at 50% 15%, var(--body-glow-1), transparent 42%),
    linear-gradient(90deg, var(--stage-grid-1) 1px, transparent 1px),
    linear-gradient(0deg, var(--stage-grid-2) 1px, transparent 1px),
    var(--surface);
  background-size: auto, 34px 34px, 34px 34px, auto;
  overflow: hidden;
}

.render-stage.is-generating {
  background:
    radial-gradient(circle at 50% 15%, var(--body-glow-1), transparent 42%),
    radial-gradient(circle at 80% 80%, var(--body-glow-2), transparent 36%),
    linear-gradient(90deg, var(--stage-generating-grid-1) 1px, transparent 1px),
    linear-gradient(0deg, var(--stage-generating-grid-2) 1px, transparent 1px),
    var(--surface);
  background-size: auto, auto, 28px 28px, 28px 28px, auto;
}

.render-stage.is-generating::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(105, 217, 183, 0.55);
  background:
    linear-gradient(90deg, transparent, rgba(105, 217, 183, 0.42), transparent) top left / 180px 1px no-repeat,
    linear-gradient(180deg, transparent, rgba(226, 184, 76, 0.45), transparent) top right / 1px 180px no-repeat,
    linear-gradient(270deg, transparent, rgba(105, 217, 183, 0.42), transparent) bottom right / 180px 1px no-repeat,
    linear-gradient(0deg, transparent, rgba(226, 184, 76, 0.45), transparent) bottom left / 1px 180px no-repeat;
  animation: render-border-scan 2.8s linear infinite;
  pointer-events: none;
}

.render-stage.is-generating::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(105, 217, 183, 0.42) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(226, 184, 76, 0.34) 0 1px, transparent 1.5px);
  background-position: 18% 28%, 72% 64%;
  background-size: 78px 78px, 112px 112px;
  animation: particle-drift 9s linear infinite;
  pointer-events: none;
}

@keyframes render-border-scan {
  0% { background-position: top left, top right, bottom right, bottom left; }
  50% { background-position: top right, bottom right, bottom left, top left; }
  100% { background-position: bottom right, bottom left, top left, top right; }
}

@keyframes particle-drift {
  from { transform: translate3d(0, 0, 0); opacity: 0.55; }
  50% { opacity: 0.9; }
  to { transform: translate3d(34px, -28px, 0); opacity: 0.55; }
}

.generation-panel {
  position: relative;
  z-index: 1;
  width: min(620px, 88%);
  min-height: 260px;
  display: grid;
  align-content: center;
  gap: 22px;
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--line));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  padding: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.generation-copy {
  display: grid;
  gap: 8px;
}

.generation-copy span {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.generation-copy strong {
  font-size: 26px;
  line-height: 1.18;
}

.generation-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.progress-rail,
.task-item i {
  height: 8px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-2) 82%, var(--line));
}

.progress-rail b,
.task-item i b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green-dark), var(--green), var(--gold));
  transition: width 320ms ease;
}

.generation-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  color: var(--muted);
  font-size: 13px;
}

.generation-meta span:first-child {
  color: var(--gold);
  font-weight: 950;
}

.particle-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.particle-field i {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--green);
  box-shadow: 0 0 14px var(--green);
  animation: local-particle 3.4s ease-in-out infinite;
}

.particle-field i:nth-child(1) { left: 12%; top: 24%; animation-delay: 0s; }
.particle-field i:nth-child(2) { left: 86%; top: 22%; animation-delay: 0.4s; }
.particle-field i:nth-child(3) { left: 74%; top: 78%; animation-delay: 0.8s; }
.particle-field i:nth-child(4) { left: 18%; top: 72%; animation-delay: 1.2s; }
.particle-field i:nth-child(5) { left: 42%; top: 12%; animation-delay: 1.6s; }
.particle-field i:nth-child(6) { left: 52%; top: 88%; animation-delay: 2s; }

@keyframes local-particle {
  0%, 100% { transform: translate3d(0, 0, 0) scale(0.7); opacity: 0.26; }
  50% { transform: translate3d(18px, -14px, 0) scale(1.2); opacity: 0.92; }
}

.empty-preview {
  width: min(520px, 86%);
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  color: var(--muted);
}

.empty-icon .icon {
  width: 20px;
  height: 20px;
}

.empty-preview strong {
  color: var(--ink);
  font-size: 22px;
}

.empty-preview span {
  max-width: 360px;
  max-height: 150px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.result-image-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.result-image-wrap img {
  max-width: 100%;
  max-height: 472px;
  display: block;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-image-wrap video {
  max-width: min(100%, 520px);
  max-height: 472px;
  display: block;
  border: 1px solid var(--line);
  background: #000;
  box-shadow: var(--shadow);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  overflow: auto;
  padding: var(--space-4);
}

.task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  overflow: auto;
  padding: var(--space-4);
}

.history-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  height: 302px;
  min-height: 302px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.task-item {
  min-height: 116px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.task-item.active {
  border-color: var(--green);
}

.task-preview {
  width: 100%;
  min-height: 116px;
  display: grid;
  align-content: start;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.task-preview span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}

.task-preview strong {
  font-size: 14px;
}

.task-preview small {
  color: var(--muted);
  font-size: 11px;
}

.task-download,
.task-waiting {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.task-waiting {
  color: var(--muted);
}

.history-item:hover {
  border-color: var(--green);
}

.history-preview {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 4px;
  border: 0;
  background: transparent;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.history-thumb {
  position: relative;
  width: 100%;
  height: 158px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 8px;
}

.history-thumb img,
.history-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb.video::after {
  content: "VIDEO";
  position: absolute;
  margin: 8px;
  justify-self: start;
  align-self: start;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 900;
}

.history-item span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}

.history-item strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-download {
  min-height: 38px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.history-download:hover {
  background: var(--green-dark);
  color: #fff;
}

.render-footer {
  min-height: 76px;
  padding: 0 var(--space-5);
  border-top: 1px solid var(--line);
}

.render-footer div {
  display: grid;
  gap: 2px;
}

.render-footer span {
  font-weight: 950;
}

.render-footer small {
  color: var(--muted);
}

.download-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--green-dark);
  background: var(--green-dark);
  color: #fff;
  padding: 0 16px;
  text-decoration: none;
  font-weight: 900;
}

.download-button.disabled {
  pointer-events: none;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

@media (max-width: 1180px) {
  .studio-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .input-console {
    height: auto;
    max-height: none;
  }

  .render-console {
    height: auto;
    min-height: 620px;
  }
}

@media (max-width: 720px) {
  .studio-shell {
    width: min(100vw - 20px, 1680px);
    padding: 12px 0;
  }

  .studio-top,
  .studio-grid {
    gap: var(--space-2);
  }

  .brand-lockup h1 {
    font-size: 23px;
  }

  .workflow-list,
  .upload-stack,
  .control-block.split,
  .metric-grid,
  .history-list {
    grid-template-columns: 1fr;
  }

  .render-stage {
    height: 420px;
    min-height: 420px;
    padding: var(--space-3);
  }

  .render-toolbar,
  .render-footer {
    padding: var(--space-3);
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions,
  .dialog-actions {
    width: 100%;
    justify-content: space-between;
  }
}
