:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2420;
  --muted: #657069;
  --line: #d9dfd8;
  --teal: #147d73;
  --teal-strong: #09665e;
  --amber: #b96d12;
  --red: #b23a34;
  --soft: #eef3ef;
  --focus: rgba(20, 125, 115, 0.22);
}

* {
  box-sizing: border-box;
}

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

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

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72vw;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status-pill.ok {
  background: #dff1e9;
  color: #0b6658;
}

.status-pill.working {
  background: #e8f1ef;
  color: var(--teal-strong);
}

.status-pill.bad {
  background: #f7ded9;
  color: var(--red);
}

.workspace {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(460px, 1.05fr);
  gap: 16px;
  padding: 16px;
}

.workflow-bar {
  margin: 16px 16px 0;
  padding: 0 16px 14px;
}

.workflow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.workflow-status {
  flex: 0 0 auto;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 700;
}

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

.workflow-step {
  display: flex;
  min-height: 58px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
}

.workflow-step strong {
  color: var(--ink);
  font-size: 13px;
}

.workflow-step span {
  font-size: 12px;
}

.workflow-step.active {
  border-color: #a7d2cb;
  background: #eef7f4;
  color: var(--teal-strong);
}

.workflow-step.done {
  border-color: #8fc7b9;
  background: #e4f3ed;
}

.workflow-step.locked {
  background: #f4f5f3;
  color: #8a938d;
}

.step-description {
  padding: 10px 12px;
  border: 1px solid #dbe9e4;
  border-radius: 8px;
  background: #f3f8f6;
  color: var(--teal-strong);
  font-size: 13px;
  line-height: 1.55;
}

.pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.pane-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.input-pane {
  padding-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0 16px;
  margin-top: 14px;
}

.field.grow {
  flex: 1 1 auto;
  min-height: 220px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--focus);
}

textarea {
  min-height: 170px;
  flex: 1 1 auto;
  padding: 12px;
  line-height: 1.62;
  resize: none;
}

.short-textarea {
  min-height: 82px;
  flex: 0 0 auto;
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

input[type="range"] {
  padding: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: var(--panel);
  color: var(--teal-strong);
  box-shadow: 0 1px 4px rgba(20, 30, 20, 0.12);
  font-weight: 700;
}

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

.settings-grid .field:nth-child(3),
.settings-grid .field:nth-child(4) {
  grid-column: span 2;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 0 16px;
  margin-top: 14px;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.actions {
  display: flex;
  gap: 10px;
  padding: 0 16px;
  margin-top: 14px;
}

button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  flex: 1 1 auto;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.primary:hover:not(:disabled) {
  background: var(--teal-strong);
}

.secondary {
  background: #fff7ec;
  color: var(--amber);
  border-color: #efd2a9;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: #b8c3bb;
}

.result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.result-pane textarea {
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #fbfcfb;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
}

.result-pane textarea:focus {
  box-shadow: none;
}

.meta {
  min-height: 38px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.asset-pane {
  margin: 0 16px 16px;
  min-height: 560px;
}

.script-pane {
  margin: 0 16px 16px;
  min-height: 520px;
}

.section-subline {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.script-head-actions,
.script-statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.script-head-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.script-head-actions button {
  flex: 0 1 160px;
}

.script-statusbar {
  justify-content: space-between;
  gap: 16px;
  margin: 14px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.script-pane textarea {
  min-height: 360px;
  flex: 1 1 auto;
  margin: 14px 16px 16px;
  width: auto;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
  resize: vertical;
}

.asset-head-actions,
.asset-controls,
.asset-statusbar,
.asset-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-controls {
  align-items: stretch;
  flex-wrap: wrap;
  padding: 0 16px;
}

.asset-controls .field {
  flex: 1 1 220px;
  min-width: 190px;
  padding: 0;
}

.asset-controls .field:nth-child(3),
.asset-controls .field:nth-child(4) {
  flex-basis: 300px;
}

.asset-statusbar {
  justify-content: space-between;
  gap: 16px;
  margin: 16px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.asset-stage-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 16px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.asset-stage {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.asset-stage span {
  display: inline-grid;
  min-width: 20px;
  min-height: 20px;
  place-items: center;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(20, 125, 115, 0.12);
  font-size: 12px;
}

.asset-stage.active {
  background: var(--panel);
  color: var(--teal-strong);
  box-shadow: 0 1px 4px rgba(20, 30, 20, 0.12);
  font-weight: 700;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  min-height: 220px;
  max-height: 620px;
  overflow: auto;
  padding: 14px 16px;
}

.asset-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.asset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.asset-card-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.asset-card-type {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.asset-card-description {
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.asset-card textarea {
  min-height: 116px;
  flex: 0 0 116px;
  padding: 9px;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.asset-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
}

.asset-card-image.prop {
  aspect-ratio: 1;
}

.asset-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.asset-card-footer span {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.asset-generate-one {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.asset-download {
  margin-right: 8px;
  color: var(--teal-strong);
  text-decoration: none;
}

.asset-download:hover {
  text-decoration: underline;
}

.asset-card-status.done {
  color: var(--teal-strong);
}

.asset-card-status.working {
  color: var(--amber);
  font-weight: 700;
}

.asset-card-status.error {
  color: var(--red);
}

.asset-empty {
  display: grid;
  min-height: 200px;
  place-items: center;
  grid-column: 1 / -1;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.asset-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.asset-actions button {
  flex: 0 1 220px;
}

.storyboard-pane {
  margin: 0 16px 24px;
  min-height: 620px;
}

.storyboard-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.storyboard-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 16px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.storyboard-step {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.storyboard-step.active {
  background: var(--panel);
  color: var(--teal-strong);
  box-shadow: 0 1px 4px rgba(20, 30, 20, 0.12);
  font-weight: 700;
}

.storyboard-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.storyboard-output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 0;
}

.storyboard-output {
  display: flex;
  min-width: 0;
  min-height: 360px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

.storyboard-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.storyboard-output-head h3 {
  margin: 0;
  font-size: 14px;
}

.storyboard-mini-actions {
  display: flex;
  gap: 6px;
}

.mini {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.storyboard-output textarea {
  min-height: 310px;
  flex: 1 1 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: vertical;
  font-size: 13px;
}

.storyboard-output textarea:focus {
  box-shadow: none;
}

.storyboard-validation {
  min-height: 42px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.storyboard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px 16px;
}

.storyboard-actions button {
  flex: 0 1 220px;
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
  }

  .workflow-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .workflow-status {
    padding-bottom: 2px;
  }

  .pane {
    min-height: 640px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid .field:nth-child(3),
  .settings-grid .field:nth-child(4) {
    grid-column: span 1;
  }

  .asset-pane {
    margin-top: 0;
  }

  .script-statusbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .asset-statusbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .storyboard-output-grid {
    grid-template-columns: 1fr;
  }

  .storyboard-statusbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .workflow-steps {
    grid-template-columns: 1fr;
  }

  .workflow-bar {
    margin: 12px 12px 0;
    padding: 0 12px 12px;
  }

  .storyboard-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .storyboard-head-actions,
  .script-head-actions,
  .storyboard-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .storyboard-head-actions button,
  .script-head-actions button,
  .storyboard-actions button {
    width: 100%;
  }
}
