* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #0f172a;
}

.subtitle {
  margin-top: 6px;
  color: #64748b;
  font-size: 1rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 0.95rem;
}

.tab.active {
  color: #0f172a;
  border-bottom-color: #3b82f6;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.form-group {
  margin-bottom: 18px;
}

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

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
  color: #334155;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.radio-card {
  position: relative;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  opacity: 0;
}

.radio-card span {
  display: block;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  text-align: center;
  font-weight: 500;
  background: white;
  transition: all 0.15s;
  font-size: 0.95rem;
}

.radio-card input:checked + span {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

.generate-btn {
  width: 100%;
  padding: 14px 20px;
  background: #0f172a;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.generate-btn:hover:not(:disabled) {
  background: #1e293b;
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result-section {
  margin-top: 32px;
  padding: 24px;
  background: white;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
}

.result-section.hidden {
  display: none;
}

.image-container {
  text-align: center;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.image-container img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.loading {
  color: #64748b;
  font-weight: 500;
}

.error {
  color: #dc2626;
  background: #fef2f2;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.prompt-details {
  margin-top: 20px;
}

.prompt-details summary {
  cursor: pointer;
  font-weight: 600;
  color: #475569;
}

.prompt-output {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.image-preview {
  margin-top: 10px;
  max-width: 180px;
}

.image-preview img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.image-preview.hidden {
  display: none;
}

footer {
  margin-top: 50px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  header h1 {
    font-size: 1.7rem;
  }
  .container {
    padding: 24px 16px;
  }
}

/* ========== v2 新增：参考图 / 文案推荐 / 结果元信息 / 运行日志 ========== */

.hidden { display: none !important; }

.tip {
  color: #64748b;
  font-size: 0.82rem;
  margin-top: 6px;
}

/* 参考图拖放区 */
.ref-drop {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  background: #fbfdff;
  transition: border-color .15s, background .15s;
}
.ref-drop:hover,
.ref-drop.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}
.ref-drop input[type="file"] {
  display: none;
}
.ref-hint {
  color: #64748b;
  font-size: 0.88rem;
}
.ref-preview {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ref-preview img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  object-fit: contain;
  background: #fff;
}
.ref-badge {
  font-size: 0.78rem;
  color: #475569;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px 10px;
}
.ref-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  color: #475569;
  margin: 0;
}
.inline-check input { margin: 0; }

.ghost-btn {
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ghost-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.ghost-btn:disabled { opacity: .55; cursor: not-allowed; }

/* 文案推荐区 */
.suggestion-section {
  margin-top: 28px;
  padding: 22px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}
.meta-chip {
  display: inline-block;
  font-size: 0.76rem;
  color: #475569;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px 10px;
}
.observed-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.86rem;
  color: #334155;
}
.obs-line { margin-bottom: 4px; }
.obs-line:last-child { margin-bottom: 0; }
.obs-line b {
  color: #0f172a;
  margin-right: 8px;
  font-weight: 600;
}
.suggestions-list {
  display: grid;
  gap: 14px;
}
.suggestion-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  background: #fcfdff;
  transition: border-color .15s, box-shadow .15s;
}
.suggestion-card.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
.sug-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.sug-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.95rem;
}
.apply-btn {
  padding: 6px 14px;
  border-radius: 9px;
  border: none;
  background: #0f172a;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.apply-btn:hover { background: #1e293b; }
.sug-why {
  color: #64748b;
  font-size: 0.82rem;
  margin: 6px 0 10px;
}
.sug-rows { display: grid; gap: 4px; }
.sug-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.86rem;
}
.sug-row:hover { background: #eff6ff; }
.sug-k { color: #64748b; font-weight: 600; }
.sug-v { color: #0f172a; word-break: break-word; }
.sug-foot {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
}
.suggestion-error {
  color: #dc2626;
  background: #fef2f2;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.9rem;
}

/* 结果元信息 */
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.warn-line {
  width: 100%;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}
.loading-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* 运行日志面板 */
.log-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100vw - 36px));
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .28);
  font-size: 0.78rem;
  z-index: 50;
  overflow: hidden;
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #111c33;
}
.log-toggle {
  background: none;
  border: none;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.log-count {
  background: #1d4ed8;
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
}
.log-tools { display: flex; gap: 6px; }
.log-tools .ghost-btn {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
  padding: 3px 10px;
  font-size: 0.72rem;
}
.log-tools .ghost-btn:hover { background: #334155; }
.log-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 8px 12px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.log-row {
  display: grid;
  grid-template-columns: 132px 150px 1fr;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  line-height: 1.5;
}
.log-ts { color: #64748b; }
.log-act { color: #93c5fd; }
.log-det { color: #cbd5e1; word-break: break-word; }
.log-row.log-ok .log-det { color: #86efac; }
.log-row.log-err .log-det { color: #fca5a5; }
.log-row.log-warn .log-det { color: #fcd34d; }
.log-row.log-srv .log-det { color: #94a3b8; }
.log-row.log-srv .log-act { color: #a5b4fc; }
.log-empty { color: #64748b; padding: 6px 0; }

@media (max-width: 640px) {
  .log-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }
  .log-row { grid-template-columns: 1fr; gap: 0; }
  .log-ts { font-size: 0.7rem; }
  .sug-row { grid-template-columns: 64px 1fr; }
}

/* ========== 图片尺寸选择 ========== */
.size-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ratio-preview {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
}
.ratio-preview span {
  display: block;
  background: linear-gradient(135deg, #dbeafe, #93c5fd);
  border: 1px solid #60a5fa;
  border-radius: 3px;
  transition: width .2s, height .2s;
}
.size-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.size-custom input[type="number"] {
  width: 96px;
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  font-size: 0.92rem;
  font-family: inherit;
}
.size-x { color: #94a3b8; font-weight: 600; }
.size-unit { color: #64748b; font-size: 0.82rem; }

@media (max-width: 640px) {
  .size-row { flex-wrap: wrap; }
  .size-row select { flex: 1 1 100%; }
}

/* ========== 页头导航（产品图 / 标签制作） ========== */
.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
}
.head-row > div { flex: 1; }
.page-nav .nav-link {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.page-nav .nav-link:hover { background: #f1f5f9; border-color: #94a3b8; }

@media (max-width: 640px) {
  .head-row { flex-direction: column; }
  header { text-align: center; }
}
