:root {
  color-scheme: light;
  --paper: #f5f2e9;
  --surface: #fbf9f3;
  --canvas: #eeece2;
  --ink: #292d25;
  --muted: #797c6f;
  --line: #dedfd3;
  --olive: #5a6541;
  --olive-dark: #465232;
  --error: #9d3d30;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, textarea, select { font: inherit; }
button, select, summary, a { -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: 0 0 auto; }
svg path { stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.studio {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(32px, 4.5vw, 76px);
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 4.5vw, 64px);
  min-height: 100svh;
}
.controls { min-width: 0; padding-top: 4px; }
fieldset { min-width: 0; border: 0; margin: 0; padding: 0; }
.field { display: grid; gap: 11px; margin-bottom: 25px; }
label { font-size: 14px; font-weight: 600; letter-spacing: .025em; }
textarea, select {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { display: block; resize: vertical; padding: 16px; font-size: 15px; line-height: 1.8; }
#prompt { min-height: 238px; max-height: 600px; }
.prompt-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.prompt-action { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--olive-dark); font-size: 12px; cursor: pointer; }
.prompt-action:not(:disabled):hover { border-color: #b7c0a2; background: #e9ecdf; }
.prompt-action:disabled { opacity: .5; cursor: not-allowed; }
.auto-expand { display: flex; align-items: center; gap: 8px; width: fit-content; min-height: 40px; margin: -8px 0 5px; color: #626859; font-size: 13px; font-weight: 400; letter-spacing: 0; cursor: pointer; }
.auto-expand input { width: 16px; height: 16px; margin: 0; accent-color: var(--olive); }
.auto-expand:has(input:disabled) { opacity: .62; cursor: not-allowed; }
.reference-control { margin-top: 13px; margin-bottom: 17px; }
.reference-control input { width: 100%; min-width: 0; font: inherit; font-size: 13px; color: var(--muted); }
.reference-control input::file-selector-button { margin-right: 9px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--olive-dark); cursor: pointer; }
.reference-preview { display: flex; align-items: center; gap: 12px; }
.reference-preview img { width: 68px; height: 68px; object-fit: contain; border-radius: 8px; background: var(--canvas); }
textarea::placeholder { color: #96988c; }
textarea:hover, select:hover { border-color: #b6bcaa; }
textarea:focus, select:focus { border-color: var(--olive); box-shadow: 0 0 0 3px #5a654114; }
textarea:disabled, select:disabled { cursor: not-allowed; opacity: .62; }
.negative-field { margin: -3px 0 29px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; cursor: pointer; color: #626859; font-size: 13px; line-height: 1.6; }
summary::-webkit-details-marker { display: none; }
summary svg { transition: transform .15s; }
details[open] summary svg { transform: rotate(180deg); }
details textarea { margin-top: 13px; min-height: 108px; font-size: 14px; }
.select-wrap { position: relative; }
.select-wrap > svg { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); pointer-events: none; color: #787e6c; }
select { height: 49px; appearance: none; padding: 0 42px 0 15px; font-size: 14px; cursor: pointer; }
.generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 53px;
  padding: 14px 20px;
  margin-top: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #fffef6;
  background: var(--olive);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .035em;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.generate:not(:disabled):hover { background: var(--olive-dark); }
.generate:not(:disabled):active { transform: translateY(1px); }
.generate:disabled { opacity: .52; cursor: not-allowed; }
.generate[data-working="true"] { opacity: .82; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 4px; }
.error-message { padding: 12px 14px; margin: 15px 0 0; border: 1px solid #e7cfc6; border-radius: 8px; background: #f7ece5; color: var(--error); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.result { position: relative; min-width: 0; }
.canvas {
  min-height: 600px;
  height: calc(100svh - 128px);
  max-height: 1000px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  border: 1px solid #dedfd2;
  border-radius: 16px;
  padding: 28px;
}
.canvas-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; color: #838875; }
.canvas-state p { font-size: 13px; letter-spacing: .08em; line-height: 1.6; margin: 0; }
.empty-icon { color: #b0b6a2; stroke: currentColor; stroke-width: 1.25; }
.empty-icon path { stroke-width: 1.25; }
.canvas-spinner, .button-spinner { display: inline-block; border: 2px solid #5a654124; border-top-color: var(--olive); border-radius: 50%; animation: spin 1s linear infinite; }
.canvas-spinner { width: 32px; height: 32px; margin-bottom: 3px; }
.button-spinner { width: 18px; height: 18px; border-color: #ffffff40; border-top-color: #fffef6; }
.elapsed { margin-top: -13px; font-size: 12px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
#result-image { display: block; width: 100%; height: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: 3px; }
.result[data-state="completed"] .canvas { background: #eae8df; }
.result-actions { display: flex; justify-content: flex-end; margin-top: 15px; }
.download { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px; padding: 10px 16px; border: 1px solid #cfd4c2; border-radius: 8px; background: var(--surface); color: var(--olive-dark); text-decoration: none; font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s; }
.download:hover { background: #e9ecdf; border-color: #b7c0a2; }
.noscript { color: var(--error); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 1600px) { .studio { padding-top: 64px; } }
@media (max-width: 900px) {
  .studio { gap: 30px; padding: 32px; grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); }
  .canvas { min-height: 580px; height: calc(100svh - 64px); padding: 18px; }
}
@media (max-width: 700px) {
  .studio { display: flex; flex-direction: column; gap: 30px; padding: 27px 20px 30px; }
  .controls, .result { width: 100%; }
  .controls { padding-top: 0; }
  #prompt { min-height: 176px; height: 176px; }
  .field { margin-bottom: 22px; }
  .negative-field { margin-bottom: 24px; }
  .canvas { height: auto; min-height: 380px; aspect-ratio: 4 / 5; max-height: none; padding: 16px; border-radius: 12px; }
  #result-image { position: absolute; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); }
  .result-actions { margin-top: 12px; }
  .download { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
}
