:root {
  color-scheme: light;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #26231f;
  background: #f6f3ed;
  --surface: #fdfbf7;
  --soft: #f3efe8;
  --line: #e3dcd1;
  --muted: #625b52;
  --accent: #963c28;
  --accent-hover: #78301f;
  --accent-light: #f5e5db;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p, fieldset { margin: 0; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner, .workspace { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
h1 { font-size: 25px; letter-spacing: -.035em; }
h2, legend, .field-label { font-size: 16px; font-weight: 650; }
.workspace { padding: 32px 0 54px; }
.mode-section { margin-bottom: 23px; }
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(430px, 100%);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ede7dd;
}
.tab, .compare button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.tab { min-height: 41px; padding: 5px 8px; white-space: nowrap; }
.tab[aria-selected="true"], .compare button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px #3424151b;
}
.mode-description {
  margin-top: 13px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.03fr); gap: 18px; align-items: start; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
fieldset { min-inline-size: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 12px; }
.photo-grid { display: flex; gap: 10px; }
.photo-field { flex: 1; min-width: 0; }
.upload {
  position: relative;
  display: grid;
  height: 223px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #c7b9aa;
  border-radius: 12px;
  background: var(--soft);
  cursor: pointer;
}
.upload:hover { border-color: var(--accent); }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.upload-input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-empty { display: grid; justify-items: center; gap: 9px; text-align: center; padding: 6px; font-size: 14px; font-weight: 600; }
.upload-plus { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-light); color: var(--accent); font-size: 23px; font-weight: 400; }
.upload img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.upload-replace { position: absolute; right: 8px; bottom: 8px; padding: 4px 8px; border-radius: 5px; background: #25221fe0; color: #fff; font-size: 12px; }
.file-name { margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
#creative-options, .prompt-field { margin-top: 22px; }
.presets { display: flex; flex-wrap: wrap; gap: 7px; }
.preset {
  min-height: 42px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.preset[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.field-label { display: block; margin-bottom: 8px; }
textarea, #settings input {
  width: 100%;
  border: 1px solid #d5cabb;
  border-radius: 9px;
  padding: 10px 12px;
  background: #fffefa;
  color: inherit;
  line-height: 1.55;
  font-size: 16px;
}
textarea { display: block; resize: vertical; min-height: 91px; }
textarea::placeholder { color: #746c62; opacity: 1; }
.submit-row, .result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.button {
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  font-size: 14px;
}
.button-primary { background: var(--accent); color: white; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-secondary { background: var(--surface); border-color: #d5cabb; color: #363129; }
.button-secondary:hover:not(:disabled) { background: var(--soft); }
.request-status { margin-top: 11px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.field-error, .request-status.is-error { color: var(--accent-hover); overflow-wrap: anywhere; }
.field-error { font-size: 13px; margin-top: 7px; line-height: 1.6; }
.result-header { min-height: 30px; margin-bottom: 12px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.compare { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: var(--soft); }
.compare button { min-height: 34px; padding: 3px 10px; font-size: 13px; }
.result-stage {
  display: grid;
  place-items: center;
  min-height: 376px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--soft);
}
.result-stage img { display: block; width: 100%; height: 100%; max-height: 590px; min-height: 0; object-fit: contain; }
#result-placeholder { text-align: center; padding: 16px; color: var(--muted); font-size: 14px; }
.text-link { color: var(--accent-hover); font-size: 14px; padding: 8px 4px; }
#save-status { flex-basis: 100%; }
dialog { width: min(445px, calc(100% - 30px)); max-height: calc(100% - 30px); padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: inherit; }
dialog::backdrop { background: #26201880; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-title h2 { font-size: 20px; }
#settings label { display: block; margin: 13px 0 5px; font-size: 14px; font-weight: 650; }
.settings-note { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 12px 0; }
#settings-error { margin-bottom: 10px; }

@media (max-width: 730px) {
  .header-inner, .workspace { width: calc(100% - 32px); }
  .header-inner { min-height: 65px; }
  .workspace { padding-top: 20px; padding-bottom: max(26px, env(safe-area-inset-bottom)); }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .mode-section { margin-bottom: 16px; }
  .panel { padding: 16px; }
  .upload { height: 184px; }
  .result-stage { min-height: 235px; }
  .result-stage img { max-height: 480px; }
}
