:root {
  color-scheme: light;
  --paper: #f3f2ea;
  --ink: #20261e;
  --muted: #5e6657;
  --line: #d7dacd;
  --accent: #d6f27a;
  --accent-dark: #415c31;
  --panel: #fdfcf8;
  --field: #f5f4ed;
  --panel-radius: 17px;
  scroll-behavior: smooth;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.55 system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: inherit; text-underline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 760; }
h3 { font-size: 14px; font-weight: 750; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid #537b34; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.topbar { min-height: 66px; padding: 12px max(4.2vw, 22px); border-bottom: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 850; font-size: 19px; text-decoration: none; white-space: nowrap; }
.mark { display: grid; place-items: center; border-radius: 50%; width: 34px; height: 34px; background: var(--accent); font-size: 23px; line-height: 1; }
.topnav, .toolbar, .section-title, .mini-toolbar, .dialog-actions { display: flex; align-items: center; gap: 12px; }
.topnav { gap: clamp(15px, 3vw, 36px); white-space: nowrap; }
.topnav a, .nav-button { display: inline-flex; color: var(--muted); padding: 5px 1px; text-decoration: none; background: none; border: 0; font-size: 13px; }
.topnav .topnav-current { color: var(--ink); font-weight: 800; }
.topnav a:hover, .nav-button:hover { text-decoration: underline; }
.toolbar { flex-shrink: 0; }
.connection { color: var(--muted); font-size: 12px; }
.connection::before { content: ''; width: 7px; height: 7px; background: #91958b; border-radius: 50%; display: inline-block; margin-right: 6px; }
.connection.online::before { background: #4e7f35; }
.outline, .solid { border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; background: var(--panel); white-space: nowrap; }
.outline:hover:not(:disabled) { background: #eeefe5; border-color: #a9b09d; }
.solid { background: var(--accent); border-color: #53633b; font-weight: 730; }
.solid:hover:not(:disabled), .generate:hover:not(:disabled) { background: #e3fa9a; }
.text-link { color: var(--accent-dark); font-weight: 670; white-space: nowrap; }
main { max-width: 1360px; padding: 36px max(4.2vw, 20px) 64px; margin: auto; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
h1 { font-size: clamp(36px, 5.2vw, 66px); line-height: 1.09; font-weight: 850; letter-spacing: -.07em; }
h1 span { color: #688944; padding-left: 6px; }
.intro p { color: var(--muted); margin-top: 9px; }
.workspace { display: grid; grid-template-columns: minmax(400px, 1.03fr) minmax(325px, .97fr); gap: 18px; align-items: start; }
#compose, .results-column { display: grid; gap: 14px; min-width: 0; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--panel-radius); padding: 17px; box-shadow: 0 2px 8px #18221806; }
.section-title { justify-content: space-between; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 13px; }
.slot { position: relative; min-width: 0; }
.drop { position: relative; display: flex; width: 100%; min-height: clamp(110px, 13vw, 165px); gap: 4px; flex-direction: column; align-items: center; justify-content: center; padding: 9px 4px; border: 1px dashed #a2ac95; border-radius: 9px; background: #eff0e6; overflow: hidden; }
.slot:nth-child(2) .drop { background: #eeece5; }
.slot:nth-child(3) .drop { background: #e9efdc; }
.drop.dragging, .drop:hover, .extra-drop.dragging, .extra-drop:hover { border-color: #486235; background-color: #e6efd7; }
.drop img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.drop.has-image .slot-name { position: absolute; bottom: 6px; left: 6px; padding: 2px 6px; background: var(--panel); border-radius: 4px; }
.drop.has-image :is(.slot-icon, .slot-action) { display: none; }
.slot-icon { font-size: 23px; line-height: 1.1; margin-bottom: 4px; color: #526642; }
.slot-name { font-weight: 750; }
.slot-action, .hint { color: var(--muted); font-size: 12px; }
.hint { margin-top: 8px; }
.hint:empty, .error:empty { display: none; }
.error { margin-top: 8px; color: #8f3127; font-size: 12px; }
.remove { position: absolute; right: 6px; top: 6px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); width: 26px; height: 26px; line-height: 1; }
.slot-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; margin-top: 6px; }
.slot-toolbar button, .depth-toggle { min-width: 0; padding: 5px 6px; font-size: 12px; }
.slot-random { min-width: 27px; }
.depth-toggle { width: 100%; margin-top: 4px; }
.depth-toggle[aria-pressed="true"] { background: var(--accent); border-color: #849854; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 7px; }
.choice { display: block; padding: 2px; min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.choice:hover { border-color: #435d2c; }
.choice[aria-pressed="true"] { border-color: #435d2c; box-shadow: 0 0 0 1px #435d2c; background: var(--accent); }
.choice img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; }
.extra-section { padding-top: 13px; margin-top: 14px; border-top: 1px solid var(--line); }
.extra-section .outline { padding: 4px 9px; font-size: 12px; }
.extra-drop { width: 100%; padding: 6px; margin-top: 7px; color: var(--muted); font-size: 12px; background: var(--field); border: 1px dashed var(--line); border-radius: 8px; }
.extra-list { display: flex; gap: 8px; flex-wrap: wrap; }
.extra-tile { position: relative; width: 64px; aspect-ratio: 1; margin-top: 8px; }
.extra-tile img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 7px; }
.extra-tile .remove { top: 3px; right: 3px; width: 21px; height: 21px; }
.link { border: 0; padding: 0; background: none; color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
textarea, input:not([type=checkbox]), select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; background: var(--field); min-width: 0; }
textarea { display: block; width: 100%; min-height: 96px; margin: 8px 0 0; resize: vertical; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.field-grid label, .controls details > label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
.field-grid :is(input, select), .controls details input { width: 100%; color: var(--ink); }
details { margin-top: 13px; padding-top: 9px; border-top: 1px solid var(--line); }
summary { cursor: pointer; color: var(--accent-dark); font-weight: 650; }
details > label { margin-top: 8px; }
details textarea { min-height: 56px; margin-top: 0; color: var(--ink); }
.style-label { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.style-label select { padding: 4px 8px; color: var(--ink); }
.generate { border: 1px solid #54643d; border-radius: 10px; padding: 12px 15px; font-weight: 820; text-align: left; background: var(--accent); font-size: 15px; }
.generate span { float: right; }
.result { display: flex; flex-direction: column; }
.result-surface { display: grid; flex: 1; place-items: center; min-height: clamp(325px, 41vw, 550px); position: relative; margin-top: 11px; border-radius: 11px; background: radial-gradient(#b4bdac 1px, transparent 1px) 0 0 / 19px 19px, #eef0e7; overflow: hidden; }
#placeholder { position: relative; padding: 16px; max-width: 460px; text-align: center; color: #495142; overflow-wrap: anywhere; }
#placeholder p { padding: 4px 8px; background: #eef0e7; }
.frame { margin: 0 auto 12px; display: grid; place-items: center; width: 54px; height: 54px; border: 1px solid #a5ad9b; border-radius: 13px; background: #eef0e7; font-size: 24px; }
#output { display: block; width: 100%; max-height: 690px; object-fit: contain; }
.history-list { display: grid; margin-top: 9px; }
.history-row { min-width: 0; border-top: 1px solid var(--line); padding: 8px 0; }
.history-row .section-title { gap: 8px; }
.history-open { border: 0; background: none; padding: 2px 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.history-open:hover { color: #355823; text-decoration: underline; }
.job-status { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #edeee7; color: var(--muted); flex-shrink: 0; }
.status-done { background: #e3efd8; color: #385d29; }
.status-failed { background: #f2e6df; color: #833827; }
.job-meta { color: var(--muted); font-size: 12px; }
.history-row .link { font-size: 12px; }
#history-more { margin-top: 6px; }
dialog { width: min(500px, calc(100% - 24px)); max-height: 90dvh; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 15px; padding: 20px; box-shadow: 0 18px 80px #14201938; }
dialog::backdrop { background: #22291b80; }
dialog p { color: var(--muted); }
#dialog form { display: grid; gap: 7px; margin-top: 13px; }
#dialog form + form { border-top: 1px solid var(--line); padding-top: 13px; }
#dialog form p { min-height: 20px; font-size: 12px; }
.inline-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.dialog-actions { justify-content: flex-end; }
.icon-button { width: 31px; height: 31px; font-size: 22px; line-height: 1; border-radius: 50%; border: 1px solid var(--line); background: var(--field); }
.gallery-dialog { width: min(1030px, calc(100% - 24px)); }
.gallery-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.gallery-categories { display: flex; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.gallery-categories button { color: var(--muted); border: 0; border-radius: 5px; background: none; padding: 4px 11px; white-space: nowrap; }
.gallery-categories button[aria-pressed="true"] { background: var(--accent); color: var(--ink); font-weight: 730; }
.search-field { flex: 1 1 180px; }
.search-field input { width: 100%; }
.tag-field select { max-width: 140px; }
.gallery-filters { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.gallery-filters label { display: flex; align-items: center; gap: 4px; }
.gallery-filters input { accent-color: #55713c; }
.gallery-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.asset { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--field); }
.asset-open { background: none; border: 0; display: flex; flex: 1; flex-direction: column; text-align: left; width: 100%; min-width: 0; padding: 0; }
.asset-image { width: 100%; display: grid; place-items: center; background: #e7e9e0; aspect-ratio: 4 / 5; }
.asset-image img { width: 100%; height: 100%; object-fit: cover; max-height: 210px; }
.asset strong, .asset-tag { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 7px; width: 100%; }
.asset strong { padding-top: 5px; font-weight: 680; }
.asset-tag, .asset-unavailable { font-size: 11px; color: var(--muted); }
.asset-use { align-self: flex-start; margin: 3px 7px 6px; font-size: 12px; }
.gallery-pages { display: flex; gap: 9px; justify-content: center; align-items: center; margin-top: 10px; }
#gallery-login { margin-top: 9px; }
.asset-dialog { width: min(610px, calc(100% - 24px)); }
.asset-preview { margin: 10px 0; border: 1px solid var(--line); border-radius: 9px; background: var(--field); min-height: 140px; text-align: center; display: grid; place-items: center; }
.asset-preview img { display: block; max-width: 100%; max-height: 62dvh; object-fit: contain; }
.asset-preview p:empty { display: none; }
.asset-actions { justify-content: flex-end; }
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  main { padding-top: 25px; }
  .workspace { grid-template-columns: 1fr; }
  .intro { align-items: flex-start; flex-direction: column; }
  .result-surface { min-height: 280px; }
  .topbar { flex-wrap: wrap; gap: 7px 12px; }
  .topnav { order: 3; width: 100%; }
  .connection { max-width: 140px; }
  .gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 475px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel { padding: 12px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .toolbar { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { :root { scroll-behavior: auto; } }
