/* 斗鱼式浅色页面 + 橙色强调；视频控件使用独立深色面板。 */
* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --bg: #f4f5f7; --bg2: #ffffff; --panel: #ffffff; --panel-2: #f7f8fa;
  --line: #e5e6eb; --line-soft: #eceef1;
  --text: #333333; --muted: #76777b; --faint: #92949a;
  --accent: #ff5d23; --accent-hover: #ff763f; --accent-soft: #fff1e9;
  --danger: #e34c4c;
  --player-panel: #242424; --player-panel-hover: #333333;
  --player-text: #ffffff; --player-muted: #b9b9b9; --player-line: rgba(255, 255, 255, .12);
  --radius: 6px; --radius-sm: 6px;
  /* UTLIVED数据监控站主色：仅「返回数据站」按钮用，和数据站/三团选人页统一 */
  --ds-blue: #2563eb; --ds-blue-hover: #1d4ed8; --ds-blue-soft: #eff6ff; --ds-text: #334155; --ds-line: #e2e8f0;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input { font-family: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(31, 35, 41, .035);
  position: sticky; top: 0; z-index: 60;
}
.topbar-start { display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; flex: none; display: block; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand-tag { color: var(--faint); font-size: 12px; padding-left: 2px; }
/* 「返回数据站」胶囊按钮（顶栏最左） */
.back-link { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 12px; border: 1px solid var(--ds-line); border-radius: 999px; background: #fff; color: var(--ds-text); font-size: 13px; font-weight: 500; line-height: 1; text-decoration: none; white-space: nowrap; transition: border-color .12s, color .12s, background .12s; }
.back-link svg { width: 16px; height: 16px; flex: none; display: block; }
.back-link:hover { border-color: var(--ds-blue); color: var(--ds-blue); background: var(--ds-blue-soft); }
.back-link:active { border-color: var(--ds-blue-hover); color: var(--ds-blue-hover); }
.back-link:focus-visible { outline: 2px solid var(--ds-blue); outline-offset: 2px; }
/* 顶栏一行：按钮区固定约 815px。窄桌面把「直播监控」叠到 UTLIVED 下面(不藏)，按钮依次缩成「数据站」→ 32px 圆形图标；手机顶栏换行，文字完整 */
@media (max-width: 1119px) {
  .topbar-start { gap: 10px; }
  .brand { display: grid; grid-template-columns: auto auto; column-gap: 10px; row-gap: 1px; align-items: center; }
  .brand .logo { grid-row: span 2; }
  .brand-name { line-height: 17px; }
  .brand-tag { font-size: 11px; line-height: 13px; padding-left: 0; }
}
@media (min-width: 641px) and (max-width: 1055px) { .back-verb { display: none; } }
@media (min-width: 641px) and (max-width: 1023px) { .back-text { display: none; } .back-link { padding: 0; } }
.controls { display: flex; align-items: center; gap: 10px; }

.layouts { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.layouts button { background: transparent; color: var(--muted); border: 0; border-radius: 6px; padding: 5px 11px; cursor: pointer; font-size: 13px; transition: background .12s, color .12s; }
.layouts button:hover { color: var(--text); }
.layouts button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 13px; cursor: pointer; font-size: 13px; transition: border-color .12s, color .12s, background .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); }
.follow-btn { display: inline-flex; align-items: center; gap: 6px; }
.follow-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.follow-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.follow-btn[aria-expanded=true] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
/* 关注快捷下拉：窄单列，按钮到面板之间留有悬停桥。 */
.favorites-dropdown { position: fixed; width: min(340px, calc(100vw - 24px)); z-index: 65; display: flex; flex-direction: column; padding: 16px;
  background: var(--panel); border: 1px solid var(--line-soft); border-top: 4px solid var(--accent); border-radius: 6px;
  box-shadow: 0 12px 36px rgba(31, 35, 41, .18); }
.favorites-dropdown[hidden] { display: none; }
.favorites-dropdown::before { content: ''; position: absolute; top: -18px; left: 0; right: 0; height: 18px; }
.favorites-dropdown::after { content: ''; position: absolute; left: var(--favorites-arrow, 50%); top: -12px; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 9px solid var(--accent); }
.favorites-tabs { display: flex; flex: none; overflow: hidden; background: var(--panel-2); border-radius: 5px; margin-bottom: 10px; }
.favorites-tabs button { flex: 1; border: 0; background: transparent; padding: 10px 4px; color: var(--muted); font-size: 13px; cursor: pointer; }
.favorites-tabs button.active { background: var(--accent); color: #fff; font-weight: 600; }
.favorites-list { max-height: 330px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.favorites-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 4px; border: 0; border-radius: 4px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.favorites-row:hover { background: var(--accent-soft); }
.favorites-row .anchor-avatar { width: 42px; height: 42px; font-size: 18px; }
.favorites-detail { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.favorites-detail strong { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.favorites-detail > span { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.favorites-state { flex: none; font-size: 11px; color: var(--faint); }
.favorites-state.online { color: var(--accent); }
.favorites-all { width: 100%; flex: none; margin-top: 12px; padding: 10px; }
.favorites-empty { text-align: center; font-size: 13px; line-height: 1.7; padding: 24px 8px; color: var(--muted); }
.favorites-empty .btn { display: block; margin: 12px auto 0; }
.wall-fullscreen { display: inline-flex; align-items: center; gap: 6px; }
.wall-fullscreen .player-icon { width: 17px; height: 17px; }
.wall-fullscreen[aria-pressed=true] { color: var(--accent); }

/* ---------- 网格 ---------- */
/* 备案：固定在视口底部的细底栏（大厂做法），不再跟在内容/单个直播间下面 */
.beian { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: flex; gap: 16px; justify-content: center; align-items: center; flex-wrap: wrap; padding: 8px 14px; background: var(--bg2); border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.beian a { color: var(--faint); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.beian a:hover { color: var(--muted); }
.beian img { height: 14px; }

.grid { display: grid; gap: 10px; padding: 12px 12px 52px; } /* 底部留白，内容不被固定备案栏遮住 */
.layout-1 { grid-template-columns: 1fr; max-width: 1320px; margin: 0 auto; }
.layout-4 { grid-template-columns: repeat(2, 1fr); }
.layout-6 { grid-template-columns: repeat(3, 1fr); }
.layout-9 { grid-template-columns: repeat(3, 1fr); }
.layout-12 { grid-template-columns: repeat(4, 1fr); }

.cell { position: relative; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; transition: border-color .12s; container-type: inline-size; }
.cell:hover { border-color: var(--line); }
.cell.playing { border-color: #d9dce1; }
.cell-video, .cell-video video { position: absolute; inset: 0; width: 100%; height: 100%; }
.cell-video { cursor: grab; }
.cell-video video { object-fit: contain; background: #000; }

/* 焦点布局：左边大画面 + 右边一列小窗（其余流仍在播）。双击小窗切换主画面，Esc 还原。 */
.grid.focus-mode { display: flex; gap: 10px; padding: 12px; height: calc(100vh - 96px); align-items: stretch; } /* 96 = 顶栏 + 底部备案栏 */
.focus-main { flex: 1; min-width: 0; display: flex; }
.focus-main .cell { width: 100%; height: 100%; aspect-ratio: auto; }
.focus-rail { width: 300px; flex: none; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.focus-rail .cell { width: 100%; aspect-ratio: 16 / 9; flex: none; }
.focus-rail .cell.playing::after { content: "双击放大"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 12px; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .12s; pointer-events: none; z-index: 8; }
.focus-rail .cell.playing:hover::after { opacity: 1; }
.focus-rail .focus-add-slot { border-style: dashed; border-color: #d9dce1; }
.focus-rail .focus-add-slot .cell-empty { background: var(--panel); }
.backdrop, .backdrop.hidden { display: none; }

/* ---------- 整墙全屏：去掉顶栏 + 备案，监控墙填满并居中；格子按行平分(16:9，网格尺寸由 JS 精算) ---------- */
body:fullscreen { display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; }
body:fullscreen .topbar, body:fullscreen .beian { display: none; }
body:fullscreen .grid { margin: 0; padding: 6px; gap: 6px; max-width: none; } /* 覆盖单布局的 max-width:1320，全屏才不被卡宽 */
body:fullscreen .grid.layout-1 { grid-template-rows: 1fr; }
body:fullscreen .grid.layout-4 { grid-template-rows: repeat(2, 1fr); }
body:fullscreen .grid.layout-6 { grid-template-rows: repeat(2, 1fr); }
body:fullscreen .grid.layout-9 { grid-template-rows: repeat(3, 1fr); }
body:fullscreen .grid.layout-12 { grid-template-rows: repeat(3, 1fr); }
body:fullscreen .grid:not(.focus-mode) .cell { aspect-ratio: auto; min-height: 0; } /* 只改普通网格；焦点布局的小窗保持 16:9，别被压塌 */
body:fullscreen .grid.focus-mode { height: 100vh; width: 100vw; } /* 焦点布局全屏时也填满 */

/* 单路全屏：那一格铺满屏幕(视频等比居中、弹幕/控件跟着上) */
.cell:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; background: #000; }

/* 空格子 */
.cell-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--bg2); border: 0; cursor: pointer; color: var(--muted); font-size: 13px; }
.cell-empty .plus { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 24px; line-height: 1; color: var(--faint); transition: .12s; }
.cell-empty.add:hover { color: var(--text); }
.cell-empty.add:hover .plus { border-color: var(--accent); color: var(--accent); }
.cell-empty.error .big { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--danger); border: 1.5px solid rgba(255, 84, 104, .4); }
.cell-empty.offline .big { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; color: var(--muted); border: 1.5px solid var(--line); }
.cell-empty .who { font-size: 12.5px; font-weight: 600; color: var(--text); max-width: 84%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-empty .msg { font-size: 12.5px; }
.cell-empty.error .msg { color: var(--danger); }
.cell-empty.offline .msg { color: var(--muted); }
.cell-empty .err-actions { display: flex; gap: 8px; margin-top: 2px; }
.cell-state-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); cursor: pointer; font-size: 15px; transition: color .12s, border-color .12s, background .12s; }
.cell-state-close:hover { color: var(--danger); border-color: var(--danger); background: #fff0f0; }
.cell-state-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* LIVE 角标 */
.cell .live-badge { position: absolute; top: 8px; left: 8px; z-index: 6; display: inline-flex; align-items: center; gap: 5px; max-width: calc(100% - 56px); background: rgba(0, 0, 0, .38); color: var(--player-text); backdrop-filter: blur(3px); padding: 3px 9px 3px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 600; opacity: .62; transition: opacity .15s; }
.cell:hover .live-badge { opacity: .92; } /* 悬停时恢复清晰，方便看名字 */
.cell .live-badge .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .live-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; animation: livepulse 2.4s ease-out infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(255, 93, 35, .5); } 70% { box-shadow: 0 0 0 5px rgba(255, 93, 35, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 93, 35, 0); } }
/* 房间数据角标：真实人数 · 贵宾人数 · 礼物总值（素净小字，无数据时不显示） */
.cell-stat { position: absolute; top: 8px; right: 8px; z-index: 6; max-width: calc(100% - 16px); font-size: 11px; line-height: 1.5; color: rgba(255, 255, 255, .72); background: rgba(0, 0, 0, .4); backdrop-filter: blur(3px); padding: 1px 8px; border-radius: 999px; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.cell-stat:empty { display: none; }

/* 悬停操作条 */
.cell-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 16px 12px 6px; color: var(--player-text); background: linear-gradient(0deg, rgba(0, 0, 0, .9), rgba(0, 0, 0, .62) 65%, transparent); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; z-index: 7; }
.cell:hover .cell-bar, .cell:focus-within .cell-bar, .cell.in-replay .cell-bar { opacity: 1; transform: none; }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 0 0 100%; min-width: 0; color: var(--player-muted); font-size: 11px; }
.replay-controls[hidden], .danmaku-layer[hidden] { display: none; }
.replay-time { font-variant-numeric: tabular-nums; }
.replay-range { appearance: none; -webkit-appearance: none; flex: 1; min-width: 30px; height: 18px; margin: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }
.replay-range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--accent) 0 var(--replay-fill, 100%), rgba(255, 255, 255, .3) var(--replay-fill, 100%) 100%); }
.replay-range::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; border: 0; margin-top: -3.5px; background: var(--accent); }
.replay-range::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .3); }
.replay-range::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
.replay-range::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--accent); }
.replay-range:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.replay-live { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 3px; padding: 3px 5px; background: transparent; color: var(--accent); cursor: pointer; font-size: 11px; white-space: nowrap; }
.replay-live::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.replay-live:hover:not(:disabled) { background: rgba(255, 93, 35, .15); }
.replay-live:disabled { color: var(--player-text); background: transparent; cursor: default; opacity: .8; }
.replay-message { flex: 0 0 100%; color: #ffd59d; }
.replay-message:empty { display: none; }
.cell.in-replay .live-badge i { background: #ffc15a; animation: none; }
.cell-grip { position: absolute; top: 8px; right: 8px; z-index: 10; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255, 255, 255, .18); border-radius: 8px;
  display: grid; place-items: center; background: rgba(10, 13, 17, .72); color: #fff; opacity: 0; transform: translateY(-3px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .35); backdrop-filter: blur(4px); cursor: grab; touch-action: none; user-select: none;
  transition: opacity .15s, transform .15s, background .12s, border-color .12s; }
.cell-grip span { display: block; font-size: 21px; line-height: 1; transform: translateY(-1px); }
.cell.playing:hover .cell-grip, .cell-grip:focus-visible, .cell.dragging .cell-grip { opacity: 1; transform: none; }
.cell-grip:hover { background: var(--accent); border-color: var(--accent); }
.cell-grip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cell-grip:active { cursor: grabbing; }
.grid.layout-1 .cell-grip { display: none; } /* 单路无从排序，隐藏拖拽手柄，别挡画面 */
.cell.dragging { opacity: .55; transform: scale(.992); z-index: 12; }
.cell.drop-target { outline: 3px solid var(--accent); outline-offset: -3px; box-shadow: inset 0 0 0 2px rgba(255, 93, 35, .32); }
body.sorting, body.sorting * { cursor: grabbing !important; user-select: none !important; }
.cell-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; width: 100%; gap: 4px 12px; }
.cell-actions-left, .cell-actions-right { display: inline-flex; align-items: center; gap: 8px; }
.cell-actions-right { margin-left: auto; }
.cell-actions button { background: transparent; border: 0; color: var(--player-text); min-width: 30px; height: 32px; padding: 0 4px; border-radius: 3px; cursor: pointer; font-size: 12.5px; line-height: 1; display: grid; place-items: center; transition: color .12s, background .12s; }
.cell-actions button:hover { background: rgba(255, 255, 255, .07); color: var(--accent); }
.cell-actions button.on { background: transparent; color: var(--accent); }
.cell-actions button:focus-visible { outline: 1px solid #fff; outline-offset: 1px; }
.player-icon { width: 21px; height: 21px; display: block; pointer-events: none; }
.cell-actions [data-act=fav].on .player-icon { fill: currentColor; }
.cell-actions [data-act=close] { color: var(--player-muted); }
.cell-actions [data-act=close]:hover { color: #ff8c8c; }
.player-divider { width: 1px; height: 15px; background: rgba(255, 255, 255, .2); margin: 0 2px; }
/* 每路音量：悬停静音键 → 上方弹出【竖向】音量滑条 + 顶部数值（对齐大厂播放器） */
.vol-wrap { position: relative; display: inline-flex; }
.vol-pop { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(4px); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--player-panel); border: 1px solid var(--player-line); border-radius: 4px; padding: 10px 8px; box-shadow: 0 -8px 24px -8px rgba(0, 0, 0, .5);
  opacity: 0; visibility: hidden; transition: opacity .14s, transform .14s, visibility .14s; }
.vol-pop::before { content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px; } /* 悬停桥：跨过与按钮的间隙 */
.vol-wrap.open .vol-pop { opacity: 1; visibility: visible; transform: translateX(-50%); }
.vol-val { color: var(--player-text); font-size: 12px; font-weight: 600; min-width: 22px; text-align: center; }
.vol-range { writing-mode: vertical-lr; direction: rtl; width: 22px; height: 96px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* 弹幕层（纯白、无用户名、右往左滚动） */
.danmaku-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 6; }
.dm { position: absolute; left: 0; white-space: nowrap; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .95), 0 0 3px rgba(0, 0, 0, .85); will-change: transform; }

/* 顶栏「弹幕」一键开关：带滑动开关特效，开/关一眼可见 */
.dm-toggle { display: inline-flex; align-items: center; gap: 7px; }
.dm-toggle .sw { width: 28px; height: 16px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.dm-toggle .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.dm-toggle.on .sw { background: var(--accent); }
.dm-toggle.on .sw::after { transform: translateX(12px); background: #fff; }

/* 弹幕设置面板：每路独立，浮动定位到所悬浮/点击的那一格「弹」按钮旁 */
.dm-control { position: relative; display: inline-flex; }
.dm-settings { --panel: var(--player-panel); --panel-2: var(--player-panel-hover); --line: var(--player-line); --text: var(--player-text); --muted: var(--player-muted); --accent-soft: rgba(255, 93, 35, .12); color-scheme: dark; position: fixed; left: 0; top: 0; width: 282px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 14px 16px; box-shadow: 0 20px 50px -16px rgba(0, 0, 0, .5); opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .14s, transform .14s, visibility .14s; z-index: 90; }
.dm-settings.show { opacity: 1; visibility: visible; transform: none; }
/* 操作条里「弹」按钮：点击开关弹幕；关闭时叠一道斜杠，状态一眼可见 */
.cell-actions [data-act=dm] { position: relative; }
.cell-actions [data-act=dm]:not(.on)::after { content: ''; position: absolute; left: 50%; top: 50%; width: 23px; height: 1.5px; border-radius: 2px;
  background: currentColor; transform: translate(-50%, -50%) rotate(-45deg); pointer-events: none; box-shadow: 0 0 2px rgba(0, 0, 0, .95); }
/* 每路清晰度：底部操作条里的清晰度按钮（带文字）+ 向上弹出的自绘深色菜单 */
.q-wrap { position: relative; display: inline-flex; }
.cell-actions .q-act { width: auto; min-width: 0; padding: 0 5px; font-size: 12px; white-space: nowrap; }
.q-menu { position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 30; display: flex; flex-direction: column; gap: 2px;
  min-width: 108px; background: var(--player-panel); border: 1px solid var(--player-line); border-radius: 4px; padding: 5px;
  box-shadow: 0 -8px 30px -8px rgba(0, 0, 0, .7); }
.q-menu[hidden] { display: none; }
.cell-actions .q-menu button { display: block; width: 100%; min-width: 0; height: auto; padding: 8px 12px; text-align: left;
  white-space: nowrap; background: transparent; color: var(--player-muted); border-radius: 3px; font-size: 13px; transition: background .12s, color .12s; }
.cell-actions .q-menu button:hover { background: var(--player-panel-hover); color: var(--player-text); }
.cell-actions .q-menu button.active { color: var(--accent); }
.cell.menu-open { overflow: visible; z-index: 20; } /* 让向上的菜单在矮格子里不被裁、并盖在邻格之上 */
.dm-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.dm-row span { width: 56px; flex: none; color: var(--text); }
.dm-row b { width: 38px; text-align: right; color: var(--muted); font-weight: 500; }
.dm-row input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.dm-pos-title { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.dm-pos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dm-pos button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 12px; padding: 7px 0; cursor: pointer; transition: border-color .12s, color .12s, background .12s; }
.dm-pos button:hover { color: var(--text); }
.dm-pos button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 选台面板 ---------- */
.picker { position: fixed; inset: 0; background: rgba(31, 35, 41, .42); display: flex; align-items: center; justify-content: center; z-index: 70; }
.picker.hidden { display: none; }
.picker-card { width: min(820px, 94vw); max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; box-shadow: 0 24px 70px -20px rgba(31, 35, 41, .25); }
.picker-head { display: flex; justify-content: space-between; align-items: center; font-weight: 650; font-size: 20px; }
.picker-head .btn { font-size: 20px; padding: 2px 7px; }
.picker-hint { font-size: 13px; color: var(--muted); margin: 8px 0 20px; line-height: 1.6; }
.picker-input { display: flex; border: 2px solid var(--accent); border-radius: 6px; overflow: hidden; margin-bottom: 20px; }
.picker-input[hidden], .picker-tabs[hidden], .preset-search[hidden], .picker-more[hidden], .anchor-card[hidden] { display: none; }
.picker-input input { flex: 1; min-width: 0; background: var(--panel); border: 0; padding: 12px 14px; color: var(--text); font-size: 14px; }
.picker-input input::placeholder { color: var(--faint); }
.picker-input input:focus { outline: 0; box-shadow: inset 0 0 0 1px var(--accent-soft); }
.picker-input .btn { border: 0; border-radius: 0; min-width: 86px; font-size: 15px; }
.picker-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.picker-tabs { display: flex; gap: 24px; }
.picker-tabs button { padding: 10px 0 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; white-space: nowrap; }
.picker-tabs button.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.preset-search { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; margin-bottom: 12px; color: var(--text); font-size: 13px; }
.preset-search:focus { outline: 0; border-color: var(--accent); }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.picker-status { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.picker-status:empty { display: none; }
.picker-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.anchor-card { display: flex; flex-direction: column; min-width: 0; gap: 12px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px; padding: 16px; transition: border-color .12s, background .12s; }
.anchor-card:hover { border-color: #ffd0bc; background: #fffaf7; }
.anchor-main { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; color: var(--text); cursor: pointer; }
.anchor-avatar { position: relative; display: grid; place-items: center; width: 60px; height: 60px; flex: none; overflow: hidden; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 22px; }
.anchor-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.anchor-details { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.anchor-details .pname { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anchor-status, .anchor-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anchor-card.online .anchor-status { color: var(--accent); }
.anchor-actions { display: flex; gap: 8px; padding-left: 72px; }
.anchor-actions button { border: 1px solid var(--line); border-radius: 4px; padding: 5px 12px; background: var(--panel); font-size: 12px; color: var(--muted); cursor: pointer; }
.anchor-actions .anchor-add { color: var(--accent); border-color: #ffd0bc; background: var(--accent-soft); }
.anchor-actions button:hover, .anchor-actions .anchor-follow.on { border-color: var(--accent); color: var(--accent); }
.picker-more { display: block; margin: 20px auto 0; min-width: 120px; }
.picker-more:disabled { opacity: .6; cursor: wait; }
.picker-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 32px 8px; grid-column: 1 / -1; }
@media (max-width: 640px) {
  .picker-card { padding: 18px; }
  .picker-presets { grid-template-columns: 1fr; }
  .picker-tabs { gap: 16px; }
  .picker-tabs button { font-size: 13px; }
  .picker-input .btn { min-width: 64px; }
}

/* ---------- 触摸设备：无 hover，操作条/角标常显 ---------- */
@media (hover: none) {
  .cell-bar { opacity: 1; transform: none; }
  .cell.playing .live-badge { opacity: .62; } /* 触摸端也保持淡一点，别太抢 */
  .cell.playing .cell-grip { opacity: .5; transform: none; } /* 触摸端常显但调淡，减少遮挡；拖动时(.dragging)自动恢复 */
  .cell.dragging .cell-grip { opacity: 1; }
  .cell-grip { width: 40px; height: 40px; }
  .grid:not(.layout-1) .cell-stat { right: 52px; } /* 多路时角标让开右上的手柄，不再被盖 */
}

/* ---------- 手机窄屏适配 ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .controls { flex-wrap: wrap; gap: 6px; }
  .brand-tag { display: none; }
  .btn, .layouts button { padding: 6px 9px; font-size: 12px; }
  .grid { padding: 8px 8px 52px; gap: 8px; }
  /* 多列布局在手机上会挤成细条 → 统一单列竖排，可上下滚动 */
  .grid.layout-4, .grid.layout-6, .grid.layout-9, .grid.layout-12 { grid-template-columns: 1fr; }
  /* 焦点布局：上方大画面 + 下方一条横向滚动小窗 */
  .grid.focus-mode { flex-direction: column; height: auto; }
  .focus-main { display: block; }
  .focus-main .cell { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .focus-rail { width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .focus-rail .cell { width: 150px; flex: none; }
  .dm-settings { width: min(282px, 92vw); }
  .cell-actions button { min-width: 30px; height: 30px; }
  .focus-rail .cell-grip { top: 6px; right: 6px; }
}

/* 小窗仍保留所有操作；缩小间距，必要时自动分成两行。 */
@container (max-width: 440px) {
  .cell-bar { padding: 13px 8px 4px; }
  .cell-actions { gap: 2px 6px; }
  .cell-actions-left, .cell-actions-right { gap: 3px; }
  .cell-actions button { min-width: 25px; height: 28px; padding: 0 3px; }
  .player-icon { width: 18px; height: 18px; }
  .player-divider { margin: 0 1px; }
  .cell-actions .q-act { font-size: 11px; }
}
@container (max-width: 250px) {
  .cell-actions-right { width: 100%; justify-content: space-between; gap: 1px; }
  .cell-actions button { min-width: 20px; padding: 0 1px; }
  .player-icon { width: 16px; height: 16px; }
  .player-divider { display: none; }
  .replay-controls { gap: 4px; }
}
