.img-tool-textarea {
  width: 100%;
  max-width: 640px;
  min-height: 96px;
}

.img-tool-preview {
  margin-top: 20px;
  text-align: center;
}

.img-tool-preview canvas,
.img-tool-preview img {
  max-width: 100%;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.img-tool-source {
  margin: 12px 0 16px;
  text-align: center;
}

.img-tool-source img {
  max-width: min(100%, 420px);
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.img-tool-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.img-tool-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.img-tool-fields input,
.img-tool-fields select,
.img-tool-fields textarea {
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
}

.img-tool-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 500 !important;
  margin-top: 22px;
}

.img-tool-check input {
  min-width: 0;
  width: 16px;
  height: 16px;
}

.img-tool-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.rec-input {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  box-sizing: border-box;
}

.rec-field {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.rec-textarea {
  width: 100%;
  max-width: 640px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  box-sizing: border-box;
  resize: vertical;
}

.error-box {
  display: none;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 14px;
}

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

.img-wm-canvas-wrap {
  margin: 12px 0 16px;
  overflow: auto;
  text-align: center;
}

#wm-canvas {
  max-width: 100%;
  touch-action: none;
  cursor: crosshair;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.img-cloud-gate {
  text-align: center;
  padding: 28px 16px;
}

.img-cloud-gate p {
  margin: 0 0 16px;
  color: #4b5563;
  line-height: 1.5;
}

.img-cloud-quota {
  margin: 0 0 14px;
  font-size: 13px;
  color: #6b7280;
}

.img-redeem-tip-wrap {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.img-redeem-tip {
  padding: 0.75rem 0.875rem;
  border-radius: 0.625rem;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.img-redeem-tip p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #1e40af;
}

.img-redeem-tip .action-row {
  margin-top: 0.625rem;
  justify-content: flex-start;
}

.img-redeem-tip .tb-btn {
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 0.35rem 0.85rem;
}

.img-cloud-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 16px;
}

.img-cloud-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.img-cloud-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-cloud-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.img-cloud-result-text {
  width: 100%;
  max-width: 720px;
  min-height: 180px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
  resize: vertical;
  white-space: pre-wrap;
}

.img-cloud-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.img-cloud-swatch {
  width: 36px;
  height: 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.img-cloud-swatch.is-active {
  border-color: #111827;
  border-width: 2px;
  box-shadow: 0 0 0 1px #fff inset;
}

.img-cloud-warn {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
}

.id-card-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 16px;
}

.id-card-thumb {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 220px);
}

.id-card-thumb img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.id-card-thumb span {
  font-size: 12px;
  color: #6b7280;
}

.id-card-scale {
  width: 100%;
  max-width: 420px;
  margin-top: 4px;
}

#scale-field .field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  max-width: 420px;
  gap: 12px;
}

.id-card-scale-val {
  font-weight: 600;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

.id-card-sheet-wrap {
  margin-top: 16px;
}

#sheet-canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

#sheet-canvas.is-dragging,
#preview-canvas.is-dragging {
  cursor: grabbing;
}

#preview-canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

.id-photo-sheet-wrap {
  margin-top: 16px;
}

.img-cloud-busy {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 14px;
}

.img-cloud-busy[hidden] {
  display: none !important;
}

.img-tool-preview.cutout-preview {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%) 8px -8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%) -8px 0 / 16px 16px,
    #f8fafc;
  text-align: center;
}

.cutout-preview img {
  max-width: 100%;
  max-height: 420px;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.img-cloud-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: img-cloud-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes img-cloud-spin {
  to { transform: rotate(360deg); }
}

.color-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
}

.color-choice:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: inline-block;
}

.checker-bg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background-color: #f3f4f6;
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.06) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.icon-preview-wrap img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  image-rendering: pixelated;
}

.style-choice-list {
  display: grid;
  gap: 10px;
}

.style-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
}

.style-choice:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
}

.style-choice span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-choice b {
  font-size: 14px;
  color: #111827;
}

.style-choice small {
  font-size: 12px;
  color: #6b7280;
}

.focus-wrap {
  margin-top: 12px;
}

.focus-point-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  cursor: crosshair;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.focus-point-container img {
  display: block;
  max-width: 100%;
  max-height: 400px;
  pointer-events: none;
}

.focus-point-marker {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.55);
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
}

.cover-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.cover-results[hidden] {
  display: none !important;
}

.wan-cost-note {
  margin: 0 0 14px;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
}

.wan-audio-hint {
  margin: -8px 0 4px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

.img-tool-fields .img-tool-check {
  margin-top: 8px;
}

.wan-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 8px;
}

.wan-preset {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.wan-preset:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.wan-preset:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wan-tier-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: #b45309;
  line-height: 1.45;
}

.wan-tier-hint[hidden] {
  display: none !important;
}

.wan-prompt {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
}

.wan-duration {
  width: 100%;
  max-width: 8rem;
  margin-top: 4px;
}

.wan-field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.wan-result {
  margin-top: 16px;
}

.wan-result video {
  display: block;
  width: 100%;
  max-height: 520px;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.wan-result[hidden] {
  display: none !important;
}

.cover-result-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.cover-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.cover-result-card img {
  display: block;
  width: 100%;
  min-height: 160px;
  max-height: 420px;
  object-fit: contain;
  background: #f3f4f6;
}

/* Image collage */
.collage-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.collage-presets .rec-chip {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.collage-presets .rec-chip.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.img-tool-fields input[type="color"] {
  min-width: 48px;
  height: 38px;
  padding: 2px;
  cursor: pointer;
}

.img-item.dragging {
  opacity: 0.55;
}

.instruct-compare-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  line-height: 1.45;
}

.instruct-compare-label input {
  margin-top: 3px;
  flex-shrink: 0;
}

.instruct-model-row.is-disabled {
  opacity: 0.45;
}

.instruct-results {
  margin-top: 20px;
}

.instruct-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.instruct-result-card {
  text-align: center;
}

.instruct-result-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.instruct-result-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  margin: 0 auto;
}

.instruct-result-img-wrap {
  position: relative;
  margin: 0 auto 10px;
}

.instruct-result-img-wrap.is-loading {
  min-height: 180px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.instruct-result-img-wrap.is-loading img {
  border: none;
  min-height: 180px;
  opacity: 0;
}

.instruct-result-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  z-index: 1;
  pointer-events: none;
}

.instruct-result-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: img-cloud-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.instruct-result-loading-text {
  margin: 0;
  font-size: 14px;
  color: #475569;
  line-height: 1.4;
  text-align: center;
}

.instruct-result-card .tb-btn {
  width: 100%;
}

.instruct-partial-err {
  margin-top: 12px;
  font-size: 13px;
  color: #b45309;
  line-height: 1.4;
}

.instruct-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.instruct-source-card {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 1;
}

.instruct-source-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 1;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}

.instruct-source-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.instruct-source-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.instruct-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.instruct-preset-row .rec-chip {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.instruct-preset-row .rec-chip.is-active {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.instruct-compare-label.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.instruct-model-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.instruct-model-head .field-label {
  margin-bottom: 0;
}

.instruct-model-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

@media (min-width: 640px) {
  .instruct-model-groups {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 14px;
    align-items: start;
  }
}

.instruct-model-group .tb-radio-row {
  margin-bottom: 0;
  gap: 10px 12px;
}

.instruct-model-group-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.instruct-select-all {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.instruct-cost-hint {
  margin: 4px 0 12px;
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
}

.ai-public-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}
.ai-public-toggle input {
  margin-top: 3px;
  flex-shrink: 0;
}

.instruct-result-group {
  margin-top: 18px;
}

.instruct-result-group:first-child {
  margin-top: 0;
}

.instruct-result-group-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 10px;
}

.img-wechat-tip {
  margin-bottom: 12px;
}

.img-hist {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.img-hist-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
}

#result-meta {
  margin-top: 16px;
}

.instruct-result-save-tip {
  margin: 0 0 8px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
  text-align: left;
}

.img-hist-empty {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
}

.img-hist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.img-hist-actions .tb-btn {
  flex: 1 1 auto;
  min-width: 0;
}

.tb-img-save-preview {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.tb-img-save-preview-panel {
  width: min(100%, 420px);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tb-img-save-preview-tip {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  font-weight: 600;
}

.tb-img-save-preview-panel img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #f1f5f9;
  -webkit-touch-callout: default;
  pointer-events: auto;
}

.tb-img-save-preview-panel .tb-btn {
  width: 100%;
}

