:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #737a82;
  --line: rgba(32,36,42,.10);
  --soft: #f1f0ed;
  --red: #d4113b;
  --green: #0c9a78;
  --orange: #ea741e;
  --shadow: 0 20px 70px rgba(28,31,36,.08);
  font-family: Inter, "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
}
button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: wait;
}

.app {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
#brandSelect {
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.workbench {
  width: min(100vw, 1680px);
  max-width: 100vw;
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(430px, 700px) minmax(340px, 1fr);
  gap: clamp(28px, 4.4vw, 72px);
  padding: clamp(18px, 2.6vw, 36px) clamp(20px, 3.4vw, 58px) clamp(16px, 2.2vw, 30px);
  overflow: hidden;
}
.left-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: center;
  gap: clamp(12px, 1.6vh, 18px);
}
.hero h1 {
  margin: 0;
  font-size: clamp(32px, 3.5vw, 46px);
  line-height: 1.04;
  letter-spacing: 0;
}
.hero p {
  max-width: 720px;
  margin: 8px 0 0;
  color: #50565f;
  font-size: 13.5px;
  line-height: 1.45;
}

.brand-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}
.brand-card {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 38px rgba(31,34,39,.035);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.brand-card:hover {
  border-color: rgba(32,36,42,.20);
  transform: translateY(-1px);
}
.brand-card.active {
  border-color: var(--brand-accent, var(--red));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent, var(--red)) 13%, transparent);
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  font-family: "SimSun", "Songti SC", serif;
  font-size: 18px;
  font-weight: 900;
}
.brand-mark.red { background: var(--red); }
.brand-mark.green { background: var(--green); }
.brand-mark.orange { background: var(--orange); }
.brand-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.1;
}
.brand-card small {
  display: block;
  margin-top: 2px;
  color: #858b93;
  font-size: 12px;
  font-weight: 650;
}

.input-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}
.input-card:has(.upload-preview:not(.hidden)) {
  gap: 9px;
  padding: 14px;
}
.input-card:has(.upload-preview:not(.hidden)) .mode-desc {
  display: none;
}
.input-card:has(.upload-preview:not(.hidden)) #description {
  min-height: 116px;
  height: 116px;
}
.mode-tabs {
  width: fit-content;
  display: inline-flex;
  gap: 3px;
  border-radius: 13px;
  padding: 3px;
  background: var(--soft);
}
.mode-tab {
  height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: transparent;
  color: #676d75;
  font-size: 13px;
  font-weight: 800;
}
.mode-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(29,32,36,.08);
}
.mode-desc {
  margin: -3px 0 0;
  color: #858b93;
  font-size: 12px;
  line-height: 1.35;
}
.upload-preview {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(32,36,42,.08);
  border-radius: 12px;
  padding: 7px;
  background: #fbfaf8;
}
.input-card:has(.upload-preview:not(.hidden)) .upload-preview {
  padding: 6px 7px;
}
.input-card:has(.upload-preview:not(.hidden)) .upload-preview img {
  width: 44px;
  height: 44px;
}
.upload-preview img {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  background: #eceae4;
  border: 1px solid rgba(32,36,42,.08);
}
.upload-preview span {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.upload-preview strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-preview small {
  color: #7c838b;
  font-size: 10px;
}
.prompt-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 9px;
}
.mode-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  align-content: start;
}
.compose-field {
  position: relative;
}
textarea {
  width: 100%;
  resize: none;
  outline: none;
  border: 1.5px solid rgba(32,36,42,.10);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  line-height: 1.45;
}
#description {
  min-height: 132px;
  height: 132px;
  padding-bottom: 46px;
  font-size: 14px;
}
.reference-upload {
  position: absolute;
  left: 10px;
  bottom: 10px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(32,36,42,.10);
  border-radius: 999px;
  padding: 0 10px 0 6px;
  background: #f7f7f4;
  color: #4f5660;
  font-size: 11px;
  font-weight: 750;
}
.reference-upload span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #17191f;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}
.reference-upload small {
  font-size: 11px;
  font-weight: 750;
}
textarea:focus,
select:focus,
input:focus {
  border-color: color-mix(in srgb, var(--brand-accent, var(--red)) 55%, #d8d6d0);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent, var(--red)) 10%, transparent);
}
.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
  padding: 0 2px;
  max-height: 56px;
  overflow: hidden;
}
.examples button {
  height: 27px;
  border: 1px solid rgba(32,36,42,.09);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  color: #69707a;
  font-size: 11px;
  font-weight: 650;
}
.upload-card {
  min-height: 108px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 1.5px dashed rgba(32,36,42,.18);
  border-radius: 16px;
  background: #faf9f6;
  color: #727982;
  text-align: center;
}
.upload-card input { display: none; }
.upload-card span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}
.upload-card small {
  max-width: 320px;
  font-size: 12px;
  line-height: 1.55;
}

.overlay-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 2px;
  border: 1px solid rgba(32,36,42,.08);
  border-radius: 18px;
  padding: 9px;
  background: rgba(255,255,255,.58);
  box-shadow: 0 12px 42px rgba(28,31,36,.045);
}
.tool-group {
  min-width: 0;
  display: grid;
  gap: 3px;
  border: 1px solid rgba(32,36,42,.08);
  border-radius: 13px;
  padding: 6px;
  background: #fbfaf8;
}
.ratio-tool {
  grid-column: 1 / -1;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px;
}
.ratio-tool .tool-fields {
  grid-template-columns: minmax(0, 1fr);
}
.tool-title {
  min-height: 16px;
  display: flex;
  align-items: center;
  font-size: 10px;
  font-weight: 850;
}
.tool-title label {
  display: flex;
  align-items: center;
  gap: 7px;
}
.tool-title.split {
  justify-content: space-between;
  gap: 10px;
}
.tool-title label.hidden {
  display: none;
}
.copy-tool {
  grid-column: 1 / -1;
}
.tool-fields {
  display: grid;
  gap: 6px;
}
.tool-fields.one { grid-template-columns: minmax(0, 1fr); }
.tool-fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool-fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-group:not(.text-tool):has(input[data-toggle]:not(:checked)) .tool-fields {
  display: none;
}
.text-tool:has(input[data-toggle="heading"]:not(:checked)) .heading-field {
  display: none;
}
.text-tool:has(input[data-toggle="subheading"]:not(:checked)) .subheading-field {
  display: none;
}
.text-tool:has(input[data-toggle="heading"]:not(:checked)):has(input[data-toggle="subheading"]:not(:checked)) .tool-fields {
  display: none;
}
select,
.tool-group input:not([type]) {
  width: 100%;
  height: 25px;
  min-width: 0;
  border: 1px solid rgba(32,36,42,.10);
  border-radius: 10px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  outline: none;
}
.input-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
#status {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 430px;
  color: #7b828a;
  font-size: 11px;
  line-height: 1.3;
}
#status.success { color: #14764a; }
#status.error { color: #b13a30; }
#status:empty { display: none; }
#startButton {
  flex: 0 0 auto;
  height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  background: #17191f;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.canvas-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.poster-shell {
  --preview-aspect: 9 / 16;
  --preview-ratio: .5625;
  --preview-max: 520px;
  position: relative;
  width: min(100%, var(--preview-max), calc((100vh - 126px) * var(--preview-ratio)));
  max-height: calc(100vh - 126px);
  display: grid;
  place-items: center;
}
.poster-shell[data-ratio="portrait"] {
  --preview-aspect: 3 / 4;
  --preview-ratio: .75;
  --preview-max: 560px;
}
.poster-shell[data-ratio="square"] {
  --preview-aspect: 1 / 1;
  --preview-ratio: 1;
  --preview-max: 620px;
}
.poster-shell[data-ratio="landscape"] {
  --preview-aspect: 16 / 9;
  --preview-ratio: 1.7778;
  --preview-max: 740px;
}
.poster-shell[data-ratio="wechat"] {
  --preview-aspect: 900 / 383;
  --preview-ratio: 2.3499;
  --preview-max: 760px;
}
.poster-wrap {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 126px);
  aspect-ratio: var(--preview-aspect);
  border-radius: 24px;
}
.poster-wrap.is-loading #poster,
.poster-wrap.is-loading .placeholder {
  filter: saturate(.78) brightness(.96);
}
#poster,
.placeholder {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: #eceae4;
  box-shadow: 0 30px 90px rgba(28,31,36,.14);
}
#poster { object-fit: contain; }
.placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  border: 1px solid rgba(32,36,42,.08);
  color: #8b9097;
}
.placeholder strong {
  color: #30343a;
  font-size: 18px;
}
.preview-progress {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border-radius: 24px;
  background: rgba(246,245,242,.76);
  color: #5d646d;
  text-align: center;
  backdrop-filter: blur(7px);
}
.preview-progress i {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(32,36,42,.14);
  border-top-color: var(--brand-accent, var(--red));
  animation: spin .9s linear infinite;
}
.preview-progress strong {
  color: var(--ink);
  font-size: 17px;
}
.preview-progress span {
  max-width: 260px;
  color: #767d86;
  font-size: 12px;
  line-height: 1.55;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.compliance {
  position: absolute;
  right: 14px;
  top: 14px;
  height: 32px;
  border: 1px solid rgba(18,128,78,.18);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(230,249,239,.94);
  color: #14764a;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 10px 30px rgba(20,118,74,.16);
}
.compliance.fail {
  background: rgba(255,231,228,.95);
  color: #a8271f;
}
.report-panel {
  position: absolute;
  right: 14px;
  top: 56px;
  width: min(360px, calc(100vw - 48px));
  max-height: 360px;
  overflow: auto;
  border: 1px solid rgba(32,36,42,.10);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 22px 70px rgba(32,35,40,.18);
}
.report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#closeReport {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f0efec;
}
.checks { display: grid; gap: 8px; }
.check {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: #f7f7f5;
}
.state {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: #16a05d;
}
.check.fail .state { background: #e5312a; }
.check strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}
.check span {
  display: block;
  color: #6d747b;
  font-size: 12px;
  line-height: 1.4;
}
.download {
  height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 12px;
  padding: 0 16px;
  background: #17191f;
  color: #fff;
  text-decoration: none;
  font-weight: 850;
}
.poster-download {
  position: absolute;
  top: clamp(0px, .45vh, 6px);
  right: clamp(0px, 1vw, 18px);
  z-index: 12;
  box-shadow: 0 14px 34px rgba(23,25,31,.16);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}
.hidden { display: none !important; }
.poster-download.hidden {
  display: inline-flex !important;
  opacity: .42;
  pointer-events: none;
  filter: saturate(.25);
}

body[data-brand="xxf"] { --brand-accent: var(--red); }
body[data-brand="yueye"] { --brand-accent: var(--orange); }

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: minmax(370px, 58vw) minmax(190px, 1fr);
    gap: 18px;
    padding-inline: 16px;
  }
  .left-panel { align-content: center; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 13px; }
  .brand-card { min-height: 66px; padding: 12px; }
  .brand-mark { width: 36px; height: 36px; font-size: 19px; }
  .input-card { padding: 14px; gap: 10px; }
  .overlay-tools { gap: 8px; }
}

@media (max-height: 820px) {
  .workbench { padding-block: 14px 12px; }
  .left-panel { gap: 10px; align-content: center; }
  .hero h1 { font-size: 28px; }
  .hero p { margin-top: 5px; line-height: 1.3; font-size: 11.5px; }
  .brand-cards { gap: 9px; }
  .brand-card { min-height: 50px; padding: 8px 11px; border-radius: 14px; }
  .brand-card strong { font-size: 13.5px; }
  .brand-card small { margin-top: 1px; font-size: 11px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 10px; font-size: 16px; }
  .input-card { gap: 8px; padding: 12px; border-radius: 18px; }
  .input-card:has(.upload-preview:not(.hidden)) { gap: 7px; padding: 11px; }
  .mode-tabs { border-radius: 11px; padding: 2px; }
  .mode-tab { height: 30px; padding-inline: 13px; border-radius: 9px; font-size: 12.5px; }
  .mode-desc { font-size: 11px; line-height: 1.3; }
  .upload-preview { padding: 6px; border-radius: 11px; }
  .upload-preview img { width: 38px; height: 38px; }
  .input-card:has(.upload-preview:not(.hidden)) .upload-preview { padding: 5px 6px; }
  .input-card:has(.upload-preview:not(.hidden)) .upload-preview img { width: 36px; height: 36px; border-radius: 8px; }
  .upload-preview strong { font-size: 11px; }
  .upload-preview small { font-size: 10px; }
  .prompt-card { gap: 8px; }
  .mode-pane { gap: 7px; }
  #description { min-height: 104px; height: 104px; padding: 10px 12px 40px; font-size: 13px; line-height: 1.4; }
  .input-card:has(.upload-preview:not(.hidden)) #description { min-height: 88px; height: 88px; padding-bottom: 36px; }
  .reference-upload { left: 8px; bottom: 8px; height: 25px; gap: 5px; padding: 0 9px 0 5px; font-size: 10px; }
  .reference-upload span { width: 16px; height: 16px; font-size: 13px; }
  .reference-upload small { font-size: 10px; }
  .examples { gap: 5px; }
  .examples button { height: 24px; padding-inline: 8px; font-size: 10.5px; }
  .input-actions { gap: 8px; }
  #status { font-size: 10px; line-height: 1.2; }
  #startButton { height: 36px; padding-inline: 15px; border-radius: 11px; font-size: 12.5px; }
  .upload-card { min-height: 88px; }
  .overlay-tools { gap: 6px; padding: 8px; margin-bottom: 2px; border-radius: 16px; }
  .tool-group { padding: 5px; border-radius: 12px; }
  .ratio-tool { padding: 5px; }
  .tool-title { min-height: 14px; font-size: 9.5px; }
  select,
  .tool-group input:not([type]) { height: 24px; border-radius: 9px; font-size: 10px; }
}
