/* 厂家一键发圈页（仅本页使用） */
:root {
  --mm-primary: #2b6de8;
  --mm-primary-dark: #1f56bd;
  --mm-danger: #d9363e;
  --mm-text: #1f2329;
  --mm-text-sub: #646a73;
  --mm-border: #e5e6eb;
  --mm-bg: #f5f6f8;
  --mm-card: #ffffff;
  --mm-radius: 12px;
  --mm-ai-bg: #fff9e8;
  --mm-ai-border: #d8a53a;
  --mm-ai-text: #79510b;
  --mm-watermark-bg: #fff;
  --mm-watermark-border: #cfd3d8;
  --mm-blocked-bg: #aeb4bb;
  --mm-blocked-text: #f8f9fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body.mm-page {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.5;
  background: var(--mm-bg); color: var(--mm-text);
  max-width: 100%; min-width: 0; overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }

.mm-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--mm-card); border-bottom: 1px solid #e4e9ed;
}
.mm-header-inner {
  max-width: 720px; min-height: 46px; margin: 0 auto; padding: 6px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1.6fr) minmax(0, 0.9fr) auto;
  align-items: center; gap: 6px; min-width: 0;
}
.mm-header-inner.has-subcategory {
  grid-template-columns: 32px minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.7fr) auto;
}
.mm-btn-back {
  width: 32px; height: 32px; min-width: 32px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
}
.mm-btn-back img { width: 22px; height: 22px; display: block; }
.mm-header-select {
  width: 100%; max-width: 100%; min-width: 0; min-height: 32px; padding: 4px 6px;
  border: 1px solid var(--mm-border); border-radius: 8px; background: #fff; color: var(--mm-text);
}
.mm-header-media { max-width: 72px; }
.mm-header-order { width: auto; max-width: 64px; }

.mm-state-card {
  max-width: 480px; margin: 80px auto; padding: 40px 24px;
  background: var(--mm-card); border-radius: var(--mm-radius); text-align: center;
}
.mm-state-icon { font-size: 40px; margin-bottom: 12px; }
.mm-state-text { color: var(--mm-text-sub); margin-bottom: 20px; line-height: 1.6; }

.mm-container { max-width: 720px; margin: 0 auto; padding: 6px; min-width: 0; }

.mm-section {
  background: var(--mm-card); border: 1px solid var(--mm-border);
  border-radius: var(--mm-radius); padding: 10px; margin-bottom: 8px; min-width: 0;
}
.mm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.mm-section-title { font-size: 14px; font-weight: 600; }
.mm-count { font-size: 12px; color: var(--mm-text-sub); white-space: nowrap; }

.mm-field { display: block; font-size: 12px; font-weight: 500; color: var(--mm-text-sub); margin-bottom: 6px; }
.mm-select, .mm-textarea {
  width: 100%; max-width: 100%; min-width: 0;
  border: 1px solid var(--mm-border); border-radius: 8px; padding: 8px; background: #fff;
}
.mm-textarea { resize: vertical; min-height: 120px; }
.mm-select:focus, .mm-textarea:focus { outline: none; border-color: var(--mm-primary); }
.mm-char-count { font-size: 11px; color: var(--mm-text-sub); text-align: right; margin-top: 4px; }

/* 文案区域头部（标题 + AI生成按钮） */
.mm-copy-head {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 6px;
}
.mm-copy-head .mm-field { margin-bottom: 0; flex: 1; min-width: 0; }
.mm-copy-head .mm-watermark-option { flex-shrink: 0; }

.mm-btn-ai {
  flex-shrink: 0; height: 30px; padding: 0 12px;
  border: 1px solid var(--mm-ai-border); border-radius: 6px;
  background: var(--mm-ai-bg); color: var(--mm-ai-text);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  line-height: 28px;
}
.mm-btn-ai:disabled { opacity: 0.55; cursor: default; }
.mm-btn-ai:not(:disabled):hover { background: #fef3c7; }

/* 产品网格 */
.mm-product-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; min-width: 0;
}
.mm-product-card {
  position: relative; border: 2px solid var(--mm-border); border-radius: 10px;
  overflow: hidden; background: #fafafa; min-width: 0;
}
.mm-product-card.is-selected { border-color: var(--mm-primary); }
.mm-product-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block; max-width: 100%;
}
.mm-product-label {
  display: block; min-height: 24px; padding: 4px 6px; font-size: 11px; line-height: 1.3;
  color: var(--mm-text); background: #fafafa;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mm-product-check {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  accent-color: var(--mm-primary);
}

/* 操作区 */
.mm-section-actions { padding: 10px; }
.mm-action-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mm-action-row + .mm-action-row { margin-top: 8px; }
.mm-action-row-secondary {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}

/* 型号水印开关 */
.mm-watermark-option {
  flex-shrink: 0; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 10px;
  border: 1px solid var(--mm-watermark-border); border-radius: 7px;
  background: var(--mm-watermark-bg); font-size: 13px; white-space: nowrap; cursor: pointer;
}
.mm-watermark-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--mm-primary); }

/* 按钮通用 */
.mm-btn-primary {
  background: var(--mm-primary); color: #fff; border: none; border-radius: 8px;
  padding: 10px; font-size: 14px; min-width: 0;
}
.mm-btn-primary:hover { background: var(--mm-primary-dark); }
.mm-btn-primary:disabled { background: #a9c1ef; cursor: not-allowed; }

.mm-btn-secondary {
  background: var(--mm-card); color: var(--mm-text); border: 1px solid var(--mm-border);
  border-radius: 8px; padding: 10px; font-size: 14px; min-width: 0;
}
.mm-btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.mm-btn-save-copy {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; font-size: 13px; white-space: nowrap;
}

/* 自动发圈按钮（BLOCKED 状态） */
.mm-btn-auto {
  flex-shrink: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 7px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--mm-blocked-bg); color: var(--mm-blocked-text); cursor: default;
}
.mm-btn-auto:not(.mm-btn-auto-blocked) {
  background: #1677c8; color: #fff; cursor: pointer;
}

.mm-actions .mm-btn-primary { grid-column: 1 / -1; }

.mm-loading, .mm-empty, .mm-error { font-size: 13px; text-align: center; padding: 12px 0; }
.mm-empty { color: var(--mm-text-sub); }
.mm-error { color: var(--mm-danger); }
.mm-feedback { font-size: 12px; min-height: 18px; padding: 0 4px; line-height: 1.5; }
.mm-feedback.success { color: #16a34a; }
.mm-feedback.error { color: var(--mm-danger); }
.mm-feedback.info { color: var(--mm-text-sub); }

.mm-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; background: rgba(31,35,41,0.92);
  color: #fff; border-radius: 8px; font-size: 14px; z-index: 200; text-align: center;
}

@media (max-width: 390px) {
  .mm-header-inner { gap: 4px; }
  .mm-header-select { font-size: 12px; padding: 4px; }
  .mm-header-media { max-width: 60px; }
  .mm-header-order { max-width: 56px; }
  .mm-product-grid { gap: 6px; }
}

@media (max-width: 320px) {
  .mm-header-inner {
    grid-template-columns: 28px minmax(0, 1fr) minmax(0, 0.85fr) auto;
  }
  .mm-header-inner.has-subcategory {
    grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.7fr) auto;
  }
  .mm-btn-back { width: 28px; height: 28px; min-width: 28px; }
  .mm-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
