:root {
  color-scheme: light;
  font-family: "Instrument Sans", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #202b29;
  background: #f4f6f3;
  --muted: #596762;
  --line: #dce4df;
  --accent: #174f42;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.top { min-height: 68px; padding: 12px max(24px, calc((100vw - 1240px)/2)); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; white-space: nowrap; text-decoration: none; font-size: 19px; color: var(--accent); }
.brand span { color: #202b29; font-weight: 600; margin-left: 10px; }
nav { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; font-size: 14px; }
a { color: var(--accent); }
main { width: min(1240px, calc(100% - 48px)); margin: 48px auto; }
h1 { margin: 0; font-size: clamp(27px, 4vw, 40px); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 22px; }
p { color: var(--muted); line-height: 1.6; }
small, .muted { color: var(--muted); font-weight: 400; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: clamp(19px, 3vw, 30px); min-width: 0; }
.login { max-width: 430px; margin: 10vh auto; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.workspace { display: grid; grid-template-columns: minmax(310px, 440px) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 8px; min-width: 0; font-size: 14px; font-weight: 600; margin-bottom: 17px; }
label:has(textarea) { margin-top: 18px; }
label:has(input[type=file]) { margin-bottom: 6px; }
.history { margin: 0; max-width: 58%; font-size: 12px; }
input, select, textarea { width: 100%; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf8; color: inherit; font: inherit; font-weight: 400; }
textarea { resize: vertical; }
button, .download { border: 1px solid var(--accent); border-radius: 8px; padding: 10px 16px; background: var(--accent); color: white; cursor: pointer; font: inherit; font-size: 14px; text-decoration: none; }
button.secondary { background: white; color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #3c806b; outline-offset: 2px; }
#generate-button, #login button { width: 100%; }
#spec { font-size: 13px; margin-top: -6px; }
.refs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.refs img { width: 52px; height: 52px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.error { color: #9b312b; overflow-wrap: anywhere; }
.error:empty { display: none; }
.results { min-height: 430px; }
#status { overflow-wrap: anywhere; }
.images { display: grid; gap: 16px; }
.images figure { margin: 0; display: grid; gap: 10px; justify-items: start; }
.images img { display: block; max-width: 100%; max-height: 65vh; object-fit: contain; border-radius: 10px; }
.steps, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 15px 0; }
.steps [aria-current=step] { background: var(--accent); color: white; }
.toolbar label, .heading label { margin-bottom: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-top: 14px; }
.fields label { margin: 0; }
.sku-row { border-bottom: 1px solid var(--line); padding-bottom: 12px; align-items: end; }
.task-head { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; margin: 8px 0; }
.task-head > input { width: 16px; height: 16px; margin-top: 13px; accent-color: var(--accent); }
.task-row, .preflight, .history-record { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0; }
.task-row button { margin: 12px 8px 0 0; }
summary { cursor: pointer; overflow-wrap: anywhere; }
#progress, pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.history-images { display: flex; flex-wrap: wrap; gap: 14px; padding-top: 12px; }
.history-images a { display: grid; gap: 4px; }
.history-images img { max-width: 240px; max-height: 240px; object-fit: contain; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
@media (max-width: 720px) {
  main { width: calc(100% - 28px); margin: 28px auto; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .top { padding: 10px 14px; }
  nav { gap: 8px; }
}

#recognition-progress { width: min(100%, 38rem); height: 0.8rem; accent-color: var(--green, #174c42); }
#recognition-counts { margin-top: 0.45rem; font-variant-numeric: tabular-nums; }
#recognition-log { margin-bottom: 1rem; }
#recognition-log summary { cursor: pointer; color: #174c42; }
.recognition-log-scroll { overflow: auto; max-height: 24rem; }
.recognition-timings { width: 100%; border-collapse: collapse; font-size: 0.88rem; text-align: left; }
.recognition-timings th, .recognition-timings td { padding: 0.55rem 0.65rem; border-bottom: 1px solid #d7e1dc; white-space: nowrap; }
.recognition-timings tbody th { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; font-weight: normal; }
.recognition-timings thead { position: sticky; top: 0; background: #f4f7f5; }

.asset-roles { margin-block: 1.5rem; padding-block: 1rem; border-block: 1px solid #d7e1dc; }
.asset-roles h3 { scroll-margin-top: 1rem; margin-top: 0; }
.asset-role-layout { display: grid; grid-template-columns: minmax(14rem, 1fr) minmax(0, 2fr); gap: 1rem; margin-bottom: 1rem; align-items: start; }
.asset-role-table, .asset-role-details { border: 1px solid #d7e1dc; border-radius: 0.6rem; overflow: hidden; }
.asset-role-table table { width: 100%; border-collapse: collapse; text-align: left; }
.asset-role-table th, .asset-role-table td { padding: .28rem .55rem; white-space: nowrap; }
.asset-role-table thead { background: #f4f7f5; }
.asset-role-table tr[data-selected="true"] { background: #e4efe9; }
.asset-role-table .asset-role-choice { width: 100%; padding: .28rem 0; color: #174c42; background: transparent; text-align: left; border: 0; font-weight: normal; }
.asset-role-details { padding: .85rem; min-width: 0; }
.asset-role-details h4 { margin: 0; }
.asset-role-workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.asset-role-files { list-style: none; padding: 0; margin: 0 0 .5rem; max-height: 11rem; overflow: auto; }
.asset-role-files button { max-width: 100%; overflow-wrap: anywhere; text-align: left; padding: .3rem .45rem; margin: .15rem 0; }
.asset-role-files [aria-pressed="true"] { background: #e4efe9; }
.asset-role-picker { margin-top: .5rem; }
.asset-role-picker summary { cursor: pointer; color: #174c42; }
.asset-role-options { max-height: 12rem; overflow: auto; margin-top: .4rem; }
.asset-role-options label { display: flex; align-items: start; gap: .4rem; overflow-wrap: anywhere; margin: .25rem 0; }
.asset-role-options input[type="checkbox"] { width: auto; margin: .15rem 0 0; }
.asset-role-preview { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.asset-role-preview img { display: block; width: 100%; max-height: 18rem; object-fit: contain; background: #f4f7f5; border-radius: .4rem; }
.asset-role-preview figcaption, .asset-role-preview p { font-size: .86rem; }
@media (max-width: 720px) {
  .asset-role-layout, .asset-role-workspace { grid-template-columns: 1fr; }
}

main:has(#studio:not([hidden])) { width: min(1536px, calc(100% - 40px)); margin: 26px auto; }
#studio { display: grid; grid-template-columns: minmax(210px, 250px) minmax(0, 1fr); gap: 24px; align-items: start; }
.project-sidebar { position: sticky; top: 16px; min-width: 0; max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; padding: 13px; background: #fff; }
.project-sidebar-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.project-sidebar-heading h2 { font-size: 17px; }
.project-sidebar-heading button { padding: .38rem .55rem; font-size: .8rem; }
.project-search { margin: .75rem 0 .4rem; }
.project-list { display: grid; gap: 4px; }
.project-list > button { display: grid; gap: .16rem; width: 100%; min-width: 0; padding: .55rem .62rem; text-align: left; background: transparent; color: var(--accent); border-color: transparent; }
.project-list > button:hover, .project-list > button[aria-current="true"] { background: #eaf2ed; }
.project-list > button strong, .project-list > button small { overflow-wrap: anywhere; }
.project-list > button small { color: var(--muted); }
.project-main { min-width: 0; }
.project-stage { display: inline-block; margin: 0; padding: .3rem .65rem; border-radius: .4rem; color: var(--accent); background: #eaf2ed; font-size: .88rem; }
#workflow-save-state { display: inline; margin-left: .55rem; font-size: .84rem; }
#project-dates { max-height: 20rem; overflow: auto; }
@media (max-width: 850px) {
  main:has(#studio:not([hidden])) { width: calc(100% - 28px); }
  #studio { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .project-sidebar { position: static; max-height: 17rem; }
}

.template-preview { border-block: 1px solid var(--line); padding-block: .9rem; margin-block: 1rem; }
.template-preview h3 { margin: 0 0 .55rem; }
.template-row { border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; margin: .38rem 0; }
.template-row h4, .template-preview details h4 { margin-bottom: .3rem; }
.template-row pre, .template-preview details pre { margin-top: 0; font: inherit; line-height: 1.6; }
.template-references { display: flex; gap: .45rem; flex-wrap: wrap; }
.template-references img { width: 68px; height: 68px; object-fit: contain; border-radius: .35rem; background: #f4f7f5; }
.template-plan-options { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
#template-job-progress { width: min(100%, 34rem); accent-color: var(--accent); }
@media (max-width: 660px) { .template-plan-options { grid-template-columns: 1fr; } }

.template-dialog { width: min(1320px, calc(100% - 40px)); max-width: none; height: min(890px, calc(100dvh - 48px)); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: inherit; background: #fff; box-shadow: 0 24px 80px #102e2440; }
.template-dialog::backdrop { background: #1625208a; }
.template-dialog-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.template-dialog-header, .template-dialog-footer { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.template-dialog-header { border-bottom: 1px solid var(--line); }
.template-dialog-header h2 { font-size: clamp(16px, 2vw, 22px); overflow-wrap: anywhere; }
.template-dialog-main { display: grid; grid-template-columns: minmax(175px, 245px) minmax(0, 1fr); min-height: 0; }
.template-dialog-sidebar { display: flex; flex-direction: column; min-height: 0; gap: .6rem; padding: .8rem; background: #f5f8f5; border-right: 1px solid var(--line); }
.template-row-list { display: grid; align-content: start; gap: .25rem; overflow: auto; flex: 1; min-height: 0; }
.template-row-list button { display: grid; gap: .15rem; padding: .55rem .6rem; text-align: left; border-color: transparent; background: transparent; overflow-wrap: anywhere; }
.template-row-list button:hover, .template-row-list button[aria-pressed=true] { background: #e3eee8; }
.template-row-list button[aria-pressed=true] { border-color: #8db2a1; }
.template-row-tools { display: flex; gap: .3rem; flex-wrap: wrap; }
.template-row-tools button { padding: .35rem .45rem; }
.template-dialog-editor { overflow: auto; padding: 14px 20px; min-height: 0; }
.template-global { border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; margin-bottom: 1rem; }
.template-dialog-editor #template-selected-row > label:first-child { margin-top: 0; }
.template-dialog-editor #template-selected-row .fields { margin-bottom: .75rem; }
.template-dialog-editor input[type=checkbox] { width: 1rem; }
.template-dialog-footer { border-top: 1px solid var(--line); flex-wrap: wrap; }
.template-dialog-footer p { margin: 0; overflow-wrap: anywhere; flex: 1; min-width: 14rem; }
.template-dialog-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
@media (max-width: 740px) {
  .template-dialog { width: calc(100% - 14px); height: calc(100dvh - 18px); }
  .template-dialog-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(88px, 26%) minmax(0, 1fr); }
  .template-dialog-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: .4rem .7rem; }
  .template-dialog-header, .template-dialog-footer, .template-dialog-editor { padding: 9px 12px; }
}

.plan-toolbar label { min-width: 11rem; flex: 1 1 12rem; }
.plan-toolbar button { min-height: 41px; }
#plan-dialog .template-dialog-actions { align-items: end; }
#plan-dialog .template-dialog-actions label { margin: 0; }
#plan-dialog #proposal-rows textarea { min-height: 6rem; }
#plan-dialog #proposal-rows > label:first-child { display: flex; align-items: center; margin-bottom: .4rem; }
#plan-dialog #proposal-rows > label:nth-child(2) { margin-top: 0; }
#plan-dialog #proposal-rows .fields textarea { min-height: 3rem; }
.plan-image-group h4 { margin: .65rem 0 .3rem; }
.plan-image-strip { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .45rem; }
.plan-image-strip figure { width: 112px; flex: 0 0 112px; margin: 0; display: grid; gap: .28rem; }
.plan-image-strip img { width: 100%; height: 85px; object-fit: contain; background: #f4f7f5; border-radius: .35rem; }
.plan-image-strip figcaption { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-image-strip button { justify-self: start; padding: .25rem .55rem; }
#plan-prompt-preview { border: 1px solid var(--line); border-radius: .5rem; padding: .7rem; background: #f5f8f5; }

.history-images figure { margin: 0; display: grid; gap: .4rem; }
.output-download-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.output-download-links a, .toolbar .generated-zip { display: inline-flex; align-items: center; }
.task-downloads:empty { display: none; }
.task-downloads { margin-top: .8rem; }
