/* ============================================================================
 * Template Video PE — Desktop UI styles (v0.2 Phase 2.0: Solo Skill 卡片网格)
 * ============================================================================
 * 视觉对齐 Labs 入口的 .dt-labs-library-card（同款边框 / hover / border-radius:0 / P5 token）
 * 主视图 = header + 分类 tab + 模板卡网格
 * Wizard / TaskFloat / Result Lightbox 在后续 task 实现
 * 相关文档: docs/template-video-frontend-requirements.md §8 视觉规范
 * ========================================================================= */

/* ============================================================================
 * Labs 入口处的 Template Video 卡片图块 (cover figure) — 保留
 * ========================================================================= */

.dt-labs-card-figure--template-video {
  background: color-mix(in srgb, var(--p5-card) 78%, var(--p5-red) 22%);
}

.dt-labs-card-figure--template-video::before {
  opacity: 0.12;
}

.tvpe-labs-icon {
  max-width: 210px;
  color: color-mix(in srgb, var(--p5-text) 80%, var(--p5-red));
}

/* ============================================================================
 * 主页容器
 * ========================================================================= */

.tvpe-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 34px;
  color: var(--p5-text);
}

.tvpe-head {
  --tvpe-hero-ink: var(--p5-text);
  --tvpe-hero-muted: var(--p5-text-secondary);
  --tvpe-hero-paper: color-mix(in srgb, var(--p5-card) 92%, var(--p5-red) 8%);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--tvpe-hero-paper);
  color: var(--tvpe-hero-ink);
  padding: clamp(28px, 4.6vw, 58px) clamp(24px, 5.6vw, 86px);
}

.tvpe-hero-media,
.tvpe-hero-shade {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.tvpe-hero-media {
  background:
    url('/img/template-video-hero-bg-dark.webp') center/cover no-repeat,
    var(--tvpe-hero-paper);
}

.tvpe-hero-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: none;
}

.tvpe-hero-shade {
  background:
    linear-gradient(90deg,
      color-mix(in srgb, var(--p5-surface) 28%, transparent) 0%,
      transparent 44%,
      color-mix(in srgb, var(--p5-black) 12%, transparent) 100%),
    linear-gradient(0deg,
      color-mix(in srgb, var(--p5-red) 9%, transparent) 0%,
      transparent 62%);
}

[data-theme="light"] .tvpe-head {
  --tvpe-hero-paper: var(--p5-card);
}

[data-theme="light"] .tvpe-hero-media {
  background: var(--tvpe-hero-paper);
}

[data-theme="light"] .tvpe-hero-media img {
  opacity: 1;
  filter: saturate(1.04) contrast(1.02);
}

[data-theme="light"] .tvpe-hero-shade {
  background:
    linear-gradient(90deg,
      color-mix(in srgb, var(--tvpe-hero-paper) 88%, transparent) 0%,
      color-mix(in srgb, var(--tvpe-hero-paper) 58%, transparent) 40%,
      color-mix(in srgb, var(--tvpe-hero-paper) 50%, transparent) 66%,
      color-mix(in srgb, var(--tvpe-hero-paper) 76%, transparent) 100%),
    linear-gradient(0deg,
      color-mix(in srgb, var(--p5-red) 10%, transparent) 0%,
      transparent 58%);
}

.tvpe-head-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tvpe-history-entry {
  min-height: 42px;
  padding-inline: 22px;
}

.tvpe-history-entry:hover,
.tvpe-history-entry:focus-visible {
  color: var(--p5-text-inverse);
}

.tvpe-head-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.tvpe-head-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 780px;
}

.tvpe-head h1 {
  margin: 0;
  color: var(--tvpe-hero-ink);
  font-family: var(--font-display);
  font-size: clamp(44px, 4.8vw, 76px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.98;
  text-transform: uppercase;
}

.tvpe-head-copy > p {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--tvpe-hero-muted);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.65;
}

.tvpe-hero-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: 760px;
  margin-top: 34px;
}

.tvpe-hero-feature {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  align-items: start;
}

.tvpe-hero-feature-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--p5-red) 52%, transparent);
  background: color-mix(in srgb, var(--p5-red) 16%, transparent);
  color: color-mix(in srgb, var(--p5-red) 72%, var(--tvpe-hero-ink));
}

.tvpe-hero-feature strong,
.tvpe-hero-feature em {
  display: block;
  min-width: 0;
  font-style: normal;
  letter-spacing: 0;
}

.tvpe-hero-feature strong {
  color: var(--tvpe-hero-ink);
  font-size: var(--text-sm);
  font-weight: 800;
  line-height: 1.25;
}

.tvpe-hero-feature em {
  margin-top: 6px;
  color: var(--tvpe-hero-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.45;
}

.tvpe-back-btn {
  margin-bottom: 18px;
}

.tvpe-kicker {
  margin-bottom: 8px;
  color: var(--p5-red);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: 1.3;
  text-transform: uppercase;
}

/* ============================================================================
 * 分类 tab 条
 * ========================================================================= */

.tvpe-categories-bar {
  margin-top: 24px;
  padding: 0 clamp(18px, 3.2vw, 56px);
}

.tvpe-category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.tvpe-category-btn {
  min-height: 38px;
  padding: 8px 18px;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: color-mix(in srgb, var(--p5-card) 88%, transparent);
  color: var(--p5-text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
  text-align: center;
  text-transform: none;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.tvpe-category-btn:hover,
.tvpe-category-btn:focus-visible,
.tvpe-category-btn.active {
  border-color: var(--p5-red);
  color: var(--p5-text);
  outline: none;
}

.tvpe-category-btn.active {
  border-color: var(--p5-red);
  background: var(--p5-red);
  color: var(--p5-text-inverse);
}

/* ============================================================================
 * 模板区 section + 模板卡网格（Solo Skill 风格）
 * ========================================================================= */

.tvpe-templates-section {
  margin-top: 22px;
  padding: 0 clamp(18px, 3.2vw, 56px);
}

.tvpe-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 32px;
}

.tvpe-section-head h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.tvpe-section-meta {
  color: var(--p5-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: 1;
}

.tvpe-template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 22px;
  align-content: start;
  min-width: 0;
}

/* 滚动加载触底哨兵：跨整行的 1px 占位，IntersectionObserver 观察它来追加下一批 */
.tvpe-template-sentinel {
  grid-column: 1 / -1;
  height: 1px;
}

/* 模板卡 — 视觉对齐 .dt-labs-library-card 但内部上下布局（顶图 + 信息区）
 * 因为模板卡比 Labs 入口卡承载更多信息（chip + 「使用」按钮）, 不沿用左右栏布局 */
.tvpe-template-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-card);
  color: var(--p5-text);
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease;
}

.tvpe-template-card:hover,
.tvpe-template-card:focus-within {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 92%, var(--p5-red) 8%);
}

.tvpe-template-figure {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--p5-border);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--p5-red) 14%, var(--p5-input-bg)),
      var(--p5-input-bg));
  color: color-mix(in srgb, var(--p5-text) 74%, var(--p5-red));
}

.tvpe-template-figure img,
.tvpe-template-figure video {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tvpe-play-mark {
  --tvpe-play-bg: color-mix(in srgb, var(--p5-text-inverse) 72%, transparent);
  --tvpe-play-fg: var(--p5-text);
  --tvpe-play-border: color-mix(in srgb, var(--p5-text) 68%, transparent);
  appearance: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 1px solid var(--tvpe-play-border);
  border-radius: 0;
  background: var(--tvpe-play-bg);
  color: var(--tvpe-play-fg);
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(2px);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

[data-theme="light"] .tvpe-play-mark {
  --tvpe-play-bg: color-mix(in srgb, var(--p5-text) 58%, transparent);
  --tvpe-play-fg: var(--p5-text-inverse);
  --tvpe-play-border: color-mix(in srgb, var(--p5-text-inverse) 76%, transparent);
}

.tvpe-play-mark:hover,
.tvpe-play-mark:focus-visible,
.tvpe-template-figure:hover .tvpe-play-mark,
.tvpe-template-figure:focus-within .tvpe-play-mark,
.tvpe-history-thumb:hover .tvpe-history-play-mark,
.tvpe-history-thumb:focus-visible .tvpe-history-play-mark {
  border-color: var(--tvpe-play-fg);
  background: color-mix(in srgb, var(--tvpe-play-fg) 14%, var(--tvpe-play-bg));
  outline: none;
}

body.tvpe-wizard-open .tvpe-template-grid .tvpe-play-mark {
  display: none !important;
  pointer-events: none !important;
}

.tvpe-thumb-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: color-mix(in srgb, var(--p5-text-secondary) 64%, transparent);
}

.tvpe-thumb-placeholder svg {
  width: 46px;
  height: 46px;
}

.tvpe-template-info {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1 1 auto;
  padding: 12px 14px 12px;
}

.tvpe-template-title {
  margin: 0;
  color: var(--p5-text);
  font-size: var(--text-md);
  font-weight: 800;
  line-height: 1.28;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tvpe-template-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 10px;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.tvpe-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--p5-muted);
  line-height: 1.3;
}

.tvpe-meta-item svg {
  flex: 0 0 auto;
}

.tvpe-meta-roles {
  gap: 6px;
}

.tvpe-role-stack {
  display: inline-flex;
  align-items: flex-start;
  gap: 4px;
  flex: 0 0 auto;
}

.tvpe-role-avatar {
  display: block;
  width: 48px;
  height: 48px;
  margin-left: 0;
  border: 1px solid var(--p5-card);
  background: var(--p5-input-bg);
  object-fit: cover;
  object-position: top center;
}

.tvpe-meta-pill {
  padding: 3px 7px;
  border: 1px solid var(--p5-border);
  background: color-mix(in srgb, var(--p5-card) 82%, transparent);
  line-height: 1.2;
}

.tvpe-template-action {
  display: flex;
  justify-content: stretch;
  margin-top: auto;
  padding-top: 4px;
}

.tvpe-use-btn {
  /* 沿用 .dt-btn-primary .dt-btn-sm 全局类，本规则只控制内部 icon 间距 */
  gap: 6px;
  width: 100%;
  justify-content: center;
}

.tvpe-grid-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 20px;
  min-height: 28px;
}

/* ============================================================================
 * 空 / 加载态
 * ========================================================================= */

.tvpe-empty,
.tvpe-loading {
  grid-column: 1 / -1;          /* span the whole grid, not a single column */
  padding: 24px 14px;
  color: var(--p5-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: center;
}

.tvpe-loading {
  color: var(--p5-text-secondary);
}

/* ----------------------------------------------------------------------------
 * Loading skeleton — shimmer placeholders that mirror .tvpe-template-card while
 * templates load (replaces the bare "加载中..." text). 2026-06-11 hjx
 * ------------------------------------------------------------------------- */
.tvpe-skeleton-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-card);
}

.tvpe-skeleton-figure {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-skeleton-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.tvpe-skeleton-line {
  height: 12px;
  border-radius: 0;
}

.tvpe-skeleton-line-title { width: 68%; height: 15px; }
.tvpe-skeleton-line-desc  { width: 92%; }

.tvpe-skeleton-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.tvpe-skeleton-pill {
  width: 54px;
  height: 18px;
  border-radius: 0;
}

.tvpe-skeleton-figure,
.tvpe-skeleton-line,
.tvpe-skeleton-pill {
  background-image: linear-gradient(
    100deg,
    color-mix(in srgb, var(--p5-card) 86%, var(--p5-border)) 28%,
    color-mix(in srgb, var(--p5-card) 64%, var(--p5-border)) 50%,
    color-mix(in srgb, var(--p5-card) 86%, var(--p5-border)) 72%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: tvpeSkeletonShimmer 1.25s ease-in-out infinite;
}

@keyframes tvpeSkeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tvpe-skeleton-figure,
  .tvpe-skeleton-line,
  .tvpe-skeleton-pill {
    animation: none;
  }
}

/* ============================================================================
 * 响应式
 * ========================================================================= */

@media (max-width: 1240px) {
  .tvpe-hero-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tvpe-template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .tvpe-page {
    padding: 0 0 24px;
  }

  .tvpe-categories-bar,
  .tvpe-templates-section {
    padding: 0 14px;
  }

  .tvpe-head {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 28px 22px;
  }

  .tvpe-head-actions {
    position: relative;
    top: auto;
    right: auto;
    justify-content: flex-end;
    margin-bottom: 20px;
  }

  .tvpe-hero-shade {
    background:
      linear-gradient(180deg,
        color-mix(in srgb, var(--tvpe-hero-paper) 86%, transparent) 0%,
        color-mix(in srgb, var(--tvpe-hero-paper) 60%, transparent) 54%,
        color-mix(in srgb, var(--tvpe-hero-paper) 86%, transparent) 100%);
  }

  .tvpe-head h1 {
    font-size: 42px;
  }

  .tvpe-head-copy > p {
    font-size: var(--text-sm);
  }

  .tvpe-hero-features {
    margin-top: 24px;
  }

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

@media (max-width: 560px) {
  .tvpe-head {
    padding: 24px 18px;
  }

  .tvpe-head h1 {
    font-size: 34px;
  }

  .tvpe-hero-features {
    grid-template-columns: 1fr;
  }

  .tvpe-hero-feature {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .tvpe-hero-feature-icon {
    width: 36px;
    height: 36px;
  }

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

/* ============================================================================
 * Wizard Modal (P0 第 2-3 项: Step 1 选角色 / Step 2 选片场)
 * ========================================================================= */

/* 复用平台 .modal-overlay.active z-index 200 + .dt-fixed-modal flex-column */
.tvpe-wizard {
  width: min(960px, 92vw);
  max-height: 88vh;
}

/* ---------- Wizard Header ---------- */

.tvpe-wizard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-wizard-template-info {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.tvpe-wizard-cover {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 52px;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-wizard-cover img,
.tvpe-wizard-cover video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tvpe-wizard-cover .tvpe-play-mark {
  display: none !important;
  pointer-events: none !important;
}

.tvpe-wizard-cover .tvpe-thumb-placeholder svg {
  width: 26px;
  height: 26px;
}

.tvpe-wizard-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.tvpe-wizard-step-indicator {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
  color: var(--p5-red);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tvpe-wizard-step-indicator strong {
  font-size: 14px;
  color: var(--p5-text);
  font-weight: 800;
}

.tvpe-wizard-step-total {
  color: var(--p5-muted);
}

.tvpe-wizard-header h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  word-break: break-word;
}

.tvpe-wizard-header p {
  margin: 4px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.tvpe-wizard-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--p5-text-secondary);
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.tvpe-wizard-close:hover,
.tvpe-wizard-close:focus-visible {
  color: var(--p5-text);
  border-color: var(--p5-border);
  background: color-mix(in srgb, var(--p5-input-bg) 80%, transparent);
  outline: none;
}

/* ---------- Wizard Body ---------- */

.tvpe-wizard-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

.tvpe-wizard-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 32px;
}

.tvpe-wizard-section-head h3 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.tvpe-wizard-hint {
  margin: -6px 0 14px;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: normal;
  word-break: normal;
}

/* ---------- Role slots (Step 1 target preview — 让用户一眼看清要选几个角色) ---------- */

.tvpe-wizard-role-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.tvpe-wizard-role-slots:empty {
  display: none;
}

.tvpe-wizard-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 148px;
  flex: 0 1 auto;
  padding: 7px 14px 7px 7px;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-card);
}

.tvpe-wizard-slot.is-empty {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--p5-border) 45%, var(--p5-red) 55%);
  background: color-mix(in srgb, var(--p5-card) 92%, var(--p5-red) 8%);
}

.tvpe-wizard-slot.is-filled {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 80%, var(--p5-red) 20%);
}

.tvpe-wizard-slot-box {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-wizard-slot.is-empty .tvpe-wizard-slot-box {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--p5-border) 45%, var(--p5-red) 55%);
  background: color-mix(in srgb, var(--p5-card) 88%, var(--p5-red) 12%);
}

.tvpe-wizard-slot-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.tvpe-wizard-slot-box .tvpe-thumb-placeholder {
  width: 100%;
  height: 100%;
}

.tvpe-wizard-slot-num {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: var(--p5-red);
}

.tvpe-wizard-slot-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tvpe-wizard-slot.is-empty .tvpe-wizard-slot-name {
  color: var(--p5-muted);
}

.tvpe-wizard-slot.is-filled .tvpe-wizard-slot-name {
  color: var(--p5-text);
}

/* ---------- Role grid (Step 1) ---------- */

.tvpe-wizard-role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.tvpe-wizard-role-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-card);
  color: var(--p5-text);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease;
}

.tvpe-wizard-role-card:hover:not(:disabled),
.tvpe-wizard-role-card:focus-visible:not(:disabled) {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 86%, var(--p5-red) 14%);
  outline: none;
}

.tvpe-wizard-role-card.is-selected {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 76%, var(--p5-red) 24%);
}

.tvpe-wizard-role-card-add {
  border-style: dashed;
  background: color-mix(in srgb, var(--p5-card) 90%, var(--p5-red) 10%);
  text-align: center;
}

.tvpe-wizard-role-card-add:hover,
.tvpe-wizard-role-card-add:focus-visible {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 78%, var(--p5-red) 22%);
  outline: none;
}

.tvpe-wizard-role-card:disabled,
.tvpe-wizard-role-card.is-not-ready {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.tvpe-wizard-role-order {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 0;
  background: var(--p5-red);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.tvpe-wizard-role-portrait {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-wizard-role-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 角色多为全身竖图，方形裁切默认居中会切掉头部 → 顶对齐优先露头/上半身 */
  object-position: top center;
  display: block;
}

.tvpe-wizard-role-add-visual {
  aspect-ratio: 1 / 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--p5-border);
  background: color-mix(in srgb, var(--p5-input-bg) 82%, var(--p5-red) 18%);
}

.tvpe-wizard-role-add-icon {
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
  color: var(--p5-red-light);
}

.tvpe-wizard-role-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
}

.tvpe-wizard-role-add-info {
  align-items: center;
  text-align: center;
}

.tvpe-wizard-role-name {
  color: var(--p5-text);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
}

.tvpe-wizard-role-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tvpe-wizard-role-tag-warn {
  color: var(--p5-text-secondary);
  border-color: color-mix(in srgb, var(--p5-text-secondary) 50%, transparent);
}

.tvpe-wizard-role-status {
  min-height: 120px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Scene grid (Step 2) ---------- */

.tvpe-wizard-scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.tvpe-wizard-scene-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-card);
  color: var(--p5-text);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.tvpe-wizard-scene-card:hover,
.tvpe-wizard-scene-card:focus-visible {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 86%, var(--p5-red) 14%);
  outline: none;
}

.tvpe-wizard-scene-card.is-selected {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-card) 76%, var(--p5-red) 24%);
}

.tvpe-wizard-scene-thumb {
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-wizard-scene-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tvpe-wizard-scene-thumb video,
.tvpe-wizard-scene-thumb .tvpe-play-mark {
  display: none !important;
}

.tvpe-wizard-scene-info {
  padding: 10px 14px 14px;
}

.tvpe-wizard-scene-title {
  color: var(--p5-text);
  font-size: var(--text-sm);
  font-weight: 800;
  line-height: 1.3;
  word-break: break-word;
}

.tvpe-wizard-scene-desc {
  margin: 4px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tvpe-wizard-scene-check {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--p5-red);
  color: #fff;
}

/* ---------- Wizard Footer ---------- */

.tvpe-wizard-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--p5-border);
  background: var(--p5-card);
}

.tvpe-wizard-footer > .dt-btn:first-child {
  order: 1;
}

.tvpe-wizard-footer-spacer {
  order: 2;
  flex: 1 1 auto;
}

#tvpe-wizard-prev-btn {
  order: 4;
}

#tvpe-wizard-next-btn {
  order: 5;
}

.tvpe-wizard-next-price {
  margin-left: 6px;
  font-weight: 700;
  letter-spacing: .02em;
  opacity: .85;
}

.tvpe-wizard-cost[hidden] { display: none; }  /* override display:flex so step-1 hide works */

.tvpe-wizard-cost {
  order: 3;
  display: flex;
  flex: 0 1 440px;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px 8px;
  min-width: 0;
  max-width: min(440px, 42vw);
  color: var(--p5-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.tvpe-wizard-cost-label {
  color: var(--p5-text-secondary);
  font-weight: 800;
}

.tvpe-wizard-cost strong {
  color: var(--p5-text);
  font-size: var(--text-sm);
  font-weight: 800;
}

.tvpe-wizard-cost-hint {
  flex: 1 1 100%;
  min-width: 0;
  text-align: right;
}

/* ---------- Role Warning Modal ---------- */

.tvpe-warning-overlay {
  z-index: 3200;
}

.tvpe-warning-modal {
  width: min(560px, 92vw);
  max-height: 82vh;
}

.tvpe-warning-header {
  align-items: flex-start;
  gap: 16px;
}

.tvpe-warning-header h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.25;
}

.tvpe-warning-header p {
  margin: 6px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.tvpe-warning-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px;
}

.tvpe-warning-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tvpe-warning-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--p5-yellow) 42%, var(--p5-border));
  background: color-mix(in srgb, var(--p5-yellow) 9%, var(--p5-card));
}

.tvpe-warning-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--p5-yellow);
  color: var(--p5-black);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.tvpe-warning-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.tvpe-warning-copy strong {
  color: var(--p5-text);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.tvpe-warning-note {
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid var(--p5-red);
  background: color-mix(in srgb, var(--p5-red) 9%, var(--p5-card));
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.tvpe-warning-footer {
  justify-content: flex-end;
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .tvpe-wizard {
    width: 96vw;
    max-height: 92vh;
  }
  .tvpe-wizard-header,
  .tvpe-wizard-body,
  .tvpe-wizard-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .tvpe-wizard-cover {
    width: 64px;
    height: 36px;
  }
  .tvpe-wizard-role-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
  .tvpe-wizard-footer {
    flex-wrap: wrap;
  }
  .tvpe-wizard-cost {
    order: -1;
    flex: 1 1 100%;
    max-width: none;
    justify-content: flex-start;
    text-align: left;
  }
  .tvpe-wizard-cost-hint {
    text-align: left;
  }
}

/* ============================================================================
 * History Modal (PC recent runs)
 * ========================================================================= */

.tvpe-history-modal {
  width: min(1280px, 96vw);
  height: min(860px, 92vh);
}

.tvpe-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-history-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.tvpe-history-header h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  word-break: normal;
  overflow-wrap: normal;
}

.tvpe-history-subtitle {
  margin: 4px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.tvpe-history-close {
  color: var(--p5-text-secondary);
}

.tvpe-history-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.tvpe-history-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-history-view-btn {
  min-width: 86px;
  justify-content: center;
  border-color: transparent;
  background: transparent;
}

.tvpe-history-view-btn.active {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-red) 12%, transparent);
  color: var(--p5-red);
}

.tvpe-history-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 28px;
  background: var(--p5-card);
}

.tvpe-history-list {
  min-width: 0;
}

.tvpe-history-list.is-card {
  display: grid;
  grid-template-columns: repeat(auto-fill, 320px);
  justify-content: start;
  gap: 14px 16px;
  align-content: start;
}

.tvpe-history-list.is-card:hover {
  border-color: transparent;
  outline: none;
  box-shadow: none;
}

.tvpe-history-list.is-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tvpe-history-card {
  min-width: 0;
  border: 1px solid var(--p5-border);
  background: var(--p5-surface);
  color: var(--p5-text);
}

.tvpe-history-list.is-card .tvpe-history-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-self: start;
  width: min(320px, 100%);
  overflow: hidden;
  max-width: 320px;
}

.tvpe-history-list.is-list .tvpe-history-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 168px;
  gap: 14px 18px;
  align-items: center;
  padding: 12px;
}

.tvpe-history-card:hover {
  border-color: var(--p5-red);
  background: color-mix(in srgb, var(--p5-surface) 88%, var(--p5-red) 12%);
}

.tvpe-history-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  border-radius: 0;
  background: var(--p5-input-bg);
  color: var(--p5-muted);
  cursor: pointer;
  padding: 0;
}

.tvpe-history-list.is-card .tvpe-history-thumb {
  border: 0;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-history-thumb img,
.tvpe-history-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tvpe-history-thumb video {
  pointer-events: none;
}

.tvpe-history-play-mark {
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  pointer-events: none;
}

.tvpe-history-thumb .tvpe-thumb-placeholder svg {
  width: 34px;
  height: 34px;
}

.tvpe-history-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tvpe-history-list.is-card .tvpe-history-info {
  padding: 14px 14px 12px;
}

.tvpe-history-list.is-list .tvpe-history-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  grid-template-rows: auto auto;
  column-gap: 18px;
  row-gap: 8px;
  align-items: center;
}

.tvpe-history-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.tvpe-history-list.is-list .tvpe-history-title-row {
  display: contents;
}

.tvpe-history-title-row h3 {
  min-width: 0;
  margin: 0;
  color: var(--p5-text);
  font-size: var(--text-md);
  font-weight: 800;
  line-height: 1.28;
  word-break: normal;
  overflow-wrap: normal;
}

.tvpe-history-status {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: 1.3;
}

.tvpe-history-list.is-list .tvpe-history-status {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: end;
}

.tvpe-history-status-mark {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--p5-muted);
}

.tvpe-history-card.is-active .tvpe-history-status-mark {
  background: var(--p5-red);
}

.tvpe-history-card.is-success .tvpe-history-status-mark {
  background: var(--p5-cyan);
}

.tvpe-history-card.is-failure .tvpe-history-status-mark {
  background: var(--p5-red);
}

.tvpe-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  line-height: 1.35;
}

.tvpe-history-list.is-list .tvpe-history-meta {
  grid-column: 1;
  grid-row: 2;
}

.tvpe-history-list.is-list .tvpe-history-progress {
  grid-column: 1 / -1;
}

.tvpe-history-meta-item {
  min-width: 0;
}

.tvpe-history-progress {
  position: relative;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}

.tvpe-history-progress span {
  display: block;
  height: 100%;
  background: var(--p5-red);
}

.tvpe-history-card.is-success .tvpe-history-progress span {
  background: var(--p5-cyan);
}

.tvpe-history-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  min-width: 156px;
}

.tvpe-history-list.is-list .tvpe-history-actions {
  align-self: center;
  justify-self: end;
}

.tvpe-history-list.is-card .tvpe-history-actions {
  align-items: flex-end;
  padding: 0 14px 14px;
  min-width: 0;
}

.tvpe-history-actions .dt-btn,
.tvpe-history-list.is-card .tvpe-history-actions .dt-btn {
  width: 100%;
  justify-content: center;
}

.tvpe-history-list.is-card .tvpe-loading,
.tvpe-history-list.is-card .tvpe-empty,
.tvpe-history-list.is-card .tvpe-history-loading-more {
  grid-column: 1 / -1;
}

.tvpe-history-footer {
  flex-shrink: 0;
  align-items: center;
  padding: 14px 28px;
  background: var(--p5-card);
}

.tvpe-history-loading-more {
  padding: 12px;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  text-align: center;
}

@media (max-width: 1080px) {
  .tvpe-history-list.is-card {
    grid-template-columns: repeat(auto-fill, 320px);
  }
}

@media (max-width: 720px) {
  .tvpe-history-modal {
    width: 96vw;
    height: 92vh;
  }

  .tvpe-history-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tvpe-history-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tvpe-history-view-toggle {
    flex: 1 1 auto;
    min-width: 0;
  }

  .tvpe-history-view-btn {
    flex: 1 1 0;
    min-width: 0;
  }

  .tvpe-history-header,
  .tvpe-history-body,
  .tvpe-history-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tvpe-history-list.is-card {
    grid-template-columns: 1fr;
  }

  .tvpe-history-list.is-card .tvpe-history-card {
    max-width: none;
  }

  .tvpe-history-list.is-list .tvpe-history-card {
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: start;
  }

  .tvpe-history-list.is-list .tvpe-history-info {
    display: flex;
    flex-direction: column;
  }

  .tvpe-history-list.is-list .tvpe-history-title-row {
    display: flex;
  }

  .tvpe-history-list.is-list .tvpe-history-status {
    align-self: flex-start;
    justify-self: auto;
  }

  .tvpe-history-list.is-list .tvpe-history-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
    min-width: 0;
  }

  .tvpe-history-list.is-list .tvpe-history-actions .dt-btn {
    width: 100%;
    justify-content: center;
  }

  .tvpe-history-title-row {
    flex-direction: column;
    gap: 6px;
  }
}

/* ============================================================================
 * Result Lightbox (P0 第 6 项)
 * ========================================================================= */

/* ============================================================================
 * Assets Modal
 * ========================================================================= */

.tvpe-assets-overlay {
  z-index: 220;
}

.tvpe-assets-modal {
  width: min(1120px, 96vw);
  height: min(820px, 92vh);
}

.tvpe-assets-header {
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-assets-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.tvpe-assets-header h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  word-break: normal;
  overflow-wrap: normal;
}

.tvpe-assets-subtitle {
  margin: 4px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.tvpe-assets-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 28px 28px;
  background: var(--p5-card);
}

.tvpe-assets-section {
  min-width: 0;
}

.tvpe-assets-section h3 {
  margin: 0 0 12px;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.tvpe-assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  min-width: 0;
}

.tvpe-assets-grid-single {
  grid-template-columns: minmax(0, 420px);
}

.tvpe-assets-card {
  min-width: 0;
  border: 1px solid var(--p5-border);
  background: var(--p5-surface);
  color: var(--p5-text);
}

.tvpe-assets-card:hover {
  border-color: var(--p5-red);
}

.tvpe-assets-image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
  color: var(--p5-muted);
}

.tvpe-assets-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tvpe-assets-image-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--p5-muted);
}

.tvpe-assets-image.is-error .tvpe-assets-image-fallback,
.tvpe-assets-card.is-empty .tvpe-assets-image-fallback {
  display: flex;
}

.tvpe-assets-image-fallback svg {
  width: 42px;
  height: 42px;
}

.tvpe-assets-card-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
}

.tvpe-assets-card-info h4 {
  margin: 0;
  color: var(--p5-text);
  font-size: var(--text-sm);
  font-weight: 800;
  line-height: 1.3;
  word-break: normal;
  overflow-wrap: normal;
}

.tvpe-assets-card-info p {
  margin: 0;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  line-height: 1.35;
}

.tvpe-assets-open-original {
  align-self: flex-start;
}

.tvpe-assets-empty,
.tvpe-assets-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 128px;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
  color: var(--p5-text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

.tvpe-assets-loading::before {
  content: '';
  width: 28px;
  height: 28px;
  margin-right: 10px;
  border: 3px solid color-mix(in srgb, var(--p5-red) 18%, transparent);
  border-top-color: var(--p5-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.tvpe-assets-footer {
  flex-shrink: 0;
  padding: 14px 28px;
  background: var(--p5-card);
}

@media (max-width: 720px) {
  .tvpe-assets-modal {
    width: 96vw;
    height: 92vh;
  }

  .tvpe-assets-header,
  .tvpe-assets-body,
  .tvpe-assets-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tvpe-assets-grid,
  .tvpe-assets-grid-single {
    grid-template-columns: 1fr;
  }
}

.tvpe-result-overlay {
  /* 复用 .modal-overlay z-index 200 + 黑底覆盖；v0.2 §6.6 黑底播放器 */
  background: rgba(0, 0, 0, 0.88);
}

.tvpe-result-card {
  width: min(1080px, 94vw);
  max-height: 92vh;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
}

.tvpe-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--p5-border);
}

.tvpe-result-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.tvpe-result-kicker {
  margin-bottom: 4px;
  color: var(--p5-red);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tvpe-result-header h2 {
  margin: 0;
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  word-break: break-word;
}

.tvpe-result-subtitle {
  margin: 4px 0 0;
  color: var(--p5-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.tvpe-result-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--p5-text-secondary);
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.tvpe-result-close:hover,
.tvpe-result-close:focus-visible {
  color: var(--p5-text);
  border-color: var(--p5-border);
  background: color-mix(in srgb, var(--p5-input-bg) 80%, transparent);
  outline: none;
}

.tvpe-result-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 18px 24px;
  background: #000;
}

.tvpe-result-video-wrap {
  position: relative;
  width: 100%;
  /* 16:9 比例 */
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--p5-border);
}

.tvpe-result-video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.tvpe-result-error {
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--p5-red) 50%, transparent);
  background: color-mix(in srgb, var(--p5-red) 8%, transparent);
  color: var(--p5-text);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.tvpe-result-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--p5-border);
  background: var(--p5-card);
}

.tvpe-result-footer-spacer {
  flex: 1 1 auto;
}

@media (max-width: 720px) {
  .tvpe-result-card {
    width: 96vw;
    max-height: 94vh;
  }
  .tvpe-result-header,
  .tvpe-result-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .tvpe-result-body {
    padding: 12px 16px;
  }
}

/* ── Template preview lightbox: click ▶ on a card to enlarge & play the sample video ── */
.tvpe-preview-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 5vh 5vw;
  background: color-mix(in srgb, var(--p5-black) 88%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.tvpe-preview-lightbox.active { display: flex; }
.tvpe-preview-lightbox-inner {
  position: relative;
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tvpe-preview-lightbox-video {
  width: 100%;
  max-height: 80vh;
  display: block;
  background: #000;
  border: 1px solid var(--p5-border);
}
.tvpe-preview-lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, #fff 28%, transparent);
  background: color-mix(in srgb, #000 52%, transparent);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease;
}
.tvpe-preview-lightbox-close:hover { border-color: var(--p5-red); color: var(--p5-red); }
.tvpe-preview-lightbox-title {
  margin-top: 14px;
  max-width: 100%;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
