:root {
  color-scheme: light;
  font-family: "Inter", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #202238;
  background: #f5f7fa;
  font-synthesis: none;
  --text: #202238;
  --muted: #656b80;
  --line: #e5e7ef;
  --violet: #573ed7;
  --violet-soft: #eeebff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, .style-option:has(:focus-visible) {
  outline: 3px solid #7860f0;
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
svg { display: block; width: 1.15em; height: 1.15em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.layout { display: grid; min-height: 100vh; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { background: white; border-right: 1px solid var(--line); padding: 30px 17px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 29px; border-bottom: 1px solid #eff0f5; }
.brand-icon { display: grid; flex: 0 0 43px; height: 43px; place-items: center; border-radius: 13px; background: var(--violet); color: white; font-size: 23px; box-shadow: 0 4px 9px #573ed72d; }
.brand strong { display: block; font-size: 1.04rem; letter-spacing: .02em; }
.brand div span { display: block; margin-top: 3px; color: var(--muted); font-size: .8rem; }
.nav-label { color: var(--muted); font-size: .8rem; margin: 27px 10px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; background: var(--violet-soft); color: #4b30bd; border-radius: 10px; padding: 12px 10px; font-size: .91rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.nav-admin { margin-top: 4px; background: transparent; color: var(--muted); }
.nav-admin:hover { background: var(--violet-soft); color: var(--violet); }

main { padding: 38px clamp(22px, 3.5vw, 54px) 44px; max-width: 1560px; width: 100%; margin-inline: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.3rem); letter-spacing: -.045em; line-height: 1.25; }
.page-header p { color: var(--muted); margin-top: 9px; font-size: 1rem; line-height: 1.5; }
.header-actions, .user-summary { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.user-summary { font-size: .85rem; }
.user-summary strong { overflow-wrap: anywhere; }
#account-points { color: var(--violet); white-space: nowrap; }
.account-dialog { color: inherit; width: min(380px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.account-dialog::backdrop { background: #2022385c; }
.account-dialog form { display: grid; gap: 8px; margin-top: 14px; }
.account-dialog label { font-weight: 700; font-size: .9rem; }
.account-dialog input { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.account-dialog .feedback, .account-dialog .error { margin: 0; }
.workspace { display: grid; grid-template-columns: minmax(285px, .8fr) minmax(340px, 1.25fr); align-items: start; gap: 19px; }
.controls { display: grid; gap: 16px; min-width: 0; }
.panel { background: white; border: 1px solid var(--line); border-radius: 17px; padding: 19px; box-shadow: 0 3px 8px #252d4a05; min-width: 0; }
.section-heading { display: flex; gap: 11px; align-items: center; min-width: 0; }
.section-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
.violet { background: #efebff; color: #573ed7; }
.mint { background: #e4f7ee; color: #147258; }
.amber { background: #fdf0d8; color: #895415; }
h2 { font-size: 1.05rem; line-height: 1.35; }
.section-heading p { color: var(--muted); font-size: .86rem; line-height: 1.4; margin-top: 4px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 8px 13px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: .88rem; line-height: 1.2; }
.secondary { background: white; border-color: #dfe1ed; color: #3c3b57; }
.secondary:hover:not(:disabled) { background: #f7f5ff; border-color: #c9bef8; color: var(--violet); }
.secondary:disabled { opacity: .55; }
.primary { background: var(--violet); color: white; width: 100%; min-height: 48px; font-size: .99rem; }
.primary:hover:not(:disabled) { background: #4830be; }
.primary:disabled { color: #4f456d; background: #e3ddf8; }
.generate-area { padding-top: 1px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.small-gap { gap: 6px; }
.link-text, .text-button { color: var(--violet); }
.text-button { padding: 4px 5px; border: 0; background: transparent; font-size: .86rem; font-weight: 700; border-radius: 6px; white-space: nowrap; }
.text-button:hover:not(:disabled) { background: var(--violet-soft); }
.muted, .text-button:disabled { color: var(--muted); }
.icon-button { background: white; display: grid; place-items: center; color: #464761; border: 1px solid var(--line); border-radius: 8px; width: 33px; height: 33px; padding: 0; }
.icon-button:hover:not(:disabled) { background: #f5f1ff; color: var(--violet); }
.icon-button:disabled { opacity: .35; }

.drop { display: grid; justify-items: center; align-content: center; gap: 8px; color: var(--text); width: 100%; margin-top: 16px; padding: 18px 10px; min-height: 138px; background: #f9f8ff; border: 1px dashed #c9bef4; border-radius: 12px; }
.drop:hover:not(:disabled), .drop-over .drop:not(:disabled) { background: #efebff; border-color: #7359e7; }
.drop-over { border-color: #7359e7; }
.drop-icon { color: #5b42d2; background: #ece8ff; padding: 8px; border-radius: 10px; font-size: 19px; margin-bottom: 2px; }
.drop strong { font-size: .88rem; font-weight: 650; }
.drop small, .source-info small { color: var(--muted); font-size: .8rem; }
.source-info { display: flex; align-items: center; gap: 9px; margin-top: 16px; padding: 9px; background: #f8f8fd; border: 1px solid #edebf7; border-radius: 10px; }
.source-info .section-icon { width: 33px; height: 33px; flex-basis: 33px; font-size: 15px; }
.source-name { flex: 1; overflow: hidden; }
.source-name strong { font-size: .88rem; display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.source-name small { display: block; margin-top: 2px; }
.page-picker { margin-top: 16px; }
.page-picker label, .picker-footer { font-size: .86rem; }
.page-picker label { font-weight: 700; }
.range-row { display: flex; gap: 7px; margin: 7px 0 9px; }
.range-row input { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid #dfe1ed; border-radius: 8px; font-size: .9rem; color: var(--text); }
.range-row .button { padding-inline: 9px; white-space: nowrap; }
.page-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(33px, 1fr)); gap: 5px; }
.page-chip { min-height: 32px; border: 1px solid var(--line); border-radius: 7px; background: #fafaff; color: #444962; padding: 0 2px; font-size: .84rem; }
.page-chip[aria-pressed="true"] { background: var(--violet-soft); color: var(--violet); border-color: #b9aaf4; font-weight: 700; }
.page-chip:disabled { opacity: .8; }
.picker-footer { color: var(--muted); margin-top: 8px; min-height: 33px; }
#pager-label { white-space: nowrap; }
.feedback, .error { margin-top: 10px; font-size: .86rem; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.error { color: #a32852; }

.styles { margin: 15px 0 0; border: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-option { border: 1px solid #e5e6f0; border-radius: 11px; padding: 5px 5px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.style-option:has(:checked) { border-color: #8c73ef; box-shadow: 0 0 0 1px #8c73ef; background: #fbf9ff; }
.style-option:has(:disabled) { cursor: default; }
.style-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.style-preview { display: grid; place-items: center; border-radius: 7px; min-height: 57px; overflow: hidden; position: relative; }
.default-preview { background: #e9e2ff; }
.mini-scene { position: relative; width: 63px; height: 39px; }
.mini-scene i, .mini-scene b, .mini-scene em { position: absolute; display: block; }
.mini-scene i { left: 8px; top: 1px; width: 31px; height: 36px; background: #fbfff8; border: 3px solid #ab9aff; border-radius: 5px; transform: rotate(-12deg); }
.mini-scene i::after { content: ""; display: block; margin: 7px 4px; height: 3px; border-radius: 2px; background: #7e70b7; box-shadow: 0 6px #d0cae5, 0 12px #d0cae5; }
.mini-scene b { border-radius: 48%; width: 25px; height: 20px; right: 5px; bottom: 1px; background: #86dbb8; transform: rotate(8deg); }
.mini-scene b::before { content: ""; display: block; position: absolute; border-radius: 50%; top: 8px; left: 6px; width: 3px; height: 3px; background: #234d42; box-shadow: 10px 0 #234d42; }
.mini-scene em { right: 4px; top: 2px; width: 10px; height: 10px; background: #ffc46a; transform: rotate(24deg); clip-path: polygon(50% 0, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0 50%, 35% 35%); }
.reference-preview { background: #ecf4f3; color: #37816f; font-size: 21px; }
.reference-preview img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.preset-library { border: 0; padding: 0; min-width: 0; margin: 14px 0 0; }
.preset-library legend { padding: 0; font-size: .9rem; font-weight: 700; }
.preset-library .styles { margin-top: 8px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.library-cover { height: 100px; background: #f4f2fa; }
.library-cover img { width: 100%; height: 100%; object-fit: contain; }
.preset-library .style-label { overflow-wrap: anywhere; }
.style-label { padding-inline: 4px; text-align: center; font-size: .88rem; font-weight: 700; }
.reference-controls { margin-top: 12px; }
.reference-controls .button { max-width: 100%; }
.visual-brief { display: grid; gap: 7px; margin-top: 15px; }
.visual-brief label { font-size: .9rem; font-weight: 700; }
.visual-brief label span, .visual-brief p { color: var(--muted); font-size: .8rem; font-weight: 400; line-height: 1.45; }
.visual-brief textarea { width: 100%; min-height: 82px; resize: vertical; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; color: inherit; background: #fff; font-size: .9rem; line-height: 1.5; }
.visual-brief textarea:focus-visible { outline: 2px solid #8c74ee; outline-offset: 2px; }
.visual-brief textarea:disabled { opacity: .7; }
#reference-button-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.output { min-height: 473px; }
.output-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sample { margin-top: 16px; text-align: center; padding-bottom: 6px; }
.sample-stage, .preview-stage {
  background-color: #f6f4fc;
  background-image: radial-gradient(#dcd6ee 1px, transparent 1px);
  background-size: 15px 15px;
  border: 1px solid #eee9f8;
  border-radius: 13px;
}
.sample-stage { min-height: 275px; display: flex; align-items: center; justify-content: center; padding: 23px 12px; gap: clamp(7px, 2vw, 25px); overflow: hidden; }
.sample-stage img { width: 34%; max-width: 160px; height: auto; object-fit: contain; filter: drop-shadow(0 9px 10px #382a6832); }
#sample-source { transform: rotate(-10deg) translateY(5px); border-radius: 4px; }
#sample-card { transform: rotate(9deg) translateY(-3px); border-radius: 6px; }
.sample-sparkles { color: #7658e5; font-size: clamp(17px, 2.5vw, 29px); transform: rotate(-7deg); }
.sample h3 { margin-top: 17px; font-size: 1.08rem; }
.sample p { color: var(--muted); margin: 6px auto 0; font-size: .89rem; line-height: 1.45; }
.preview-tabs { display: flex; gap: 7px; margin: 16px 0 12px; }
.preview-tabs button { border: 0; background: #f4f4f9; color: #55576d; border-radius: 8px; padding: 8px 11px; font-size: .88rem; }
.preview-tabs button[aria-pressed="true"] { color: #4b30bd; font-weight: 700; background: var(--violet-soft); }
.source-pager { justify-content: center; font-size: .87rem; color: var(--muted); margin: 0 0 9px; }
.source-pager input { width: 52px; min-height: 33px; text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 0 4px; color: var(--text); }
.preview-stage { min-height: 200px; display: grid; justify-items: center; align-items: center; padding: 14px; }
.preview-stage img { width: auto; max-width: 100%; max-height: 540px; box-shadow: 0 4px 12px #2420481f; cursor: zoom-in; }
.preview-stage p { color: var(--muted); font-size: .88rem; }
.progress-box { padding: 10px 12px; background: #f6f3ff; border-radius: 10px; margin-bottom: 12px; color: #503ab2; font-size: .87rem; line-height: 1.4; }
progress { display: block; width: 100%; height: 8px; border: 0; border-radius: 10px; margin-top: 8px; background: #e8e0fc; overflow: hidden; accent-color: var(--violet); }
progress::-webkit-progress-bar { background: #e8e0fc; }
progress::-webkit-progress-value { background: var(--violet); border-radius: 10px; transition: width .14s; }
.empty-results { color: var(--muted); text-align: center; padding: 38px 12px; font-size: .9rem; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 155px), 1fr)); gap: 10px; }
.result-card { border: 1px solid var(--line); border-radius: 11px; min-width: 0; overflow: hidden; }
.result-thumb { display: grid; place-items: center; border: 0; border-radius: 0; padding: 10px; width: 100%; height: 202px; background: #f5f2fc; cursor: zoom-in; }
.result-thumb img { display: block; width: 100%; height: 182px; object-fit: contain; }
.result-footer { padding: 7px; font-size: .85rem; gap: 3px; flex-wrap: wrap; }
.result-footer .button { min-height: 32px; padding-inline: 7px; font-size: .81rem; }
#enlarged { padding: 11px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); max-width: 93vw; max-height: 93vh; }
#enlarged::backdrop { background: #242039b8; }
#enlarged img { display: block; margin: 9px auto 0; max-width: 100%; max-height: 80vh; object-fit: contain; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 189px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  main { padding-inline: 22px; }
  .workspace { gap: 13px; }
  .panel { padding: 14px; }
}
@media (max-width: 870px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .output { min-height: 0; }
}
@media (max-width: 580px) {
  .layout { display: block; }
  .sidebar { display: flex; justify-content: space-between; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 9px 13px; gap: 6px; }
  .brand { border: 0; padding: 0; gap: 6px; }
  .brand-icon { flex-basis: 33px; height: 33px; font-size: 17px; border-radius: 8px; }
  .brand strong { font-size: .9rem; }
  .brand div span { font-size: .7rem; }
  .nav-label { display: none; }
  .nav-item { padding: 7px; gap: 3px; font-size: .77rem; }
  main { padding: 19px 13px 26px; }
  .page-header { align-items: start; gap: 8px; }
  .page-header p { font-size: .88rem; }
  .page-header .button { white-space: nowrap; padding-inline: 7px; }
  .sample-stage { min-height: 214px; }
}
