:root {
  color-scheme: light;
  --ink: #24302c;
  --muted: #69746e;
  --line: #e0e5df;
  --paper: #f6f7f3;
  --accent: #28634a;
  --tint: #e9f1e9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, .button { cursor: pointer; }
button, .button, select, input, textarea { border: 1px solid var(--line); border-radius: 9px; }
button, .button { background: white; padding: 9px 14px; font-weight: 550; text-decoration: none; text-align: center; transition: background .16s, border-color .16s; }
button:hover, .button:hover { background: #f0f3ed; border-color: #c1cec3; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #6b9a7a; outline-offset: 3px;
}
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.25; letter-spacing: -.8px; font-weight: 650; }
h2 { font-size: 17px; letter-spacing: -.3px; font-weight: 650; }
h3 { font-size: 15px; }
.site-header { border-bottom: 1px solid var(--line); background: #fcfdfa; }
.nav { max-width: 1440px; margin: auto; min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 32px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 34px; height: 34px; object-fit: cover; border-radius: 9px; }
.brand strong { font-size: 16px; letter-spacing: -.3px; }
.brand span { color: var(--muted); margin-left: 9px; padding-left: 13px; border-left: 1px solid var(--line); font-size: 13px; }
.nav-links { display: flex; align-items: center; gap: 22px; font-size: 13px; }
.nav-links a { color: var(--muted); text-decoration: none; }
main { max-width: 1440px; margin: auto; padding: 30px 32px 48px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.intro p { color: var(--muted); margin-top: 8px; }
.intro-note { font-size: 12px; color: var(--muted); white-space: nowrap; }
.workspace { display: grid; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr); gap: 24px; align-items: start; }
.controls { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; min-width: 0; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-weight: 600; }
.eyebrow { text-transform: uppercase; color: var(--muted); font-size: 10px; letter-spacing: 1.4px; margin-bottom: 3px; }
.small, .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.hint { margin-top: 8px; line-height: 1.65; }
summary { cursor: pointer; font-weight: 550; }
.connection summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.connection summary::after { content: "+"; font-size: 18px; font-weight: 400; }
.connection[open] summary::after { content: "−"; }
.connection input[type=password], .connection input[type=text] { width: 100%; margin: 12px 0 8px; }
.connection small { display: block; color: var(--muted); margin-top: 10px; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.text-button { border: 0; background: none; padding: 4px 0; font-size: 12px; color: var(--muted); }
.text-button:hover { background: none; color: var(--ink); }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #f1f4ef; border-radius: 10px; margin: 20px 0; }
.segments label { position: relative; cursor: pointer; text-align: center; }
.segments input { position: absolute; opacity: 0; }
.segments span { display: block; padding: 8px; border-radius: 7px; color: var(--muted); }
.segments input:checked + span { background: white; color: var(--accent); box-shadow: 0 1px 4px #24302c0c; font-weight: 600; }
.segments input:focus-visible + span { outline: 2px solid var(--accent); }
.segments input:disabled + span { opacity: .5; cursor: not-allowed; }
textarea, select, input[type=password], input[type=text], input[type=number] { background: #fff; padding: 10px 12px; width: 100%; }
textarea { display: block; resize: vertical; min-height: 154px; max-height: 420px; line-height: 1.75; }
textarea::placeholder { color: #929a94; }
.prompt-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
#prompt-count { font-variant-numeric: tabular-nums; }
.prompt-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.prompt-examples button { font-size: 11px; padding: 5px 9px; border-color: transparent; background: #f5f6f2; font-weight: 400; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid label, .field { display: grid; gap: 7px; font-size: 12px; font-weight: 550; }
.field-grid + .field-grid { margin-top: 14px; }
.field-grid select { min-width: 0; }
.model-id { display: block; font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); margin-top: 9px; }
.advanced { margin-top: 16px; }
.advanced .field-grid { margin-top: 12px; }
.upload-zone { padding: 15px; border: 1px dashed #b4c4b5; background: #f7f9f5; border-radius: 10px; margin-bottom: 16px; }
.upload-zone.dragover { border-color: var(--accent); background: var(--tint); }
.upload-zone input { max-width: 100%; font-size: 12px; margin-top: 8px; }
.upload-zone input::file-selector-button { border: 0; background: var(--tint); color: var(--accent); padding: 7px 10px; border-radius: 6px; margin-right: 8px; cursor: pointer; }
.reference-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.reference-row img { width: 58px; height: 58px; object-fit: contain; border-radius: 6px; background: white; }
#reference-name { overflow-wrap: anywhere; flex: 1; font-size: 12px; min-width: 0; }
.launch { margin-top: 22px; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: #1e503b; border-color: #1e503b; }
#generate { width: 100%; min-height: 46px; font-size: 14px; }
.launch .hint { text-align: center; font-size: 11px; }
.stage { min-width: 0; }
.stage-header { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin: 0 2px 12px; gap: 12px; }
.status-badge { font-size: 11px; padding: 3px 9px; border-radius: 5px; background: var(--tint); color: var(--accent); white-space: nowrap; }
.canvas { background: #ecf0e9; border: 1px solid #e0e6dc; border-radius: 16px; min-height: 460px; overflow: hidden; }
.empty { min-height: 460px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 35px; }
.empty img { width: clamp(150px, 24vw, 220px); max-height: 225px; object-fit: contain; mix-blend-mode: multiply; margin-bottom: 16px; }
.empty h3 { font-size: 19px; font-weight: 550; margin-bottom: 8px; }
.empty p { font-size: 13px; color: var(--muted); max-width: 320px; }
.busy { border-radius: 11px; border: 1px solid #cedfce; background: #f1f7ef; padding: 16px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.busy p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.spinner { display: inline-block; height: 12px; width: 12px; border: 2px solid #bdd1bd; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }
.message { padding: 13px 16px; border-radius: 9px; background: #f2f4ee; border: 1px solid var(--line); margin-bottom: 14px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.error { background: #fff4ef; border-color: #e8cbbc; color: #8b432b; }
.result { margin: 0; padding: 16px; }
.result + .result { border-top: 1px solid var(--line); }
.image-preview { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.image-preview:hover { background: none; }
.image-preview img { max-width: 100%; max-height: 640px; display: block; object-fit: contain; margin: auto; border-radius: 7px; }
.result figcaption { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.result figcaption .button { font-size: 12px; background: #fff; }
.canvas-note { color: var(--muted); font-size: 12px; margin: 13px 3px 0; }
.history { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.history-head p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.history-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.history-card { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.history-thumb { width: 100%; height: 135px; object-fit: contain; border-radius: 6px; background: #f0f3ed; }
.history-prompt { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; overflow-wrap: anywhere; }
.history-card time { color: var(--muted); font-size: 10px; }
.history-actions { display: flex; gap: 7px; margin-top: auto; flex-wrap: wrap; }
.history-actions button, .history-actions a { font-size: 11px; padding: 5px 8px; }
.history-empty { padding: 22px 0; color: var(--muted); font-size: 13px; }
#legacy-history { margin-top: 20px; }
#legacy-list { margin-top: 12px; }
footer { padding: 0 24px 28px; text-align: center; color: var(--muted); font-size: 11px; }
dialog { max-width: min(96vw, 1400px); max-height: 94dvh; width: fit-content; border: 0; border-radius: 12px; padding: 15px; background: var(--paper); }
dialog::backdrop { background: #17251ce0; }
.dialog-toolbar { display: flex; justify-content: end; gap: 12px; margin-bottom: 12px; }
dialog img { display: block; max-width: 100%; max-height: 78dvh; object-fit: contain; }
@media (min-width: 1600px) { main { padding-top: 40px; } .canvas, .empty { min-height: 530px; } }
@media (max-width: 1050px) { .workspace { grid-template-columns: 350px minmax(0, 1fr); gap: 18px; } .controls { padding: 18px; } .history-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  .nav { padding: 12px 18px; } main { padding: 24px 18px 32px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .intro-note { display: none; } .nav-links { gap: 16px; }
  .canvas, .empty { min-height: 300px; }
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-header { margin-top: 0; } .empty img { width: 140px; }
}
@media (max-width: 430px) {
  .brand span { display: none; } .nav-links { font-size: 12px; gap: 12px; }
  main { padding: 20px 12px 30px; } .controls { padding: 16px; }
  .intro p { font-size: 12px; } .history-head { align-items: start; }
  .history-grid { gap: 10px; } .history-card { padding: 10px; }
  .busy { align-items: start; } .busy button { flex-shrink: 0; padding: 7px 9px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
