:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --text: #1f2524;
  --muted: #6e7773;
  --line: #dde5df;
  --green: #2f755f;
  --green-soft: #e6f2ed;
  --warm: #b87732;
  --warm-soft: #f7eee4;
  --red-soft: #f6e9e7;
  --red: #a94d49;
  --shadow: 0 16px 34px rgba(36, 45, 40, .08);
}

[hidden] {
  display: none !important;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 390px;
  grid-template-areas:
    "topbar topbar"
    "sources sources"
    "workspace output";
  gap: 12px;
  padding: 14px;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.source-grid {
  grid-area: sources;
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(220px, .85fr) minmax(360px, 1.4fr);
  gap: 12px;
  align-items: start;
}

.source-controls {
  display: grid;
  gap: 10px;
}

.output {
  grid-area: output;
  background: #fbfcfa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.workspace {
  grid-area: workspace;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-area {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.auth-area .trial-pill {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #c7e3d7;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 700;
}

.auth-area button {
  min-height: 34px;
  padding: 7px 11px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
}

.auth-user strong {
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.2; }
h2 { font-size: 15px; }
p { color: var(--muted); font-size: 12px; line-height: 1.45; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 13px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.warm {
  color: var(--warm);
  background: var(--warm-soft);
}

.upload-zone {
  position: relative;
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px dashed #b8c3bc;
  border-radius: 8px;
  padding: 11px;
  background: #f8faf7;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone strong { font-size: 13px; }
.upload-zone span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

.dual-upload,
.dual-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dual-preview .image-preview {
  height: 220px;
}

.media-preview {
  width: 100%;
  height: 220px;
  margin-top: 10px;
  display: block;
  object-fit: cover;
  background: #e8ece8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-preview {
  width: 100%;
  height: 220px;
  margin-top: 10px;
  display: block;
  object-fit: cover;
  background: #e8ece8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.style-helper {
  display: grid;
  align-content: end;
  gap: 5px;
}

.style-helper button {
  width: 100%;
  min-height: 35px;
  padding: 8px 10px;
}

.style-helper p {
  min-height: 32px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

select, textarea, .key-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 8px 10px;
}

textarea {
  min-height: 72px;
  line-height: 1.55;
  resize: vertical;
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-controls .toolbar {
  min-height: 86px;
  align-items: center;
}

.source-controls .toolbar .actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.source-controls .api-notice {
  min-height: 72px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 34px;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

button:hover { filter: brightness(.98); }

button:disabled {
  cursor: wait;
  opacity: .78;
}

button.is-loading::after {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .8s linear infinite;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.analysis-card {
  min-height: 118px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.analysis-card h3 {
  display: inline-flex;
  margin-bottom: 7px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
}

.analysis-card p {
  white-space: pre-line;
}

.analysis-card:nth-child(2) h3,
.analysis-card:nth-child(3) h3 { background: var(--warm-soft); color: var(--warm); }
.analysis-card:nth-child(4) h3 { background: var(--red-soft); color: var(--red); }

.shot-list {
  display: grid;
  gap: 8px;
}

.shot {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.shot-time {
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}

.detail-shot {
  grid-template-columns: 38px 1fr;
}

.detail-shot strong {
  color: var(--text);
}

.prompt-panel {
  position: sticky;
  top: 12px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7ece8;
  flex: 1;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.prompt-output {
  min-height: 360px;
}

.detail-image-panel[hidden] {
  display: none;
}

.detail-canvas {
  width: 100%;
  display: block;
  aspect-ratio: 9 / 14;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .65);
}

.detail-image-panel .actions {
  margin-top: 10px;
}

.quality-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.quick-optimize,
.template-library,
.history-library {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.quick-optimize .panel-title,
.template-library .panel-title,
.history-library .panel-title {
  margin-bottom: 8px;
}

.history-library {
  background: #fbfcfa;
}

.compact-actions {
  gap: 7px;
}

.compact-actions button {
  min-height: 31px;
  padding: 6px 9px;
  font-size: 12px;
  background: #f8faf7;
}

.quality-box .panel-title {
  margin-bottom: 8px;
}

.quality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quality-item {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 12px;
  line-height: 1.2;
}

.quality-item.is-pass {
  background: var(--green-soft);
  color: var(--green);
}

.quality-item.is-miss {
  background: var(--red-soft);
  color: var(--red);
}

.quality-advice {
  display: grid;
  gap: 6px;
  margin-top: 9px;
}

.quality-advice p {
  padding: 8px 9px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.quality-advice strong {
  color: var(--text);
}

.template-list {
  display: grid;
  gap: 7px;
}

.template-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfa;
}

.template-item strong {
  font-size: 12px;
}

.template-item p {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.template-item .actions {
  gap: 6px;
}

.template-item button {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 12px;
}

.empty-mini {
  padding: 10px;
  border: 1px dashed #c9d5ce;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  line-height: 1.45;
}

.note {
  min-height: 18px;
  margin-top: 8px;
  color: var(--green);
}

.api-notice {
  border-color: #ead0ae;
  background: #fff9f0;
}

.api-notice h2 {
  color: var(--warm);
  margin-bottom: 6px;
}

.key-panel {
  border-color: #cbd9d2;
}

.key-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 8px;
}

.key-panel .panel-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.key-panel .actions {
  align-self: end;
}

.key-panel .note {
  grid-column: 1 / -1;
  margin-top: 0;
}

.output .panel {
  padding: 12px;
}

.output textarea {
  min-height: 76px;
}

.output .prompt-output {
  min-height: 340px;
}

.error-text {
  color: var(--red);
}

.is-updated {
  animation: pulse 1s ease;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 117, 95, .35); }
  100% { box-shadow: 0 0 0 12px rgba(47, 117, 95, 0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "sources"
      "workspace"
      "output";
  }
  .source-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .output {
    border-left: 0;
  }
  .prompt-panel { position: static; }
  .key-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .topbar, .source-grid, .workspace, .output { margin: 14px; }
  .source-grid { display: grid; grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .analysis-grid, .settings-grid { grid-template-columns: 1fr; }
  .key-panel { grid-template-columns: 1fr; }
  .media-preview, .image-preview { height: auto; aspect-ratio: 4 / 3; }
}

.simple-shell {
  grid-template-columns: minmax(720px, 1fr) 420px;
  grid-template-areas:
    "topbar topbar"
    "mode mode"
    "quick quick"
    "workspace output";
  max-width: 1680px;
  margin: 0 auto;
}

.mode-panel { grid-area: mode; }

.focus-hero {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 22px 26px;
  background:
    linear-gradient(135deg, rgba(47, 117, 95, .12), rgba(255, 255, 255, .86) 46%),
    #fff;
}

.focus-hero .eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}

.focus-hero h2 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.18;
}

.focus-hero p {
  max-width: 720px;
  font-size: 13px;
}

.workflow-steps {
  min-width: 390px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.workflow-steps span {
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 8px 10px;
  border: 1px solid #cbd8d0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  color: #25443a;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
  padding: 16px;
  text-align: left;
  border-color: #cfdad4;
  background: #fff;
}

.mode-card strong {
  font-size: 18px;
}

.mode-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.mode-card.is-active {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}

.simple-grid {
  grid-area: quick;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(520px, 1.18fr);
  gap: 12px;
  align-items: start;
}

.upload-panel,
.simple-settings-panel {
  min-height: 100%;
}

.main-product-preview {
  height: 300px;
  object-fit: contain;
  background: #eef2ee;
}

.video-upload-block .media-preview {
  height: 300px;
  object-fit: cover;
  background: #eef2ee;
}

.upload-media-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

body[data-mode="视频提示词"] .upload-media-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upload-media-card {
  min-width: 0;
}

.hidden-advanced-input {
  display: none;
}

.simple-settings-panel label {
  margin-bottom: 10px;
}

.simple-controls {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.simple-controls h3 {
  margin-top: 4px;
  font-size: 13px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button {
  min-height: 36px;
  background: #f8faf7;
}

.segmented button.is-active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

.helper-text {
  padding: 9px 11px;
  border-radius: 8px;
  background: #f8faf7;
}

.compact-select-label {
  max-width: 150px;
  margin-bottom: 0 !important;
}

.video-meta-grid {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(220px, 320px);
  gap: 12px;
  align-items: end;
}

.voice-select-label {
  max-width: 320px;
  margin-bottom: 0 !important;
}

.video-meta-grid select {
  width: 100%;
}

.primary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.big-action {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 16px;
  min-width: 190px;
}

.simple-results {
  grid-area: workspace;
}

.result-panel {
  min-height: 460px;
}

.result-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.result-card h3 {
  font-size: 14px;
  margin-bottom: 8px;
}

.result-card canvas {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
}

.result-card .actions {
  margin-top: 9px;
  gap: 6px;
}

.result-card .actions button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #c9d5ce;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfa;
  text-align: center;
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 31, 27, .42);
}

.auth-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 31, 27, .25);
  padding: 18px;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  padding: 0;
  font-size: 20px;
  background: #f8faf7;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form h2 {
  font-size: 18px;
  padding-right: 36px;
}

.privacy-note {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--green-soft);
  color: #42675a;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.auth-form input,
.auth-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfdad3;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.tag-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.tag-field-head {
  display: grid;
  gap: 3px;
}

.tag-field-head span {
  color: var(--muted);
  font-size: 12px;
}

.tag-field-head p {
  margin: 0;
  color: #6b7c72;
  font-size: 12px;
}

.tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-options button {
  min-height: 32px;
  border: 1px solid #cfdad3;
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.tag-options button.is-selected {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(47, 117, 95, 0.16);
}

.agree-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px;
}

.agree-row input {
  width: auto;
  min-height: auto;
}

.auth-submit {
  min-height: 40px;
}

.form-error {
  min-height: 18px;
  color: var(--red);
}

.switch-auth,
.login-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.switch-auth button,
.login-links button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 700;
}

.profile-list {
  display: grid;
  gap: 8px;
}

.profile-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.profile-row span {
  color: var(--muted);
}

.inner-panel {
  margin-top: 12px;
  box-shadow: none;
}

.advanced-settings summary {
  cursor: pointer;
  font-weight: 800;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.advanced-grid .actions,
.advanced-grid .note,
.advanced-grid .api-notice {
  grid-column: 1 / -1;
}

.compact-output textarea {
  min-height: 64px;
}

.compact-output .prompt-output {
  min-height: 360px;
}

.compact-output {
  gap: 12px;
}

.compact-output .panel {
  box-shadow: 0 14px 28px rgba(36, 45, 40, .07);
}

@media (max-width: 1180px) {
  .simple-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "mode"
      "quick"
      "workspace"
      "output";
  }
  .simple-grid,
  body[data-mode="视频提示词"] .upload-media-grid {
    grid-template-columns: 1fr;
  }
  .focus-hero {
    align-items: stretch;
    flex-direction: column;
  }
  .workflow-steps {
    min-width: 0;
  }
  .advanced-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .auth-area {
    justify-content: flex-start;
  }
  .auth-grid {
    grid-template-columns: 1fr;
  }
}
