:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17221a;
  background: #f3f1eb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 0%, #c9ddca 0, transparent 31%),
    radial-gradient(circle at 0 72%, #e4dcc7 0, transparent 29%),
    #f3f1eb;
}

.shell { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 80px; }
.shell.queue-only { width: min(1040px, calc(100% - 40px)); }
.queue-only .card { padding: 22px; }
.queue-only .upload {
  min-height: 340px;
  height: 340px;
  grid-template-columns: 300px minmax(0, 1fr);
  place-items: center start;
  gap: 24px;
  padding: 20px 32px 20px 20px;
  text-align: left;
}
.queue-only .upload img { width: 300px; height: 300px; border-radius: 12px; object-fit: cover; background: #e6e8e1; }
.queue-only #upload-copy { display: none; }
.queue-only .compact-upload-copy { display: block; grid-column: 2; }
.queue-only .compact-upload-copy strong { font-size: 1.08rem; }
.queue-only .compact-upload-copy small { margin-top: 7px; }
.queue-only .collection-panel {
  position: static;
  margin-top: 20px;
  padding: 16px;
}
.queue-only .collection-panel .gallery {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.shell.workspace-active {
  width: min(1280px, calc(100% - 40px));
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-areas:
    "hero hero"
    "upload upload"
    "collection result";
  gap: 20px 24px;
  align-items: start;
}
.hero { margin-bottom: 28px; }
.workspace-active .hero { grid-area: hero; margin-bottom: 0; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.account-actions { display: flex; align-items: center; gap: 8px; }
.credit-balance { padding: 8px 11px; border-radius: 999px; background: #e4f1e5; color: #28613a; font-size: .76rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.credit-balance.is-empty { background: #f6ead8; color: #8a5a19; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .15em; font-size: .72rem; color: #5d7a63; font-weight: 800; }
h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0; line-height: 1; }
h1 > span { font-size: clamp(2.7rem, 7vw, 4.8rem); letter-spacing: -.065em; }
.custom-label {
  display: inline-flex;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.62);
  color: #47614d;
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.redeem-trigger { padding: 9px 13px; border: 1px solid #bfcdbf; background: rgba(255,255,255,.58); color: #315d3b; font-size: .78rem; }
.redeem-trigger:hover:not(:disabled) { background: #fff; color: #234a2e; }
.workspace-switch { padding: 9px 10px; border: 1px solid transparent; background: transparent; color: #617064; font-size: .72rem; }
.workspace-switch:hover:not(:disabled) { background: rgba(255,255,255,.55); color: #315d3b; transform: none; }

.card, .result {
  background: #fffefa;
  border: 1px solid #dcd9d0;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 18px 48px #34402f1c;
}

.card { display: grid; gap: 18px; }
.workspace-active .card {
  grid-area: upload;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 8px 14px;
  padding: 16px;
}
.upload {
  min-height: 340px;
  border: 1.5px dashed #8ca18e;
  border-radius: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(145deg, #f8faf5, #f0f4ec);
  text-align: center;
  transition: border-color .2s, transform .2s;
}
.upload:hover { border-color: #2f6840; transform: translateY(-1px); }
.upload.is-dragging { border-color: #285f38; background: #e7f0e5; box-shadow: inset 0 0 0 3px rgba(40,95,56,.12); transform: translateY(-2px); }
.upload input { display: none; }
.upload strong, .upload small { display: block; }
.upload small { margin-top: 7px; color: #747c72; font-weight: 400; }
.upload-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 13px; border-radius: 50%; background: #2b6039; color: white; font-size: 27px; font-weight: 300; }
.upload img { width: 100%; height: 430px; object-fit: contain; background: #20251f; }
.compact-upload-copy { display: none; }
.workspace-active .upload {
  grid-row: 1 / 3;
  min-height: 118px;
  height: 118px;
  grid-template-columns: 118px minmax(0, 1fr);
  place-items: center start;
  gap: 13px;
  padding-right: 16px;
  text-align: left;
}
.workspace-active .upload img { width: 118px; height: 118px; object-fit: cover; background: #e6e8e1; }
.workspace-active #upload-copy { display: none; }
.workspace-active .compact-upload-copy { display: block; grid-column: 2; }
.workspace-active #preview[hidden] ~ .compact-upload-copy { position: relative; grid-column: 1 / 3; padding-left: 54px; }
.workspace-active #preview[hidden] ~ .compact-upload-copy::before {
  content: "+";
  position: absolute;
  left: 7px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2b6039;
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  transform: translateY(-50%);
}
.workspace-active .compact-upload-copy small { margin-top: 3px; color: #747c72; font-size: .72rem; }
.workspace-active .product-type-control { grid-column: 2; grid-row: 1; }
.workspace-active .fixed-spec { grid-column: 2; grid-row: 2; }
.workspace-active #submit { grid-column: 3; grid-row: 1; padding: 12px 18px; }
.workspace-active #status { grid-column: 3; grid-row: 2; margin: 0; text-align: left; }

.product-type-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  color: #586257;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}
.product-type-control[hidden] { display: none; }
.product-type-control input {
  position: absolute;
  opacity: 0;
}
.product-type-control i {
  position: relative;
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: #cbd3ca;
  transition: background .18s;
}
.product-type-control i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px #1e2b1e36;
  transition: transform .18s;
}
.product-type-control input:checked + i { background: #285f38; }
.product-type-control input:checked + i::after { transform: translateX(15px); }
.product-type-control em {
  min-width: 26px;
  color: #516052;
  font-style: normal;
}

.fixed-spec { display: flex; flex-wrap: wrap; gap: 8px; }
.fixed-spec span { padding: 7px 10px; border-radius: 999px; background: #edf3eb; color: #3f5f46; font-size: .78rem; font-weight: 700; }

button, .secondary-action {
  border: 0;
  border-radius: 11px;
  background: #285f38;
  color: white;
  padding: 15px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  transition: background .2s, transform .2s;
}
button:hover:not(:disabled), .secondary-action:hover { background: #1f4d2c; transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.tool-actions button { position: relative; transition: background .16s, color .16s, opacity .16s, transform .16s; }
.tool-actions button.is-loading { background: #5d765f; color: #fff; opacity: .86; }
.tool-actions button.is-loading::before {
  content: "";
  display: inline-block;
  width: .78em;
  height: .78em;
  margin-right: 7px;
  border: 2px solid rgba(255,255,255,.42);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -.08em;
  animation: export-spin .75s linear infinite;
}
.tool-actions button.is-success { background: #2e6b3e; color: #fff; }
.tool-actions button.is-error { background: #9b4f43; color: #fff; }
@keyframes export-spin { to { transform: rotate(360deg); } }
#status { margin: -4px 2px 0; min-height: 1.4em; color: #657065; font-size: .9rem; text-align: center; }

.result { margin-top: 24px; scroll-margin-top: 20px; }
.workspace-active .result { grid-area: result; margin-top: 0; }
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.result h2 { margin: 0; font-size: 1.35rem; }
.back-to-list {
  padding: 9px 13px;
  border: 1px solid #cbd4ca;
  background: #fff;
  color: #35553c;
  font-size: .8rem;
}
.back-to-list:hover:not(:disabled) { background: #edf2eb; color: #29442f; transform: none; }
.secondary-action { text-decoration: none; padding: 10px 14px; font-size: .88rem; }
#output { display: block; width: 100%; border-radius: 14px; background: #e8e8e3; }
.source-reference { display: flex; align-items: center; gap: 8px; color: #687068; font-size: .72rem; font-weight: 700; }
.source-reference img { width: 38px; height: 38px; border: 1px solid #d7dbd3; border-radius: 8px; object-fit: cover; background: #ecece7; }
.preview-export { padding: 10px 14px; font-size: .8rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 14px; margin-top: 18px; }
.gallery-card { display: grid; gap: 8px; padding: 8px; border: 1px solid #dde1d9; background: #fff; color: #263128; text-align: left; opacity: .76; }
.gallery-card:hover:not(:disabled) { opacity: .9; }
.gallery-card.is-selected { border-color: #285f38; box-shadow: 0 0 0 2px rgba(40,95,56,.13); opacity: 1; }
.gallery-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 9px; }
.gallery-card span { font-size: .78rem; }
.queue-card {
  min-width: 0;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f7f8f4;
}
.queue-card.is-selected { border-color: #285f38; box-shadow: 0 0 0 2px rgba(40,95,56,.1); }
.queue-card .gallery-card { width: 100%; }
.queue-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 5px; }
.queue-card-actions.has-retry { grid-template-columns: 1.35fr 1fr 1fr; }
.queue-card-actions button {
  padding: 6px 4px;
  border: 1px solid #d7ddd4;
  border-radius: 7px;
  background: #fff;
  color: #526056;
  font-size: .66rem;
  font-weight: 700;
}
.queue-card-actions button:hover:not(:disabled) { background: #edf2eb; color: #285f38; transform: none; }
.queue-card-actions .continue-query { background: #e7f1e6; color: #285f38; }
.queue-card-actions .retry-generation { background: #f5ead8; color: #8a5a19; }
.queue-card-actions button:last-child { color: #8a4b42; }
.queue-error {
  display: -webkit-box;
  margin: 2px 3px 0;
  overflow: hidden;
  color: #a04e42;
  font-size: .66rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.history-note { color: #697169; font-size: .75rem; }
.history-gallery,
#gallery {
  max-height: min(66vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 5px;
}
.history-gallery::-webkit-scrollbar,
#gallery::-webkit-scrollbar { width: 8px; }
.history-gallery::-webkit-scrollbar-track,
#gallery::-webkit-scrollbar-track { border-radius: 999px; background: #ecefe8; }
.history-gallery::-webkit-scrollbar-thumb,
#gallery::-webkit-scrollbar-thumb { border: 2px solid #ecefe8; border-radius: 999px; background: #a8b1a5; }
.history-gallery::-webkit-scrollbar-thumb:hover,
#gallery::-webkit-scrollbar-thumb:hover { background: #7d8b7d; }
.history-card-details { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.history-card-details strong { flex: none; font-size: .75rem; white-space: nowrap; }
.history-card-details small { color: #778077; font-size: .68rem; font-weight: 600; }
.collection-panel {
  grid-area: collection;
  position: sticky;
  top: 16px;
  padding: 12px;
  border: 1px solid #dcd9d0;
  border-radius: 18px;
  background: #fffefa;
  box-shadow: 0 14px 38px #34402f14;
}
.collection-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 11px; background: #edf0e9; }
.collection-tab { padding: 9px 10px; border-radius: 8px; background: transparent; color: #626b62; font-size: .8rem; }
.collection-tab:hover:not(:disabled) { background: rgba(255,255,255,.65); color: #315d3b; transform: none; }
.collection-tab.is-active { background: #fff; color: #285f38; box-shadow: 0 2px 8px #34402f17; }
.collection-tab:disabled { opacity: .35; }
.collection-section { margin-top: 13px; }
.collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px; }
.collection-heading h2 { margin: 0; font-size: .95rem; }
.collection-heading > span { color: #707970; font-size: .7rem; font-weight: 700; }
.collection-panel .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.collection-panel .gallery-card { padding: 6px; border-radius: 10px; }
.collection-panel .queue-card { padding: 4px; }
.collection-panel .gallery-card img { border-radius: 7px; }
.collection-panel .gallery-card span { font-size: .7rem; }
.preview-workspace { margin-top: 18px; padding: 10px; border: 1px solid #dde1d9; border-radius: 17px; background: #f1f2ed; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 2px 10px; }
.preview-toolbar > span { color: #687068; font-size: .74rem; font-weight: 700; }
#preview-label { color: #315d3b; }
.preview-workspace #output { width: min(100%, 620px); margin: 0 auto; aspect-ratio: 3 / 4; object-fit: contain; cursor: pointer; user-select: none; touch-action: manipulation; transition: opacity .12s; }
.preview-workspace #output:focus-visible { outline: 3px solid rgba(40,95,56,.28); outline-offset: 3px; }
.preview-workspace #output.is-showing-before { opacity: .96; }
.preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 3px 1px; }

.tool-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 18px; }
.workspace-active #result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "heading heading"
    "preview tools";
  gap: 16px;
  align-items: start;
}
.workspace-active #result > .result-heading { grid-area: heading; }
.workspace-active #result > .preview-workspace { grid-area: preview; margin-top: 0; }
.workspace-active #result > .tool-grid { grid-area: tools; margin-top: 0; }
.tool-panel { display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid #dde1d9; border-radius: 15px; background: #f9faf6; }
.fallback-panel { border: 1px dashed #d7d9d1; border-radius: 15px; background: #fbfaf6; }
.fallback-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; color: #3e4a40; font-size: .82rem; font-weight: 800; cursor: pointer; list-style: none; }
.fallback-panel summary::-webkit-details-marker { display: none; }
.fallback-panel summary::after { content: "+"; order: 2; color: #607263; font-size: 1.1rem; font-weight: 500; }
.fallback-panel[open] summary::after { content: "−"; }
.fallback-panel .api-cost { margin-left: auto; }
.fallback-content { display: grid; gap: 12px; padding: 0 16px 16px; }
.regenerate-button { border: 1px solid #c7d1c6; background: transparent; color: #35553c; }
.regenerate-button:hover:not(:disabled) { background: #edf2eb; color: #29442f; }
.tool-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tool-heading > div { display: flex; align-items: center; gap: 9px; }
.tool-heading h3 { margin: 0; font-size: 1rem; }
.tool-index { color: #66806b; font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.no-cost, .api-cost { flex: none; padding: 5px 8px; border-radius: 999px; font-size: .68rem; font-weight: 800; }
.no-cost { background: #e4f1e5; color: #28613a; }
.api-cost { background: #f6ead8; color: #8a5a19; }
.tool-description { min-height: 3.2em; margin: -7px 0 0; color: #687068; font-size: .8rem; }

.slider-list { display: grid; gap: 0; }
.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 11px 0;
  border-bottom: 1px solid #e5e8e1;
  color: #364239;
  font-size: .82rem;
  font-weight: 750;
}
.slider-row:first-child { padding-top: 2px; }
.slider-row:last-child { padding-bottom: 2px; border-bottom: 0; }
.slider-row output {
  min-width: 32px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9efe7;
  color: #315d3b;
  font-size: .72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.slider-row input { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: #2b6039; cursor: pointer; }
.select-list { display: grid; gap: 9px; }
.select-list label {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #465248;
  font-size: .77rem;
  font-weight: 750;
}
.select-list label > span { line-height: 1.25; }
.select-list select { width: 100%; min-width: 0; padding: 10px 32px 10px 10px; border: 1px solid #cfd5cc; border-radius: 9px; background: white; color: #263128; font: inherit; }
.tool-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: auto; }
.tool-panel button { padding: 11px 12px; font-size: .82rem; }
.ghost-button { border: 1px solid #cbd4ca; background: transparent; color: #3a553f; }
.ghost-button:hover:not(:disabled) { background: #edf2eb; color: #29442f; }
.tool-status {
  min-height: 0;
  margin: -3px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: #f0f3ed;
  color: #697169;
  font-size: .72rem;
  line-height: 1.45;
}

.redeem-dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 20px; background: #fffefa; color: #17221a; box-shadow: 0 28px 80px rgba(24,34,26,.28); }
.redeem-dialog::backdrop, .workspace-dialog::backdrop { background: rgba(26,35,28,.58); backdrop-filter: blur(5px); }
.redeem-form { display: grid; gap: 18px; padding: 24px; }
.redeem-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.redeem-heading h2 { margin: 0; font-size: 1.35rem; }
.dialog-close { width: 34px; height: 34px; padding: 0; border: 1px solid #d5dbd2; border-radius: 50%; background: transparent; color: #4d5a4f; font-size: 1.35rem; line-height: 1; }
.dialog-close:hover:not(:disabled) { background: #edf2eb; color: #29442f; transform: none; }
.redeem-field { display: grid; gap: 7px; color: #3f4940; font-size: .82rem; font-weight: 800; }
.redeem-field input { width: 100%; padding: 13px 14px; border: 1px solid #cbd4ca; border-radius: 10px; background: white; color: #263128; font: inherit; text-transform: uppercase; }
.redeem-field input:focus { outline: 3px solid rgba(40,95,56,.14); border-color: #608168; }
.redeem-status { min-height: 1.4em; margin: -6px 1px 0; color: #5f695f; font-size: .8rem; }

.workspace-dialog { width: min(470px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 22px; background: #fffefa; color: #17221a; box-shadow: 0 32px 90px rgba(24,34,26,.32); }
.workspace-form { display: grid; gap: 20px; padding: 28px; }
.workspace-heading { display: flex; align-items: flex-start; gap: 14px; }
.workspace-heading h2 { margin: 1px 0 7px; font-size: 1.35rem; }
.workspace-heading p { margin: 0; color: #697169; font-size: .82rem; line-height: 1.55; }
.workspace-mark { display: grid; flex: none; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: #285f38; color: #fff; font-size: 1.25rem; font-weight: 900; }

@media (max-width: 980px) {
  .shell, .shell.queue-only { width: min(760px, calc(100% - 32px)); }
  .queue-only .collection-panel .gallery { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); }
  .shell.workspace-active { width: min(760px, calc(100% - 32px)); display: block; }
  .workspace-active .hero { margin-bottom: 20px; }
  .workspace-active .card {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    grid-template-rows: auto auto auto;
  }
  .workspace-active .upload { grid-column: 1 / 3; grid-row: 1; }
  .workspace-active .product-type-control { grid-column: 1; grid-row: 2; }
  .workspace-active .fixed-spec { grid-column: 2; grid-row: 2; }
  .workspace-active #submit { grid-column: 2; grid-row: 3; }
  .workspace-active #status { grid-column: 1; grid-row: 3; }
  .collection-panel { position: static; margin-top: 20px; }
  .collection-panel .gallery { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); }
  .workspace-active #result { display: grid; grid-template-columns: 1fr; grid-template-areas: "heading" "preview" "tools"; margin-top: 20px; }
}

@media (max-width: 560px) {
  .shell { padding: 38px 0 56px; }
  .hero-top { flex-direction: column; align-items: stretch; }
  .account-actions { align-items: flex-end; flex-direction: column-reverse; }
  h1 > span { font-size: 2.55rem; }
  .custom-label { font-size: .78rem; }
  .upload { min-height: 260px; }
  .upload img { height: 340px; }
  .workspace-active .upload img { width: 68px; height: 68px; }
  .result-heading { align-items: flex-start; flex-direction: column; }
  .secondary-action { width: 100%; }
  .preview-toolbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 390px) {
  .tool-actions { grid-template-columns: 1fr; }
  .tool-heading { flex-direction: column; }
}
