/* ==========================================================================
   Apple 风格设计系统
   配色 / 材质 / 排版参照 Apple HIG 与 apple-design 技能：
   - 材质层次：导航与浮层用半透明 + backdrop-filter，内容在其下滚动
   - 排版：字号相关的 tracking 与 leading（大标题负字距，正文接近 0）
   - 动效：弹簧曲线（spring），可被打断；reduce-motion 下退化为交叉淡入
   ========================================================================== */

:root {
  color-scheme: dark;

  /* —— 系统色板（暗色） —— */
  --sys-blue: #0a84ff;
  --sys-cyan: #64d2ff;
  --sys-green: #30d158;
  --sys-indigo: #5e5ce6;
  --sys-orange: #ff9f0a;
  --sys-pink: #ff375f;
  --sys-purple: #bf5af2;
  --sys-red: #ff453a;
  --sys-teal: #40c8e0;
  --sys-yellow: #ffd60a;

  /* —— 语义色 —— */
  --accent: var(--sys-blue);
  --accent-2: var(--sys-cyan);

  /* —— 背景与材质 —— */
  --bg-base: #000000;
  --bg-elevated: #1c1c1e;
  --bg-elevated-2: #2c2c2e;
  --bg-grouped: #000000;

  --material-thin: rgba(30, 30, 32, 0.62);
  --material-regular: rgba(28, 28, 30, 0.78);
  --material-thick: rgba(22, 22, 24, 0.92);

  /* —— 文本层级（Apple label 语义） —— */
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.36);
  --label-4: rgba(235, 235, 245, 0.22);

  /* —— 分隔线与填充 —— */
  --separator: rgba(84, 84, 88, 0.65);
  --separator-opaque: #38383a;
  --fill-1: rgba(120, 120, 128, 0.20);
  --fill-2: rgba(120, 120, 128, 0.32);

  /* —— 圆角（Apple 连续圆角观感的近似） —— */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* —— 弹簧参数：默认临界阻尼，无过冲 —— */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);       /* ≈ response 0.4 / damping 1.0 */
  --spring-bouncy: cubic-bezier(0.34, 1.4, 0.64, 1); /* 仅用于有动量的交互 */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.62);
}

/* 浅色主题：同一套语义名，仅换值 */
:root[data-theme='light'] {
  color-scheme: light;
  --sys-blue: #007aff;
  --sys-cyan: #0a84ff;
  --sys-green: #34c759;
  --sys-indigo: #5856d6;
  --sys-orange: #ff9500;
  --sys-pink: #ff2d55;
  --sys-purple: #af52de;
  --sys-red: #ff3b30;
  --sys-teal: #30b0c7;
  --sys-yellow: #ffcc00;
  --accent: var(--sys-blue);
  --accent-2: var(--sys-teal);

  --bg-base: #f2f2f7;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #ffffff;
  --bg-grouped: #f2f2f7;

  --material-thin: rgba(255, 255, 255, 0.62);
  --material-regular: rgba(250, 250, 252, 0.8);
  --material-thick: rgba(255, 255, 255, 0.94);

  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --label-4: rgba(60, 60, 67, 0.18);

  --separator: rgba(60, 60, 67, 0.29);
  --separator-opaque: #c6c6c8;
  --fill-1: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--label);
  font-family: var(--sans);
  /* 正文：leading 1.5，tracking 接近 0（小字略正） */
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }

/* 主题切换时避免亮度突跳 */
body, .panel, .top, .seg, input, textarea, .btn {
  transition: background-color 380ms var(--ease-out), border-color 380ms var(--ease-out), color 380ms var(--ease-out);
}

/* ==========================================================================
   背景
   ========================================================================== */

.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--separator) 1px, transparent 1px),
    linear-gradient(90deg, var(--separator) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 100% 55% at 50% 0%, #000 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 100% 55% at 50% 0%, #000 10%, transparent 72%);
  opacity: 0.35;
}
.bg__orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.3; will-change: transform; }
.bg__orb--a { width: 620px; height: 620px; background: var(--accent); top: -260px; left: -180px; }
.bg__orb--b { width: 540px; height: 540px; background: var(--sys-purple); top: 60px; right: -200px; opacity: 0.22; }

/* ==========================================================================
   导航：半透明材质，内容在其下滚动（scroll edge effect 思路）
   ========================================================================== */

.top {
  position: sticky; top: 0; z-index: 30;
  background: var(--material-thin);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  /* 不用 1px 硬分割线，改用底部渐变让内容自然淡出 */
  border-bottom: 1px solid var(--separator);
}
.top__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.top__brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.mark {
  flex: none;
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 8px 12px; border-radius: var(--r-sm); color: #fff;
  background: linear-gradient(160deg, var(--sys-blue), var(--sys-indigo));
  box-shadow: var(--shadow-sm);
}
/* 大标题：负字距 + 紧 leading */
.top h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.021em; line-height: 1.2; }
.top p { margin: 1px 0 0; font-size: 13px; color: var(--label-2); letter-spacing: 0.006em; }

.top__actions { display: flex; align-items: center; gap: 8px; }

.link {
  color: var(--accent); text-decoration: none; font-size: 15px;
  padding: 6px 4px; border-radius: var(--r-sm);
}
.link:hover { text-decoration: underline; }

/* ==========================================================================
   按钮：按下即反馈（pointer-down），不等 click
   ========================================================================== */

.btn {
  font: inherit; font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--label);
  background: var(--fill-1);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 9px 16px;
  cursor: pointer;
  /* transform 走弹簧曲线，按下立刻缩小 */
  transition: transform 160ms var(--spring), background-color 200ms var(--ease-out),
    opacity 200ms var(--ease-out), border-color 200ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--fill-2); }
.btn:active:not(:disabled) { transform: scale(0.96); transition-duration: 90ms; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn--primary {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); }

/* 播放入口：与「解析」区分开，用描边 + 图形符号，避免两个实心主按钮抢焦点 */
.btn--play {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 46%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn--play::before {
  content: '';
  width: 0; height: 0;
  border-left: 8px solid currentColor;
  border-top: 5.5px solid transparent;
  border-bottom: 5.5px solid transparent;
}
.btn--play:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
}

.btn--ghost { background: transparent; border-color: var(--separator); }
.btn--ghost:hover:not(:disabled) { background: var(--fill-1); }

.btn--sm { font-size: 13px; padding: 6px 12px; border-radius: var(--r-sm); }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--fill-1); border: 0; color: var(--label);
  cursor: pointer;
  transition: transform 160ms var(--spring), background-color 200ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--fill-2); }
.icon-btn:active { transform: scale(0.92); transition-duration: 90ms; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
/* 图标表示「点击后会切换到什么」：暗色下显示太阳，浅色下显示月亮 */
:root[data-theme='dark'] .i-moon { display: none; }
:root[data-theme='light'] .i-sun { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

main { padding: 26px 0 48px; display: grid; gap: 18px; }

/* 关键：grid/flex 子项默认 min-width:auto，会被 textarea 里那种
   超长且无空格的标签行（如 EXT-X-STREAM-INF）撑破布局，产生横向滚动。
   这里逐层允许收缩，让 100% 宽度真正生效。 */
main > *,
.panel,
.pane,
.field,
.actions,
.player-card { min-width: 0; }

/* ==========================================================================
   面板：分组卡片
   ========================================================================== */

.panel {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.panel--plain { background: transparent; box-shadow: none; padding: 0; }

.panel__head { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; flex-wrap: wrap; }
.panel__head h2 {
  margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.022em; line-height: 1.25;
}
.panel__sub { margin: -8px 0 14px; font-size: 13.5px; color: var(--label-2); }

.count {
  font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 1px 8px; border-radius: var(--r-full);
  background: var(--fill-1); color: var(--label-2);
}
.hint-inline { font-size: 13px; color: var(--label-3); }

/* ==========================================================================
   分段控件（Apple segmented control）
   ========================================================================== */

.segmented {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--fill-1); border-radius: var(--r-md);
  max-width: 100%; flex-wrap: wrap;
}
.segmented__btn {
  font: inherit; font-size: 13.5px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--label-2); background: transparent; border: 0;
  padding: 7px 15px; border-radius: 10px; cursor: pointer;
  transition: color 180ms var(--ease-out), background-color 180ms var(--ease-out),
    transform 160ms var(--spring);
  -webkit-tap-highlight-color: transparent;
}
.segmented__btn:hover { color: var(--label); }
.segmented__btn:active { transform: scale(0.97); transition-duration: 90ms; }
.segmented__btn[aria-selected='true'] {
  color: var(--label); background: var(--bg-elevated-2);
  box-shadow: var(--shadow-sm); font-weight: 600;
}

.pane { display: grid; gap: 14px; }

textarea, input[type='url'], input[type='text'] {
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  width: 100%; max-width: 100%; min-width: 0;
  color: var(--label);
  background: var(--fill-1);
  border: 1px solid transparent; border-radius: var(--r-md);
  padding: 12px 14px; outline: none; resize: vertical;
  transition: border-color 200ms var(--ease-out), background-color 200ms var(--ease-out);
}
textarea { min-height: 200px; }
textarea:focus, input[type='url']:focus, input[type='text']:focus {
  border-color: var(--accent); background: var(--bg-elevated);
}
::placeholder { color: var(--label-3); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--label-2); }

.note { margin: 0; font-size: 13px; color: var(--label-2); line-height: 1.6; }
.note strong { color: var(--label); font-weight: 600; }
.note code { font-family: var(--mono); font-size: 12px; background: var(--fill-1); padding: 1px 6px; border-radius: 5px; }

/* 文件拖放 */
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center;
  border: 1.5px dashed var(--separator-opaque); border-radius: var(--r-lg);
  padding: 38px 20px; cursor: pointer; color: var(--label-2);
  background: var(--fill-1);
  transition: border-color 200ms var(--ease-out), background-color 200ms var(--ease-out), transform 200ms var(--spring);
}
.drop:hover { border-color: var(--accent); color: var(--label); }
.drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); transform: scale(1.01); }
.drop__icon { font-size: 26px; line-height: 1; color: var(--accent); }
.drop__text { font-size: 14px; }

.actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.sample-label { font-size: 13px; color: var(--label-3); margin-left: 2px; }

/* ==========================================================================
   播放器
   ========================================================================== */

.player-card {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
/* 播放舞台：播放器在底层，封面盖在上面。
   解析成功时只显示封面，点封面才开始加载播放器（省流量，也不出现空黑框）。 */
.player-stage {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  width: 100%;
  min-width: 0;
}
#playerHost {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  min-width: 0;
}
/* 成为 .dplayer 根节点后，它内部用绝对定位铺满自己，这里只需保持它是定位基准 */
#playerHost.dplayer { position: absolute; }
#playerHost > .dplayer-video-wrap { height: 100%; }
#playerHost > .dplayer-video-wrap > video { height: 100%; object-fit: contain; }

/* 封面：可点击，点下即播放；淡出时不做位移，避免和播放器首帧错位 */
.player-cover {
  position: absolute; inset: 0; z-index: 2;
  display: block; width: 100%; height: 100%;
  padding: 0; border: 0; cursor: pointer;
  background: #000; color: #fff;
  font: inherit; text-align: left;
  transition: opacity 320ms var(--ease-out), visibility 0s linear 320ms;
  -webkit-tap-highlight-color: transparent;
}
.player-cover.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }

/* 封面图：从视频里截取的真实帧（.player-cover__art 是 img/背景），
   在截到之前先显示一层占位底纹，避免空白 */
.player-cover__art {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #0b0e16;
}
.player-cover__art.is-placeholder {
  background-image:
    radial-gradient(circle at 24% 30%, color-mix(in srgb, var(--sys-blue) 46%, transparent), transparent 60%),
    linear-gradient(150deg, #10131c, #05070c 78%);
}
/* 截帧进行中：轻微脉动，表示还在取图 */
.player-cover__art.is-loading::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 28%, rgba(255,255,255,0.12) 50%, transparent 72%);
  background-size: 220% 100%;
  animation: coverShimmer 1.25s linear infinite;
}
@keyframes coverShimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
/* 截帧失败：回退到描边网格，而不是留一片纯色 */
.player-cover__art.is-fallback::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 78% 62% at 50% 46%, #000 12%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 78% 62% at 50% 46%, #000 12%, transparent 76%);
}

.player-cover__inner { position: absolute; inset: 0; display: grid; place-items: center; }
.player-cover__play {
  width: 78px; height: 78px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  transition: transform 220ms var(--spring), background-color 220ms var(--ease-out);
}
.player-cover__play svg { width: 30px; height: 30px; fill: #fff; margin-left: 3px; }
.player-cover:hover .player-cover__play { transform: scale(1.08); background: rgba(255, 255, 255, 0.24); }
.player-cover:active .player-cover__play { transform: scale(0.97); transition-duration: 90ms; }

/* 封面上的标题与元信息，压一层渐变保证可读性 */
.player-cover__text {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 40px 20px 16px;
  display: grid; gap: 3px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
  pointer-events: none;
}
.player-cover__title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-cover__meta {
  font-family: var(--mono); font-size: 12px; color: rgba(255, 255, 255, 0.68);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.player-meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px;
  margin-top: 14px; font-size: 13px; color: var(--label-2);
}
.meta-item { display: flex; align-items: baseline; gap: 6px; min-width: 0; max-width: 100%; }
.meta-k { flex: none; color: var(--label-3); }
.player-meta code {
  font-family: var(--mono); font-size: 12px; color: var(--label-2);
  background: var(--fill-1); padding: 2px 8px; border-radius: 6px;
}
/* 地址可能极长。行内元素上 max-width / text-overflow 都不生效，
   所以这里作为可压缩的 flex 子项（min-width:0）才能截断并显示省略号；
   完整地址见元素的 title，悬浮即可查看。 */
.meta-v--url {
  min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* 质量菜单 */
.quality-menu {
  position: relative;
}
.quality-list {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 40;
  min-width: 190px; padding: 6px;
  background: var(--material-thick);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  /* 从触发器处缩放出现（spatial consistency） */
  transform-origin: bottom left;
  opacity: 0; transform: scale(0.94) translateY(6px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 220ms var(--spring);
}
.quality-list.is-open { opacity: 1; transform: none; pointer-events: auto; }
.quality-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; font: inherit; font-size: 13.5px; text-align: left;
  padding: 8px 11px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--label); cursor: pointer;
}
.quality-item:hover { background: var(--fill-1); }
.quality-item[aria-checked='true'] { color: var(--accent); font-weight: 600; }
.quality-item[aria-checked='true']::after { content: '✓'; }

/* ==========================================================================
   概览统计：自适应网格
   ========================================================================== */

/* 概览统计：用卡片自身的边框做间隔，避免最后一行留白处露出底色 */
.stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0; border: 1px solid var(--separator); border-radius: var(--r-md);
  overflow: hidden;
}
.stat {
  background: var(--bg-elevated);
  padding: 11px 14px 12px;
  display: grid; gap: 2px; min-width: 0;
  border-right: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
}
.stat__k { font-size: 12.5px; color: var(--label-2); letter-spacing: 0.006em; }
.stat__v {
  font-size: 14.5px; font-weight: 500; letter-spacing: -0.008em;
  overflow-wrap: anywhere;
}
/* 长地址类的值：单行截断 + 省略号，完整内容见 title */
.stat__v.is-truncate {
  display: block; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ==========================================================================
   告警 / 提示
   ========================================================================== */

.alert {
  border-radius: var(--r-lg); padding: 16px 18px;
  background: color-mix(in srgb, var(--sys-red) 14%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--sys-red) 34%, transparent);
}
.alert__title { margin: 0 0 5px; font-weight: 600; font-size: 15px; color: var(--sys-red); letter-spacing: -0.01em; }
.alert__body { margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--label); }
.alert__hint { margin: 9px 0 0; font-size: 13px; color: var(--label-2); line-height: 1.6; }

.notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.notes li { font-size: 13.5px; line-height: 1.6; color: var(--label-2); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.notes code { font-family: var(--mono); font-size: 11.5px; color: var(--sys-orange); background: var(--fill-1); padding: 1px 6px; border-radius: 5px; }
.notes strong { font-family: var(--mono); font-weight: 600; color: var(--label); }
.notes em { font-family: var(--mono); font-size: 11.5px; font-style: normal; color: var(--label-3); }

/* ==========================================================================
   表格
   ========================================================================== */

.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--separator); }
.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--label-3);
  padding: 9px 12px; background: var(--bg-elevated-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--separator);
}
.t td {
  padding: 9px 12px; background: var(--bg-elevated); vertical-align: middle;
  border-bottom: 1px solid var(--separator);
}
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--bg-elevated-2); }
.t .num { font-family: var(--mono); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t .mono { font-family: var(--mono); font-size: 11.5px; }
.t .uri { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label-2); }
.t .flags { display: flex; gap: 4px; flex-wrap: wrap; }
.t .flag { color: var(--sys-green); text-align: center; }
.t .is-enc { color: var(--sys-orange); }
.t .is-derived { color: var(--label-3); }
.t--seg tbody tr { cursor: pointer; }
.t--seg tbody tr.row--pending td { background: color-mix(in srgb, var(--sys-orange) 12%, var(--bg-elevated)); }

.flag-badge {
  font-family: var(--mono); font-size: 10.5px; padding: 1.5px 6px; border-radius: 5px;
  background: var(--fill-1); color: var(--label-2); white-space: nowrap;
}
.flag-badge--disc { color: var(--sys-cyan); }
.flag-badge--gap { color: var(--sys-red); }
.flag-badge--map { color: var(--sys-purple); }
.flag-badge--dr { color: var(--sys-green); }
.tag-iframe { font-family: var(--mono); font-size: 10px; margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--sys-purple) 30%, transparent); color: var(--label); }

.chip-link {
  font: inherit; font-family: var(--mono); font-size: 11.5px; cursor: pointer;
  background: none; border: 0; padding: 0; color: var(--accent);
  border-bottom: 1px dashed currentColor;
}

/* ==========================================================================
   时间轴：分片条
   ========================================================================== */

.timeline { border-radius: var(--r-md); padding: 14px; background: var(--fill-1); }
.timeline__track { display: flex; gap: 2px; height: 44px; align-items: stretch; }
.seg {
  position: relative; min-width: 3px; border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 34%, transparent);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; color: var(--label);
  overflow: hidden; cursor: default;
  transition: transform 180ms var(--spring), filter 180ms var(--ease-out);
}
.seg:hover { filter: brightness(1.4); transform: scaleY(1.08); }
.seg--key { background: color-mix(in srgb, var(--sys-orange) 40%, transparent); }
.seg--disc { box-shadow: inset 3px 0 0 var(--sys-cyan); }
.seg--gap { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--sys-red) 38%, transparent) 0 5px, transparent 5px 10px); }
.seg--part { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--sys-orange) 30%, transparent) 0 5px, transparent 5px 10px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sys-orange) 55%, transparent); }

.legend { list-style: none; display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0 0; padding: 0; font-size: 12.5px; color: var(--label-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw--normal { background: color-mix(in srgb, var(--accent) 34%, transparent); }
.sw--key { background: color-mix(in srgb, var(--sys-orange) 40%, transparent); }
.sw--disc { background: var(--fill-1); box-shadow: inset 3px 0 0 var(--sys-cyan); }
.sw--gap { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--sys-red) 38%, transparent) 0 4px, transparent 4px 8px); }
.sw--part { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--sys-orange) 30%, transparent) 0 4px, transparent 4px 8px); }

/* ==========================================================================
   JSON / 详情
   ========================================================================== */

.json, .detail {
  margin: 12px 0 0; padding: 14px; max-height: 460px; overflow: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--fill-1); border-radius: var(--r-md);
  white-space: pre; tab-size: 2; color: var(--label-2);
}
.detail { color: var(--accent); max-height: 300px; }

.foot { padding: 24px 0 40px; color: var(--label-3); font-size: 13px; }
.foot p { margin: 0; }
.foot code { font-family: var(--mono); font-size: 12px; color: var(--label-2); background: var(--fill-1); padding: 1px 6px; border-radius: 5px; }

.is-hidden { display: none !important; }

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

@media (max-width: 720px) {
  .wrap { width: min(1120px, 100% - 28px); }
  .top h1 { font-size: 17px; }
  .top p { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .t .uri { max-width: 130px; }
  .panel, .player-card { padding: 16px; border-radius: var(--r-lg); }
  .segmented__btn { padding: 7px 11px; font-size: 13px; }
  .player-meta code { max-width: 40ch; }
}

/* ==========================================================================
   无障碍：减弱动效 / 减弱透明度 / 高对比
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  /* 不做位移/弹簧，改为短交叉淡入 */
  .btn, .icon-btn, .segmented__btn, .seg, .drop { transition: opacity 200ms var(--ease-out), color 200ms var(--ease-out), background-color 200ms var(--ease-out) !important; }
  .btn:active, .icon-btn:active, .segmented__btn:active, .drop.is-over { transform: none !important; }
  .seg:hover { transform: none !important; }
  .quality-list { transform: none; transition: opacity 200ms var(--ease-out); }
}

@media (prefers-reduced-transparency: reduce) {
  .top, .quality-list { background: var(--bg-elevated); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  .panel, .player-card, .stat, .t td { background: var(--bg-base); }
  .top { border-bottom-color: var(--label); }
  .separator, .stats, .table-wrap { border-color: var(--label); }
  .note, .stat__k, .hint-inline { color: var(--label); }
}
