* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0e0e12;
  color: #e8e8ed;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.site-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  padding: 6px 12px 8px;
  font-size: 10px;
  color: #666;
  background: #12121a;
  border-top: 1px solid #222;
  line-height: 1.5;
}
.site-footer a,
.site-footer .site-footer-link {
  color: #888;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}
.site-footer a:hover,
.site-footer .site-footer-link:hover { color: #ff0050; }

/* 素材防复制：禁止选中、原生拖拽 */
img,
video,
canvas,
.canvas-bg-video,
.canvas-dh-video {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.asset-card-preview,
.bg-template-btn,
.dh-avatar-btn,
#canvasStage,
.canvas-stage {
  -webkit-user-select: none;
  user-select: none;
}

.header {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #16161d;
  border-bottom: 1px solid #2a2a38;
  flex-shrink: 0;
}

.logo { font-weight: 600; font-size: 14px; }
.logo .ver { font-size: 11px; color: #ff0050; margin-left: 6px; font-weight: 400; }

.header-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.header-actions button {
  padding: 5px 10px;
  border: 1px solid #2a2a38;
  background: #16161d;
  color: #e8e8ed;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}

.header-actions button:hover { background: #222; }
.header-actions button.primary { background: #ff0050; border-color: #ff0050; font-weight: 600; }
.header-actions button.primary:hover { background: #ff3373; }

.header-actions button.export-btn {
  background: #2a2a38;
  border-color: #3a3a48;
  color: #666;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
  cursor: not-allowed;
}
.header-actions button.export-btn.export-active {
  background: linear-gradient(135deg, rgba(255, 0, 80, 0.92), rgba(255, 60, 120, 0.75));
  border-color: #ff0050;
  color: #fff;
  cursor: pointer;
  animation: export-hint-pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(255, 0, 80, 0.55);
  transform: translateY(-1px);
}
.header-actions button.export-btn.export-active:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff3373, rgba(255, 60, 120, 0.9));
  filter: brightness(1.05);
}
.header-actions button.export-btn:disabled {
  opacity: 1;
  cursor: not-allowed;
}
.header-actions button.export-btn.export-busy:disabled {
  opacity: 0.65;
  cursor: wait;
}
@keyframes export-hint-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 0, 80, 0.45); transform: translateY(-1px) scale(1); }
  50% { box-shadow: 0 0 20px rgba(255, 0, 80, 0.85); transform: translateY(-2px) scale(1.04); }
}

.layout { flex: 1; display: flex; overflow: hidden; }

.sidebar {
  width: 220px;
  background: #16161d;
  padding: 10px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar.left { border-right: 1px solid #2a2a38; width: 220px; display: flex; flex-direction: column; overflow: hidden; }
.sidebar.right { width: 230px; border-left: 1px solid #2a2a38; }

.sidebar h3 {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar section { margin-bottom: 14px; }

/* 标签页 */
.tabs-wrap { flex-shrink: 0; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.tabs { display: flex; gap: 4px; flex-shrink: 0; }
.tabs-script-row {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid #2a2a38;
}

.tab {
  flex: 1;
  padding: 6px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 5px;
  color: #888;
  cursor: pointer;
  font-size: 12px;
}

.tab.active { background: #ff0050; border-color: #ff0050; color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; flex: 1; min-height: 0; overflow-y: auto; }

#tabBg.tab-panel.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#tabFx.tab-panel.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.template-list { display: flex; flex-direction: column; gap: 5px; max-height: 200px; overflow-y: auto; }

.tpl-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 5px;
  color: #e8e8ed;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}

.tpl-btn:hover { border-color: #ff0050; }
.tpl-btn span { font-size: 18px; }
.tpl-btn.person { border-color: #1b5e20; }
.tpl-btn.person:hover { border-color: #00e676; }

.tool-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }

.tool-btns button {
  padding: 8px 4px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 5px;
  color: #bbb;
  cursor: pointer;
  font-size: 11px;
}

.tool-btns button:hover { border-color: #ff0050; color: #fff; }
.tool-btns button.active { border-color: #ff0050; background: rgba(255,0,80,0.15); color: #fff; }

.asset-panel {
  margin-top: 10px;
  border-top: 1px solid #2a2a38;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  max-height: calc(100vh - 320px);
}

.asset-panel-title {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  line-height: 1.4;
}

.asset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

.asset-card {
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  padding: 6px;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s;
}

.asset-card:hover { border-color: #ff0050; }
.asset-card:active { cursor: grabbing; }

.asset-card-preview {
  position: relative;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a24;
  margin-bottom: 4px;
  font-size: 10px;
}

.asset-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.asset-card-name {
  font-size: 10px;
  color: #aaa;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-card-tag {
  font-size: 9px;
  color: #666;
  text-align: center;
  margin-top: 2px;
}

.fx-filter {
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.fx-grid {
  max-height: calc(100vh - 280px);
}

.coming-soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 32px 16px;
  text-align: center;
}

.coming-soon-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.9;
}

.coming-soon-text {
  font-size: 14px;
  color: #aaa;
  line-height: 1.6;
  margin: 0;
}

.auto-layout-section {
  padding: 8px 0;
}

.btn-auto-layout {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ff0050, #ff6b00);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-auto-layout:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 0, 80, 0.35);
}

.btn-auto-layout:active {
  transform: translateY(0);
}

#tabLayout.tab-panel.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#tabScript.tab-panel.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.script-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.script-type-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  color: #e8e8ed;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
  overflow: hidden;
}

.script-type-card:hover {
  border-color: #ff0050;
  background: rgba(255, 0, 80, 0.06);
}

.script-type-card .script-type-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
  width: 18px;
  text-align: center;
}
.script-type-card .script-type-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #2a2a38;
  padding-top: 10px;
  overflow: hidden;
}

.script-editor-head {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.script-editor-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.script-editor-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.script-field { margin-bottom: 10px; }
.script-field label {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}
.script-field input[type="text"],
.script-field input[type="number"],
.script-field select,
.script-field textarea {
  width: 100%;
  padding: 6px 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #e8e8ed;
  font-size: 12px;
}
.script-field textarea { resize: vertical; min-height: 60px; }

.script-style-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.script-style-pick {
  padding: 8px 4px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 5px;
  color: #bbb;
  cursor: pointer;
  font-size: 10px;
  text-align: center;
}

.script-style-pick:hover { border-color: #ff0050; color: #fff; }
.script-style-pick.active { border-color: #ff0050; background: rgba(255,0,80,0.12); color: #fff; }

.script-item-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.script-item-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 6px;
  align-items: center;
}

.script-item-row .script-item-no {
  font-size: 11px;
  color: #666;
  text-align: center;
}

.script-lottery-list .script-slot-row {
  grid-template-columns: 24px minmax(0, 1fr) auto;
}

.script-lottery-list .script-lottery-text {
  width: 100%;
  min-width: 0;
}

.script-lottery-rate-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.script-lottery-rate {
  width: 48px;
  padding: 6px 4px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a1a;
  color: #fff;
  font-size: 12px;
  text-align: center;
}

.script-lottery-rate-wrap.is-linked .script-lottery-rate {
  opacity: 0.55;
  cursor: not-allowed;
  background: #111;
}

.script-lottery-rate-unit {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

.script-btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.script-btn-row button,
.btn-script-primary {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: #ff0050;
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.script-btn-row button.secondary,
.btn-script-secondary {
  background: #0e0e12;
  border: 1px solid #2a2a38;
  color: #ccc;
  font-weight: 400;
}

.script-btn-row button:hover,
.btn-script-primary:hover { background: #ff3373; }

.script-btn-row button.secondary:hover,
.btn-script-secondary:hover { border-color: #ff0050; color: #fff; }

.script-hint {
  font-size: 10px;
  color: #666;
  line-height: 1.5;
  margin: 6px 0 10px;
}

.script-coming-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 183, 77, 0.15);
  color: #ffb74d;
  font-size: 10px;
  margin-left: 6px;
  font-weight: 400;
}

.canvas.drag-over {
  outline: 2px dashed #ff0050;
  outline-offset: 2px;
}

/* 图层 */
.layer-list { display: flex; flex-direction: column; gap: 4px; }

.layer-tip {
  font-size: 10px;
  color: #666;
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: #0e0e12;
  border-radius: 4px;
}

.layer-empty {
  text-align: center;
  font-size: 12px;
  color: #555;
  line-height: 1.8;
  padding: 24px 8px;
}

.layer-row.hidden-layer { opacity: 0.45; }

.layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 4px;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  min-width: 0;
}

.layer-row.active { border-color: #ff0050; background: rgba(255,0,80,0.08); }

.layer-btns { display: flex; gap: 2px; }
.layer-btns button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  opacity: 0.7;
}
.layer-btns button:hover { opacity: 1; }

/* 画布 */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0a0a0f;
  background-image: radial-gradient(circle, #1a1a24 1px, transparent 1px);
  background-size: 18px 18px;
  overflow: hidden;
}

.canvas-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #16161d;
  border-bottom: 1px solid #2a2a38;
  flex-shrink: 0;
  font-size: 12px;
  flex-wrap: nowrap;
}

.canvas-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.canvas-toolbar select {
  padding: 4px 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #ccc;
}

.inline-check { display: flex; align-items: center; gap: 4px; color: #888; cursor: pointer; }
.inline-check input { width: auto; }

.zoom-btns { display: flex; align-items: center; gap: 6px; }
.zoom-btns button {
  width: 24px; height: 24px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
}

.canvas-meta-inline {
  flex-shrink: 0;
  margin-left: auto;
  color: #666;
  white-space: nowrap;
  padding-left: 12px;
}

.canvas-layers-wrap {
  position: relative;
  flex-shrink: 0;
}

.canvas-layers-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  padding: 0;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
}

.canvas-layers-btn:hover {
  border-color: #444;
  color: #fff;
}

.canvas-layers-btn.active {
  border-color: #ff0050;
  color: #ff0050;
  background: rgba(255, 0, 80, 0.1);
}

.canvas-layers-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  width: 240px;
  max-height: 320px;
  overflow: auto;
  background: #16161d;
  border: 1px solid #2a2a38;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.canvas-layers-head {
  padding: 8px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #ccc;
  border-bottom: 1px solid #2a2a38;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.canvas-layers-hint {
  font-weight: 400;
  color: #666;
  font-size: 10px;
}

.canvas-layers-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}

.canvas-layers-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 5px;
  font-size: 11px;
  color: #ccc;
  cursor: pointer;
  user-select: none;
}

.canvas-layers-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.canvas-layers-item.selected {
  background: rgba(255, 0, 80, 0.12);
  color: #fff;
}

.canvas-layers-item .layer-idx {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-size: 10px;
  color: #666;
}

.canvas-layers-item .layer-kind {
  flex-shrink: 0;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #2a2a38;
  color: #888;
}

.canvas-layers-item .layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-layers-item.kind-base .layer-kind { color: #888; }
.canvas-layers-item.kind-bg-image .layer-kind { color: #42a5f5; background: rgba(66, 165, 245, 0.15); }
.canvas-layers-item.kind-bg-video .layer-kind { color: #ce93d8; background: rgba(171, 71, 188, 0.15); }
.canvas-layers-item.kind-dh .layer-kind { color: #00e676; background: rgba(0, 230, 118, 0.12); }
.canvas-layers-item.kind-element .layer-kind { color: #ffb74d; background: rgba(255, 183, 77, 0.12); }
.canvas-layers-item.kind-guide .layer-kind { color: #00e676; background: rgba(0, 230, 118, 0.12); }

.canvas-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.canvas-stage {
  position: relative;
  flex-shrink: 0;
}

.canvas-voucher-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  max-width: min(520px, calc(100% - 24px));
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 0, 80, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(255, 0, 80, 0.35);
}

.canvas-preview-watermark {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  background-repeat: repeat;
  background-size: 320px 200px;
}

.canvas-dh-layer {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.canvas-dh-sound-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.canvas-dh-sound-btn:hover {
  background: rgba(255, 0, 80, 0.85);
  color: #fff;
}

.canvas-dh-sound-btn:active {
  transform: scale(0.94);
}

.canvas-dh-sound-btn.is-muted {
  color: #ffb74d;
}

.canvas-dh-sound-btn .dh-sound-icon {
  display: block;
  flex-shrink: 0;
}

.canvas-dh-sound-btn .dh-sound-off {
  display: none;
}

.canvas-dh-sound-btn.is-muted .dh-sound-on {
  display: none;
}

.canvas-dh-sound-btn.is-muted .dh-sound-off {
  display: block;
}

.canvas-bg-video {
  position: absolute;
  object-fit: cover;
  pointer-events: none;
  z-index: 1;
  display: none;
  border-radius: inherit;
}

.canvas-bg-image-layer {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  display: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.canvas {
  position: relative;
  z-index: 3;
  background: #1a1a2e;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow: hidden;
  flex-shrink: 0;
}

.bg-layer-handle {
  position: absolute;
  border: 2px dashed #42a5f5;
  background: rgba(66, 165, 245, 0.06);
  pointer-events: auto;
  cursor: move;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  touch-action: none;
  user-select: none;
}

.bg-layer-handle.video {
  border-color: #ab47bc;
  background: rgba(171, 71, 188, 0.06);
}

.bg-layer-handle.selected {
  box-shadow: 0 0 0 1px rgba(66, 165, 245, 0.35);
}

.bg-layer-handle.video.selected {
  box-shadow: 0 0 0 1px rgba(171, 71, 188, 0.35);
}

.bg-layer-handle span {
  pointer-events: none;
  font-size: 9px;
  color: #42a5f5;
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 3px;
}

.bg-layer-handle.video span {
  color: #ce93d8;
}

.bg-layer-handle .resize-handle {
  display: block;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: #42a5f5;
  border-radius: 2px;
  cursor: nwse-resize;
  pointer-events: auto;
}

.bg-layer-handle.video .resize-handle {
  background: #ab47bc;
}

.canvas-dh-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
  border-radius: inherit;
}

.canvas.has-dh-video .person-zone {
  background: transparent;
}

.canvas.has-dh-video .person-zone:not(.selected) span {
  display: none;
}

.canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
}

.el {
  position: absolute;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.el.selected { outline: 2px solid #ff0050; outline-offset: 1px; }
.el.locked { cursor: not-allowed; opacity: 0.85; }
.el.editing { cursor: text; user-select: text; outline: 2px dashed #00e676; }
.el.editing .resize-handle { display: none !important; }

.el .resize-handle {
  display: none;
  position: absolute;
  right: -4px; bottom: -4px;
  width: 10px; height: 10px;
  background: #ff0050;
  border-radius: 2px;
  cursor: nwse-resize;
}

.el.selected .resize-handle { display: block; }

/* LIVE 动画 */
.live-dot {
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* 商品栏 */
.prod-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: #aaa;
  font-size: 13px;
}

.prod-icon { font-size: 28px; opacity: 0.4; }
.prod-name { font-size: 14px; }
.prod-price { color: #ff0050; font-weight: 700; }
.prod-img-wrap {
  flex: 1;
  width: 78%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.prod-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.prod-slot-icon { font-size: 22px; opacity: 0.45; }
.prod-slot-img {
  max-width: 52%;
  max-height: 42%;
  object-fit: cover;
  border-radius: 6px;
}
.prod-slot-name { font-size: 13px; }
.prod-slot-price { color: #ff0050; font-weight: 700; font-size: 13px; }

.prop-prod-block {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2a2a38;
}
.prop-prod-block-bar:last-of-type {
  margin-bottom: 6px;
}
.prop-prod-block-title {
  font-size: 12px;
  font-weight: 600;
  color: #ffb74d;
  margin-bottom: 6px;
}
.prop-prod-img-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.prop-prod-preview {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}
.prop-prod-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.prop-prod-preview-ph {
  font-size: 22px;
  opacity: 0.45;
}
.prop-prod-img-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.prop-prod-btn {
  padding: 4px 8px;
  border: 1px solid #2a2a38;
  background: #16161d;
  color: #ddd;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.prop-prod-btn:hover {
  border-color: #ff0050;
  color: #fff;
}
.prop-prod-btn.subtle {
  color: #888;
}

/* 出镜区 */
.person-zone {
  position: absolute;
  border: 2px dashed #00e676;
  background: rgba(0, 230, 118, 0.05);
  pointer-events: auto;
  cursor: move;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  touch-action: none;
  user-select: none;
}

.person-zone.selected {
  border-color: #00e676;
  box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.35);
}

.person-zone .resize-handle {
  display: none;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: #00e676;
  border-radius: 2px;
  cursor: nwse-resize;
  pointer-events: auto;
}

.person-zone.selected .resize-handle { display: block; }

.person-zone span {
  pointer-events: none;
  font-size: 9px;
  color: #00e676;
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 3px;
}

.person-zone.oval { border-radius: 50%; }

/* 右侧属性 */
.sidebar label {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 10px;
}

.sidebar label input[type="color"] {
  display: block;
  width: 100%;
  height: 32px;
  margin-top: 3px;
  border: none;
  cursor: pointer;
}

.sidebar label input[type="file"] {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #888;
  width: 100%;
}

.sidebar hr { border: none; border-top: 1px solid #2a2a38; margin: 12px 0; }

.sidebar select {
  width: 100%;
  margin-top: 3px;
  padding: 5px 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #e8e8ed;
  font-size: 12px;
}

.check-row { display: flex !important; align-items: center; gap: 6px; cursor: pointer; }
.check-row input { width: auto; margin: 0; }

.tip { font-size: 10px; color: #666; line-height: 1.5; margin-top: 8px; }

.prop-panel label {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
}

.prop-panel input,
.prop-panel select,
.prop-panel textarea {
  width: 100%;
  margin-top: 3px;
  padding: 5px 7px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #e8e8ed;
  font-size: 12px;
}

.prop-panel textarea { resize: vertical; min-height: 44px; white-space: pre-wrap; }

.prop-hms-row {
  display: flex;
  gap: 6px;
  margin: -4px 0 8px;
}
.prop-hms-row input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  text-align: center;
}

.hint { font-size: 12px; color: #666; text-align: center; padding: 16px 0; }

.align-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.align-bar.hidden { display: none; }

.align-bar button {
  flex: 1 1 30%;
  padding: 5px;
  font-size: 10px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
}

.align-bar button:hover { border-color: #ff0050; color: #fff; }

.bg-template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

#tabBg .bg-tab-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}

#tabBg .bg-tab-settings {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 8px;
  min-height: 36px;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  background: #16161d;
  color: #ccc;
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  box-sizing: border-box;
  user-select: none;
  text-align: center;
}
.bg-upload-btn:hover { border-color: #444; color: #eee; }

#tabBg .bg-template-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  padding: 8px 6px;
  background: #0e0e12;
}

.bg-media-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 8px;
  position: sticky;
  top: 0;
  background: #0e0e12;
  z-index: 2;
  padding-bottom: 4px;
}

.bg-media-tab {
  flex: 1;
  padding: 7px 4px;
  font-size: 11px;
  border: 1px solid #2a2a38;
  background: #16161d;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.bg-media-tab:first-child { border-radius: 6px 0 0 6px; }
.bg-media-tab:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.bg-media-tab.active {
  background: rgba(255, 0, 80, 0.15);
  border-color: #ff0050;
  color: #fff;
  font-weight: 600;
}

.bg-template-btn video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bg-template-btn .bg-video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#tabBg .bg-template-grid {
  margin-top: 0;
}

.bg-load-more {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed #444;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
}
.bg-load-more:hover { border-color: #666; color: #ddd; }

#tabBg label select {
  width: 100%;
  margin-top: 4px;
  padding: 5px 6px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 4px;
  color: #ddd;
  font-size: 11px;
}

.bg-template-btn {
  position: relative;
  aspect-ratio: 9 / 16;
  border: 2px solid #2a2a38;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #1a1a24;
}

.bg-template-grid.landscape {
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.bg-template-grid.landscape .bg-template-btn {
  aspect-ratio: 16 / 9;
  max-height: 52px;
}

.bg-template-btn:hover { border-color: #666; }
.bg-template-btn.active { border-color: #ff0050; box-shadow: 0 0 0 1px rgba(255,0,80,0.4); }

.bg-template-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-template-btn span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 4px;
  font-size: 9px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  text-align: center;
  line-height: 1.2;
}

/* 数字人 Tab */
.dh-section { display: flex; flex-direction: column; gap: 10px; }
.dh-mode-tabs { display: flex; gap: 0; }
.dh-mode-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  border: 1px solid #2a2a38;
  background: #16161d;
  color: #888;
  cursor: pointer;
}
.dh-mode-tab:first-child { border-radius: 6px 0 0 6px; }
.dh-mode-tab:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.dh-mode-tab.active {
  background: rgba(255, 0, 80, 0.15);
  border-color: #ff0050;
  color: #fff;
  font-weight: 600;
}
.dh-panel { display: none; }
.dh-panel.active { display: block; }
.dh-label { display: block; font-size: 11px; color: #888; margin-bottom: 8px; }
.dh-label.dh-inline { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.dh-label.dh-inline input { margin: 0; }
.dh-label textarea,
.dh-label select {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  background: #0e0e12;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  color: #e8e8ed;
  font-size: 12px;
  resize: vertical;
}
.dh-audio-actions { display: flex; gap: 8px; margin-bottom: 8px; align-items: stretch; }
.dh-mic-test {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  background: #16161d;
  color: #ccc;
  font-size: 11px;
  cursor: pointer;
}
.dh-mic-test:hover { border-color: #444; color: #eee; }
.dh-mic-test.active { border-color: #00e676; color: #00e676; }
.dh-mic-warn {
  margin: 0 0 8px;
  padding: 8px;
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.45;
  color: #ffb74d;
  background: rgba(255, 183, 77, 0.08);
  border: 1px solid rgba(255, 183, 77, 0.25);
}
.dh-mic-warn[hidden] { display: none !important; }
.dh-mic-level-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #12121a;
  border: 1px solid #2a2a38;
}
.dh-mic-level-wrap[hidden] { display: none !important; }
.dh-mic-level-label {
  flex-shrink: 0;
  font-size: 10px;
  color: #888;
}
.dh-mic-level-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #2a2a38;
  overflow: hidden;
}
.dh-mic-level-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #00e676, #ff0050);
  transition: width 0.08s linear;
}
.dh-mic-level-hint {
  flex-shrink: 0;
  font-size: 10px;
  color: #666;
  min-width: 28px;
  text-align: right;
}
.dh-audio-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  background: #16161d;
  color: #ccc;
  font-family: inherit;
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
  user-select: none;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
}
.dh-audio-btn:hover { border-color: #444; color: #eee; }
.dh-audio-btn.recording { border-color: #ff0050; color: #ff0050; }
.dh-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #2a2a38;
  border-radius: 10px;
  background: linear-gradient(180deg, #1a1a24 0%, #12121a 100%);
}
.dh-audio-player.is-idle .dh-audio-play {
  background: #2a2a38;
  box-shadow: none;
  cursor: default;
}
.dh-audio-player.is-recording {
  border-color: rgba(255, 0, 80, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 0, 80, 0.12);
}
.dh-audio-player.is-recording .dh-audio-play {
  background: #ff0050;
  animation: dh-rec-pulse 1.2s ease-in-out infinite;
}
@keyframes dh-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 80, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(255, 0, 80, 0); }
}
.dh-audio-hint {
  font-size: 10px;
  color: #666;
}
.dh-audio-player.has-audio .dh-audio-hint { display: none; }
.dh-audio-player.is-recording .dh-audio-hint { color: #ff6b8a; }
.dh-audio-play {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff0050, #ff3373);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 0, 80, 0.35);
}
.dh-audio-play:hover { filter: brightness(1.08); }
.dh-audio-play .icon-play { display: block; }
.dh-audio-play .icon-pause { display: none; }
.dh-audio-play.playing .icon-play { display: none; }
.dh-audio-play.playing .icon-pause { display: block; }
.dh-audio-track {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dh-audio-progress {
  width: 100%;
  height: 4px;
  margin: 0;
  accent-color: #ff0050;
  cursor: pointer;
}
.dh-audio-times {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #888;
  font-variant-numeric: tabular-nums;
}
.dh-audio-sep { color: #555; }
.dh-audio-clear {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #666;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.dh-audio-clear:hover { color: #ff6b6b; background: rgba(255, 107, 107, 0.1); }
.dh-btn, .dh-upload-btn {
  flex: 1;
  padding: 8px;
  text-align: center;
  border: 1px solid #2a2a38;
  border-radius: 6px;
  background: #16161d;
  color: #ccc;
  font-size: 11px;
  cursor: pointer;
}
.dh-btn.recording { border-color: #ff0050; color: #ff0050; }
.dh-upload-btn input { display: none; }
.dh-group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.dh-group-tab {
  padding: 4px 8px;
  border: 1px solid #333;
  border-radius: 999px;
  background: #1a1a24;
  color: #aaa;
  font-size: 10px;
  cursor: pointer;
}
.dh-group-tab.active {
  border-color: #ff0050;
  color: #fff;
  background: rgba(255, 0, 80, 0.15);
}
.dh-avatar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.dh-avatar-btn {
  position: relative;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 2px solid #2a2a38;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #1a1a24;
}
.dh-avatar-btn.active { border-color: #ff0050; }
.dh-avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dh-avatar-btn span {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 3px;
  font-size: 9px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  text-align: center;
}
.btn-dh-generate {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #ff0050;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-dh-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.dh-status { min-height: 18px; font-size: 11px; color: #888; text-align: center; }
.dh-hint { font-size: 10px; color: #666; line-height: 1.45; margin: 0 0 8px; }
.dh-custom-upload {
  margin-bottom: 8px;
  padding: 8px;
  border: 1px dashed #444;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.dh-custom-upload.hidden { display: none; }
.dh-upload-avatar-btn {
  display: inline-block;
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 11px;
  color: #ddd;
  cursor: pointer;
}
.dh-upload-avatar-btn input { display: none; }
.dh-avatar-name-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #12121a;
  color: #eee;
  font-size: 11px;
  box-sizing: border-box;
}
.dh-tool-row {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
}
.dh-btn-secondary {
  flex: 1;
  border-color: #555;
  color: #ccc;
}
.dh-verify-report {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #12121a;
  font-size: 10px;
  line-height: 1.5;
  color: #aaa;
  max-height: 120px;
  overflow-y: auto;
}
.dh-verify-report.hidden { display: none; }
.dh-verify-report .ok { color: #6fdc8c; }
.dh-verify-report .fail { color: #ff6b6b; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
