:root {
  color-scheme: light;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #272922;
  background: #efede7;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button { font: inherit; }

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 28px auto;
  overflow: hidden;
  border: 1px solid #d9d5ca;
  border-radius: 18px;
  background: #f8f6f0;
  box-shadow: 0 24px 70px rgba(54, 49, 39, 0.08);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border-bottom: 1px solid #dedacf;
}

.kicker { margin: 0 0 8px; color: #9d4c35; font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; letter-spacing: -0.05em; }

.model-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #d7d2c7;
  border-radius: 7px;
  color: #6b6d65;
  font-size: 12px;
  font-weight: 700;
}

.section { padding: 28px; }
.section + .section { border-top: 8px solid #e6e1d7; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.section-number {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #2d2f29;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.section-heading h2 { margin-bottom: 2px; font-size: 20px; letter-spacing: -0.03em; }
.section-heading p { margin-bottom: 0; color: #76786f; font-size: 14px; }
.source-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.source-actions span { color: #85877e; font-size: 12px; }
.source-button {
  display: inline-grid;
  height: 34px;
  padding: 0 13px;
  place-items: center;
  border: 1px solid #cbc6bb;
  border-radius: 7px;
  background: #fffdf8;
  color: #353730;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.source-button:hover { border-color: #8f8a7f; }
.product-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }

.product-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d7d2c6;
  border-radius: 10px;
  background: #e4e0d7;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease;
}

.product-card:hover { transform: translateY(-2px); border-color: #aaa497; }
.product-card:active, .mode-button:active, .generate-button:active { transform: translateY(1px); }
.product-card.is-active { border: 3px solid #a94f36; }
.product-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }

.product-card span {
  position: absolute;
  right: 7px;
  bottom: 7px;
  left: 7px;
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(248, 246, 240, 0.92);
  color: #2d2f29;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-bar {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 8px 9px 8px 12px;
  border: 1px solid #d7d2c6;
  border-radius: 10px;
  background: #fffdf8;
}

.action-label { color: #6f7169; font-size: 12px; font-weight: 800; white-space: nowrap; }
.mode-buttons { display: flex; gap: 6px; }
.mode-button, .generate-button { height: 34px; border-radius: 7px; font-size: 13px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.mode-button { padding: 0 12px; border: 1px solid #d1ccc0; background: #fffdf8; color: #353730; }
.mode-button.is-active { border-color: #2d2f29; background: #2d2f29; color: #fff; }
.generate-button { padding: 0 15px; border: 0; background: #a94f36; color: #fff; }
.generate-button:disabled { cursor: wait; opacity: 0.58; }
.output-section { min-height: 520px; }

.result-frame {
  position: relative;
  display: grid;
  width: min(100%, 420px);
  aspect-ratio: 1;
  overflow: hidden;
  place-items: center;
  border: 1px solid #d6d1c5;
  border-radius: 12px;
  background: #eeebe3;
}

.empty-state, .loading-state { display: grid; padding: 28px; place-items: center; color: #74766e; text-align: center; }
.empty-state p, .loading-state p { margin: 10px 0 0; font-size: 13px; }
.empty-mark { width: 56px; height: 56px; border: 1px dashed #aaa59a; border-radius: 10px; }
.loading-state strong { margin-top: 16px; }

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #cbc6ba;
  border-top-color: #a94f36;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

#result-image { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.error-text { width: min(100%, 420px); margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid #a94f36; background: #f4e5df; color: #7d3826; font-size: 13px; }
footer { padding: 16px 28px; border-top: 1px solid #dedacf; color: #83857d; font-size: 11px; }
[hidden] { display: none !important; }

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

@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 620px); margin: 10px auto; }
  .page-header, .section { padding: 20px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .source-actions { align-items: flex-start; flex-wrap: wrap; }
  .source-actions span { width: 100%; }
  .action-bar { align-items: flex-start; flex-wrap: wrap; }
  .mode-buttons { order: 3; width: 100%; flex-wrap: wrap; }
  .output-section { min-height: auto; }
}
