/* Workspace two-column layout */
.workspace-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  align-items: start;
  gap: 22px;
}

.workspace-shell.workspace-preview-collapsed {
  grid-template-columns: minmax(0, 1fr) 48px;
}

.workspace-left {
  min-width: 0;
}

.workspace-preview-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding-right: 2px;
}

.preview-collapse-toggle {
  justify-self: end;
  width: 46px;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid #d8e3f2;
  border-radius: 8px;
  background: #fff;
  color: #1f5fc8;
  box-shadow: 0 10px 24px rgba(31, 42, 68, .08);
}

.workspace-preview-collapsed .workspace-preview-panel {
  overflow: visible;
  padding-right: 0;
}

.workspace-preview-collapsed .workspace-preview-panel .preview-card,
.workspace-preview-collapsed .workspace-preview-panel .preview-details-card {
  display: none;
}

.preview-card,
.workspace-preview-panel .final-prompt-panel {
  border: 1px solid #d8e3f2;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 14px 34px rgba(31, 42, 68, .07);
}

.preview-card h3,
.workspace-preview-panel .final-prompt-panel strong {
  margin: 0 0 10px;
}

.workspace-preview-image-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.workspace-preview-image-box img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  background: #f3f7fc;
}

.preview-summary {
  display: grid;
  gap: 8px;
  margin: 0;
}

.preview-summary div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #d8e3f2;
}

.preview-summary dt {
  color: #65748b;
  font-size: 12px;
}

.preview-summary dd {
  margin: 0;
  color: #17233a;
  font-weight: 800;
  word-break: break-word;
}

.workspace-preview-panel .final-prompt-panel {
  margin: 0;
}

.workspace-preview-panel .final-prompt-head {
  display: grid;
  gap: 8px;
}

.workspace-preview-panel #final-prompt-preview {
  min-height: 160px;
}

.workspace-preview-panel .stats {
  display: grid;
  gap: 8px;
}

.workspace-preview-panel .recent-card {
  padding: 12px;
}

.workspace-preview-panel .thumb-list,
.workspace-preview-panel .recent-image-grid,
.workspace-preview-panel .image-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 1180px) {
  .workspace-shell {
    grid-template-columns: 1fr;
  }

  .workspace-shell.workspace-preview-collapsed {
    grid-template-columns: 1fr;
  }

  .workspace-preview-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.preview-live-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e4ebf5;
}

.preview-live-block h4 {
  margin: 0 0 8px;
  color: #17233a;
  font-size: 14px;
}

.preview-filled-list .field-note {
  margin: 0;
}

.preview-live-fields div {
  grid-template-columns: 92px minmax(0, 1fr);
}

.preview-live-fields dd {
  font-weight: 700;
}

.inline-generate-hidden {
  display: none !important;
}

.fixed-generate-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

#fixed-preview-prompt-btn {
  border: 1px solid #2f6fda;
  background: #ffffff;
  color: #1f5fc8;
}

#fixed-preview-prompt-btn:hover {
  background: #eef5ff;
}

@media (max-width: 720px) {
  .fixed-generate-actions {
    width: 100%;
  }

  .fixed-generate-actions button {
    flex: 1;
  }
}

.inline-preview-hidden,
.soft-hidden {
  display: none !important;
}

.advanced-settings {
  border: 1px dashed #cdd9eb;
  border-radius: 16px;
  background: #f8fbff;
  margin: 16px 0;
  padding: 0;
}

.advanced-settings summary {
  cursor: pointer;
  padding: 14px 16px;
  color: #365477;
  font-weight: 800;
}

.advanced-settings label {
  display: block;
  padding: 0 16px 16px;
}

.preview-details-card summary {
  cursor: pointer;
  color: #17233a;
  font-weight: 900;
  list-style-position: inside;
}

.preview-details-card[open] summary {
  margin-bottom: 10px;
}

.sales-text-pure-mode .sales-text-panel::after {
  content: '当前选择纯图：不会生成图中文字，标题和卖点无需填写。';
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #d8e3f2;
  border-radius: 12px;
  background: #f6f9ff;
  color: #506683;
  font-size: 13px;
}

.history-bottom-card {
  margin-top: 22px;
  border: 1px solid #d8e3f2;
  border-radius: 20px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 16px 38px rgba(31, 42, 68, .06);
}

.history-bottom-card h2 {
  margin-top: 0;
}

/* Lighten optional image-text settings inside sales prompt */
.sales-text-panel {
  margin-top: 12px;
  padding: 12px 12px 10px;
  border: 1px solid #e4ebf5;
  border-radius: 12px;
  background: #f8fbff;
}

.sales-text-panel .label-first-title {
  font-size: 14px;
  font-weight: 900;
  color: #24344d;
}

.sales-text-panel .label-first-title::after {
  content: '（可选）';
  color: #73839a;
  font-weight: 700;
}

.sales-text-panel > .field-note {
  margin: 4px 0 8px;
  font-size: 12px;
}

.sales-text-panel .row {
  margin-top: 8px;
}

.sales-text-pure-mode .sales-text-panel {
  background: #fafcff;
}

.sales-text-pure-mode .sales-text-panel::after {
  margin-top: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: #eef5ff;
  color: #506683;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .workspace-shell {
    grid-template-columns: 1fr;
  }
}

/* Multi-reference image workflow */
.reference-upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: end;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #d8e3f2;
  border-radius: 16px;
  background: #f8fbff;
}

.vision-chat-panel {
  display: grid;
  grid-template-columns: 200px minmax(220px, .8fr) minmax(420px, 1.35fr);
  gap: 12px;
  align-items: end;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  background: #f8fbff;
}

.vision-chat-panel.product-inline-vision {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  grid-template-columns: 130px minmax(160px, .6fr) minmax(360px, 1.15fr) minmax(260px, .85fr);
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.product-inline-vision label {
  margin: 0;
  gap: 0;
  font-size: 0;
}

.product-inline-vision select,
.product-inline-vision input[type="text"] {
  height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 13px;
}

.vision-chat-panel .image-type-picker {
  margin: 0;
}

.vision-chat-panel .image-type-head {
  margin-bottom: 8px;
}

.chat-context-row {
  display: contents;
}

.chat-context-row label {
  margin: 0;
}

.chat-input-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid #c7d7ee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(31, 42, 68, .06);
}

.chat-upload-btn {
  width: auto;
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: #eef5ff;
  color: #1f5fc8;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.chat-input-shell textarea {
  min-height: 38px;
  max-height: 96px;
  margin-top: 0;
  border: 0;
  resize: vertical;
  box-shadow: none;
}

.chat-input-shell textarea:focus {
  outline: 2px solid #d7e7ff;
}

.chat-send-btn {
  min-height: 38px;
  white-space: nowrap;
}

#analyze-images-status {
  grid-column: 1 / -1;
}

.product-inline-vision .chat-input-shell {
  height: 38px;
  min-width: 0;
  padding: 4px;
  gap: 6px;
  border-color: #d8e3f2;
  box-shadow: none;
}

.product-inline-vision .chat-upload-btn {
  min-width: 74px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.product-inline-vision .chat-input-shell textarea {
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  overflow: hidden;
  resize: none;
}

.product-inline-vision .chat-send-btn {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
}

.product-inline-vision #analyze-images-status {
  position: absolute;
  left: 0;
  top: calc(100% + 3px);
  z-index: 2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-image-card {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  background: #ffffff;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.product-image-card.selected {
  border-color: #2374ff;
  background: #eef5ff;
  box-shadow: 0 0 0 2px rgba(35, 116, 255, .12);
}

.product-image-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.product-image-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 800;
  white-space: nowrap;
}

.product-image-controls select {
  min-width: 0;
}

.workspace-preview-images {
  display: grid;
  gap: 10px;
}

.workspace-preview-thumb {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  background: #f8fbff;
}

.workspace-preview-thumb img {
  grid-row: span 2;
  width: 92px;
  height: 78px;
  object-fit: cover;
  border-radius: 10px;
  background: #ffffff;
}

.workspace-preview-thumb strong {
  color: #17233a;
  font-size: 13px;
}

.workspace-preview-thumb span {
  color: #65748b;
  font-size: 12px;
  word-break: break-all;
}

.reference-file-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 0;
  min-width: 0;
}

.reference-file-list-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.reference-file-list-head button,
.reference-file-list li button {
  padding: 6px 10px;
}

.reference-file-list ul {
  display: flex;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 2px 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
}

.reference-file-list li {
  position: relative;
  flex: 0 0 132px;
  width: 132px;
  height: 92px;
  background: #ffffff;
  border: 2px solid #17233a;
  border-radius: 8px;
  display: block;
  overflow: hidden;
  padding: 0;
  scroll-snap-align: start;
}

.reference-file-list li img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-file-list li button {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  background: rgba(9, 18, 32, .72);
  color: #fff;
  line-height: 1;
}

.reference-preview-strip-empty {
  min-height: 92px;
  border: 2px dashed #d8e3f2;
  border-radius: 8px;
  background: #ffffff;
}

.product-inline-vision .reference-file-list {
  grid-column: auto;
  align-self: center;
  gap: 0;
}

.product-inline-vision .reference-file-list-head {
  display: none;
}

.product-inline-vision .reference-file-list ul {
  gap: 8px;
  height: 38px;
  padding: 0 2px 2px;
  scrollbar-width: thin;
}

.product-inline-vision .reference-file-list li {
  flex-basis: 56px;
  width: 56px;
  height: 36px;
  border-color: #17233a;
}

.product-inline-vision .reference-file-list li button {
  right: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  font-size: 13px;
}

.product-inline-vision .reference-preview-strip-empty {
  height: 36px;
  min-height: 36px;
  border: 2px solid #17233a;
}

.history-source-list {
  display: grid;
  gap: 10px;
}

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

.history-source-grid .history-source-preview {
  display: grid;
  gap: 6px;
  border: 1px solid #d8e3f2;
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
  text-align: left;
}

.history-source-grid img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 9px;
}

.history-source-grid span,
.history-source-grid small {
  display: block;
  word-break: break-word;
}

@media (max-width: 720px) {
  .reference-upload-panel {
    grid-template-columns: 1fr;
  }

  .vision-chat-panel {
    grid-template-columns: 1fr;
  }

  .chat-context-row,
  .chat-input-shell {
    grid-template-columns: 1fr;
  }

  .chat-upload-btn {
    width: 100%;
    border-radius: 8px;
  }
}

