:root {
  --ink: #172033;
  --muted: #687386;
  --line: #dce2ea;
  --paper: #ffffff;
  --navy: #13233d;
  --teal: #0f766e;
  --mint: #dff8f1;
  --gold: #d49a36;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #f1f4f8;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 80% -5%, #cbece7 0, transparent 32%), #f1f4f8; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.workbench-nav {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 12px max(24px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: var(--navy);
  color: #fff;
}
.workbench-brand, .workbench-nav nav { display: flex; align-items: center; gap: 12px; }
.workbench-brand { color: #fff; text-decoration: none; }
.workbench-nav nav { flex-wrap: wrap; justify-content: flex-end; }
.workbench-nav nav a { color: #dce8f5; text-decoration: none; font-size: 14px; font-weight: 800; }
.health-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 99px; background: rgba(255,255,255,.1); font-size: 12px; }
.health-pill i { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.15); }
.health-pill.ready i { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.15); }
.health-pill.error i { background: #fb7185; }
body.product-reconstruction-mode .product-hidden-ui { display: none !important; }
body.product-reconstruction-mode .job-queue-detail { display: none !important; }

.feedback-prompt {
  position: fixed;
  z-index: 30;
  top: 84px;
  right: 16px;
  width: min(310px, calc(100vw - 32px));
  padding: 11px 12px;
  border: 1px solid rgba(15,118,110,.28);
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 14px 34px rgba(19,35,61,.14);
  color: var(--ink);
  cursor: text;
}
.feedback-prompt p { margin: 0 0 8px; color: var(--ink); font-size: 12px; font-weight: 850; line-height: 1.5; }
.feedback-prompt label { display: grid; gap: 5px; color: var(--teal); font-size: 12px; font-weight: 950; }
.feedback-prompt textarea { width: 100%; min-height: 66px; max-height: 66px; resize: none; overflow: hidden; border: 1px solid #aabec6; border-radius: 7px; background: #fff; color: var(--ink); padding: 6px 8px; font: inherit; font-size: 12px; line-height: 1.45; transition: min-height .18s ease, max-height .18s ease, box-shadow .18s ease; }
.feedback-prompt textarea:focus, .feedback-prompt:focus-within textarea { min-height: 188px; max-height: 188px; resize: vertical; overflow: auto; outline: 0; box-shadow: 0 0 0 3px rgba(15,118,110,.15); }

main { width: min(1320px, calc(100% - 36px)); margin: 0 auto; padding: 18px 0 70px; }
.hero { max-width: 800px; margin-bottom: 28px; }
.hero p, .panel-head small, .activity-head small { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 950; letter-spacing: .15em; }
.hero h1 { margin: 0; font-size: clamp(38px, 6vw, 66px); line-height: 1.02; letter-spacing: -.045em; }
.hero > span { display: block; margin-top: 16px; color: var(--muted); line-height: 1.7; }

.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.mode-card { min-height: 190px; position: relative; display: grid; align-content: start; gap: 7px; padding: 22px; text-align: left; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.83); color: var(--ink); cursor: pointer; transition: .18s ease; }
.mode-card:hover { transform: translateY(-2px); border-color: #91aaa5; }
.mode-card.selected { border: 2px solid var(--teal); background: #fff; box-shadow: 0 16px 40px rgba(15,118,110,.12); }
.mode-card em { position: absolute; right: 18px; top: 16px; color: #aab4c2; font-style: normal; font-weight: 900; }
.mode-card strong { font-size: 21px; }
.mode-card b { color: var(--teal); font-size: 13px; }
.mode-card span { margin-top: 6px; color: var(--muted); line-height: 1.65; font-size: 13px; }

.create-layout { display: grid; grid-template-columns: minmax(0,1fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: 0 18px 45px rgba(35,51,75,.08); }
.upload-panel, .activity { padding: 24px; }
.workbench-create-split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .55fr); gap: 22px; align-items: stretch; }
.create-left-column, .create-upload-column, .create-settings-column { min-width: 0; }
.create-left-column { display: grid; gap: 20px; }
.workbench-mode-grid { margin: 0; }
.workbench-mode-grid .mode-card { min-height: 106px; padding: 16px; gap: 5px; border-radius: 14px; }
.workbench-mode-grid .mode-card em { top: 12px; right: 14px; }
.workbench-mode-grid .mode-card strong { font-size: 18px; }
.workbench-mode-grid .mode-card span { margin-top: 2px; font-size: 12px; line-height: 1.48; }
.create-upload-column { display: flex; flex-direction: column; }
.create-settings-column { padding-left: 22px; border-left: 1px solid var(--line); }
.panel-head, .activity-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2, .activity-head h2 { margin: 0; font-size: 25px; }
.panel-head > span { padding: 7px 10px; border-radius: 99px; background: var(--mint); color: var(--teal); font-size: 12px; font-weight: 900; }

.dropzone { min-height: 300px; position: relative; display: grid; place-items: center; overflow: hidden; border: 1.5px dashed #aab5c4; border-radius: 16px; background: #f7f9fc; cursor: pointer; }
.dropzone.dragging { border-color: var(--teal); background: var(--mint); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-empty { display: grid; gap: 8px; text-align: center; }
.drop-empty b { font-size: 17px; }
.drop-empty small { color: var(--muted); }
.dropzone img { width: 100%; height: 360px; object-fit: contain; background: #e7ebf1; }
.replace-hint { position: absolute; right: 12px; bottom: 12px; padding: 7px 10px; border-radius: 8px; background: rgba(19,35,61,.82); color: #fff; font-size: 12px; font-weight: 850; }
.file-meta { margin-top: 9px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.settings-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; }
.settings-grid label { display: grid; gap: 7px; color: #405069; font-size: 13px; font-weight: 850; }
.settings-grid select { width: 100%; min-height: 44px; border: 1px solid #cfd7e3; border-radius: 10px; background: #fff; padding: 8px 11px; color: var(--ink); }
.mode-freedom { grid-column: 1 / -1; }
.mode-freedom[hidden] { display: none; }
.mode-settings { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; }
.mode-settings[hidden] { display: none; }
.mode-settings .wide { grid-column: 1 / -1; }
.mode-settings p { grid-column: 1 / -1; margin: 0; padding: 12px 14px; border-radius: 10px; background: #eff6f5; color: #536276; font-size: 12px; line-height: 1.6; }
.freedom-control > span { display: flex; justify-content: space-between; }
.freedom-control > span strong { color: var(--teal); font-size: 17px; }
.freedom-control input { width: 100%; accent-color: var(--teal); }
.freedom-control small { display: flex; justify-content: space-between; color: #8a95a5; font-size: 10px; }
.freedom-control i { font-style: normal; }
.form-error { margin-top: 15px; padding: 11px 13px; border-radius: 10px; background: #fff1f2; color: #be123c; font-size: 13px; font-weight: 800; }
.primary-button { width: 100%; min-height: 50px; margin-top: 18px; border: 0; border-radius: 12px; background: var(--teal); color: #fff; font-weight: 950; cursor: pointer; }
.primary-button:disabled { background: #adb6c3; cursor: not-allowed; }
.product-retry-hint { margin-top: 10px; color: #10b981; font-size: 13px; font-weight: 700; line-height: 1.5; text-align: center; }


.activity-retention-notice { flex: 1 1 auto; margin: 0; color: #dc2626; font-size: 14px; font-weight: 950; text-align: center; }
.activity { margin-top: 20px; }
.activity-head > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.activity-head select, .activity-head button { min-height: 38px; border: 1px solid #cfd7e3; border-radius: 9px; background: #fff; padding: 0 10px; color: #445269; }
.activity-head button { cursor: pointer; font-weight: 850; }
.queue-summary { margin: -6px 0 12px; padding: 10px 12px; border: 1px solid #a7dfd5; border-radius: 10px; background: #ecfdf5; color: #0f766e; font-size: 12px; font-weight: 850; line-height: 1.5; }
.job-list { display: grid; gap: 8px; }
.jobs-empty { padding: 32px; border-radius: 12px; background: #f5f7fa; color: var(--muted); text-align: center; }
.job-row { display: grid; grid-template-columns: minmax(190px,1fr) minmax(180px,.8fr) 80px 180px; gap: 14px; align-items: center; min-height: 68px; padding: 11px 13px; border: 1px solid #e0e5ec; border-radius: 12px; }
.job-main { min-width: 0; display: grid; gap: 4px; }
.job-main strong, .job-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-main span { color: var(--muted); font-size: 12px; }
.job-main .job-queue-detail { color: #0f766e; font-size: 11px; font-weight: 850; line-height: 1.35; }
.job-progress { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.job-progress > span { height: 6px; overflow: hidden; border-radius: 99px; background: #e5e9ef; }
.job-progress i { display: block; height: 100%; background: var(--teal); }
.job-state { justify-self: start; padding: 6px 9px; border-radius: 99px; background: #edf2f7; color: #46556b; font-size: 11px; font-weight: 900; }
.job-state.SUCCEEDED { background: #dcfce7; color: #15803d; }
.job-state.FAILED, .job-state.NEEDS_REVIEW { background: #fff1f2; color: #be123c; }
.job-actions { display: flex; justify-content: flex-end; gap: 6px; }
.job-actions button, .job-actions a { min-height: 34px; display: inline-flex; align-items: center; border: 1px solid #cad3df; border-radius: 8px; background: #fff; color: #334155; padding: 0 10px; text-decoration: none; font-size: 12px; font-weight: 850; cursor: pointer; }
.job-actions .cancel { color: #be123c; }
.activity-load-more { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 42px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.activity-load-more button { min-height: 38px; border: 1px solid #94a3b8; border-radius: 9px; padding: 0 18px; background: #fff; color: #334155; font-weight: 900; cursor: pointer; }
.activity-load-more button:hover { border-color: var(--teal); color: var(--teal); }
.algorithm-disclaimer { margin: 16px auto 0; color: #7c8798; font-size: 11px; line-height: 1.6; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 20; transform: translateX(-50%); max-width: min(520px,calc(100vw - 32px)); padding: 12px 16px; border-radius: 11px; background: #13233d; color: #fff; box-shadow: 0 15px 40px rgba(0,0,0,.25); font-weight: 800; }
.preview-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(6, 15, 28, .68); backdrop-filter: blur(5px); }
.preview-modal[hidden] { display: none; }
.preview-dialog { display: grid; gap: 14px; width: min(980px, calc(100vw - 48px)); max-height: calc(100vh - 48px); padding: 18px; border: 1px solid rgba(255,255,255,.24); border-radius: 18px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.38); }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--ink); }
.preview-head strong { font-size: 17px; }
.preview-head button { width: 34px; height: 34px; border: 1px solid #cfd7e3; border-radius: 50%; background: #fff; color: #334155; font-size: 24px; line-height: 1; cursor: pointer; }
.preview-status { display: grid; place-items: center; min-height: 52px; margin: 0; padding: 14px; border-radius: 10px; background: #eef2f7; color: var(--muted); font-size: 13px; text-align: center; }
.preview-status[data-state="error"] { background: #fff1f2; color: #be123c; }
.preview-status[hidden], .preview-dialog img[hidden] { display: none; }
.preview-dialog img { display: block; width: 100%; max-height: calc(100vh - 190px); object-fit: contain; border-radius: 10px; background: #eef2f7; }
.preview-download { justify-self: end; min-height: 38px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 9px; background: var(--teal); color: #fff; text-decoration: none; font-size: 13px; font-weight: 900; }

@media (max-width: 980px) {
  .mode-grid, .create-layout { grid-template-columns: 1fr; }
  .workbench-create-split { grid-template-columns: 1fr; }
  .workbench-mode-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .create-settings-column { padding: 24px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .job-row { grid-template-columns: minmax(180px,1fr) minmax(150px,.8fr) 80px; }
  .job-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 640px) {
  .feedback-prompt { top: 12px; }
  .workbench-nav { align-items: flex-start; flex-direction: column; }
  .workbench-nav nav { justify-content: flex-start; }
  main { width: min(100% - 22px,1320px); padding-top: 28px; }
  .workbench-mode-grid { grid-template-columns: 1fr; }
  .settings-grid, .mode-settings, .comparison { grid-template-columns: 1fr; }
  .mode-settings .wide { grid-column: auto; }
  .job-row { grid-template-columns: 1fr; }
  .job-actions { grid-column: auto; }
  .activity-head { align-items: flex-start; flex-direction: column; }
  .preview-modal { padding: 12px; }
  .preview-dialog { width: calc(100vw - 24px); max-height: calc(100vh - 24px); padding: 13px; }
  .preview-dialog img { max-height: calc(100vh - 155px); }
}

.mode-guide {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.job-failure-detail {
  display: grid;
  gap: 3px;
  color: #be123c;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
  white-space: normal;
}

.job-failure-detail strong { font-size: 12px; }

.dropzone:focus-within,
.mode-card:focus-visible,
.job-actions button:focus-visible,
.job-actions a:focus-visible,
.activity-head button:focus-visible,
.activity-head select:focus-visible,
.preview-head button:focus-visible,
.preview-download:focus-visible {
  outline: 3px solid #f7c948;
  outline-offset: 3px;
}

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

@media (max-width: 1024px) {
  .mode-guide,
  .job-failure-detail,
  .file-meta {
    white-space: normal;
  }
}

@media (max-width: 390px) {
  .upload-panel,
  .activity { padding: 16px; }
  .mode-guide { font-size: 12px; }
}
