/* ============================================================
   AI Test Lab · 全部样式（剧场模式 v3）
   布局：左 = 大播放器（固定尺寸）· 右 = 播放列表（独立滚动）
   顶部分类 chips 全局筛选；视频 object-fit: contain 绝不拉伸
   ============================================================ */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e6eaf1;
  --txt: #1f2937;
  --dim: #6b7280;
  --accent: #2563eb;
  --stage: #0f172a;

  --c-video: #2563eb;
  --c-sweep: #7c3aed;
  --c-image: #059669;
  --c-agent: #d97706;
  --c-music: #db2777;

  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --ctl-h: 34px;
  --topbar-h: 92px;   /* 顶栏估算高度，用于右侧列表视口高度计算 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.7;
}

/* ============ 布局：左播放器 + 右列表 ============ */

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  align-items: start;
}

/* ============ 顶栏（全局分类筛选） ============ */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex: none; }
.brand h1 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand h1::before {
  content: ""; width: 4px; height: 20px;
  background: var(--accent); border-radius: 2px;
}
.brand-sub { font-size: 12.5px; color: var(--dim); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12.5px; padding: 3px 14px;
  border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--dim);
  cursor: pointer; user-select: none; font: inherit; font-size: 12.5px;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip .n { opacity: .65; font-size: 11.5px; margin-left: 3px; }
.lang-btn { margin-left: 10px; font-weight: 600; }

/* ============ 左侧：剧场 ============ */

.stage-wrap { min-width: 0; }

.stage {
  background: var(--stage);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 2px 12px rgba(15,23,42,.25);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  /* 固定舞台：宽高锁定，不随视频内容变化 */
  height: min(68vh, 620px);
}
.stage video, .stage img {
  /* 保真核心：视频按原始宽高比完整显示，绝不拉伸不裁切 */
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
}
.stage .stage-hint { color: #64748b; font-size: 13px; padding: 40px; text-align: center; }
/* ---------- 音频舞台（YuE2 等音乐条目） ---------- */
.stage .stage-audio {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; width: min(640px, 92%); height: 100%;
  padding: 18px 22px 12px; text-align: center; overflow: hidden;
}
.stage .stage-audio-icon {
  font-size: 44px; line-height: 1; color: var(--c-music);
  text-shadow: 0 0 30px rgba(219, 39, 119, .45);
}
.stage .stage-audio-label { color: #cbd5e1; font-size: 14px; line-height: 1.6; }
.stage .stage-audio audio { width: 100%; flex: none; }
.stage .stage-audio-lyric {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; text-align: left;
  border-top: 1px solid rgba(148, 163, 184, .18); padding-top: 10px;
}
.stage .stage-audio-lyric .lyric-head {
  color: #64748b; font-size: 12px; letter-spacing: .12em; margin-bottom: 6px; flex: none;
}
.stage .stage-audio-lyric .lyric-body {
  margin: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto;
  color: #cbd5e1; font: 13px/1.9 ui-monospace, "SF Mono", Consolas, "Microsoft YaHei", monospace;
  white-space: pre-wrap; word-break: break-word; padding-right: 10px;
  scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.stage:fullscreen { height: 100vh; }
.stage:fullscreen video { max-height: 100vh; }

/* ---------- 自定义控制条 ---------- */

.controls {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px 12px;
  flex-wrap: wrap;
}
.ctl-btn {
  width: var(--ctl-h); height: var(--ctl-h);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--txt);
  cursor: pointer; flex: none;
  font: inherit; font-size: 13px;
  transition: border-color .15s ease, color .15s ease;
}
.ctl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ctl-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(37,99,235,.08); font-weight: 700; }
.ctl-btn svg { width: 16px; height: 16px; fill: currentColor; }
.ctl-btn.rate, .ctl-btn.wide { width: auto; padding: 0 12px; }

.c-time { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; flex: none; }

.c-seek-wrap { position: relative; flex: 1 1 160px; height: var(--ctl-h); display: flex; align-items: center; min-width: 120px; }
.c-buffer {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 4px; border-radius: 2px;
  background: rgba(37,99,235,.25); pointer-events: none;
}
.c-seek {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), #e2e8f0 var(--fill, 0%));
  outline: none; cursor: pointer; position: relative; z-index: 1;
}
.c-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.c-seek::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.c-vol { -webkit-appearance: none; appearance: none; width: 80px; height: 4px; border-radius: 2px; background: #e2e8f0; outline: none; cursor: pointer; }
.c-vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.c-vol::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }

/* ---------- 倍速选择菜单（弹出面板，直接点选） ---------- */

#rate-menu {
  position: fixed;
  z-index: 100;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(15,23,42,.18);
  padding: 6px;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  min-width: 210px;
}
#rate-menu.open { display: grid; }
.rate-opt {
  font: inherit; font-size: 12.5px; font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none; color: var(--txt);
  cursor: pointer;
  transition: all .1s ease;
}
.rate-opt:hover { background: var(--bg); border-color: var(--line); }
.rate-opt.on {
  background: rgba(37,99,235,.1);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 标题条 / 详情 ---------- */

.stage-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.controls + .stage-bar { border-top: 1px solid var(--line); }
.st-title { font-size: 14px; font-weight: 700; }
.st-summary { font-size: 12.5px; color: var(--dim); }
.st-actions { margin-left: auto; }
.st-btn {
  font: inherit; font-size: 12px; padding: 3px 12px;
  border-radius: 99px; border: 1px solid var(--line);
  background: var(--bg); color: var(--dim); cursor: pointer;
}
.st-btn:hover { border-color: var(--accent); color: var(--accent); }

.detail {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.d-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.d-cat {
  font-size: 11.5px; padding: 1px 10px; border-radius: 99px;
  color: var(--cat-color, var(--accent));
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 10%, transparent);
}
.badge { font-size: 11.5px; padding: 1px 10px; border-radius: 99px; background: rgba(37,99,235,.10); color: var(--accent); }
.badge.green { background: rgba(5,150,105,.12); color: #059669; }
.badge.amber { background: rgba(217,119,6,.12); color: #b45309; }
.badge.gray  { background: rgba(107,114,128,.12); color: #4b5563; }
.badge.purple{ background: rgba(124,58,237,.12); color: #7c3aed; }

.d-section { margin-top: 12px; font-size: 13px; }
.d-label {
  font-size: 12.5px; font-weight: 700; color: var(--dim);
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.d-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.detail table { width: 100%; border-collapse: collapse; }
.detail td { vertical-align: top; padding: 3px 8px 3px 0; font-size: 12.5px; }
.detail td.k { color: var(--dim); white-space: nowrap; width: 5.5em; }
.detail ul { margin: 0 0 0 1.4em; font-size: 12.5px; }
.detail li { margin: 2px 0; }
.links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; }
.links a { color: var(--accent); text-decoration: none; }

/* ============ 右侧：播放列表（测试 + 片段合一，独立滚动） ============ */

.sidebar {
  min-width: 0;
  position: sticky; top: calc(var(--topbar-h) + 8px);
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 28px);
  overflow-y: auto;                 /* 整栏唯一滚动容器，消除双滚动条 */
  scrollbar-width: thin;
}
.sidebar-head {
  font-size: 12.5px; font-weight: 700; color: var(--dim);
  margin-bottom: 10px; padding-left: 4px; flex: none;
  position: sticky; top: 0;         /* 滚动时标题钉在栏顶 */
  background: var(--bg);
  z-index: 1;
}
.testlist {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 4px 6px;
  flex: none;                       /* 不再内部滚动，跟随整栏滚动 */
}
.list-group-label {
  font-size: 11px; font-weight: 700; color: var(--dim);
  padding: 5px 4px 0;
  letter-spacing: .04em;
}
.testitem {
  display: flex; gap: 8px; align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
  text-align: left; width: 100%;
  font: inherit; color: inherit;
}
.testitem:hover { border-color: var(--accent); }
.testitem.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.ti-dot {
  width: 7px; height: 7px; flex: none;
  border-radius: 50%;
  background: var(--cat-color, var(--accent));
}
.testitem.active .ti-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat-color, var(--accent)) 25%, transparent); }
.testitem .ti-text { min-width: 0; }
.testitem .ti-title {
  font-size: 12.5px; font-weight: 500; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.testitem.active .ti-title { font-weight: 700; }

/* ---------- 测试内的片段播放列表 ---------- */

#reelnav { flex: none; margin-top: 12px; }
.playlist {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pl-head {
  padding: 8px 12px;
  font-size: 12px; font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pl-hint { font-weight: 400; font-size: 11px; color: var(--dim); }
/* ---------- 片段选集（紧凑方块，像视频网站的"选集"） ---------- */

.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
  padding: 10px 12px;
}
.pl-break {
  grid-column: 1 / -1;        /* 系列切换：独占一行强制换行 */
  height: 1px;
  margin: 3px 0;
  background: var(--line);
}
.pl-chip {
  height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--dim);
  font: inherit; font-size: 12.5px; font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all .12s ease;
}
.pl-chip:hover { border-color: var(--accent); color: var(--accent); }
.pl-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.pl-eq { width: 14px; height: 14px; }

/* ★ 甜点档位：金色角标，一眼定位 */
.pl-chip.starred {
  position: relative;
  border-color: #f59e0b;
}
.pl-chip.starred:hover { border-color: #d97706; color: #b45309; }
.pl-chip.starred.active { border-color: #f59e0b; box-shadow: 0 2px 6px rgba(245,158,11,.4); }
.pl-star {
  position: absolute; top: -5px; right: -4px;
  font-size: 10px; line-height: 1;
  color: #f59e0b;
  text-shadow: 0 1px 2px rgba(255,255,255,.8);
  pointer-events: none;
}

/* ============ 页脚 / 空状态 ============ */

.footer {
  max-width: 1440px; margin: 0 auto;
  padding: 16px 24px 32px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--dim);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer code { background: #eef1f6; border-radius: 4px; padding: 0 5px; font-size: 11.5px; }

.empty {
  text-align: center; color: var(--dim);
  padding: 32px 0; border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ============ 移动端 ============ */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 12px 12px 32px; gap: 14px; }

  /* 移动端：先播放器后列表，恢复自然文档流 */
  .sidebar { position: static; max-height: none; overflow-y: visible; }
  .stage-wrap { order: -1; }
  .sidebar-head { position: static; }

  .testlist {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .testlist::-webkit-scrollbar { display: none; }
  .testitem { flex: none; width: 210px; }
  .list-group-label { display: none; }
  .sidebar-head { display: none; }

  .stage { height: min(52vh, 440px); }

  /* 控制条压缩：音量滑杆隐藏（用系统音量键），进度条独占一行 */
  .c-vol, .c-time.dur { display: none; }
  .controls { gap: 6px; padding: 6px 8px; }
  .ctl-btn { width: 38px; height: 38px; }      /* 触控热区 ≥ 38px */
  .ctl-btn.rate, .ctl-btn.wide { padding: 0 9px; }
  .c-seek-wrap { flex: 1 1 100%; order: -1; margin-bottom: 2px; }

  /* 片段选集：移动端方块加大触控热区 */
  .pl-chip { height: 40px; }
}

@media (hover: none) {
  .chip, .st-btn { padding-top: 5px; padding-bottom: 5px; }
}

@media print {
  .topbar, .footer, .sidebar, .controls { display: none; }
  .layout { grid-template-columns: 1fr; }
}
