/*
 * 海内存知弹窗样式（2.12）：浅色「雾白」与深色「夜航」两套色板，跟随系统 prefers-color-scheme。
 * 组件只引用令牌，深色只重定义令牌，不在媒体查询里写组件颜色。
 * 层级靠间距、字重与少量状态色建立：B 站粉只给缓存主按钮，B 站蓝给选中、链接与进度；
 * 分隔一律用发丝线，不把每块内容都包成卡片（见 .impeccable.md）。
 */
:root {
  color-scheme: light;
  /* 雾白：白到浅灰的底、墨色文字。次要文字 #6b7480 在浅底上约 4.6:1，保证 11–12px 小字可读。 */
  --ink-strong: #1d2129;
  --ink: #4a5361;
  --ink-soft: #6b7480;
  --surface: #f7f8fa;
  --surface-raised: #ffffff;
  --surface-soft: #eef0f3;
  --shell-bg: linear-gradient(180deg, #ffffff 0, #f7f8fa 160px);
  --line: rgba(29, 33, 41, 0.08);
  --line-strong: rgba(29, 33, 41, 0.16);
  --blue: #00aeec;
  --blue-deep: #0088bb;
  --blue-wash: rgba(0, 174, 236, 0.1);
  --pink: #fb7299;
  --pink-deep: #f25d8a;
  /* 白字压在 #fb7299 上只有约 2.6:1；主按钮改用加深一档的同色相渐变（白字约 3.1–3.7:1），观感仍是 B 站粉。 */
  --pink-fill: linear-gradient(135deg, #f25d8a, #e64a7b);
  /* 小号粉色文字（画质卡片的 VIP/登录 标记）在白底上需要约 4.5:1。 */
  --pink-ink: #d63a6e;
  --pink-glow: 0 6px 16px -8px rgba(251, 114, 153, 0.7);
  --success: #0f9d74;
  --warning: #b97a10;
  --danger: #e03e3e;
  --danger-wash: rgba(224, 62, 62, 0.08);
  --value: var(--ink-strong);
  --selected-bg: var(--ink-strong);
  --selected-ink: #ffffff;
  --track-off: #d5d9df;
  --progress-wash: #e8f6fc;
  /* 进度填充 = 不透明实色 × 父层透明度 × 静态渐变遮罩（左 28% → 右 50% 的蓝），拆开的原因见 .button-progress。 */
  --progress-solid: rgb(0, 174, 236);
  --progress-alpha: 0.5;
  --progress-alpha-start: 0.56;
  /* 画质滑杆：普通档是 B 站蓝的渐变；顶档是一片由浅到深的海（见 .quality-row[data-top]）。 */
  --quality-fill: linear-gradient(90deg, rgba(0, 174, 236, 0.35), #00aeec);
  --sea: linear-gradient(90deg, #8fe3ff, #2bb3e6 45%, #1587c6);
  --sea-foam: rgba(255, 255, 255, 0.42);
  --sea-bubble: rgba(255, 255, 255, 0.8);
  --toast-bg: #1f2530;
  --toast-ink: #eef1f5;
  --toast-action: #6fd3f7;
  --menu-shadow: 0 12px 32px -12px rgba(20, 26, 36, 0.28);

  --gutter: 16px;
  --radius: 8px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* 带一点回弹的缓动：滑杆松手后拇指弹回档位、顶档的瓶子落定都用它。 */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* 画质滑杆专用：单调缓出、无过冲，拇指落档时稳而不飘。 */
  --glide: cubic-bezier(0.25, 1, 0.5, 1);
  /* 读取中的骨架与按钮上扫过的一道光。 */
  --shimmer: rgba(255, 255, 255, 0.7);
  --z-popover: 100;
  --z-toast: 200;
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", ui-monospace, Menlo, Consolas, monospace;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-strong);
  background: var(--surface);
}

/* 夜航：深墨蓝底与极淡的粉/青光晕；发丝线用白色低透明度，数值用青色。 */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink-strong: #e8ebf0;
    --ink: #b4bcc8;
    --ink-soft: #8a93a3;
    --surface: #0e121a;
    --surface-raised: #161b25;
    --surface-soft: #1d2331;
    --shell-bg:
      radial-gradient(120% 60% at 100% 0%, rgba(255, 107, 157, 0.1), transparent 60%),
      radial-gradient(90% 50% at 0% 0%, rgba(58, 210, 255, 0.08), transparent 55%),
      #0e121a;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.16);
    --blue: #3ad2ff;
    --blue-deep: #6fdcff;
    --blue-wash: rgba(58, 210, 255, 0.12);
    --pink: #ff6b9d;
    --pink-deep: #ff5590;
    --pink-fill: linear-gradient(135deg, #f8669a, #ea4580);
    --pink-ink: #ff7aa8;
    --pink-glow: 0 8px 22px -10px rgba(255, 85, 144, 0.8);
    --success: #3ddc97;
    --warning: #ffb547;
    --danger: #ff6b6b;
    --danger-wash: rgba(255, 107, 107, 0.12);
    --value: var(--blue-deep);
    --selected-bg: var(--surface-soft);
    --selected-ink: var(--ink-strong);
    --track-off: #2a3242;
    --progress-wash: var(--surface-soft);
    --progress-solid: rgb(58, 210, 255);
    --progress-alpha: 0.5;
    --progress-alpha-start: 0.44;
    --quality-fill: linear-gradient(90deg, rgba(58, 210, 255, 0.3), #3ad2ff);
    --sea: linear-gradient(90deg, #5fd9ff, #1f9fd6 45%, #0f5f9c);
    --sea-foam: rgba(255, 255, 255, 0.3);
    --shimmer: rgba(255, 255, 255, 0.07);
    --sea-bubble: rgba(255, 255, 255, 0.65);
    --toast-bg: #222a38;
    --toast-ink: #eef1f5;
    --toast-action: #6fdcff;
    --menu-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  width: 360px;
  max-width: 100%;
  margin: 0;
  background: var(--surface);
}

/* 弹窗内容一旦超过 Chrome 的 600px 高度上限（例如 Windows 的微软雅黑行高更大、画质折成两行、展开「详情」），
   Windows 上会出现 15px 的经典滚动条，并把内容向左挤。弹窗里不要滚动条：隐藏后内容仍可滚轮 / 键盘滚动，
   但不再占宽。scrollbar-width 管新版 Chrome，::-webkit-scrollbar 兜住其余。 */
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

button, a, input, summary { font: inherit; color: inherit; }
button { cursor: pointer; }
:is(button, a, input, summary):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p, dl, dd { margin: 0; }

/* 数字用正文字体的等宽数位：与中文混排时字距自然，心跳刷新时宽度也不跳。 */
.button-speed, .button-label, dd, .tab-count, .cover-status, .library-summary, .quality-size, .video-meta {
  font-variant-numeric: tabular-nums;
}

svg { flex: none; }
.caret {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 160ms var(--ease-out);
}

/* ---- 外壳与页眉 -------------------------------------------------------------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  padding: 0 var(--gutter);
  background: var(--shell-bg);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 6px;
}
.brand-lockup { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-icon { width: 20px; height: 20px; }
/* 主名与诗句同字号、同字距、不留间隙：缩小字号或加间距会让「己」脱离上半句，读成「名字 + 副标题」。
   区分只靠字重与颜色（--ink-soft 在浅/深色下都约 4.5:1），不用 opacity——它随底色漂移。 */
.brand-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; letter-spacing: 0.06em; white-space: nowrap; }
.brand-name { font-weight: 650; }
.brand-verse { color: var(--ink-soft); font-weight: 400; }

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color 140ms ease, color 140ms ease;
}
.icon-button:hover { background: var(--surface-soft); color: var(--ink-strong); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.settings-button[aria-expanded="true"] { background: var(--blue-wash); color: var(--blue-deep); }
.alert-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 1.5px var(--surface);
}

.text-button {
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.text-button:hover { color: var(--ink-strong); }
.text-button:disabled { color: var(--ink-soft); cursor: progress; }

/* ---- 一级导航：选中态是 1.5px 下划线，不铺整块底色 ------------------------------------ */

.panel-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-tabs button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 0 8px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  transition: color 140ms ease;
}
.panel-tabs button:hover { color: var(--ink-strong); }
.panel-tabs button[aria-selected="true"] { color: var(--ink-strong); }
.panel-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1.5px;
  border-radius: 1px;
  background: var(--blue);
}
.tab-count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 16px;
  text-align: center;
}
.panel-tabs button[aria-selected="true"] .tab-count { background: var(--blue-wash); color: var(--blue-deep); }

.health-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--danger-wash);
  border-radius: var(--radius);
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 12px;
}
.health-banner .text-button { color: var(--danger); }

.panel-stack { flex: 1; }
.panel-view { padding: 10px 0 8px; animation: panel-enter 180ms var(--ease-out); }
@keyframes panel-enter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---- 当前视频 --------------------------------------------------------------- */

.current-video { display: grid; gap: 10px; }
.current-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14.5px;
  font-weight: 640;
  line-height: 1.42;
  letter-spacing: 0.01em;
}
.current-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-top: -6px;
  color: var(--ink-soft);
  font-size: 12px;
}
.current-owner { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 读取页面时的骨架：形状与「内容切换 + 画质卡片」一致，识别完成后真实控件在同一位置出现，弹窗不跳高度。
   只看主按钮的 data-state="reading"（初始 HTML 就是它，脚本第一次设状态后就再也不会回来）。 */
.current-skeleton { display: none; gap: 8px; }
.current-video:has(.cache-button[data-state="reading"]) .current-skeleton { display: grid; }
.skeleton-bar { position: relative; display: block; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.skeleton-bar::after, .cache-button[data-state="reading"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 25%, var(--shimmer) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: shimmer-sweep 1.6s ease-in-out infinite;
}
.skeleton-mode { width: 156px; height: 32px; border-radius: 10px; }
.skeleton-card { display: grid; justify-items: center; gap: 6px; padding: 10px 14px 24px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-raised); }
.skeleton-name { width: 88px; height: 16px; }
.skeleton-size { width: 52px; height: 10px; }
.skeleton-track { justify-self: stretch; height: 26px; margin-top: 2px; }
.skeleton-card .skeleton-bar::after { animation-delay: 120ms; }
.skeleton-card .skeleton-track::after { animation-delay: 220ms; }
@keyframes shimmer-sweep { 60%, 100% { transform: translateX(100%); } }

.format-controls { display: grid; gap: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 内容二选一：等分的分段控件，选中项是一块抬起的浅色滑块。 */
.mode-row { display: flex; align-items: center; gap: 12px; }
.segmented {
  display: grid;
  flex: none;
  grid-template-columns: repeat(2, 76px);
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-soft);
}
.segmented button {
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.segmented button:hover { color: var(--ink-strong); }
.segmented button[aria-checked="true"] {
  background: var(--surface-raised);
  color: var(--ink-strong);
  box-shadow: 0 1px 2px rgba(20, 26, 36, 0.14), inset 0 0 0 1px var(--line);
}

/* 画质滑杆（像 ChatGPT 的推理强度控件）：上方居中是档位名与体积，下方一根粗杆，左低右高。
   几何与 src/popup.js 的 renderQualitySlider 一致：N 个档位等距排在 [拇指半径, 宽 - 拇指半径]，
   第 i 档在 --at = i / (N - 1)。原生 range 只铺在可选段（宽 = 拇指 + (总宽 - 拇指) × --q-reach），
   所以它的拇指与装饰档位点严格重合；锁定段画成斜纹、在 range 之外，拖不进去。
   填充用 clip-path 裁出长度：不改布局，渐变也不会随长度被拉伸。 */
.quality-row {
  display: grid;
  gap: 5px;
  padding: 7px 14px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-raised);
}
.quality-head { display: grid; justify-items: center; gap: 1px; min-width: 0; }
.quality-name { max-width: 100%; overflow: hidden; color: var(--blue-deep); font-size: 16px; font-weight: 750; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.quality-size { min-height: 15px; color: var(--ink-soft); font-size: 11.5px; line-height: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quality-row[data-empty="true"] .quality-name { color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.quality-row[data-empty="true"] :is(.quality-track, .quality-ends) { display: none; }
/* 拇指与填充共用同一个会过渡的 --q-pos：各自给 transform / clip-path 加过渡时，
   两者在主线程与合成线程上起步不同步，滑行中填充会拖在拇指后面（拖尾）。 */
@property --q-pos { syntax: "<number>"; inherits: true; initial-value: 1; }
.quality-track {
  transition: --q-pos 280ms var(--glide);
  --thumb: 22px;
  --span: calc(100% - var(--thumb));
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  /* 让拇指层用 cqw 按轨道宽度平移（transform 的百分比只认自身宽度）。 */
  container-type: inline-size;
}
/* 叠放：轨道上的档位点与锁定斜纹在最下，填充盖住已走过的档位点，range 在最上接收拖动。 */
.quality-fill {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: var(--quality-fill);
  clip-path: inset(0 calc(var(--span) * (1 - var(--q-pos, 1))) 0 0 round 999px);
}
.quality-locked {
  position: absolute;
  inset: 0 0 0 calc(var(--thumb) / 2 + var(--span) * var(--q-lock, 1));
  border-radius: 0 999px 999px 0;
  background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--ink-soft) 24%, transparent) 5px 7px);
}
.quality-stop {
  position: absolute;
  top: 50%;
  left: calc(var(--thumb) / 2 + var(--span) * var(--at));
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink-soft) 55%, transparent);
  pointer-events: none;
}
.quality-slider {
  position: absolute;
  z-index: 2;
  top: 0;
  left: calc(var(--span) * var(--q-offset, 0));
  width: calc(var(--thumb) + var(--span) * var(--q-reach, 1));
  height: 100%;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.quality-slider::-webkit-slider-runnable-track { height: 100%; background: transparent; }
/* 原生拇指透明：它只负责命中、键盘与读屏，位置仍按整档吸附（value 是档位序号）。 */
.quality-slider::-webkit-slider-thumb {
  width: var(--thumb);
  height: var(--thumb);
  margin-top: 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.quality-slider:focus-visible { outline: none; }
/* 看得见的拇指。--q-pos 是它的位置（0–1，与档位坐标同一套）：拖动时由脚本按指针连续写入、关掉过渡，
   于是它跟手而不是一格一格地跳；松手后 --q-pos 移到最近档位，用无过冲的缓出落定，停稳后才切换档位。
   外层只有拇指大小、只做 translateX（距离用 cqw 按轨道宽算；铺满轨道再平移会撑出弹窗的横向滚动），圆钮画在 ::before 上：
   悬停 / 按住用 transform 缩放，「过档」与「登顶」的弹跳用独立的 scale / rotate 属性，两者叠加互不覆盖。 */
.quality-knob, .quality-splash {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: var(--thumb);
  height: 100%;
  pointer-events: none;
  transform: translateX(calc((100cqw - var(--thumb)) * var(--q-pos, 1)));
}
.quality-track[data-dragging="true"] { transition: none; }
.quality-knob::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 0;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(10, 16, 28, 0.28), 0 0 0 1px rgba(10, 16, 28, 0.06);
  transition: transform 160ms var(--ease-out), box-shadow 160ms ease;
}
.quality-slider:not(:disabled):hover + .quality-knob::before { transform: scale(1.06); }
.quality-track[data-dragging="true"] .quality-knob::before { transform: scale(1.16); box-shadow: 0 3px 10px rgba(10, 16, 28, 0.3), 0 0 0 1px rgba(10, 16, 28, 0.06); }
.quality-slider:focus-visible + .quality-knob::before { box-shadow: 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--blue); }
/* 拖过一个档位时拇指轻轻一跳，像碰到了一格刻度。 */
.quality-knob.is-tick::before { animation: knob-tick 220ms var(--ease-out); }
@keyframes knob-tick { 40% { scale: 1.14; } }
/* 下载中不能换档：整根杆变淡，浪与气泡也停下。 */
.quality-slider:disabled { cursor: default; }
.quality-track:has(.quality-slider:disabled) { opacity: 0.6; }
.quality-ends { display: flex; justify-content: space-between; padding: 0 2px; color: var(--ink-soft); font-size: 10.5px; line-height: 13px; }
.quality-ends span:only-child, .quality-ends span:empty + span { margin-left: auto; }
.quality-ends [data-locked="true"] { color: var(--pink-ink); }

/* 顶档 = 漂流瓶漂到了最远处：杆身是一片由浅到深的海，
   ::before 是水面的浪（两层错位的波纹缓缓向右推），::after 是水里往上冒的气泡，拇指里是一只漂流瓶。
   只切 data-top，节点常驻：轮询刷新不会让动画从头开始（AGENTS 8.1）。两种动画都只动 transform。
   无缝循环：一圈平移的距离（40px）必须同时是两层波纹花纹宽度（40px、20px）的整数倍，气泡同理（26px），
   否则每圈结束时花纹会「跳」一下，看起来像动画被截断。 */
.quality-row[data-top="true"] .quality-fill { background: var(--sea); }
.quality-row[data-top="true"] .quality-fill::before {
  --swell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 26'%3E%3Cpath fill='%23fff' d='M0 9Q10 4 20 9T40 9V0H0Z'/%3E%3C/svg%3E");
  --ripple: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 26'%3E%3Cpath fill='%23fff' d='M0 6Q5 9 10 6T20 6V0H0Z'/%3E%3C/svg%3E");
  content: "";
  position: absolute;
  inset: 0 0 0 -40px;
  background: var(--sea-foam);
  -webkit-mask: var(--swell) 0 0 / 40px 26px repeat-x, var(--ripple) 0 4px / 20px 26px repeat-x;
  mask: var(--swell) 0 0 / 40px 26px repeat-x, var(--ripple) 0 4px / 20px 26px repeat-x;
  animation: quality-tide 3.2s linear infinite;
}
.quality-row[data-top="true"] .quality-fill::after {
  content: "";
  position: absolute;
  inset: 0 0 -26px;
  background:
    radial-gradient(circle at 14px 20px, transparent 0 1.6px, var(--sea-bubble) 1.7px 2.3px, transparent 2.5px),
    radial-gradient(circle at 41px 30px, var(--sea-bubble) 0 1.1px, transparent 1.5px),
    radial-gradient(circle at 63px 14px, transparent 0 1.2px, var(--sea-bubble) 1.3px 1.8px, transparent 2px),
    radial-gradient(circle at 88px 38px, var(--sea-bubble) 0 0.9px, transparent 1.3px);
  background-size: 104px 26px;
  opacity: 0.85;
  animation: quality-bubbles 4.8s linear infinite;
}
.quality-row[data-top="true"] .quality-name {
  background: linear-gradient(90deg, #2bb3e6, #1587c6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* 拇指里的漂流瓶：与工具栏图标同一个倾斜瓶身（线稿版），白色圆钮不变，深浅色下都清晰。 */
.quality-row[data-top="true"] .quality-knob::before {
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg transform='translate(16 16.5) rotate(38) scale(0.9) translate(-16 -16)' fill='none' stroke='%231587c6' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M13 6.5V8.5Q13 10 11.5 11Q7.5 13 7.5 17.5V26Q7.5 30 11.5 30H20.5Q24.5 30 24.5 26V17.5Q24.5 13 20.5 11Q19 10 19 8.5V6.5'/%3E%3Crect x='11.5' y='2' width='9' height='4.5' rx='1.5' fill='%23E9A15B' stroke='none'/%3E%3Cpath d='M8 21Q12 19 16 21T24 21'/%3E%3C/g%3E%3C/svg%3E") center / 14px no-repeat;
}
.quality-track:has(.quality-slider:disabled) .quality-fill::before,
.quality-track:has(.quality-slider:disabled) .quality-fill::after { animation-play-state: paused; }
@keyframes quality-tide { to { transform: translateX(40px); } }
@keyframes quality-bubbles { to { transform: translateY(-26px); } }

/* 登顶：从次高档升到最高档的那一下（只在用户操作时，脚本加 .is-surging，约 0.8 秒后摘掉）。
   一道白浪头从左到右扫过整片海、海面闪亮一下，漂流瓶被托起来猛弹一下再落定，脚下溅开一圈水花和水滴，
   画质名字跟着一跳，整张卡片外沿荡开一圈海蓝的光。全部是一次性动画，只动 transform / opacity / filter。 */
.quality-surge {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 46%, rgba(255, 255, 255, 0.95) 52%, transparent 66%);
  opacity: 0;
  transform: translateX(-100%);
}
.quality-splash::before, .quality-splash::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 0;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  opacity: 0;
}
.quality-splash::before { border: 2px solid #2bb3e6; }
.quality-splash::after {
  background:
    radial-gradient(circle at 50% 4%, #2bb3e6 0 1.6px, transparent 2px),
    radial-gradient(circle at 92% 30%, #8fe3ff 0 1.4px, transparent 1.8px),
    radial-gradient(circle at 88% 82%, #2bb3e6 0 1.2px, transparent 1.6px),
    radial-gradient(circle at 12% 80%, #8fe3ff 0 1.4px, transparent 1.8px),
    radial-gradient(circle at 6% 28%, #2bb3e6 0 1.2px, transparent 1.6px);
}
.quality-row.is-surging { animation: surge-glow 820ms ease-out; }
.quality-row.is-surging .quality-name { animation: surge-name 560ms var(--spring); }
.quality-row.is-surging .quality-track { animation: surge-thump 420ms var(--ease-out); }
.quality-row.is-surging .quality-fill { animation: surge-flash 760ms ease-out; }
.quality-row.is-surging .quality-surge { animation: surge-sweep 680ms cubic-bezier(0.2, 0.7, 0.3, 1); }
.quality-row.is-surging .quality-knob::before { animation: surge-bottle 720ms var(--ease-out); }
.quality-row.is-surging .quality-splash::before { animation: surge-ring 640ms ease-out 90ms; }
.quality-row.is-surging .quality-splash::after { animation: surge-drops 700ms ease-out 90ms; }
@keyframes surge-glow { 0% { box-shadow: 0 0 0 0 rgba(43, 179, 230, 0.5); } 100% { box-shadow: 0 0 0 12px rgba(43, 179, 230, 0); } }
@keyframes surge-name { 0% { scale: 0.86; } 45% { scale: 1.18; } 100% { scale: 1; } }
@keyframes surge-thump { 30% { translate: 0 2px; } 60% { translate: 0 -1.5px; } 100% { translate: 0 0; } }
@keyframes surge-flash { 0% { filter: brightness(1.45) saturate(1.2); } 100% { filter: none; } }
@keyframes surge-sweep { 0% { opacity: 1; transform: translateX(-100%); } 100% { opacity: 0.2; transform: translateX(100%); } }
@keyframes surge-bottle {
  0% { scale: 1; rotate: 0deg; }
  28% { scale: 1.6; rotate: -22deg; }
  52% { scale: 0.86; rotate: 12deg; }
  74% { scale: 1.12; rotate: -5deg; }
  100% { scale: 1; rotate: 0deg; }
}
@keyframes surge-ring { 0% { opacity: 0.9; scale: 0.7; } 100% { opacity: 0; scale: 2.8; } }
@keyframes surge-drops { 0% { opacity: 1; scale: 0.6; } 70% { opacity: 0.9; } 100% { opacity: 0; scale: 2.4; } }

/* 账号说明：画质下方一行小字，未登录时右侧是「去登录」。 */
.auth-note { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; margin-top: -2px; padding: 0 2px; color: var(--ink-soft); font-size: 12px; line-height: 1.4; }
.auth-note[hidden] { display: none; }
.auth-note-text { min-width: 0; }
.auth-note[data-tone="warning"] { color: var(--warning); }
.auth-action { flex: none; padding: 0; border: 0; background: transparent; color: var(--blue-deep); font-size: 12px; font-weight: 650; white-space: nowrap; }
.auth-action:hover { text-decoration: underline; }
.account-chip { margin-left: auto; padding: 0 7px; border-radius: 999px; background: color-mix(in srgb, var(--pink) 14%, transparent); color: var(--pink-ink); font-size: 11px; font-weight: 700; line-height: 19px; cursor: default; }

.audio-row { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-soft); }
.audio-row-label { color: var(--ink-soft); font-size: 12px; }
.audio-summary { color: var(--ink-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }


/* 主按钮：空闲时粉色动作，下载时蓝色进度从左向右填充（只动 transform，不引起布局抖动）。
   暂停按钮叠在它右侧；下载中给主按钮右侧让出位置，文字不会被盖住。 */
.cache-control { position: relative; }
.cache-button {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 52px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: var(--pink-fill);
  color: #ffffff;
  box-shadow: var(--pink-glow);
  transition: transform 160ms var(--ease-out), filter 160ms ease, box-shadow 160ms ease;
}
.cache-button:not(:disabled):hover { filter: brightness(0.96); transform: translateY(-1px); }
.cache-button:not(:disabled):active { transform: translateY(1px) scale(0.99); }
.cache-button:disabled { background: var(--surface-soft); color: var(--ink-soft); box-shadow: none; cursor: not-allowed; }
.cache-button:is([data-state="downloading"], [data-state="paused"], [data-state="error"]) { background: var(--progress-wash); color: var(--ink-strong); box-shadow: inset 0 0 0 1px var(--line); }
.cache-button[data-state="downloading"] { cursor: progress; }
.cache-button[data-state="complete"] { background: var(--surface-soft); color: var(--success); box-shadow: inset 0 0 0 1px var(--line); cursor: default; }
/* 进度填充的右缘是一道缓慢起伏的水波（漂流瓶意象）。
   - 用 translateX 平移整块而不是 scaleX：缩放会把右缘波纹压扁；两者都只动 transform，不引起布局抖动。
   - 实色填充（::before）与波纹（::after）都是不透明子层、交界重叠 1px；半透明由父层 opacity 与静态渐变遮罩
     统一给出。若两层各自半透明，交界的亚像素会露出一条深色或浅色的缝。
   - 波纹只对 ::after 做 translateY 循环（合成层动画）。节点常驻，进度每次刷新只改 --progress-ratio，
     动画不会重启（AGENTS 8.1；npm run test:popup 校验）。暂停 / 出错时水面停住。 */
.button-progress {
  --wave: 9px;
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: calc(100% + var(--wave));
  opacity: var(--progress-alpha);
  transform: translateX(calc((var(--progress-ratio, 0) - 1) * (100% - var(--wave))));
  -webkit-mask: linear-gradient(90deg, rgba(0, 0, 0, var(--progress-alpha-start)), #000);
  mask: linear-gradient(90deg, rgba(0, 0, 0, var(--progress-alpha-start)), #000);
  transition: transform 420ms var(--ease-out);
}
.button-progress::before { content: ""; position: absolute; inset: 0 calc(var(--wave) - 1px) 0 0; background: var(--progress-solid); }
.button-progress::after {
  --wave-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 18'%3E%3Cpath d='M0 0H5Q9 4.5 5 9T5 18H0Z'/%3E%3C/svg%3E");
  content: "";
  position: absolute;
  top: -18px;
  bottom: 0;
  right: 0;
  width: var(--wave);
  background: var(--progress-solid);
  -webkit-mask: var(--wave-svg) 0 0 / var(--wave) 18px repeat-y;
  mask: var(--wave-svg) 0 0 / var(--wave) 18px repeat-y;
  animation: progress-tide 2.4s linear infinite;
}
.cache-button:is([data-state="paused"], [data-state="error"]) .button-progress::after { animation-play-state: paused; }
@keyframes progress-tide { to { transform: translateY(18px); } }
.cache-button:is([data-state="idle"], [data-state="complete"], [data-state="disabled"], [data-state="reading"]) .button-progress { opacity: 0; }
/* 读取页面：不是进度（没有水波），只是一道光从左到右扫过，漂流瓶在文字前轻轻摇晃，表示「正在找」。 */
.cache-button[data-state="reading"] { background: var(--surface-soft); color: var(--ink-soft); box-shadow: none; cursor: progress; }
.cache-button[data-state="reading"] .button-glyph { display: block; transform-origin: 50% 70%; animation: glyph-bob 1.8s ease-in-out infinite; }
@keyframes glyph-bob { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-2px) rotate(8deg); } }
.button-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 650;
}
.cache-control:has(.pause-button:not([hidden])) .button-content { padding-right: 54px; }
.button-text { display: grid; justify-self: start; gap: 1px; min-width: 0; text-align: left; }
.button-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.button-label { white-space: nowrap; }
/* 漂流瓶字形只在「开始」（空闲）与「收到」（已缓存）两个时刻出现；下载中不分散对数字的注意。 */
.button-glyph { display: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cache-button:is([data-state="idle"], [data-state="complete"]) .button-glyph { display: block; }
.button-glyph .glyph-sea { opacity: 0.7; }
.button-glyph .glyph-letter { display: none; opacity: 0.8; }
.cache-button[data-state="complete"] .glyph-sea { display: none; }
.cache-button[data-state="complete"] .glyph-letter { display: inline; }
.cache-button[data-state="complete"] .glyph-cork { fill: currentColor; }
.button-sub { font-size: 11px; font-weight: 500; opacity: 0.7; white-space: nowrap; }
.button-sub:empty { display: none; }
.button-content:has(.button-speed:empty) { grid-template-columns: 1fr; }
.button-content:has(.button-speed:empty) .button-text { justify-self: center; text-align: center; }
.button-content:has(.button-speed:empty) .button-title { justify-content: center; }
/* 暂停 / 出错没有速度列，但仍按下载中的版式左对齐，切换状态时文字不跳到中间。 */
.cache-button:is([data-state="paused"], [data-state="error"]) .button-content .button-text { justify-self: start; text-align: left; }
.cache-button:is([data-state="paused"], [data-state="error"]) .button-content .button-title { justify-content: flex-start; }
.cache-button[data-state="idle"] .button-label { font-size: 15px; letter-spacing: 0.1em; }
.button-speed { justify-self: end; min-width: 8.5ch; font-size: 12px; font-weight: 600; text-align: right; white-space: nowrap; opacity: 0.86; }
.button-speed:empty { display: none; }

.pause-button {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-raised) 80%, transparent);
  color: var(--ink-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transform: translateY(-50%);
  transition: background-color 140ms ease, transform 140ms var(--ease-out);
}
.pause-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pause-button:hover:not(:disabled) { background: var(--surface-raised); transform: translateY(-50%) scale(1.06); }
.pause-button:active:not(:disabled) { transform: translateY(-50%) scale(0.95); }
.pause-button:disabled { cursor: progress; opacity: 0.5; }

.action-hint { margin-top: -4px; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.action-hint[data-tone="error"] { color: var(--danger); }

/* ---- 提前加载 --------------------------------------------------------------- */

.preload { display: grid; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.preload-head { display: flex; align-items: center; gap: 8px; }
.preload-head h3 { font-size: 12.5px; font-weight: 640; letter-spacing: 0.04em; white-space: nowrap; }

.status-pill {
  display: inline-flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-pill::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--track-off); }
.status-pill[data-state="active"]::before { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }
.status-pill[data-state="warning"] { color: var(--warning); }
.status-pill[data-state="warning"]::before { background: var(--warning); }

.switch, .switch-input {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--track-off);
  transition: background-color 160ms ease;
}
.switch > span, .switch-input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  transition: transform 160ms var(--ease-out);
}
.switch[aria-checked="true"], .switch-input:checked { background: var(--blue); }
.switch[aria-checked="true"] > span, .switch-input:checked::after { transform: translateX(14px); }
.switch-input { appearance: none; cursor: pointer; }

/* 概览：三个数字装进一个发丝线细框，中间用竖线分隔。 */
.assist-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-raised) 70%, transparent);
}
.assist-summary div { min-width: 0; padding: 6px 10px 7px; }
.assist-summary div + div { border-left: 1px solid var(--line); }
.assist-summary dt { color: var(--ink-soft); font-size: 10.5px; letter-spacing: 0.04em; }
.assist-summary dd { overflow: hidden; color: var(--value); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; text-overflow: ellipsis; white-space: nowrap; }

/* 标题行里的「详情」开关：文字 + 小箭头，展开时箭头翻转。 */
.details-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 1px;
  padding: 2px 2px 2px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  transition: color 140ms ease;
}
.details-toggle:hover { color: var(--ink-strong); }
.details-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }

/* 详细数据：读数表——标签左、数值右，中间点线引导视线对齐。 */
.assist-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; margin-top: 4px; }
.assist-metrics div { display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 2px 0; }
.assist-metrics div::before {
  content: "";
  order: 1;
  flex: 1;
  min-width: 12px;
  border-bottom: 1px dotted var(--line-strong);
  transform: translateY(-3px);
}
.assist-metrics dt { order: 0; flex: none; color: var(--ink-soft); font-size: 11.5px; cursor: help; }
.assist-metrics dd { order: 2; overflow: hidden; color: var(--value); font-size: 12px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.assist-metrics :is(.assist-node, .assist-trouble) { grid-column: 1 / -1; }
.assist-metrics .is-warning dd { color: var(--warning); }
.assist-metrics .assist-node dd { max-width: 70%; font-family: var(--mono); font-size: 10.5px; font-weight: 500; }

/* ---- 片库 ------------------------------------------------------------------- */

.library-summary { margin-bottom: 2px; color: var(--ink-soft); font-size: 12px; }
/* 评价邀请卡片：grid 行高 0fr→1fr 展开收起，高度不用写死；收起时 inert（见 popup.html）。 */
.review-card {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: grid-template-rows 280ms var(--ease-out), opacity 200ms ease, transform 280ms var(--ease-out), margin 280ms var(--ease-out);
}
.review-card[data-open="true"] { grid-template-rows: 1fr; margin-bottom: 10px; opacity: 1; transform: none; pointer-events: auto; }
.review-card-inner { display: grid; gap: 8px; min-height: 0; overflow: hidden; }
.review-card[data-open="true"] .review-card-inner { padding: 10px 12px; border-radius: 10px; background: var(--blue-wash); box-shadow: inset 0 0 0 1px var(--line); }
.review-copy strong { font-size: 13px; font-weight: 620; }
.review-copy p { margin-top: 2px; color: var(--ink); font-size: 12px; line-height: 1.45; }
.review-actions { display: flex; align-items: center; gap: 14px; }
.review-go {
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--selected-bg);
  color: var(--selected-ink);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  transition: filter 140ms ease, transform 140ms var(--ease-out);
}
.review-go:hover { filter: brightness(1.12); }
.review-go:active { transform: scale(0.97); }
.video-list { display: grid; }
.video-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.video-item:last-child { border-bottom: 0; }
/* 封面来自 B 站图床：离线观看、图床被墙或任务没带封面时只剩底色，所以底色本身要像一张「视频占位」
   （淡蓝渐变 + 播放三角），而不是一块灰。img 设为定位元素，加载成功时盖住占位图形。 */
.cover-wrap {
  position: relative;
  width: 72px;
  height: 45px;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue-wash), transparent 75%), var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
.cover-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 12px;
  height: 14px;
  margin: auto;
  background: var(--line-strong);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  /* 三角形重心在左 1/3，几何居中看起来偏左，右移 1px 做视觉居中。 */
  transform: translateX(1px);
}
.cover-wrap img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.cover-status {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(10, 14, 20, 0.72);
  color: #f2f4f7;
  font-size: 10px;
  line-height: 15px;
}
.video-copy { display: grid; gap: 3px; min-width: 0; }
.video-link {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-link:hover { color: var(--blue-deep); text-decoration: none; }
.video-meta { overflow: hidden; color: var(--ink-soft); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.video-owner { color: var(--ink-soft); }
.video-item[data-status="error"] .video-state { color: var(--danger); }
.item-progress { height: 2px; overflow: hidden; border-radius: 1px; background: var(--surface-soft); }
.item-progress > span {
  display: block;
  height: 100%;
  transform: scaleX(var(--progress-ratio, 0));
  transform-origin: left center;
  background: var(--blue);
  transition: transform 420ms var(--ease-out);
}
.video-item:is([data-status="paused"], [data-status="error"]) .item-progress > span { background: var(--ink-soft); opacity: 0.5; }

.video-actions { display: flex; gap: 2px; }
.item-action {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  transition: color 140ms ease, background-color 140ms ease;
}
.item-action svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.item-action:hover:not(:disabled) { background: var(--surface-soft); color: var(--ink-strong); }
.save-button:hover:not(:disabled), .toggle-button:hover:not(:disabled) { background: var(--blue-wash); color: var(--blue-deep); }
.delete-button:hover:not(:disabled) { background: var(--danger-wash); color: var(--danger); }
.item-action:active:not(:disabled) { transform: scale(0.94); }
.item-action:disabled { cursor: wait; opacity: 0.45; }
.save-button:is(:hover, :focus-visible):not(:disabled) .download-arrow { animation: download-arrive 360ms var(--ease-out) both; }
@keyframes download-arrive { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.trash-lid { transform-origin: 7px 7px; transition: transform 180ms var(--ease-out); }
.delete-button:is(:hover, :focus-visible):not(:disabled) .trash-lid { transform: translateY(-1.5px) rotate(-8deg); }

.empty-state { display: grid; justify-items: center; gap: 4px; padding: 36px 0 28px; text-align: center; }
.empty-state strong { font-size: 13.5px; font-weight: 620; }
.empty-state p { color: var(--ink-soft); font-size: 12px; }

/* ---- 设置 ------------------------------------------------------------------- */

.settings-head { display: flex; align-items: center; gap: 8px; margin: -6px 0 6px -8px; }
.settings-head h2 { font-size: 14.5px; font-weight: 640; letter-spacing: 0.02em; }
.settings-group { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-group:last-child { border-bottom: 0; }
.settings-group h3 { color: var(--ink-soft); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.settings-group-head { display: flex; align-items: center; justify-content: space-between; }
.setting-note { color: var(--ink-soft); font-size: 11.5px; line-height: 1.5; }
.setting-note code { padding: 0 4px; border-radius: 4px; background: var(--surface-soft); font-family: var(--mono); font-size: 10.5px; }

.appearance { display: grid; gap: 6px; }
.timeline-preview { display: flex; height: 4px; margin-top: 4px; overflow: hidden; border-radius: 2px; }
.preview-played { width: 28%; background: var(--played-color, #00a1d6); }
.preview-native { width: 18%; background: #aeb8c1; }
.preview-preheat { width: 34%; background: var(--preheat-color, #ff8a1f); }
.preview-empty { width: 20%; background: var(--surface-soft); }
.timeline-legend { display: flex; gap: 14px; color: var(--ink-soft); font-size: 11px; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.timeline-legend b { font-weight: inherit; }
.timeline-legend i { width: 6px; height: 6px; border-radius: 50%; }
.legend-played { background: var(--played-color, #00a1d6); }
.legend-native { background: #aeb8c1; }
.legend-preheat { background: var(--preheat-color, #ff8a1f); }
.appearance[data-highlight="false"] :is(.preview-preheat, .legend-preheat) { background: #aeb8c1; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; font-size: 13px; }
.color-input { width: 32px; height: 22px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-raised); cursor: pointer; }

.preheat-controls { min-width: 0; margin: 0; padding: 0; border: 0; }
.preheat-controls legend { margin-bottom: 8px; padding: 0; font-size: 13px; }
.preheat-controls:disabled { opacity: 0.45; }
.preheat-controls:disabled :is(button, input, label) { cursor: default; }
.swatch-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.swatches { display: flex; gap: 8px; }
.swatches button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch-color);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatches button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink-strong); }
.custom-color { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border: 1px solid var(--line-strong); border-radius: 14px; font-size: 12px; cursor: pointer; }
.custom-color[data-selected="true"] { border-color: var(--ink-strong); }
.custom-color input { width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.custom-color input::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.setting-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.health-status { font-size: 12px; }
.health-status[data-state="ok"] { color: var(--success); }
.health-status[data-state="failed"] { color: var(--danger); }
.health-status[data-state="checking"] { color: var(--ink-soft); }
.health-list { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.5; }
.health-list:empty { display: none; }
.health-list strong { margin-right: 6px; font-weight: 620; }

.about-list { display: grid; gap: 4px; font-size: 12px; }
.about-list div { display: flex; justify-content: space-between; gap: 12px; }
.about-list dt { color: var(--ink-soft); }

/* ---- 页脚与提示 ------------------------------------------------------------- */

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}
.app-footer-link { color: var(--ink-soft); }

.toast {
  position: fixed;
  z-index: var(--z-toast);
  right: var(--gutter);
  bottom: 12px;
  left: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 12px;
  box-shadow: var(--menu-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms var(--ease-out);
}
.toast[data-visible="true"] { opacity: 1; pointer-events: auto; transform: none; }
.toast-action { padding: 2px 4px; border: 0; background: transparent; color: var(--toast-action); font-size: 12px; font-weight: 700; white-space: nowrap; }
.toast-action:hover { filter: brightness(1.15); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .download-arrow { animation: none !important; }
  /* 无限循环的水波、画质顶档的浪与气泡在全局 0.01ms 时长下会变成高频闪烁，必须直接停掉（渐变保留，只是不动）。 */
  .button-progress::after, .quality-fill::before, .quality-fill::after,
  .skeleton-bar::after, .cache-button[data-state="reading"]::after, .cache-button[data-state="reading"] .button-glyph { animation: none !important; }
  /* 登顶与过档的弹跳、水花在减少动态时整组不播，只保留顶档的配色。 */
  .quality-row.is-surging, .quality-row.is-surging *, .quality-row.is-surging *::before, .quality-row.is-surging *::after, .quality-knob.is-tick::before { animation: none !important; }
  .quality-track { transition: none !important; }
}
