:root {
  --bg: #edf0f3;
  --chrome: #172026;
  --chrome-2: #222c33;
  --surface: #ffffff;
  --surface-soft: #f6f7f9;
  --surface-tint: #eef7f5;
  --ink: #1a2229;
  --muted: #66737f;
  --line: #d6dde3;
  --line-strong: #b8c2cc;
  --blue: #285cc4;
  --teal: #08796f;
  --amber: #a56b00;
  --red: #b42318;
  --green: #16834a;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(24, 34, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 360px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: var(--blue);
  background: #f5f8ff;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: #214fb0;
}

button.ghost {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #f5f7fa;
}

button.ghost.danger {
  border-color: rgba(180, 35, 24, 0.42);
  color: #ffd7d3;
}

button.ghost.danger:hover {
  border-color: rgba(255, 215, 211, 0.78);
  background: rgba(180, 35, 24, 0.18);
}

button.compact {
  min-height: 32px;
}

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

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 92, 196, 0.13);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.2;
  font-weight: 760;
}

h2 {
  font-size: 15px;
  font-weight: 720;
}

code {
  display: block;
  overflow: hidden;
  color: #384553;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 360px;
  grid-template-rows: 58px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 250px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--chrome);
  color: #fff;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7b84d;
  color: #172026;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong,
.brand-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  color: #b8c3cc;
  font-size: 12px;
  margin-top: 1px;
}

.top-metrics {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.status-pill,
.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #dbe4ec;
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill {
  border-color: rgba(8, 121, 111, 0.68);
  background: rgba(8, 121, 111, 0.18);
}

.metric-pill b {
  color: #fff;
}

.sidebar {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 10px;
  background: #f8fafb;
  border-right: 1px solid var(--line);
}

.nav-item {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px;
  color: var(--muted);
  text-align: left;
}

.nav-item span,
.nav-item b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item span {
  font-size: 12px;
}

.nav-item b {
  font-size: 15px;
}

.nav-item.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.workspace {
  grid-row: 2;
  min-width: 0;
  padding: 16px;
  overflow: auto;
}

.inspector {
  grid-row: 2;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px 16px 16px 0;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-head {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.crumbs {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.work-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.mimicry-grid,
.copy-grid {
  grid-template-columns: minmax(250px, 0.72fr) minmax(360px, 1.18fr) minmax(330px, 0.95fr);
}

.full-grid {
  grid-template-columns: minmax(280px, 0.9fr) minmax(240px, 0.68fr) minmax(360px, 1.1fr);
}

.data-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
}

.span-left,
.span-main,
.span-mid,
.span-right,
.span-wide {
  min-width: 0;
}

.span-wide {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.flat {
  box-shadow: none;
}

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

.panel-head.tight {
  margin-top: 12px;
}

.panel-kicker,
.counter-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2f6;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.counter-badge {
  background: var(--surface-tint);
  color: var(--teal);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
}

.field span,
.check-row span {
  color: #3b4956;
  font-size: 13px;
}

.file-field input {
  padding: 7px;
  background: var(--surface-soft);
}

.full-avatar-field,
.full-image-prompt-field {
  display: none !important;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(100px, 150px);
  gap: 10px;
}

.compact-field {
  min-width: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 12px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.media-preview {
  min-height: 238px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f2f5f7;
  color: var(--muted);
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 260px;
  object-fit: contain;
  background: #111820;
}

.result-box {
  min-height: 104px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 11px;
  border: 1px solid #d7dee5;
  border-radius: 6px;
  background: #f8fafb;
  color: #26313a;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-box.short {
  min-height: 82px;
  max-height: 170px;
}

.result-box.tall {
  min-height: 232px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.pipeline span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #2f3d4a;
  font-size: 13px;
}

.segment-list,
.slot-list,
.asset-list,
.task-list {
  display: grid;
  gap: 10px;
}

.segment-list:empty,
.slot-list:empty,
.asset-list:empty,
.task-list:empty {
  min-height: 76px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.segment-list:empty::before {
  content: "暂无分段";
}

.slot-list:empty::before {
  content: "暂无替换位";
}

.asset-list:empty::before {
  content: "暂无资产";
}

.task-list:empty::before {
  content: "暂无任务";
}

.segment-row,
.slot-row,
.asset-row,
.task-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segment-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 104px 112px;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.segment-row textarea {
  min-height: 56px;
  margin: 0;
}

.segment-row audio {
  grid-column: 2 / -1;
  width: 100%;
  height: 34px;
}

.project-fusion-box {
  display: grid;
  gap: 8px;
}

.project-fusion-box .button-row {
  justify-content: flex-start;
}

.segment-scene {
  grid-column: 2 / -1;
  min-width: 0;
  display: grid;
  gap: 8px;
}

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

.reference-mode-field {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.reference-mode-field select {
  width: auto;
  min-height: 32px;
  padding: 0 32px 0 10px;
}

.scene-preview {
  min-height: 62px;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.scene-preview.empty {
  grid-template-columns: 1fr;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.scene-preview img {
  width: 82px;
  height: 52px;
  border-radius: 6px;
  background: var(--surface-soft);
  object-fit: cover;
}

.scene-preview code {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-click-target {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.preview-click-target:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 6px;
}

.image-preview-open {
  overflow: hidden;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 32, 0.72);
}

.image-preview-dialog {
  position: relative;
  z-index: 1;
  width: min(760px, 92vw);
  max-height: 92vh;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 24, 32, 0.32);
}

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

.image-preview-head h2 {
  margin: 0;
  font-size: 16px;
}

.image-preview-dialog img {
  width: 100%;
  max-height: 72vh;
  display: block;
  border-radius: 6px;
  background: var(--surface-soft);
  object-fit: contain;
}

.image-preview-dialog code {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-video-preview {
  grid-column: 2 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment-video-preview.empty {
  min-height: 72px;
  grid-template-columns: 1fr;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.segment-video-preview video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 260px;
  display: block;
  border-radius: 6px;
  background: #101820;
  object-fit: contain;
}

.segment-video-meta {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 8px;
}

.segment-video-meta code {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.slot-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.asset-row,
.task-row {
  display: grid;
  gap: 6px;
  padding: 11px;
}

.row-title {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e1ebff;
  color: #214fb0;
  font-weight: 800;
}

.tag {
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f5ef;
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}

.tag.warn {
  background: #fff2d8;
  color: var(--amber);
}

.tag.error {
  background: #fee4e2;
  color: var(--red);
}

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

.event-log {
  display: grid;
  gap: 8px;
}

.event-item {
  padding: 9px 10px;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  background: #f8fafb;
  color: #2c3843;
  font-size: 13px;
  line-height: 1.5;
}

.video-gallery {
  min-height: 110px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.video-gallery:empty,
.video-gallery > .muted {
  min-height: 88px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.video-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.video-card video,
.task-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  display: block;
  border-radius: 6px;
  background: #101820;
  object-fit: contain;
}

.video-card video {
  border-radius: 8px 8px 0 0;
}

.video-meta {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.task-video {
  max-height: 260px;
}

.inline-audio {
  width: 100%;
  height: 34px;
  margin: 9px 0 11px;
}

@media (max-width: 1400px) {
  .shell {
    grid-template-columns: 100px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 2;
    grid-row: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 0 16px 16px;
  }
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(160px, 1fr) auto;
  }

  .top-metrics {
    justify-content: flex-end;
  }

  .top-actions {
    display: none;
  }

  .mimicry-grid,
  .copy-grid,
  .full-grid,
  .data-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .topbar,
  .sidebar,
  .workspace,
  .inspector {
    grid-column: 1;
    grid-row: auto;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 12px;
  }

  .top-metrics {
    justify-content: flex-start;
  }

  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    min-width: 94px;
  }

  .view-head,
  .button-row {
    align-items: stretch;
    justify-content: flex-start;
  }

  .view-head,
  .button-row,
  .control-strip,
  .pipeline,
  .segment-row,
  .slot-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
