:root {
  --ag-bg: #f5f8f6;
  --ag-surface: #ffffff;
  --ag-surface-soft: #eef5f1;
  --ag-ink: #14231e;
  --ag-muted: #586a63;
  --ag-border: #d9e3de;
  --ag-primary: #087a5b;
  --ag-primary-hover: #056548;
  --ag-accent: #d95f4f;
  --ag-gold: #9a6813;
  --ag-focus: #0b6eae;
  --ag-danger: #b42318;
  --ag-shadow: 0 8px 24px rgba(25, 55, 44, 0.08);
}

* { letter-spacing: 0; }

body {
  color: var(--ag-ink);
  background: var(--ag-bg);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

.app-header {
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--ag-border);
  box-shadow: none;
}

.header-inner { max-width: 1520px; padding-inline: 32px; }
.brand { color: var(--ag-ink); font-weight: 700; }
.brand-mark { background: var(--ag-primary); border-radius: 6px; }
.brand-mark img { filter: brightness(0) invert(1); }

.task-history-button,
.restart-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ag-muted);
}
.task-history-button:hover,
.restart-button:hover { color: var(--ag-ink); background: var(--ag-surface-soft); border-color: var(--ag-border); }

.workspace { max-width: 1520px; padding: 32px; gap: 24px; }
.editor { border-radius: 8px; border-color: var(--ag-border); box-shadow: none; background: var(--ag-surface); }
.page-heading { min-height: auto; padding: 32px 36px 24px; border-bottom: 1px solid var(--ag-border); background: transparent; }
.page-heading h1 { font-size: 30px; line-height: 1.2; color: var(--ag-ink); }
.page-heading p:last-child { color: var(--ag-muted); }
.studio-scene-art { display: none; }
.eyebrow { color: var(--ag-primary); font-size: 12px; font-weight: 700; }

.workflow-steps { margin: 0; padding: 16px 28px; background: #fbfdfc; border-bottom: 1px solid var(--ag-border); }
.workflow-steps li button { min-height: 48px; border-radius: 6px; }
.workflow-steps li.current button { color: var(--ag-primary); background: #e7f3ed; box-shadow: inset 0 -2px 0 var(--ag-primary); }
.workflow-steps li.completed button { color: #315f4e; }

.form-section { margin: 0; padding: 32px 36px; border: 0; border-bottom: 1px solid var(--ag-border); border-radius: 0; box-shadow: none; background: transparent; }
.section-icon { border-radius: 6px; background: var(--ag-surface-soft); color: var(--ag-primary); }
.section-step { color: var(--ag-accent); }

input,
textarea,
select {
  border-color: #bccbc4;
  border-radius: 6px;
  color: var(--ag-ink);
  background: #fff;
}
input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ag-focus) 28%, transparent);
  outline-offset: 2px;
  border-color: var(--ag-focus);
}

.dropzone { border-color: #aabdb4; border-radius: 8px; background: #fbfdfc; }
.dropzone:hover { border-color: var(--ag-primary); background: #f1f8f4; }
.dropzone-icon { color: var(--ag-primary); }

#creativeSettingsSection > .creative-story-heading { margin-top: 32px; }
.story-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.story-option { min-height: 92px; border-radius: 6px; border-color: var(--ag-border); }
.story-option:has(input:checked) { border-color: var(--ag-primary); background: #eaf5ef; box-shadow: inset 0 0 0 1px var(--ag-primary); }
.story-option small { color: var(--ag-muted); }

.segmented-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--ag-surface-soft); border-radius: 6px; }
.segmented-options label { position: relative; min-height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 4px; font-weight: 650; }
.segmented-options input { position: absolute; opacity: 0; }
.segmented-options label:has(input:checked) { color: var(--ag-primary); background: #fff; box-shadow: 0 1px 4px rgba(20, 35, 30, 0.12); }
.segmented-options label:has(input:disabled) { cursor: not-allowed; opacity: 0.48; }

.field-label {
  margin-bottom: 8px;
  color: var(--ag-ink);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
}

.selling-points-list { display: grid; gap: 8px; }
.selling-point-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
.field .selling-point-row input { min-width: 0; }
.selling-point-remove {
  display: inline-flex;
  width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ag-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.selling-point-remove:hover { border-color: #d19a91; background: #fff4f2; }
.selling-point-remove:focus-visible { outline: 3px solid color-mix(in srgb, var(--ag-focus) 18%, transparent); outline-offset: 2px; }
.selling-point-remove img { width: 18px; height: 18px; }
.selling-points-add { width: auto !important; margin-top: 10px; padding: 0 14px; gap: 8px; }
.selling-points-list.has-error input { border-color: var(--ag-danger); }
.task-readonly .selling-point-remove,
.task-readonly .selling-points-add { display: none; }
.choice-field { padding: 0; border: 0; }
.choice-field legend { margin-bottom: 8px; font-weight: 650; }
.creative-control-grid,
.output-spec-grid { align-items: end; }

.primary-button { min-height: 46px; border-radius: 6px; background: var(--ag-primary); box-shadow: none; }
.primary-button:hover:not(:disabled) { background: var(--ag-primary-hover); }
.secondary-button { min-height: 44px; border-radius: 6px; border-color: var(--ag-border); color: var(--ag-ink); background: #fff; }
.secondary-button:hover:not(:disabled) { background: var(--ag-surface-soft); border-color: #aebeb6; }

.preview-panel { border-radius: 8px; border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow); background: var(--ag-surface); }
.status-label.success,
.mode-badge.live { color: #096247; background: #e7f5ee; border-color: #b8decf; }
.mode-badge.unconfigured { color: var(--ag-danger); background: #fff0ee; border-color: #f1c2bc; }
.placement-advice { margin: 16px 0 0; padding: 12px 14px; color: #5e450e; background: #fff7df; border-left: 3px solid var(--ag-gold); }

.product-upload-shell #imageList .product-image-item {
  display: grid;
  height: 198px;
  aspect-ratio: auto;
  grid-template-rows: 160px 38px;
  border-radius: 8px;
}
.product-upload-shell #imageList .product-image-item > img {
  width: 100%;
  height: 160px;
}
.primary-image-control {
  display: inline-flex;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-top: 1px solid var(--ag-border);
  background: #fff;
  color: var(--ag-primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}
.primary-image-control:hover:not(:disabled) { background: var(--ag-surface-soft); }
.primary-image-control:disabled { color: #fff; background: var(--ag-primary); opacity: 1; cursor: default; }
.primary-image-control img { width: 14px; height: 14px; }
.primary-image-control:disabled img { filter: brightness(0) invert(1); }

.video-stage[data-ratio="16:9"],
.video-main-visual .video-stage[data-ratio="16:9"],
.viewing-task .video-main-visual .video-stage[data-ratio="16:9"] { width: min(100%, 720px); aspect-ratio: 16 / 9; }
.video-stage[data-ratio="1:1"],
.video-main-visual .video-stage[data-ratio="1:1"],
.viewing-task .video-main-visual .video-stage[data-ratio="1:1"] { width: min(100%, 520px); aspect-ratio: 1; }
.video-stage[data-ratio="9:16"] { aspect-ratio: 9 / 16; }

.keyframe-grid[data-ratio="16:9"] .keyframe-focus .image-preview-button img { aspect-ratio: 16 / 9; }
.keyframe-grid[data-ratio="1:1"] .keyframe-focus .image-preview-button img { aspect-ratio: 1; }

.settings-page { min-width: 0; }
.settings-shell { width: min(1040px, calc(100% - 64px)); margin: 0 auto; padding: 48px 0 80px; }
.settings-heading { margin-bottom: 28px; }
.settings-heading h1 { margin: 6px 0 10px; font-size: 32px; }
.settings-heading p:last-child { color: var(--ag-muted); }
.settings-form { background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: 8px; box-shadow: var(--ag-shadow); }
.settings-section { padding: 32px; border-bottom: 1px solid var(--ag-border); }
.settings-section-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.settings-section-title > span { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; background: var(--ag-surface-soft); }
.settings-section-title img { width: 20px; height: 20px; }
.settings-section-title h2 { margin: 0 0 4px; font-size: 20px; }
.settings-section-title p { margin: 0; color: var(--ag-muted); }
.settings-form .field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-form .field-wide { grid-column: 1 / -1; }
.settings-form .field select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 40px 12px 13px;
  border: 1px solid #bccbc4;
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.settings-form .field select:hover { border-color: #909c94; }
.settings-form .field select:focus {
  border-color: var(--ag-focus);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ag-focus) 15%, transparent);
}
.model-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.password-control { display: grid; grid-template-columns: 1fr 44px; }
.password-control input { border-radius: 6px 0 0 6px; }
.icon-button { min-width: 44px; min-height: 44px; border: 1px solid #bccbc4; border-left: 0; border-radius: 0 6px 6px 0; background: #fff; cursor: pointer; }
.icon-button img { width: 18px; }
.inline-status { min-height: 24px; margin: 12px 0 0; color: var(--ag-muted); }
.settings-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 24px 32px; }
.settings-actions a { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.form-message[data-tone="success"] { color: #096247; background: #e7f5ee; border-color: #b8decf; }

@media (max-width: 900px) {
  .settings-shell { width: min(100% - 32px, 1040px); padding-top: 32px; }
  .settings-form .field-grid,
  .model-grid { grid-template-columns: 1fr !important; }
  .settings-section { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
