:root {
  --bg: #111313;
  --bg-grid: rgba(255, 255, 255, 0.045);
  --paper: #f3efe4;
  --paper-2: #e8e1d1;
  --paper-3: #fffaf0;
  --ink: #151716;
  --muted: #706b60;
  --line: #cec4b1;
  --line-strong: #a99e8d;
  --accent: #10b6a9;
  --accent-deep: #087b73;
  --amber: #ffb347;
  --green: #74a72e;
  --red: #c94e41;
  --blue: #287fba;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
  --radius: 8px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Segoe UI Variable Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

@keyframes progressPulse {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(140%);
  }
}

@keyframes taskEnter {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    box-shadow: 0 0 0 rgba(16, 182, 169, 0);
  }
  55% {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow: 0 16px 34px rgba(16, 182, 169, 0.18);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow: none;
  }
}

@keyframes optimisticGlow {
  0% {
    box-shadow: 0 0 0 rgba(16, 182, 169, 0);
  }
  50% {
    box-shadow: 0 12px 30px rgba(16, 182, 169, 0.2);
  }
  100% {
    box-shadow: 0 0 0 rgba(16, 182, 169, 0);
  }
}

@keyframes streamCaret {
  50% {
    opacity: 0.18;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--paper);
  font-family: var(--sans);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

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

button {
  cursor: pointer;
}

button,
a,
.tool-panel,
.task-card,
.asset-tile,
.workflow-tile,
.reference-option,
.selected-reference {
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease;
}

.app-shell {
  width: min(1800px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 24px;
}

.topbar {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(243, 239, 228, 0.16);
  border-radius: var(--radius);
  background: rgba(17, 19, 19, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-block,
.brand-copy,
.status-line,
.topbar-actions,
.view-switch,
.panel-head,
.segmented,
.form-actions,
.tile-actions,
.task-actions,
.task-meta,
.section-title,
.node-browser-head,
.override-head,
.progress-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 10px;
  min-width: 0;
}

.brand-mark,
.login-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--bg);
  font-weight: 900;
}

.brand-copy h1,
.panel-head h2,
.login-panel h1 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.15;
}

.brand-copy h1 {
  white-space: nowrap;
}

.kicker {
  margin-bottom: 4px;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.status-line {
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

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

.view-switch {
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(243, 239, 228, 0.18);
  border-radius: var(--radius);
  background: rgba(243, 239, 228, 0.08);
}

.view-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--paper-2);
  background: transparent;
  font-weight: 850;
}

.view-button.active {
  color: var(--bg);
  background: var(--paper);
}

.status-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 240px;
  padding: 7px 10px;
  border: 1px solid rgba(243, 239, 228, 0.2);
  border-radius: 999px;
  color: var(--paper-2);
  background: rgba(243, 239, 228, 0.08);
  font-size: 0.86rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip.strong {
  color: var(--bg);
  background: var(--paper);
}

.status-chip.ok {
  color: #dff8ee;
  background: rgba(16, 182, 169, 0.2);
  border-color: rgba(16, 182, 169, 0.45);
}

.status-chip.warn {
  color: #fff3d8;
  background: rgba(255, 179, 71, 0.2);
  border-color: rgba(255, 179, 71, 0.45);
}

.status-chip.muted {
  color: #d2c9b9;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(390px, 0.72fr) minmax(680px, 1.42fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.workspace-grid[data-view="studio"] .library-panel,
.workspace-grid[data-view="library"] .composer-panel,
.workspace-grid[data-view="library"] .task-panel,
.workspace-grid[data-view="system"] .library-panel,
.workspace-grid[data-view="system"] .task-panel {
  display: none;
}

.workspace-grid[data-view="library"],
.workspace-grid[data-view="system"] {
  grid-template-columns: minmax(0, 1fr);
}

.workspace-grid[data-view="library"] .library-panel {
  min-height: calc(100vh - 118px);
}

.workspace-grid[data-view="system"] .composer-panel {
  width: 100%;
  justify-self: stretch;
}

.tool-panel,
.login-panel {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.tool-panel {
  min-height: 70vh;
  padding: 14px;
  animation: riseIn 220ms ease both;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.segmented {
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: var(--bg);
  background: var(--amber);
}

.task-form,
.workflow-import,
.library-section,
.task-stream,
.workflow-list,
.override-list {
  display: grid;
  gap: 12px;
}

.workflow-import {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span,
.check-field span {
  color: #4b463d;
  font-size: 0.82rem;
  font-weight: 850;
}

.field.compact {
  gap: 5px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper-3);
  color: var(--ink);
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  min-height: 142px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(16, 182, 169, 0.18);
  border-color: var(--accent);
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.check-field {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper-3);
}

.check-field input {
  width: auto;
  min-height: auto;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 6px;
  font-weight: 850;
  text-decoration: none;
}

.button {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--paper-3);
}

.button.primary {
  border-color: #087b73;
  color: #071817;
  background: var(--accent);
}

.button.submit-button {
  min-width: 96px;
  padding-inline: 16px;
  border-color: #000;
  color: var(--paper-3);
  background: #111313;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.button.submit-button:not(:disabled):hover {
  border-color: #000;
  background: #000;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
}

.button.secondary {
  color: var(--paper);
  border-color: #252b29;
  background: #202422;
}

.button.upload-button,
.button.reference-upload-button {
  color: var(--ink);
  border-color: rgba(169, 158, 141, 0.82);
  background: rgba(255, 250, 240, 0.68);
  box-shadow: none;
}

.button.upload-button:not(:disabled):hover,
.button.reference-upload-button:not(:disabled):hover {
  color: #073c38;
  border-color: rgba(8, 123, 115, 0.62);
  background: rgba(16, 182, 169, 0.1);
}

.button.slim {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.button.wide {
  width: 100%;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.button:not(:disabled):hover,
.icon-button:not(:disabled):hover,
.view-button:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(243, 239, 228, 0.18);
  color: var(--paper);
  background: rgba(243, 239, 228, 0.08);
}

.tool-panel .icon-button {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--paper-3);
}

.icon-button.danger,
.button.danger {
  color: #fff4ee;
  background: var(--red);
  border-color: #a93d31;
}

.form-actions {
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.workflow-submit-actions {
  padding-top: 0;
  padding-bottom: 2px;
}

.text-task-form textarea[name="text_system_prompt"] {
  min-height: 132px;
}

.text-task-form textarea[name="text_user_prompt"] {
  min-height: 172px;
}

.model-combo-panel {
  display: grid;
  gap: 8px;
}

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

.model-combo-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(206, 196, 177, 0.7);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.66);
}

.model-combo-current span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.model-combo-current strong {
  min-width: 0;
  overflow: hidden;
  color: #073c38;
  font-size: 0.9rem;
  font-weight: 920;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-preview {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(8, 123, 115, 0.42);
  border-radius: 6px;
  color: #073c38;
  background: linear-gradient(135deg, rgba(16, 182, 169, 0.17), rgba(255, 179, 71, 0.2));
}

.price-preview > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.price-preview span {
  color: #075d56;
  font-size: 0.82rem;
  font-weight: 900;
}

.price-preview strong {
  color: #071817;
  font-family: var(--mono);
  font-size: 1.55rem;
  line-height: 1;
}

.price-preview p {
  margin: 0;
  color: #4d4639;
  font-size: 0.82rem;
  font-weight: 760;
}

.key-manager-form,
.system-manager-form {
  gap: 14px;
}

.system-manager-form {
  grid-template-columns: minmax(0, 1.36fr) minmax(420px, 0.64fr);
  align-items: start;
}

.system-manager-form .form-actions,
.system-section-keys {
  grid-column: 1 / -1;
}

.system-section-access,
.system-section-aliases {
  align-self: start;
}

.system-section {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.58);
}

.system-section-head,
.model-access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.system-section-head strong,
.model-access-head strong {
  color: var(--ink);
  font-weight: 920;
}

.system-section-head span,
.model-access-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 820;
}

.system-key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.key-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.68);
}

.key-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.key-section-head strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 900;
}

.key-status {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 58%;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(237, 229, 212, 0.62);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-status.ok {
  color: #075d56;
  border-color: rgba(16, 182, 169, 0.45);
  background: rgba(16, 182, 169, 0.14);
}

.key-status.warn {
  color: #755116;
  border-color: rgba(255, 179, 71, 0.55);
  background: rgba(255, 179, 71, 0.18);
}

.key-clear {
  justify-self: start;
}

.model-access-list {
  display: grid;
  gap: 10px;
}

.model-access-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.model-alias-list {
  display: grid;
  gap: 8px;
}

.model-alias-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(220px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(206, 196, 177, 0.78);
  border-radius: 6px;
  background: var(--paper-3);
}

.model-alias-row.disabled {
  border-color: rgba(193, 153, 65, 0.46);
  background: rgba(237, 229, 212, 0.56);
}

.model-alias-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model-alias-meta strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-alias-meta em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-alias-controls {
  display: grid;
  gap: 8px;
}

.model-enabled-toggle {
  justify-self: end;
  padding: 0;
  border: 0;
  background: transparent;
}

.model-enabled-toggle span {
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 820;
}

.model-alias-row.disabled .model-enabled-toggle span {
  color: #7a5a1e;
}

.model-alias-row.disabled input[data-model-alias-id] {
  background: rgba(255, 253, 247, 0.68);
}

.model-access-row {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(206, 196, 177, 0.78);
  border-radius: 6px;
  background: var(--paper-3);
}

.model-access-row.selected {
  border-color: rgba(8, 123, 115, 0.58);
  background: rgba(16, 182, 169, 0.1);
}

.account-access-check {
  min-width: 0;
  align-self: stretch;
  padding: 0;
  border: 0;
  background: transparent;
}

.account-access-copy,
.dialog-model-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.account-access-copy strong,
.dialog-model-copy strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-access-copy em,
.dialog-model-copy em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-access-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-access-dialog {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.model-access-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(9, 10, 10, 0.72);
  backdrop-filter: blur(10px);
}

.model-access-panel {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(243, 239, 228, 0.2);
  border-radius: 8px;
  color: var(--ink);
  background: #f8f1e4;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
  animation: modalIn 180ms ease both;
}

.model-access-dialog-head,
.model-access-dialog-tools,
.model-access-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.model-access-dialog-head {
  border-bottom: 1px solid rgba(206, 196, 177, 0.78);
  background: rgba(255, 253, 247, 0.78);
}

.model-access-dialog-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model-access-dialog-head strong {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 940;
}

.model-access-dialog-head span,
.model-access-dialog-tools span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-access-dialog-tools {
  border-bottom: 1px solid rgba(206, 196, 177, 0.68);
}

.model-access-dialog-tools > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-access-dialog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
}

.dialog-model-check {
  align-self: stretch;
  min-width: 0;
  background: rgba(255, 253, 247, 0.78);
}

.dialog-model-check.mixed {
  border-color: rgba(122, 99, 45, 0.4);
  background: rgba(255, 179, 71, 0.13);
}

.model-access-dialog-actions {
  border-top: 1px solid rgba(206, 196, 177, 0.78);
  background: rgba(255, 253, 247, 0.78);
}

.asset-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.reference-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reference-upload-zone {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.76);
}

.reference-upload-zone:focus {
  outline: 3px solid rgba(16, 182, 169, 0.16);
  border-color: var(--accent-deep);
}

.reference-upload-zone.dragging {
  border-color: var(--accent-deep);
  background: rgba(16, 182, 169, 0.14);
  box-shadow: inset 0 0 0 2px rgba(16, 182, 169, 0.2), 0 10px 26px rgba(8, 123, 115, 0.14);
}

.reference-upload-zone.dragging::after {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border: 1px solid rgba(8, 123, 115, 0.38);
  border-radius: 6px;
}

.reference-drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 96px;
  padding: 20px 12px;
  border: 1px dashed rgba(206, 196, 177, 0.86);
  border-radius: 6px;
  color: var(--ink);
  text-align: center;
  background: rgba(248, 245, 239, 0.78);
}

.reference-drop-hint svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--accent-deep);
}

.reference-drop-hint div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.reference-drop-hint strong,
.reference-drop-hint span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reference-drop-hint strong {
  font-size: 0.9rem;
  font-weight: 900;
}

.reference-drop-hint span {
  color: var(--muted);
  font-size: 0.78rem;
}

.selected-reference-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.selected-reference-list.empty {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.62);
  font-size: 0.84rem;
}

.selected-reference {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--accent-deep);
  border-radius: 6px;
  background: rgba(16, 182, 169, 0.1);
}

.selected-reference > div,
.reference-thumb {
  position: relative;
}

.selected-reference > div {
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 5px;
  background: #242826;
}

.selected-reference > .reference-thumb,
.reference-option .reference-thumb {
  overflow: visible;
}

.reference-thumb b {
  position: absolute;
  z-index: 4;
  top: 5px;
  left: 5px;
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border: 2px solid #fffaf0;
  border-radius: 999px;
  color: #111313;
  background: var(--amber);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.36);
}

.reference-zoom-preview {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(6px) scale(0.96);
  border: 2px solid var(--paper-3);
  border-radius: 8px;
  background: #242826;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  object-fit: contain;
}

.reference-thumb:hover {
  z-index: 40;
}

.reference-thumb:hover .reference-zoom-preview {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.selected-reference .reference-zoom-preview,
.reference-option .reference-zoom-preview {
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  display: block;
  object-fit: contain;
}

.selected-reference img,
.selected-reference video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-reference strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-reference .icon-button {
  width: 30px;
  height: 30px;
}

.reference-picker {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.74);
  animation: riseIn 180ms ease both;
}

.reference-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #4b463d;
  font-size: 0.84rem;
  font-weight: 900;
}

.reference-picker-head span {
  color: var(--muted);
  font-weight: 750;
}

.reference-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 8px;
  max-height: 264px;
  overflow: auto;
  padding-right: 2px;
}

.reference-option {
  min-width: 0;
  display: grid;
  grid-template-rows: 78px auto auto;
  gap: 5px;
  padding: 7px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-3);
}

.reference-option:hover,
.asset-tile:hover,
.workflow-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 17, 17, 0.14);
}

.reference-option.active {
  border-color: var(--accent-deep);
  box-shadow: inset 0 0 0 2px rgba(16, 182, 169, 0.18);
}

.reference-option span {
  display: block;
  height: 78px;
  min-width: 0;
  overflow: hidden;
  border-radius: 5px;
  background: #242826;
}

.reference-option span.reference-thumb {
  overflow: visible;
}

.reference-option strong,
.reference-option em {
  min-width: 0;
  overflow: hidden;
  font-size: 0.76rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-option em {
  color: var(--accent-deep);
  font-weight: 900;
}

.asset-check {
  min-height: 112px;
  display: grid;
  grid-template-rows: 74px auto;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-3);
  cursor: pointer;
}

.asset-check.active {
  border-color: var(--accent-deep);
  box-shadow: inset 0 0 0 2px rgba(16, 182, 169, 0.24);
}

.asset-check input {
  position: absolute;
  opacity: 0;
}

.asset-check span,
.asset-preview {
  min-width: 0;
  overflow: hidden;
}

.asset-check strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.asset-check img,
.asset-check video,
.asset-preview img,
.asset-preview video,
.reference-option img,
.reference-option video,
.output-tile img,
.output-tile video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.selected-reference img.reference-zoom-preview,
.reference-option img.reference-zoom-preview {
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  object-fit: contain;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 10px;
}

.asset-tile,
.workflow-tile,
.task-card,
.node-browser,
.override-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-3);
}

.asset-tile,
.reference-option,
.task-card {
  content-visibility: auto;
}

.asset-tile {
  contain-intrinsic-size: auto 112px;
}

.reference-option {
  contain-intrinsic-size: auto 128px;
}

.task-card {
  contain-intrinsic-size: auto 154px;
}

.task-card.text-task-card {
  contain-intrinsic-size: auto 260px;
}

.asset-tile {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 8px;
  padding: 8px;
}

.asset-preview {
  width: 82px;
  height: 82px;
  border-radius: 6px;
  background: #242826;
}

.asset-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
}

.asset-copy strong,
.workflow-tile strong,
.task-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-copy span,
.workflow-tile span,
.task-card span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.mono {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 6px;
}

.section-title {
  justify-content: space-between;
  color: #4b463d;
  font-weight: 900;
}

.library-section + .library-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.workflow-list {
  gap: 8px;
}

.workflow-tile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px;
}

.workflow-tile.active {
  border-color: var(--accent-deep);
}

.workflow-tile button:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: left;
  border: 0;
  color: inherit;
  background: transparent;
}

.node-browser {
  padding: 10px;
}

.workflow-prompt-box,
.quick-param-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.68);
}

.workflow-prompt-head,
.quick-param-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.workflow-prompt-head strong,
.quick-param-head strong {
  font-size: 0.92rem;
}

.workflow-prompt-head select {
  min-height: 34px;
}

.workflow-field-tag {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-prompt-box textarea {
  min-height: 116px;
}

.quick-param-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.quick-param {
  min-height: 58px;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
}

.quick-param span,
.quick-param em {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-param span {
  color: var(--accent-deep);
  font-family: var(--mono);
  font-weight: 900;
}

.quick-param strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-browser-head {
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.node-browser-head span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.node-browser-head input {
  max-width: 210px;
  min-height: 34px;
}

.node-field-list {
  max-height: 188px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.node-field {
  min-height: 82px;
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
}

.node-id {
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 900;
}

.node-field strong,
.node-field em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-field em {
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
}

.field-preview {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.override-head {
  justify-content: space-between;
  margin-top: 2px;
}

.override-row {
  display: grid;
  grid-template-columns: 76px 1fr 1.35fr 1.1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.task-panel-head {
  align-items: flex-start;
}

.task-panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: min(100%, 360px);
}

.task-pager {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.task-page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-pager-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.task-page-button {
  min-width: 34px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-3);
  font-size: 0.78rem;
  font-weight: 900;
}

.task-page-button.page-number {
  padding-inline: 6px;
}

.task-page-button.active {
  border-color: var(--accent-deep);
  color: #071817;
  background: var(--accent);
}

.task-page-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.task-page-gap {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 900;
}

.task-stream {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  width: 100%;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 130px) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
}

.task-card.text-task-card {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  padding: 10px;
}

.task-card.task-enter {
  animation: taskEnter 520ms ease both;
}

.task-card.optimistic {
  border-color: rgba(16, 182, 169, 0.48);
  animation: taskEnter 360ms ease both, optimisticGlow 1800ms ease-in-out infinite;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(15, 17, 17, 0.14);
}

.task-info {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.task-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.task-card-head > div:not(.task-status-cluster) {
  min-width: 0;
  display: grid;
  gap: 0;
}

.task-title-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-title-line strong,
.task-title-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title-line span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.task-status-cluster {
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: max-content;
  white-space: nowrap;
}

.task-mode-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(40, 127, 186, 0.34);
  border-radius: 999px;
  color: #1d5f89;
  background: linear-gradient(180deg, rgba(40, 127, 186, 0.12), rgba(16, 182, 169, 0.1));
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.74);
}

.status-badge {
  min-width: 74px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: #101313;
  background: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 900;
}

.status-badge.succeeded {
  background: #c7e99b;
}

.status-badge.failed,
.status-badge.cancelled {
  color: white;
  background: var(--red);
}

.status-badge.running {
  background: #a6e6df;
}

.status-badge.queued,
.status-badge.pending,
.status-badge.submitting,
.status-badge.submitted {
  background: #ffe2a9;
}

.progress-row {
  gap: 10px;
  margin: 1px 0;
}

.progress-row strong {
  width: 42px;
  color: #3d3932;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: right;
}

.progress-track {
  flex: 1 1 auto;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-2);
}

.progress-track span {
  position: relative;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--amber));
  overflow: hidden;
  transition: width 420ms ease;
}

.progress-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  display: none;
}

.task-card.submitting .progress-track span::after,
.task-card.running .progress-track span::after {
  display: block;
  animation: progressPulse 1300ms ease-in-out infinite;
}

.task-card.succeeded .progress-track span::after,
.task-card.failed .progress-track span::after,
.task-card.cancelled .progress-track span::after {
  display: none;
  animation: none;
}

.task-meta {
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}

.task-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-param-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.usage-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.usage-chip {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #514b42;
  background: rgba(237, 229, 212, 0.62);
  font-size: 0.78rem;
  font-weight: 800;
}

.usage-chip strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.error-line {
  margin: 0;
  padding: 8px;
  border-radius: 6px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.prompt-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 6px 6px 9px;
  border: 1px solid rgba(206, 196, 177, 0.66);
  border-radius: 6px;
  background: #ede5d4;
  transition: background 160ms ease, border-color 160ms ease;
}

.prompt-row.is-toggleable {
  grid-template-columns: minmax(0, 1fr) auto;
}

.prompt-row.expanded {
  align-items: start;
  border-color: var(--line-strong);
  background: #f1eadb;
}

.prompt-line {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #38342e;
  font-size: 0.79rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-row.expanded .prompt-line {
  max-height: min(36vh, 320px);
  overflow: auto;
  padding-right: 4px;
  text-overflow: clip;
  white-space: pre-wrap;
}

.prompt-toggle {
  min-width: 42px;
  min-height: 24px;
  align-self: center;
  padding: 3px 8px;
  border: 1px solid rgba(8, 123, 115, 0.34);
  border-radius: 999px;
  color: #075d56;
  background: rgba(16, 182, 169, 0.11);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.prompt-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--accent-deep);
  background: rgba(16, 182, 169, 0.18);
}

.prompt-row.expanded .prompt-toggle {
  align-self: start;
}

.error-line {
  color: #8a1f16;
  background: #f8dcd5;
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.output-tile {
  min-width: 0;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  background: #fffdf7;
}

button.output-tile {
  width: 100%;
  cursor: zoom-in;
}

.output-tile:hover {
  transform: translateY(-1px);
  border-color: var(--accent-deep);
  box-shadow: 0 8px 18px rgba(15, 17, 17, 0.13);
}

.task-output-side {
  min-width: 0;
  display: grid;
  align-content: start;
  max-width: 130px;
}

.output-empty {
  min-height: 82px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(237, 229, 212, 0.45);
  font-size: 0.82rem;
}

.output-empty.warn {
  color: #6f4d14;
  border-color: rgba(255, 179, 71, 0.62);
  background: rgba(255, 226, 169, 0.34);
}

.output-tile > :first-child {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 5px;
  background: #202422;
}

.text-output-preview {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 8px;
  color: var(--paper);
  background: #202422;
}

.text-output-preview strong {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.text-output-preview span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--paper-2);
  font-size: 0.7rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
  min-width: 0;
  align-self: start;
}

.task-actions .button,
.task-actions .icon-button {
  width: auto;
}

.task-card.has-image-output .task-actions {
  width: 106px;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  align-self: center;
  gap: 6px;
}

.task-card.has-image-output .task-actions .button,
.task-card.has-image-output .task-actions .icon-button {
  width: 100%;
}

.task-card.has-image-output .task-actions .button {
  justify-content: flex-start;
  white-space: nowrap;
}

.task-card.has-image-output .task-actions .icon-button {
  height: 32px;
}

.text-result,
.text-result-empty {
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
}

.text-result {
  position: relative;
  overflow: hidden;
}

.text-result:not(.expanded)::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 42px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0), #fffdf7);
}

.text-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.text-result-head strong {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.text-result-head span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 850;
}

.text-result-body {
  max-height: 168px;
  margin: 0;
  overflow: hidden;
  padding: 10px;
  color: #2e2b26;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text-result.expanded .text-result-body {
  max-height: min(68vh, 740px);
  overflow: auto;
  padding-bottom: 14px;
}

.text-result.streaming .text-result-body::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-deep);
  animation: streamCaret 900ms steps(1) infinite;
}

.text-result-empty {
  display: grid;
  place-items: center;
  min-height: 86px;
  padding: 14px;
  color: var(--muted);
  border-style: dashed;
  background: rgba(255, 250, 240, 0.62);
  font-size: 0.82rem;
}

.text-task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.text-task-actions .button,
.text-task-actions .icon-button {
  width: auto;
}

.text-task-action-group {
  display: contents;
}

.text-task-action-group.is-hidden {
  display: none;
}

.empty-state,
.empty-inline {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 250, 240, 0.62);
  text-align: center;
}

.empty-inline {
  min-height: 46px;
}

.file-preview {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: #202422;
}

.file-preview .icon {
  width: 30px;
  height: 30px;
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(243, 239, 228, 0.16);
  border-radius: var(--radius);
  color: var(--paper);
  background: #202422;
  box-shadow: var(--shadow);
}

.toast.success {
  border-color: rgba(16, 182, 169, 0.6);
}

.toast.error {
  border-color: rgba(201, 78, 65, 0.7);
}

.output-preview-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.output-preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(9, 10, 10, 0.72);
  backdrop-filter: blur(10px);
}

.output-preview-panel {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(243, 239, 228, 0.18);
  border-radius: var(--radius);
  background: #111313;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  animation: modalIn 180ms ease both;
}

.output-preview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(243, 239, 228, 0.14);
  color: var(--paper);
  background: rgba(32, 36, 34, 0.96);
}

.output-preview-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-preview-stage {
  min-height: min(62vh, 620px);
  display: grid;
  place-items: center;
  padding: 14px;
  background: #0c0e0d;
}

.output-preview-stage img,
.output-preview-stage video {
  max-width: 100%;
  max-height: calc(100vh - 128px);
  display: block;
  border-radius: 6px;
  object-fit: contain;
}

.preview-file {
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--paper);
}

.preview-text {
  width: 100%;
  max-height: calc(100vh - 128px);
  margin: 0;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(243, 239, 228, 0.14);
  border-radius: 6px;
  color: var(--paper);
  background: #151716;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  padding: 20px;
}

.login-mark {
  color: var(--paper);
  background: var(--bg);
}

.button-icon svg {
  width: 16px;
  height: 16px;
}

.saved-account-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.saved-account-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.whitelist-account-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.whitelist-account {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-3);
  font-weight: 850;
}

.saved-account {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper-3);
}

.saved-account span {
  color: var(--muted);
  font-size: 0.78rem;
}

.whitelist-account:hover,
.saved-account:hover {
  transform: translateY(-1px);
  border-color: var(--accent-deep);
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
  }

  .task-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

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

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .brand-copy h1 {
    white-space: normal;
  }

  .workspace-grid,
  .workflow-import,
  .workflow-prompt-head,
  .system-key-grid,
  .key-section-head,
  .model-combo-grid,
  .model-alias-row,
  .param-grid,
  .override-row,
  .task-card {
    grid-template-columns: 1fr;
  }

  .key-section-head,
  .system-section-head,
  .model-access-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .model-access-actions {
    justify-content: flex-start;
  }

  .model-enabled-toggle {
    justify-self: start;
  }

  .model-access-toolbar,
  .model-access-dialog-head,
  .model-access-dialog-tools,
  .model-access-dialog-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .model-access-dialog-grid {
    grid-template-columns: 1fr;
  }

  .key-status {
    max-width: 100%;
  }

  .task-panel-tools {
    justify-content: flex-start;
  }

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

  .tool-panel {
    min-height: auto;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1 1 0;
  }
}
