:root {
  --ink: var(--ui-text);
  --muted: var(--ui-text-secondary);
  --line: var(--ui-separator);
  --paper: var(--ui-surface);
  --navy: var(--ui-nav);
  --teal: var(--ui-accent);
  --mint: var(--ui-accent-soft);
}

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 17% 8%, rgba(99, 128, 255, 0.095), transparent 29%),
    radial-gradient(circle at 88% 4%, rgba(118, 88, 246, 0.07), transparent 31%),
    linear-gradient(145deg, #f8faff 0%, var(--ref-bg) 48%, #f3f5ff 100%);
  background-attachment: fixed;
  color: var(--ui-text);
}

.workbench-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 58px;
  padding: 0 max(24px, calc((100vw - 1320px) / 2));
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--ref-nav-dark);
  color: var(--ui-nav-text);
  box-shadow: 0 12px 32px rgba(23, 24, 34, 0.12);
}

.workbench-brand strong {
  color: var(--ui-nav-text);
  font-size: 16px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.workbench-nav nav {
  gap: 12px;
}

.workbench-nav nav a {
  color: var(--ui-nav-muted);
  font-size: 13px;
  font-weight: 500;
}

.workbench-nav nav a:hover {
  color: var(--ui-nav-text);
}

.health-pill {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ui-nav-text);
  font-size: 11px;
  font-weight: 550;
}

.feedback-prompt {
  position: fixed;
  z-index: 50;
  top: auto;
  right: 20px;
  bottom: 20px;
  width: 116px;
  height: 42px;
  margin: 0;
  padding: 0 14px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--ui-separator);
  border-radius: 10px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
  color: var(--ui-text);
  cursor: text;
  transition:
    width 180ms ease,
    height 180ms ease,
    padding 180ms ease,
    border-color 180ms ease;
}

.feedback-prompt::before {
  content: "意见反馈";
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 600;
}

.feedback-prompt p,
.feedback-prompt label {
  height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.feedback-prompt:focus-within {
  width: min(320px, calc(100vw - 24px));
  height: auto;
  padding: 16px;
  border-color: var(--ui-separator-strong);
}

.feedback-prompt:focus-within::before {
  height: auto;
  margin-bottom: 10px;
  justify-content: flex-start;
  color: var(--ui-text);
  font-size: 15px;
}

.feedback-prompt:focus-within p,
.feedback-prompt:focus-within label {
  height: auto;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
}

.feedback-prompt:focus-within p {
  margin: 0 0 10px;
  color: var(--ui-text-secondary);
  font-size: 12px;
  line-height: 1.55;
  font-weight: 400;
}

.feedback-prompt:focus-within label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  color: var(--ui-text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.feedback-prompt textarea,
.feedback-prompt textarea:focus,
.feedback-prompt:focus-within textarea {
  width: 100%;
  min-height: 96px;
  max-height: 180px;
  padding: 9px 10px;
  resize: vertical;
  overflow: auto;
  border: 1px solid var(--ui-separator-strong);
  border-radius: 8px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: none;
}

main {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.panel {
  border: 1px solid rgba(216, 221, 234, 0.74);
  border-radius: 16px;
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow-panel);
}

.upload-panel {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.workbench-create-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.create-left-column {
  min-width: 0;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  grid-template-areas:
    "modes upload"
    "guide upload";
  grid-template-rows: auto 1fr;
  gap: 16px 20px;
  align-items: start;
}

.workbench-mode-grid {
  grid-area: modes;
  margin: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  border: 1px solid rgba(216, 221, 234, 0.74);
  border-radius: var(--ref-radius-card);
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow-panel);
}

.workbench-mode-grid .mode-card {
  min-height: 78px;
  padding: 14px 13px 13px 16px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ui-text);
  box-shadow: none;
  transform: none;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.workbench-mode-grid .mode-card:hover {
  border-color: transparent;
  background: var(--ui-surface-hover);
  transform: none;
}

.workbench-mode-grid .mode-card.selected {
  border: 1px solid rgba(118, 88, 246, 0.28);
  background: linear-gradient(135deg, rgba(85, 116, 247, 0.1), rgba(118, 88, 246, 0.08));
  box-shadow: inset 3px 0 0 var(--ref-purple);
}

.workbench-mode-grid .mode-card em {
  top: 10px;
  right: 11px;
  color: var(--ui-text-tertiary);
  font-size: 10px;
  font-weight: 600;
}

.workbench-mode-grid .mode-card strong {
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 650;
}

.workbench-mode-grid .mode-card b {
  color: var(--ui-text-secondary);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 450;
}

.workbench-mode-grid .mode-card.selected strong {
  color: var(--ref-blue);
}

.mode-guide {
  grid-area: guide;
  margin: 0;
  padding: 12px 13px;
  border: 1px solid rgba(216, 221, 234, 0.72);
  border-radius: 10px;
  background: var(--ref-surface);
  color: var(--ui-text-secondary);
  font-size: 11px;
  line-height: 1.55;
}

.create-upload-column {
  grid-area: upload;
  min-width: 0;
  min-height: 556px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(216, 221, 234, 0.74);
  border-radius: var(--ref-radius-panel);
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow-panel);
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head small,
.activity-head small {
  margin-bottom: 6px;
  color: var(--ui-text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
}

.panel-head h2,
.activity-head h2 {
  color: var(--ui-text);
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.panel-head > span {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-size: 11px;
  font-weight: 550;
}

.dropzone {
  min-height: 468px;
  flex: 1 1 auto;
  border: 1px dashed rgba(191, 199, 221, 0.82);
  border-radius: var(--ref-radius-card);
  background: linear-gradient(180deg, rgba(251, 252, 255, 0.82), rgba(247, 249, 255, 0.96));
  box-shadow: none;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: rgba(0, 113, 227, 0.55);
  background: var(--ui-accent-soft);
}

.drop-empty {
  width: min(100%, 640px);
  min-height: 400px;
  padding: 225px 28px 30px;
  justify-content: flex-start;
  gap: 9px;
  background-image: url("assets/workbench-upload-empty.webp");
  background-repeat: no-repeat;
  background-position: center 48px;
  background-size: 210px auto;
}

.drop-empty[hidden],
.dropzone img[hidden],
.replace-hint[hidden],
.file-meta[hidden] {
  display: none;
}

.drop-empty::before {
  display: none;
}

.drop-empty b {
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 600;
}

.drop-empty small {
  color: var(--ui-text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.dropzone img {
  width: 100%;
  height: 468px;
  object-fit: contain;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--ref-surface-soft), var(--ref-bg));
}

.replace-hint {
  right: 12px;
  bottom: 12px;
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.84);
  color: #fff;
}

.file-meta {
  margin-top: 10px;
  color: var(--ui-text-secondary);
  font-size: 12px;
}

.create-settings-column {
  position: sticky;
  top: 78px;
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(216, 221, 234, 0.74);
  border-radius: var(--ref-radius-panel);
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow-panel);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.settings-grid label {
  gap: 7px;
  color: var(--ui-text-secondary);
  font-size: 13px;
  font-weight: 550;
}

.settings-grid select {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--ui-separator-strong);
  border-radius: 8px;
  background: var(--ref-surface);
  color: var(--ui-text);
  box-shadow: none;
}

.settings-grid select:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-soft);
}

.mode-settings {
  grid-template-columns: 1fr;
  gap: 14px;
}

.mode-settings p {
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--ui-surface-soft);
  color: var(--ui-text-secondary);
  font-size: 11px;
  line-height: 1.6;
}

.freedom-control > span strong {
  color: var(--ui-accent);
  font-size: 15px;
  font-weight: 650;
}

.freedom-control input {
  accent-color: var(--ui-accent);
}

.freedom-control small {
  color: var(--ui-text-tertiary);
}

.form-error {
  margin-top: 16px;
  border-radius: 8px;
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.primary-button {
  min-height: 48px;
  margin-top: 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ref-blue), var(--ref-purple));
  color: #fff;
  box-shadow: 0 10px 24px rgba(85, 116, 247, 0.22);
  font-weight: 650;
  transition:
    background-color 160ms ease,
    opacity 160ms ease;
}

.primary-button:not(:disabled):hover {
  background: linear-gradient(135deg, var(--ref-blue-hover), #6749ee);
  transform: none;
}

.primary-button:disabled {
  background: #d2d2d7;
  color: #86868b;
  opacity: 1;
}

.product-retry-hint {
  color: var(--ui-text-secondary);
  font-size: 11px;
}

.activity {
  margin-top: 32px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--ref-radius-panel);
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow-panel);
}

.activity-head {
  min-height: 72px;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--ui-separator);
}

.activity-retention-notice {
  color: var(--ui-danger);
  font-size: 11px;
  font-weight: 500;
}

.activity-head > div:last-child {
  gap: 8px;
}

.activity-head select,
.activity-head button,
.activity-load-more button {
  min-height: 36px;
  border: 1px solid var(--ui-separator-strong);
  border-radius: 8px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: none;
  font-size: 12px;
}

.activity-head button,
.activity-load-more button {
  font-weight: 550;
}

.activity-head button:hover,
.activity-load-more button:hover {
  border-color: rgba(0, 113, 227, 0.4);
  color: var(--ui-accent);
}

.queue-summary {
  margin: 0;
  padding: 10px 20px;
  border: 0;
  border-bottom: 1px solid var(--ui-separator);
  border-radius: 0;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-size: 11px;
  font-weight: 550;
}

.job-list {
  display: grid;
  gap: 0;
}

.jobs-empty {
  margin: 0;
  padding: 38px 20px;
  border: 0;
  border-radius: 0;
  background: var(--ui-surface);
  color: var(--ui-text-secondary);
}

.job-row {
  min-height: 72px;
  padding: 12px 20px;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.7fr) 108px minmax(150px, auto);
  gap: 18px;
  border: 0;
  border-bottom: 1px solid var(--ui-separator);
  border-radius: 0;
  background: var(--ui-surface);
  box-shadow: none;
}

.job-main {
  gap: 4px;
}

.job-main strong {
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 600;
}

.job-main span,
.job-main .job-queue-detail {
  color: var(--ui-text-secondary);
  font-size: 11px;
  font-weight: 400;
}

.job-progress {
  color: var(--ui-text-secondary);
  font-size: 10px;
}

.job-progress > span {
  height: 5px;
  background: var(--ui-surface-hover);
}

.job-progress i {
  background: var(--ui-accent);
}

.job-state {
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 0;
  background: transparent;
  color: var(--ui-text-secondary);
  font-size: 11px;
  font-weight: 550;
}

.job-state::before {
  content: "•";
  color: var(--ui-text-tertiary);
}

.job-state.SUCCEEDED {
  background: transparent;
  color: var(--ui-success);
}

.job-state.SUCCEEDED::before {
  content: "✓";
  color: var(--ui-success);
}

.job-state.RUNNING::before,
.job-state.PROCESSING::before {
  content: "◌";
  color: var(--ui-accent);
}

.job-state.PENDING::before,
.job-state.QUEUED::before {
  content: "…";
  color: var(--ui-warning);
}

.job-state.FAILED,
.job-state.NEEDS_REVIEW {
  background: transparent;
  color: var(--ui-danger);
}

.job-state.FAILED::before,
.job-state.NEEDS_REVIEW::before {
  content: "!";
  color: var(--ui-danger);
}

.job-state.CANCELLED::before {
  content: "×";
  color: var(--ui-text-tertiary);
}

.job-actions {
  gap: 6px;
}

.job-actions button,
.job-actions a {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--ui-separator-strong);
  border-radius: 8px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 11px;
  font-weight: 550;
}

.job-actions button:hover,
.job-actions a:hover {
  border-color: rgba(0, 113, 227, 0.4);
  color: var(--ui-accent);
}

.job-actions .cancel {
  color: var(--ui-danger);
}

.activity-load-more {
  min-height: 48px;
  margin: 0;
  border-top: 0;
  color: var(--ui-text-secondary);
}

.job-failure-detail {
  color: var(--ui-danger);
}

.algorithm-disclaimer {
  color: var(--ui-text-tertiary);
  font-size: 11px;
}

.toast {
  border-radius: 10px;
  background: var(--ui-nav);
  color: var(--ui-nav-text);
  box-shadow: var(--ui-shadow-md);
}

.preview-modal {
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: none;
}

.preview-dialog {
  gap: 14px;
  width: min(980px, calc(100vw - 48px));
  padding: 18px;
  border: 0;
  border-radius: 18px;
  background: var(--ui-surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.26);
}

.preview-head {
  color: var(--ui-text);
}

.preview-head button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ui-separator);
  border-radius: 8px;
  background: var(--ui-surface-soft);
  color: var(--ui-text-secondary);
}

.preview-dialog img {
  background: var(--ui-bg);
}

.preview-download {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--ui-accent);
  color: #fff;
  font-weight: 600;
}

@media (max-width: 1100px) {
  .workbench-create-split {
    grid-template-columns: 1fr;
  }

  .create-left-column {
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .create-settings-column {
    position: static;
    top: auto;
  }

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

  .mode-freedom,
  .mode-settings,
  .form-error,
  .primary-button,
  .product-retry-hint {
    grid-column: 1 / -1;
  }

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

  .mode-settings p {
    grid-column: 1 / -1;
  }

  .job-row {
    grid-template-columns: minmax(200px, 1fr) minmax(150px, 0.7fr) 96px;
  }

  .job-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 767px) {
  body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .workbench-nav {
    order: 1;
    width: 100%;
    min-height: 52px;
    padding: 8px 14px;
    align-items: center;
    flex-direction: row;
  }

  .workbench-brand strong {
    font-size: 14px;
  }

  .workbench-nav nav {
    justify-content: flex-end;
  }

  .health-pill {
    display: none;
  }

  main {
    order: 2;
    width: calc(100% - 24px);
    padding: 20px 0 48px;
  }

  .create-left-column {
    grid-template-columns: 1fr;
    grid-template-areas:
      "modes"
      "guide"
      "upload";
    gap: 12px;
  }

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

  .create-upload-column,
  .create-settings-column {
    padding: 18px 16px;
    border-radius: 16px;
  }

  .create-upload-column {
    min-height: 0;
  }

  .dropzone {
    min-height: 350px;
  }

  .drop-empty {
    min-height: 320px;
    padding: 188px 18px 24px;
    background-position: center 36px;
    background-size: 165px auto;
  }

  .dropzone img {
    height: 340px;
  }

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

  .mode-freedom,
  .mode-settings,
  .form-error,
  .primary-button,
  .product-retry-hint {
    grid-column: auto;
  }

  .activity {
    margin-top: 24px;
    border-radius: 16px;
  }

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

  .activity-retention-notice {
    text-align: left;
  }

  .job-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px;
  }

  .job-actions {
    grid-column: auto;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .feedback-prompt {
    order: 3;
    position: static;
    width: calc(100% - 24px);
    height: auto;
    margin: 0 auto 20px;
    padding: 16px;
    overflow: visible;
    box-shadow: var(--ui-shadow-sm);
  }

  .feedback-prompt::before {
    display: none;
  }

  .feedback-prompt p,
  .feedback-prompt label {
    height: auto;
    overflow: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .feedback-prompt p {
    margin: 0 0 10px;
    color: var(--ui-text-secondary);
    font-size: 12px;
    line-height: 1.55;
    font-weight: 400;
  }

  .feedback-prompt label {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    color: var(--ui-text-secondary);
    font-size: 12px;
    font-weight: 500;
  }
}

@media (max-width: 420px) {
  .workbench-nav nav a {
    font-size: 12px;
  }

  main,
  .feedback-prompt {
    width: calc(100% - 24px);
  }

  .workbench-mode-grid,
  .create-upload-column,
  .create-settings-column {
    padding: 16px;
  }

  .workbench-mode-grid {
    padding: 8px;
  }

  .workbench-mode-grid .mode-card {
    min-height: 70px;
  }

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

  .dropzone {
    min-height: 320px;
  }

  .drop-empty {
    min-height: 290px;
    padding-top: 172px;
    background-position: center 32px;
    background-size: 148px auto;
  }

  .dropzone img {
    height: 280px;
  }

  .activity-head > div:last-child,
  .activity-head select,
  .activity-head button {
    width: 100%;
  }

  .job-actions {
    display: flex;
  }

  .job-actions button,
  .job-actions a {
    min-height: 44px;
    flex: 1 1 auto;
    justify-content: center;
  }

  .preview-modal {
    padding: 12px;
  }

  .preview-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 13px;
  }
}
