:root {
  --bg: #f6f4ef;
  --panel: #fbfaf6;
  --panel-strong: #ffffff;
  --text: #202421;
  --muted: #667067;
  --faint: #8c958c;
  --line: #dedbd2;
  --line-strong: #cbc7bc;
  --accent: #16685a;
  --accent-soft: #e5f0eb;
  --accent-dark: #0f4f45;
  --amber: #b76a19;
  --amber-soft: #fff2d8;
  --danger: #a94335;
  --danger-soft: #fae8e3;
  --shadow: 0 12px 28px rgba(31, 35, 30, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 64px calc(100vh - 64px);
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 310px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand-title {
  font-size: 16px;
  font-weight: 760;
}

.brand-subtitle,
.modal-subtitle,
.meta,
.hint {
  color: var(--muted);
  font-size: 12px;
}

.version-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

#versionPath {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 470px;
}

.primary-button,
.ghost-button,
.danger-button,
.text-button,
.icon-button,
.chip-button {
  border: 1px solid transparent;
  border-radius: 7px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.primary-button {
  padding: 9px 13px;
  background: var(--accent);
  color: white;
  font-weight: 720;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  padding: 8px 11px;
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: #f2f0e9;
}

.ghost-button.small {
  padding: 6px 9px;
  font-size: 12px;
}

.danger-button {
  padding: 7px 10px;
  border-color: #efc2b8;
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  padding: 4px 6px;
  background: transparent;
  color: var(--muted);
}

.text-button:hover {
  background: #eeece4;
  color: var(--text);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 800;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: #bfd5ce;
}

.sidebar {
  grid-row: 2;
  overflow-y: auto;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #efede5;
}

.sidebar-section + .sidebar-section {
  margin-top: 22px;
}

.sidebar-label {
  margin: 0 8px 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 780;
}

.sidebar-label.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 4px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.56);
}

.nav-item.active {
  border-color: #bdd4cc;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 780;
}

.nav-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-meta {
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  grid-row: 2;
  overflow-y: auto;
  padding: 22px 22px 36px;
}

.workspace-header {
  margin-bottom: 16px;
}

.section-header-card,
.utility-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.section-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

.section-core {
  max-width: 900px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.content-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  color: var(--muted);
}

.insert-row::before,
.insert-row::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.insert-row button {
  padding: 6px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.insert-row button:hover {
  background: var(--panel-strong);
  color: var(--accent-dark);
}

.beat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(31, 35, 30, 0.03);
}

.beat-row.dragging {
  opacity: 0.5;
}

.beat-row.drop-before {
  border-top-color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}

.beat-row.drop-after {
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.beat-main {
  grid-column: 1;
  min-width: 0;
}

.beat-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 28px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0eee7;
  color: var(--faint);
  cursor: grab;
  user-select: none;
}

.beat-title-wrap {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.beat-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.32;
  letter-spacing: 0;
}

.beat-meta {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #efede6;
  color: var(--muted);
  font-size: 12px;
}

.tag.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.material-count-tag {
  border: 1px solid transparent;
  font-weight: 760;
}

.tag.material-count-tag.status-primary {
  border-color: #c4d8d0;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tag.material-count-tag.status-backup {
  border-color: #d6d3ca;
  background: #f1f0eb;
  color: #686f68;
}

.tag.material-count-tag.status-transition {
  border-color: #e5c991;
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.material-count-tag.status-discard_candidate {
  border-color: #d8d3ca;
  background: #ecebe6;
  color: #7d746d;
}

.beat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 250px;
}

.beat-core {
  margin: 12px 0 0;
  color: #394039;
  font-size: 14px;
  line-height: 1.55;
}

.beat-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}

.detail-cell {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
}

.detail-label {
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 760;
}

.detail-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.video-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0;
  min-width: 0;
}

.video-row {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.video-row.status-primary {
  border-color: #cadfd7;
}

.video-row.status-backup {
  border-color: #d4d1c8;
  background: #f7f6f2;
}

.video-row.status-transition {
  border-color: #e7c990;
  background: #fffaf0;
}

.video-row.status-discard_candidate {
  border-style: dashed;
  border-color: #d2cec4;
  background: #f0efea;
}

.video-row.status-discard_candidate .keyframe-thumb {
  filter: saturate(0.62);
}

.video-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 9px 7px;
  border-bottom: 1px solid var(--line);
}

.video-row-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.material-status {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

.material-status.status-primary {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.material-status.status-backup {
  background: #e7e5de;
  color: #606860;
}

.material-status.status-transition {
  background: var(--amber-soft);
  color: var(--amber);
}

.material-status.status-discard_candidate {
  background: #e1dfd7;
  color: #776e67;
}

.video-row-meta,
.keyframe-time {
  color: var(--faint);
  font-size: 11px;
}

.video-id {
  overflow: hidden;
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-purpose {
  padding: 0 9px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.video-reason {
  margin-top: -5px;
  padding: 0 9px 9px;
  color: #7b837b;
  font-size: 11px;
  line-height: 1.45;
}

.keyframe-strip {
  display: flex;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: 9px;
  scrollbar-color: #bab6aa transparent;
  scrollbar-width: thin;
}

.keyframe-card {
  width: 176px;
  min-width: 176px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
}

.keyframe-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background:
    linear-gradient(135deg, rgba(22, 104, 90, 0.18), rgba(183, 106, 25, 0.18)),
    #d9d5ca;
}

.keyframe-info {
  padding: 7px;
}

.keyframe-file {
  overflow: hidden;
  color: #30372f;
  font-size: 10px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyframe-caption {
  display: -webkit-box;
  overflow: hidden;
  min-height: 48px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.move-material-button {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f3f0e8;
  color: var(--accent-dark);
  font-size: 11px;
  white-space: nowrap;
}

.empty-materials {
  display: grid;
  place-items: center;
  min-height: 104px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.missing-keyframes {
  width: 260px;
  min-width: 260px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.missing-title {
  margin-bottom: 5px;
  color: var(--danger);
  font-weight: 780;
}

.revision-box {
  display: flex;
  grid-column: 2;
  align-self: start;
  min-width: 0;
  flex-direction: column;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.revision-title {
  font-size: 13px;
  font-weight: 800;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-button {
  padding: 6px 8px;
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
}

.chip-button:hover,
.chip-button.active {
  border-color: #bdd4cc;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.revision-textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  line-height: 1.45;
}

.revision-textarea:focus,
.select:focus {
  outline: 2px solid rgba(22, 104, 90, 0.18);
  border-color: #9bc1b8;
}

.revision-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pending-badge {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.changes-list {
  display: flex;
  max-height: 58vh;
  overflow-y: auto;
  flex-direction: column;
  gap: 8px;
}

.changes-empty {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.changes-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.changes-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.changes-target {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 820;
}

.changes-op {
  color: var(--muted);
  font-size: 12px;
}

.changes-body {
  color: #384039;
  font-size: 13px;
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 35, 30, 0.36);
  z-index: 80;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(760px, 100%);
}

.modal.payload {
  width: min(980px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 820;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.version-name {
  font-weight: 820;
}

.version-summary {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.payload-preview {
  max-height: 56vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f241f;
  color: #eef5ed;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.info-block {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.info-title {
  margin-bottom: 7px;
  font-weight: 820;
}

.info-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .beat-row {
    grid-template-columns: minmax(0, 1fr) 250px;
  }

  .revision-box {
    padding-left: 10px;
  }

  .revision-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .revision-footer .primary-button {
    width: 100%;
  }

  .keyframe-card {
    width: 164px;
    min-width: 164px;
  }
}


.section-extra {
  max-width: 980px;
  margin: 8px 0 0;
  color: #4e5b52;
  font-size: 13px;
  line-height: 1.5;
}

.section-support {
  max-width: 980px;
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-support span {
  margin-right: 8px;
  color: var(--accent-dark);
  font-weight: 800;
}

.beat-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.beat-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.beat-supplement {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.beat-supplement div {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
}

.beat-supplement span {
  margin-right: 8px;
  color: var(--accent-dark);
  font-weight: 800;
}

.video-row-title {
  flex-wrap: wrap;
}

.material-assignment {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  background: #efede6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.4;
  white-space: nowrap;
}

.material-assignment.is-reuse {
  background: #eaf0f6;
  color: #365a75;
}

.video-detail-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 9px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.utility-grid .info-body {
  white-space: pre-wrap;
}

@media (max-width: 1420px) {
  .beat-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


.version-select {
  max-width: 180px;
  min-width: 126px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 12px;
}

.version-select:focus {
  outline: 2px solid rgba(22, 104, 90, 0.18);
  border-color: #9bc1b8;
}
