:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --ink: #18201c;
  --muted: #66736c;
  --line: #dfe5dc;
  --accent: #1f7a4d;
  --accent-dark: #135637;
  --amber: #b86b19;
  --rose: #a83d52;
  --blue: #2d5f88;
  --shadow: 0 12px 28px rgba(24, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #17211b;
  color: #f8fbf3;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 750;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f1c84b;
  color: #17211b;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-link {
  min-height: 42px;
  border-radius: 8px;
  color: #cfd9d2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  text-decoration: none;
}

.rail-link.active,
.rail-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.rail-link svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.upload-button svg,
.checklist svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.workspace {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 22px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.35;
}

.topbar-actions,
.asset-controls,
.result-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-panel {
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-state {
  max-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-panel input {
  width: 170px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: #fbfcf9;
  color: var(--ink);
}

.auth-panel input:focus {
  outline: 2px solid rgba(45, 95, 136, 0.18);
  border-color: var(--blue);
}

.auth-panel .icon-button {
  width: 32px;
  min-height: 32px;
}

.operator-app .workspace {
  gap: 18px;
}

.operator-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.operator-summary {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 8px;
  align-content: start;
}

.operator-summary span,
.operator-summary small {
  color: var(--muted);
  font-size: 12px;
}

.operator-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.1;
}

.operator-status-panel {
  display: grid;
  gap: 12px;
}

.operator-action-list,
.operator-failure-list {
  display: grid;
  gap: 8px;
}

.operator-action,
.operator-failure {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.operator-failure {
  display: grid;
  gap: 6px;
}

.operator-failure p,
.operator-failure small {
  margin: 0;
}

.operator-failure p {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.operator-failure small {
  color: var(--muted);
}

.operator-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.operator-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}

.operator-table th,
.operator-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.operator-table th {
  color: var(--muted);
  background: #f5f7f2;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.operator-table tr:last-child td {
  border-bottom: 0;
}

.primary-button,
.secondary-button,
.icon-button,
.upload-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.upload-button {
  padding: 0 14px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.upload-button:hover,
.icon-button:hover {
  border-color: #aebbb2;
}

.secondary-button:disabled,
.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.status-strip div {
  min-height: 68px;
  padding: 14px;
  background: #fffefa;
  display: grid;
  gap: 4px;
}

.status-strip strong {
  font-size: 13px;
}

.status-strip span {
  color: var(--muted);
  font-size: 13px;
}

.product-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 14px;
}

.product-card {
  min-height: 154px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.credit-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.credit-balance {
  min-width: 128px;
  padding: 14px;
  border-radius: 8px;
  background: #eef7f1;
  border: 1px solid rgba(31, 122, 77, 0.18);
  display: grid;
  justify-items: end;
  gap: 2px;
}

.credit-balance strong {
  color: var(--accent-dark);
  font-size: 34px;
  line-height: 1;
}

.credit-balance span,
.subtle-line,
.quote-details,
.provider-details {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.subtle-line,
.quote-details,
.provider-details {
  margin: 0;
}

.provider-details {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.package-list {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.package-pill {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3f6f2;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

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

.policy-card {
  min-height: 176px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  display: grid;
  align-content: start;
  gap: 10px;
}

.policy-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.policy-card-head svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.policy-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.policy-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compact-field {
  max-width: 220px;
}

.section {
  display: grid;
  gap: 14px;
}

.two-column {
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  align-items: start;
}

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

.form-panel,
.checklist-panel {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.row-heading {
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.wide {
  margin-top: 14px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.asset-controls select,
.editable-field input,
.editable-field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcf9;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.asset-controls select:focus,
.editable-field input:focus,
.editable-field textarea:focus {
  outline: 2px solid rgba(31, 122, 77, 0.18);
  border-color: var(--accent);
}

.editable-field textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

.editable-field textarea.tall {
  min-height: 148px;
}

.inline-status {
  color: var(--muted);
  font-size: 13px;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.checklist li {
  display: flex;
  gap: 10px;
  line-height: 1.45;
}

.checklist svg {
  color: var(--accent);
  margin-top: 2px;
}

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

.asset-card,
.result-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.asset-card {
  overflow: hidden;
}

.asset-card.selected {
  border-color: rgba(31, 122, 77, 0.55);
  box-shadow: 0 0 0 2px rgba(31, 122, 77, 0.12), var(--shadow);
}

.asset-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #e9eee8;
}

.asset-card div {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.asset-card strong,
.asset-card span,
.asset-card small {
  overflow-wrap: anywhere;
}

.asset-card span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.asset-card small {
  color: var(--muted);
}

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

.result-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

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

.pill {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff1d8;
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.hook {
  margin: 0;
  color: var(--rose);
  font-weight: 800;
  line-height: 1.45;
}

.result-video-slot {
  min-height: 120px;
}

.result-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  display: block;
  background: #0f1712;
  border-radius: 8px;
}

.video-placeholder {
  min-height: 120px;
  margin: 0;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c3bb;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 14px;
}

.editor-grid {
  display: grid;
  gap: 10px;
}

.editable-field {
  display: grid;
  gap: 6px;
}

.editable-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.storyboard {
  display: grid;
  gap: 8px;
}

.scene {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.scene strong {
  color: var(--ink);
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 8px;
}

.meta-list div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.meta-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meta-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

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

.review-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.review-button svg {
  width: 15px;
  height: 15px;
}

.review-button:hover:not(:disabled) {
  border-color: rgba(31, 122, 77, 0.42);
  color: var(--accent);
}

.review-button:disabled {
  color: var(--muted);
  background: #eef3ee;
  cursor: not-allowed;
}

.empty-state {
  margin: 0;
  min-height: 70px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c3bb;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.compact-empty {
  min-height: 48px;
  padding: 12px;
  font-size: 13px;
}

.debug-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.debug-toolbar .compact-field {
  min-width: 180px;
}

.observability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.ops-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdf9;
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
}

.metric-card span,
.metric-card small,
.ops-panel-head span,
.ops-meta dt {
  color: var(--muted);
}

.metric-card span,
.ops-panel-head span,
.ops-meta dt {
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.metric-card small {
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.guidance-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdf9;
  padding: 14px;
  margin-bottom: 14px;
}

.guidance-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.guidance-head div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.guidance-head span:first-child,
.guidance-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.guidance-head strong {
  color: var(--ink);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.guidance-panel p {
  margin: 0 0 12px;
  color: var(--ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.guidance-meta {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.2fr;
  gap: 10px;
  margin: 0;
}

.guidance-meta div {
  border-top: 1px solid #dde7df;
  padding-top: 8px;
}

.guidance-meta dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.ops-panel {
  min-width: 0;
  padding: 14px;
}

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

.ops-list {
  display: grid;
  gap: 10px;
}

.ops-item {
  border: 1px solid #dde7df;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

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

.ops-item-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.status-pill {
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf1ee;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.status-succeeded {
  background: #dff3e4;
  color: #216337;
}

.status-failed,
.status-blocked {
  background: #fde8df;
  color: #90452c;
}

.status-queued,
.status-running,
.status-retrying {
  background: #e9edf7;
  color: #364b7d;
}

.status-cancelled {
  background: #ece7dc;
  color: #63513d;
}

.ops-meta {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.ops-meta div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
}

.ops-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.debug-box {
  margin: 0;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #111915;
  color: #dce9dd;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .rail-nav {
    display: flex;
    overflow-x: auto;
  }

  .rail-link {
    min-width: max-content;
  }

  .two-column,
  .product-strip,
  .status-strip,
  .policy-grid,
  .operator-band,
  .observability-grid,
  .ops-grid,
  .guidance-meta {
    grid-template-columns: 1fr;
  }

  .credit-card {
    grid-template-columns: 1fr;
  }

  .credit-balance {
    justify-items: start;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .row-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .asset-controls,
  .result-actions,
  .form-actions {
    width: 100%;
  }

  .auth-panel {
    width: 100%;
  }

  .auth-panel input {
    min-width: 0;
    flex: 1 1 160px;
  }

  .primary-button,
  .secondary-button,
  .upload-button {
    flex: 1 1 160px;
  }

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

  .result-grid,
  .asset-grid {
    grid-template-columns: 1fr;
  }
}
