/* Standalone "fvplayer-style" player — ẩn controls native YouTube, custom bar + phụ đề tương tác. */
:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --bg-elev: #171a21;
  --card: #1a1e26;
  --card-2: #21252f;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --accent: #ff0033;
  --accent-glow: rgba(255, 0, 51, 0.35);
  --radius: 14px;
}

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

html, body { background: var(--bg); color: var(--text); }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(1100px 480px at 15% -10%, rgba(255, 0, 51, 0.13), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ---- Header ---- */
.pv-header {
  max-width: 960px;
  margin: 0 auto;
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}
.pv-brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .01em;
}
.pv-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  border-radius: 7px;
  text-indent: .06em;
}
.pv-brandname em {
  font-style: normal;
  color: var(--accent);
  font-weight: inherit;
  margin-left: .18rem;
}
.pv-nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.pv-nav a,
.pv-nav button {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--card);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.pv-nav a:hover, .pv-nav button:hover { border-color: var(--accent); }
.pv-nav .ft-star-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pv-nav .ft-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 .3em;
  margin-left: .35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
}

/* ---- Layout ---- */
.pv-main {
  max-width: 960px;
  margin: 0 auto;
  padding: .4rem 1.1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.pv-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
/* Player card co/giãn theo người dùng (kéo góc dưới-phải): về flex column,
   .pv-player lấp phần còn lại, .pv-controls giữ đáy. */
.pv-card.pv-resized {
  display: flex;
  flex-direction: column;
  height: 360px;
}
.pv-card.pv-resized .pv-player {
  padding-top: 0;
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.pv-card.pv-resized .pv-controls {
  flex: 0 0 auto;
}
.pv-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text-dim);
  opacity: .6;
  cursor: ns-resize;
  touch-action: none;
  z-index: 12;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius) 0 0 0;
}
.pv-resize svg { width: 18px; height: 18px; }
.pv-resize:hover, .pv-resize:focus-visible { opacity: 1; color: var(--accent); }

/* ---- Chuyển giao diện player: tùy chỉnh ⇄ kiểu YouTube (như Downloader) ---- */
.pv-mode {
  position: absolute;
  top: .5rem;
  left: .5rem;
  width: 32px;
  height: 32px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 50%;
  color: #fff;
  opacity: .85;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .12s, border-color .12s;
}
.pv-mode svg { width: 16px; height: 16px; }
.pv-mode:hover, .pv-mode:focus-visible { opacity: 1; border-color: var(--accent); color: var(--accent); }

.pv-native {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
  background: #000;
  display: none;
}
/* Chế độ kiểu Downloader: hiện embed native (controls YouTube gốc), ẩn toàn bộ
   UI tùy chỉnh (shield, controls bar) + embed cũ. Nút `.pv-resize` vẫn hiệu lực
   trong native mode (user yêu cầu) nên KHÔNG nằm trong list ẩn. */
#pv-card.native-mode .pv-native { display: block; }
#pv-card.native-mode #pv-frame,
#pv-card.native-mode .pv-bigplay,
#pv-card.native-mode .pv-controls { display: none !important; }

/* ---- Ads (footer) ---- */
.ads-footer {
  max-width: 960px;
  margin: 0 auto 1rem;
  padding: 1rem 1.1rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 1rem;
}

/* ---- Player khung + nút phát lớn ---- */
.pv-player {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 56.25%;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}
.pv-player iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}
.pv-bigplay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .38);
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pv-bigplay svg {
  width: 74px;
  height: 74px;
  padding: 20px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .5);
  opacity: 1;
  transition: transform .12s ease, background .12s;
}
.pv-bigplay:hover svg { transform: scale(1.06); }
/* Shield luôn hiện (chặn logo/More-videos), chỉ ẩn nút play khi đang phát */
.pv-bigplay.playing { background: transparent; cursor: default; }
.pv-bigplay.playing svg { display: none; }

/* ---- Thanh điều khiển tùy chỉnh ---- */
.pv-controls {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1rem;
  background: var(--bg-soft);
}
.pv-pbtn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.pv-pbtn:hover { color: var(--accent); border-color: var(--accent); }
.pv-pbtn .ic { width: 20px; height: 20px; fill: currentColor; }
.pv-pbtn.playing .ic-play { display: none; }
.pv-pbtn:not(.playing) .ic-pause { display: none; }

/* Nút transport: rewind / back 5s / fwd 5s */
.pv-xbtn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-xbtn:hover { color: var(--accent); border-color: var(--accent); }
.pv-xbtn .ic { width: 17px; height: 17px; fill: currentColor; }
/* Mute: .muted → hiện icon câm (.) */
.pv-xbtn.muted .ic-vol { display: none; }
.pv-xbtn:not(.muted) .ic-mute { display: none; }

/* Playback rate */
.pv-rates-wrap { position: relative; flex: 0 0 auto; }
.pv-rate {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 .6rem 0 .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-rate:hover, .pv-rate.open { color: var(--accent); border-color: var(--accent); }
.pv-rate-caret { width: 12px; height: 12px; fill: currentColor; }
.pv-rates-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  min-width: 78px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .35rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.pv-rate-item {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: .38rem .6rem;
  border-radius: 7px;
  font-size: .84rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.pv-rate-item:hover { background: var(--card-2); }
.pv-rate-item.on { background: var(--accent); color: #fff; }

.pv-seek {
  flex: 1 1 auto;
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.pv-seek-bg {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}
.pv-seek-prog {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
}
.pv-seek-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  margin-left: -5px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .55);
  transform: scale(0);
  transition: transform .12s;
  pointer-events: none;
}
.pv-seek:hover .pv-seek-thumb,
.pv-seek.dragging .pv-seek-thumb { transform: scale(1); }

.pv-time {
  flex: 0 0 auto;
  font-size: .85rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Lỗi ---- */
.pv-err {
  color: #ffb4c0;
  background: rgba(255, 0, 51, .08);
  border: 1px solid rgba(255, 0, 51, .3);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .9rem;
  display: none;
}
.pv-err:not(:empty) { display: block; }

/* ---- Thông tin video ---- */
.pv-info { position: relative; padding: 1rem 1.1rem; }
.pv-info-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-info-close:hover { color: var(--accent); border-color: var(--accent); }
.pv-info-close .ic { width: 16px; height: 16px; fill: currentColor; }
.pv-title {
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
  padding-right: 2rem;
}
.pv-meta {
  margin-top: .35rem;
  font-size: .9rem;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.pv-dot { color: var(--border); }
.pv-id {
  margin-top: .35rem;
  font-size: .78rem;
  color: var(--text-dim);
}
.pv-id code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .08rem .4rem;
  font-size: .76rem;
}
.pv-info .pv-id { padding-right: 2.4rem; }
/* link kênh trong meta → search channelid (giống downloader). */
.pv-meta a.dl-meta-author {
  color: var(--text-dim);
  text-decoration: none;
  transition: color .12s;
}
.pv-meta a.dl-meta-author:hover { color: var(--accent); }
/* Favourite Star trong thẻ info — GÓC DƯỚI-PHẢI (góc trên-phải đã có nút đóng). */
.pv-info .ft-star {
  top: auto;
  bottom: 1.05rem;
  right: 1rem;
}
.pv-info .pv-meta { padding-right: 2.4rem; }

/* ---- Phụ đề song ngữ ---- */
.pv-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem .9rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.pv-pick-wrap {
  flex: 1 1 0;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.pv-pick-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pv-pick-wrap select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%239aa3b2'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 9px center;
  background-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .45rem 2.1rem .45rem .75rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.pv-pick-wrap select:focus,
.pv-pick-wrap select:hover { border-color: var(--accent); outline: none; }
.pv-pick-wrap select:disabled { opacity: .5; cursor: default; }
.pv-pick-wrap select:disabled:hover { border-color: var(--border); }

/* Nút hoán đổi 2 phụ đề */
.pv-swap {
  flex: none;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-swap .ic { width: 17px; height: 17px; fill: currentColor; }
.pv-swap:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-soft); }

/* Checkbox gộp panel */
.pv-checks {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  white-space: nowrap;
}
.pv-combined-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  padding-bottom: .45rem;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.pv-combined-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.pv-combined-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
}
.pv-combined-toggle:hover .pv-combined-label { color: var(--text); }

.pv-content {
  display: flex;
  flex-direction: column;
}
.pv-sub-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pv-sub-search-pad {
  flex: 0 0 auto;
}
.pv-sub-group {
  max-height: 36vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
/* KHÔNG dùng `transition: height` ở đây: khi co panel theo active line, height
   animate → clientHeight nhỏ dần → maxTop còn bé → trình duyệt clamp scrollTop
   xuống → active line bị đẩy ra khỏi đáy panel trong lúc co. Đã test, bỏ. */
.pv-sub-sec { border-top: 1px solid var(--border); }
.pv-sub-pri .pv-line-text { font-weight: 600; }

/* Chế độ gộp panel (dòng trên-dòng dưới trong 1 panel) */
.pv-content.pv-combined .pv-sub-col-sec { display: none; }
.pv-content.pv-combined .pv-sub-pri {
  max-height: 72vh;
  border-top: none;
}
.pv-pair { border-bottom: 1px solid var(--border); }
/* 2 dòng phụ đề trên-dưới sát nhau hơn: ngôn ngữ 1 padding-bottom nhỏ, ngôn ngữ 2 padding-top rất nhỏ */
.pv-pair .pv-line { padding-top: .1rem; padding-bottom: .12rem; }
.pv-pair .pv-line-sec { padding-top: .02rem; padding-bottom: .3rem; }

.pv-pair .pv-line-sec .pv-line-text { font-weight: 500; }
/* Chế độ gộp: timestamp nằm HORIZONTAL phía TRÊN phụ đề (một dòng riêng, trái)
   thay vì nằm bên trái dòng text — flex-wrap đẩy .pv-line-time xuống dòng riêng.
   .pv-line-time-ph (placeholder ẩn của ngôn ngữ 2) vẫn giữ nguyên 1 dòng cùng độ cao
   để text ngôn ngữ 2 xếp đúng cột ngang với ngôn ngữ 1. */
.pv-line-time-ph { visibility: hidden; }
.pv-content.pv-combined .pv-pair .pv-line {
  flex-wrap: wrap;
  row-gap: .08rem;
}
.pv-content.pv-combined .pv-pair .pv-line-time {
  flex: 0 0 100%;
  padding-top: 0;
}

.pv-empty,
.pv-loading {
  padding: .8rem 1.1rem;
  color: var(--text-dim);
  font-size: .88rem;
}

/* Spinner chờ nạp thông tin + transcripts — phong cách giống Downloader (.state) */
.pv-waiting {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-dim);
}
.pv-waiting[hidden] { display: none; }

.pv-waiting .state-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.pv-waiting p { margin: 0 0 0.35rem; color: var(--text-dim); }

.pv-waiting .state-main {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.pv-spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid var(--border, #2a2f3a);
  border-top-color: var(--accent);
  animation: pv-spin 0.8s linear infinite;
}

@keyframes pv-spin { to { transform: rotate(360deg); } }

/* Dòng phụ đề */
.pv-line {
  display: flex;
  gap: .75rem;
  padding: .4rem .9rem;
  border-left: 3px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.pv-line:hover { background: var(--card-2); }
.pv-line-time {
  flex: 0 0 auto;
  font-size: .7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding-top: .2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.pv-line-text { flex: 1 1 auto; font-size: .96rem; word-break: break-word; }
.pv-line.pv-active {
  border-left-color: var(--accent);
  background: var(--card);
}
.pv-line.pv-active .pv-line-time { 
  color: var(--accent);
}
.pv-line.pv-active .pv-line-text {
  font-size: 1.06em;
  font-weight: bold;
  background: #fffccf;
  color: #584300;
}
/* Dòng ngôn ngữ 2 nhỏ + nhạt hơn; có timestamp (2-panel) hoặc không (gộp).
   Active: list 1 nền #fffccf, list 2 nền #fffcde, cả hai chữ #584300, timestamp accent. */
.pv-line-sec .pv-line-text { font-size: .88rem; opacity: .92; }
.pv-line-sec.pv-active .pv-line-text { font-size: .88rem; opacity: 1; background: #fffcde; color: #584300; }

/* Mục tiêu nhảy Enter/Shift+Enter trong search */
.pv-line.pv-curr {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.pv-line.pv-hidden { display: none !important; }

/* Search trong transcript (row dưới mỗi panel — không sticky; Copy nằm ngoài pill) */
.pv-sub-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .45rem .7rem .7rem;
}
.pv-sub-search-box {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: .28rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
}
.pv-sub-search-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: var(--text-dim);
}
.pv-sub-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  font-size: .82rem;
  padding: .35rem 0;
}
.pv-sub-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.pv-sub-search-count {
  flex: 0 0 auto;
  font-size: .7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pv-sub-search-clear {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .72rem;
  line-height: 1;
  padding: .25rem;
  border-radius: 50%;
  transition: color .12s;
}
.pv-sub-search-clear:hover { color: var(--accent); }
.pv-sub-copy {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: .7rem;
  font-weight: 600;
  padding: .28rem .62rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.pv-sub-copy:hover { color: var(--accent); border-color: var(--accent); }
.pv-sub-copy.copied { color: #22a05b; border-color: #22a05b; }
/* Nút Pause/Resume trong panel (trước Copy) */
.pv-pause-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: .7rem;
  font-weight: 600;
  padding: .28rem .62rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-pause-btn .ic { width: 12px; height: 12px; fill: currentColor; flex: none; }
.pv-pause-btn:hover { color: var(--accent); border-color: var(--accent); }
.pv-pause-btn.playing { color: var(--text); }
.pv-pause-btn:not(.playing) .ic-pause { display: none; }
.pv-pause-btn.playing .ic-play { display: none; }
.pv-content.pv-no-time .pv-line-time { display: none; }
mark {
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 0 2px;
}

.pv-sub-group::-webkit-scrollbar { width: 9px; }
.pv-sub-group::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid var(--card);
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .pv-picks { gap: .55rem .7rem; }
  .pv-checks {
    flex: 1 1 100%;
    gap: 1.2rem;
    padding-bottom: .15rem;
  }
}

@media (max-width: 560px) {
  .pv-header { padding: .7rem .8rem; }
  .pv-main { padding: .35rem .8rem 2.5rem; }
  .pv-nav a,
  .pv-nav button { padding: .3rem .65rem; font-size: .78rem; }
  .pv-bigplay svg { width: 62px; height: 62px; padding: 16px; }
  .pv-controls { padding: .5rem .75rem; gap: .55rem; }
  .pv-pbtn { width: 34px; height: 34px; }
  .pv-xbtn { width: 30px; height: 30px; }
  .pv-mode { width: 30px; height: 30px; top: .24rem; left: .24rem; }
  .pv-rate { height: 30px; font-size: .74rem; padding: 0 .5rem 0 .6rem; }
  .pv-time { font-size: .78rem; }
  .pv-line { padding: .36rem .7rem; }
  .pv-pause-btn .pv-pause-label { display: none; }
  .pv-pause-btn { padding: .28rem .5rem; }
}

/* ---- Anonymous Playlist / Favorites (★) ---- */
.ft-star {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: transform 0.15s, color 0.15s, background 0.15s;
}
.ft-star svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  pointer-events: none;
}
.ft-star:hover { transform: scale(1.12); background: rgba(0, 0, 0, 0.8); }
.ft-star.on { color: #ffbc06; }
.ft-star.on svg { fill: #ffbc06; stroke: #ffbc06; }
.ft-star--top {
  top: 1rem;
  right: 1rem;
  bottom: auto;
}

/* nút scroll lên đầu trang (đồng bộ trang chủ) */
.scroll-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  z-index: 40;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: background .15s, border-color .15s, transform .15s, opacity .2s;
}
.scroll-top:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}
.scroll-top[hidden] { display: none; }

/* ---- Pull-to-refresh (iOS standalone PWA — Safari tắt gesture gốc) ---- */
.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  z-index: 999;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s ease;
  opacity: 0;
  transform: translateY(-60px);
}
.ptr-indicator.ptr-armed {
  opacity: 1;
}
.ptr-indicator svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ptr-indicator.ptr-armed svg {
  animation: ptr-spin 0.7s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---- FT panel modal ---- */
.ft-backdrop {
  position: fixed;
  z-index: 1150;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.ft-panel {
  position: fixed;
  z-index: 1200;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  will-change: transform;
  width: min(430px, calc(100vw - 2rem));
  max-height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.ft-panel[hidden], .ft-backdrop[hidden] { display: none; }
/* Khoá trang khi Playlist mở: body không cuộn + overscroll containment — chống
   scroll-chain từ .ft-panel-body tràn ra trang / khối nội dung (phụ đề) bên dưới trên
   MỌI trình duyệt (iOS cũ bỏ qua overscroll-behavior → overflow:hidden là hàng rào
   cuối). Backdrop + panel phủ toàn màn (z-index 1150+) nên mọi phần tử bên dưới không
   thể nhận gesture nữa. */
body.ft-panel-open {
  overflow: hidden;
  overscroll-behavior: contain;
}
/* iOS cuộn documentElement chứ KHÔNG cuộn <body> — body overflow:hidden là chưa đủ,
   trang phía sau vẫn giãn/rubber-band được và "nuốt" gesture khi chạm panel (playlist
   đơ tới khi vuốt ra ngoài ép scroll → repaint). Phải khoá luôn html. */
html.ft-panel-open {
  overflow: hidden;
  overscroll-behavior: contain;
}
.ft-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .95rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.ft-panel-head h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.ft-panel-head h2 svg { width: 16px; height: 16px; fill: #ffbc06; stroke: #ffbc06; vertical-align: -2px; }
.ft-panel-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: .4rem;
  line-height: 1;
}
.ft-panel-close:hover { color: var(--text); }
/* Nút đảo ngược thứ tự — NGAY TRƯỚC nút x. Ở trang player .pv-pl-modes đã giữ
   margin-left:auto (đẩy cả cụm pl-modes + rev + x về mép phải) nên rev override
   margin-left:0 để không tạo khe hở giữa pl-modes và nút x. */
.ft-panel-rev {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  line-height: 0;
  margin-left: 0;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.ft-panel-rev svg { width: 15px; height: 15px; fill: currentColor; flex: none; }
.ft-panel-rev:hover { color: var(--accent); border-color: var(--accent); }
/* Nút chế độ phát playlist (CHỈ trang player — inject bởi player.js). */
.pv-pl-modes { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.pv-pl-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  line-height: 0;
  transition: color .12s, border-color .12s, background-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.pv-pl-btn svg { width: 15px; height: 15px; fill: currentColor; flex: none; }
.pv-pl-btn:hover { color: var(--accent); border-color: var(--accent); }
.pv-pl-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ft-panel-body { overflow-y: auto; padding: .75rem 1rem; overscroll-behavior: contain; }
.ft-empty {
  color: var(--text-dim);
  text-align: center;
  font-size: .92rem;
  line-height: 1.6;
  padding: 1.5rem .5rem;
  margin: 0;
}
.ft-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.12s ease;
}
.ft-item:last-child { border-bottom: none; }
.ft-item-main {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.ft-item-thumb {
  width: 96px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-soft);
  flex-shrink: 0;
}
.ft-item-thumb-ph { background: var(--bg-soft); }
.ft-item-info { display: flex; flex-direction: column; min-width: 0; touch-action: none; }
.ft-item-title {
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ft-item-author { color: var(--text-dim); font-size: .76rem; margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-item-actions { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.ft-item-act {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
}
.ft-item-act svg { width: 15px; height: 15px; fill: none; }
.ft-item-act:hover { color: var(--text); background: var(--bg-soft); }
.ft-item-del:hover { color: var(--accent); }

.ft-grip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 30px;
  color: var(--text-dim);
  cursor: grab;
  touch-action: none; /* cho phép Pointer Events kéo liên tục trên mobile */
  -webkit-touch-callout: none;
  user-select: none;
}
.ft-grip:active { cursor: grabbing; }
.ft-grip svg { width: 16px; height: 16px; display: block; }
.ft-item[draggable="true"] { cursor: grab; }
.ft-item.ft-dragging {
  /* Item đang được nhấc ra khỏi list: làm MỜ (vẫn giữ chỗ, vẫn thấy vị trí gốc). */
  opacity: 0.4;
  filter: grayscale(0.3);
}

/* Bản clone nổi theo con trỏ lúc kéo: GIỮ NGUYÊN cả khối .ft-item (grip + thumb + actions). */
.ft-drag-clone {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  pointer-events: none;
  z-index: 1200;
  background: var(--card);
  border: none;
  border-radius: 10px;
  box-shadow: none;
  opacity: 0.92;
  transform: scale(1.03);
  cursor: grabbing;
  -webkit-user-drag: none;
  user-select: none;
  transition: none;
}
.ft-drag-clone img { pointer-events: none; }

.ft-panel-foot {
  flex: none;
  margin: 0;
  padding: .6rem 1rem .7rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: .74rem;
  text-align: center;
}
.ft-panel, .ft-panel * {
  -webkit-touch-callout: none;
  -webkit-user-select: none !important;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
/* ---- SSR landing (SEO): khối tĩnh chèn trước player, player.js gỡ khi boot ---- */
.seo-video {
  max-width: 720px;
  margin: 0 auto 1.4rem;
  padding: 1rem 1.1rem;
  background: var(--card, #1a1e26);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
}
.seo-video .dl-title {
  margin: 0 0 .5rem;
  font-size: clamp(1.15rem, 2.8vw, 1.5rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text, #e8eaed);
}
.seo-video .dl-author {
  margin: 0 0 .7rem;
  color: var(--text-dim, #9aa0a6);
  font-size: .92rem;
}
.seo-video img.dl-thumb {
  display: block;
  max-width: 100%;
  width: 480px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border, #2a2f3a);
  margin: 0 0 .7rem;
}
.seo-video .dl-links a.dl-srclink {
  font-weight: 600;
  text-decoration: none;
}
.seo-video .dl-links a.dl-srclink:hover { text-decoration: underline; }
.seo-video .dl-note {
  color: var(--text-dim, #9aa0a6);
  font-size: .9rem;
  margin: .5rem 0 0;
}
