/* ============================================================
   styles.css — Giao diện KullAnime (Mobile-first, Dark Mode)
   Tailwind cung cấp utility class; file này xử lý layout &
   component phức tạp + hiệu ứng không có sẵn.
   ============================================================ */

/* ── Nhúng font VNF-Comic Sans cho phụ đề (hoạt động trên mọi thiết bị) ── */
@font-face {
  font-family: 'VNF-Comic Sans';
  src: url('./fonts/VNF-Comic Sans.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* ── Glassmorphism design tokens — siêu trong để nền sao/hoa xuyên qua (liquid glass) ── */
  --bg: #0a0e1a;
  --bg-soft: rgba(255, 255, 255, 0.012);
  --bg-card: rgba(255, 255, 255, 0.018);
  --bg-elev: rgba(255, 255, 255, 0.032);
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #eef2ff;
  --text-dim: #aab3d0;
  --text-faint: #7985a8;
  --primary: #a855f7;
  --primary-strong: #8b3df0;
  --accent: #22d3ee;
  --accent-soft: #0ea5c4;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --glass-blur: 18px;
  --glass-border: 1px solid rgba(255, 255, 255, 0.09);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.32);
  --grad: linear-gradient(135deg, #a855f7 0%, #6366f1 45%, #22d3ee 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  /* Nền trong suốt để aurora (z-index -2) hiện lên — màu nền đặc nằm ở .bg-aurora */
  background: transparent;
  color: var(--text);
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

/* ═══════════ FLUID / UNIVERSAL RESPONSIVE BASE ═══════════
   Đảm bảo mọi nội dung tự co giãn mượt theo mọi kích thước cửa sổ:
   chống tràn ngang, ảnh/video luôn thu lại đúng khung chứa,
   và chữ dài / URL dài tự ngắt xuống dòng thay vì đẩy bố cục.
   (Không đặt overflow-x trên body để giữ position: sticky header hoạt động bình thường.) */
body {
  width: 100%;
  overflow-wrap: anywhere;
}
img, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}
iframe { border: 0; }
p, h1, h2, h3, h4, h5, h6, li, a, span, div, td, th {
  overflow-wrap: break-word;
}

/* ═══════════ NIGHT SKY + SAKURA BACKGROUND ═══════════
   Nền tối + 2 blob rất mờ giữ chiều sâu, sao tĩnh (JS sinh box-shadow),
   12 sao nhấp nháy, 1 sao băng thưa, 6 cánh hoa anh đào rơi.
   Tất cả animation chỉ dùng transform/opacity (GPU, rẻ nhất). */
.bg-aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--bg); }
.aurora-blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; will-change: transform; animation: auroraFloat 26s ease-in-out infinite alternate; }
.blob-1 { width: 46vw; height: 46vw; background: radial-gradient(circle at 30% 30%, #a855f7 0%, rgba(168,85,247,0.4) 45%, transparent 70%); top: -12%; left: -8%; }
.blob-2 { width: 40vw; height: 40vw; background: radial-gradient(circle at 60% 40%, #2563eb 0%, rgba(37,99,235,0.4) 45%, transparent 70%); bottom: -14%; right: -10%; animation-delay: -13s; }
@keyframes auroraFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(4vw, -3vw) scale(1.12); }
  100% { transform: translate(-3vw, 4vw) scale(0.94); }
}
/* Sao tĩnh: 1 div duy nhất, JS bơm box-shadow (~90 chấm) — không animation, 0 tốn GPU */
.star-field { position: absolute; top: 0; left: 0; width: 2px; height: 2px; border-radius: 50%; background: transparent; opacity: 0.95; z-index: 1; pointer-events: none; forced-color-adjust: none; }
/* Sao dạng span DOM thật — CHUNG LỚP .bg-aurora với cánh hoa sakura (JS rải ~60 chấm).
   Mỗi chấm là 1 span absolute. forced-color-adjust: none — chặn trình duyệt (Auto Dark /
   Forced Colors) đảo màu trắng của sao thành đen trên trang nền tối. */
.star-dot { position: absolute; border-radius: 50%; background: #fff; pointer-events: none; forced-color-adjust: none; animation: starTwinkle 3s ease-in-out infinite; }
/* Lớp sao tĩnh CSS thuần (~40 chấm radial-gradient) — LUÔN hiện kể cả khi JS bị
   lỗi/bị chặn trên deploy; chồng thêm với lớp box-shadow của JS (#starField)
   → trời sao dày và tự nhiên hơn. */
.bg-aurora::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0.9;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(2px 2px at 3% 7%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(2px 2px at 9% 22%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(3px 3px at 14% 41%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 63%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 11% 88%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 18% 12%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(3px 3px at 21% 30%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(2px 2px at 25% 55%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 22% 76%, rgba(255,255,255,0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 5%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(2px 2px at 33% 19%, rgba(255,255,255,0.75) 50%, transparent 51%),
    radial-gradient(2px 2px at 29% 45%, rgba(255,255,255,0.35) 50%, transparent 51%),
    radial-gradient(3px 3px at 36% 68%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(2px 2px at 31% 92%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 42% 11%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(2px 2px at 45% 26%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 38%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(3px 3px at 48% 52%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 74%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 52% 88%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(2px 2px at 55% 4%, rgba(255,255,255,0.55) 50%, transparent 51%),
    radial-gradient(3px 3px at 58% 16%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(2px 2px at 53% 33%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 62% 47%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 57% 61%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(3px 3px at 65% 79%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 60% 95%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 72% 9%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 76% 24%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(3px 3px at 70% 39%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 56%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 71%, rgba(255,255,255,0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 72% 86%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 85% 6%, rgba(255,255,255,0.55) 50%, transparent 51%),
    radial-gradient(3px 3px at 88% 21%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 36%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 91% 51%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 86% 66%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(3px 3px at 93% 82%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 96% 94%, rgba(255,255,255,0.5) 50%, transparent 51%);
}
/* 12 sao nhấp nháy (opacity) — vị trí/kích cỡ/chu kỳ rải ngẫu nhiên bằng tay */
/* 12 sao nhấp nháy (opacity) — vị trí/kích cỡ/chu kỳ rải ngẫu nhiên bằng tay */
.twinkle { position: absolute; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px rgba(255,255,255,0.7); forced-color-adjust: none; animation: starTwinkle 3s ease-in-out infinite; }
.t1 { top: 8%; left: 12%; width: 3px; height: 3px; animation-duration: 2.6s; }
.t2 { top: 18%; left: 78%; width: 2px; height: 2px; animation-duration: 3.4s; animation-delay: -1.2s; }
.t3 { top: 32%; left: 45%; width: 3px; height: 3px; animation-duration: 2.2s; animation-delay: -0.6s; }
.t4 { top: 12%; left: 55%; width: 2px; height: 2px; animation-duration: 4.1s; animation-delay: -2s; }
.t5 { top: 55%; left: 8%; width: 2px; height: 2px; animation-duration: 3s; animation-delay: -1.6s; }
.t6 { top: 68%; left: 88%; width: 3px; height: 3px; animation-duration: 2.8s; animation-delay: -0.3s; }
.t7 { top: 42%; left: 68%; width: 2px; height: 2px; animation-duration: 3.8s; animation-delay: -2.4s; }
.t8 { top: 78%; left: 32%; width: 2px; height: 2px; animation-duration: 2.4s; animation-delay: -1s; }
.t9 { top: 25%; left: 28%; width: 2px; height: 2px; animation-duration: 3.2s; animation-delay: -2.8s; }
.t10 { top: 62%; left: 58%; width: 3px; height: 3px; animation-duration: 3.6s; animation-delay: -0.9s; }
.t11 { top: 88%; left: 72%; width: 2px; height: 2px; animation-duration: 2.9s; animation-delay: -1.9s; }
.t12 { top: 48%; left: 22%; width: 2px; height: 2px; animation-duration: 4.3s; animation-delay: -0.2s; }
@keyframes starTwinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }
/* Sao băng: vệt sáng bay chéo 1s mỗi 10s (9s ẩn, 1s bay) */
.meteor { position: absolute; top: -5%; left: 70%; width: 140px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #fff, transparent); forced-color-adjust: none; transform: rotate(-35deg); opacity: 0; animation: meteorFall 10s linear infinite; }
@keyframes meteorFall {
  0%, 91% { transform: rotate(-35deg) translateX(0); opacity: 0; }
  92% { opacity: 1; }
  98%, 100% { transform: rotate(-35deg) translateX(-46vw); opacity: 0; }
}
/* Cánh hoa anh đào rơi: shape cánh (border-radius 100% 0), rơi + đu đưa + xoay.
   Nhỏ (10-14px), opacity ~0.5 → thấy qua khe, không phân tâm khi đọc chữ. */
.petal { position: absolute; top: -4%; border-radius: 100% 4px 100% 4px; background: linear-gradient(135deg, #fbcfe8, #f472b6); opacity: 0; animation: petalFall linear infinite; }
.p1 { left: 8%; width: 12px; height: 12px; animation-duration: 16s; animation-delay: 0s; }
.p2 { left: 28%; width: 10px; height: 10px; animation-duration: 19s; animation-delay: -6s; }
.p3 { left: 48%; width: 14px; height: 14px; animation-duration: 15s; animation-delay: -3s; }
.p4 { left: 66%; width: 11px; height: 11px; animation-duration: 18s; animation-delay: -11s; }
.p5 { left: 82%; width: 13px; height: 13px; animation-duration: 17s; animation-delay: -8s; }
.p6 { left: 94%; width: 10px; height: 10px; animation-duration: 20s; animation-delay: -14s; }
@keyframes petalFall {
  0% { transform: translate3d(0, -4vh, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.55; }
  50% { transform: translate3d(3vw, 52vh, 0) rotate(200deg); opacity: 0.5; }
  92% { opacity: 0.45; }
  100% { transform: translate3d(-2vw, 108vh, 0) rotate(380deg); opacity: 0; }
}
/* Tắt hiệu ứng (công tắc dưới footer) → giữ nền tối phẳng + 2 blob rất mờ */
body.fx-mode-off .star-field, body.fx-mode-off .star-dot, body.fx-mode-off .twinkle, body.fx-mode-off .meteor, body.fx-mode-off .petal { display: none; }
body.fx-mode-off .aurora-blob { animation: none; opacity: 0.18; }
/* Chế độ pháo hoa → ẩn sao/sakura, chỉ hiện pháo hoa */
body.fx-mode-fireworks .star-field, body.fx-mode-fireworks .star-dot, body.fx-mode-fireworks .twinkle, body.fx-mode-fireworks .meteor, body.fx-mode-fireworks .petal { display: none; }
/* Tab ẩn → dừng hết animation nền (tiết kiệm pin) */
body.bg-paused .bg-aurora * { animation-play-state: paused !important; }
/* Tôn trọng người dùng bật "Giảm chuyển động" trong hệ điều hành → tắt hết */
@media (prefers-reduced-motion: reduce) {
  .aurora-blob, .twinkle, .meteor, .petal { animation: none !important; }
  .meteor, .petal { display: none; }
}
/* Mobile chạy full hiệu ứng như desktop (sao + hoa + sao băng) — không giới hạn */

/* Glass surface helper */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border: var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 clamp(12px, 3vw, 24px); box-sizing: border-box; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Tab panels: chỉ hiện panel active */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ============ HEADER (thu gọn, bám sát nội dung) ============ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  padding: 4px 0 2px;
  background: transparent;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 46px;
  padding: 0 clamp(10px, 2vw, 16px);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.014);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: var(--glass-border);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.brand { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer; padding: 2px; color: var(--text); min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-name em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-logo { font-size: 20px; line-height: 1; filter: drop-shadow(0 0 8px rgba(168,85,247,0.6)); flex-shrink: 0; }

.main-nav { position: relative; display: flex; gap: 4px; background: rgba(255, 255, 255, 0.014); padding: 3px; border-radius: 12px; border: var(--glass-border); overflow: visible; }
.nav-ind {
  position: absolute; top: 3px; left: 3px; height: calc(100% - 6px); z-index: 0;
  background: var(--grad); border-radius: 9px; box-shadow: 0 6px 18px rgba(168, 85, 247, 0.45);
  transition: transform .3s cubic-bezier(.22,.68,.35,1.08), width .3s cubic-bezier(.22,.68,.35,1.08);
  will-change: transform, width; pointer-events: none;
}
.nav-tab { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: none; background: transparent; color: var(--text-dim); border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: color 0.18s ease; white-space: nowrap; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: #fff; }
.nav-tab .tab-icon { font-size: 15px; }
.header-actions { display: flex; align-items: center; gap: 6px; }
/* Nút header gọn theo header thấp (desktop) — mobile giữ nguyên theo breakpoint riêng */
.app-header .btn { padding: 7px 12px; font-size: 13px; }

/* ============ BUTTONS ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; transition: all 0.16s ease; line-height: 1; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 22px rgba(139, 61, 240, 0.45); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: linear-gradient(135deg, #0ea5c4, #22d3ee); border-color: transparent; color: #fff; box-shadow: 0 8px 22px rgba(6, 182, 212, 0.4); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #fb7185); border-color: transparent; color: #fff; }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--border-strong); }
.btn-subtle { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-subtle:hover { color: var(--text); background: var(--bg-soft); }
.btn-block { width: 100%; }
.btn-login { background: var(--bg-elev); border: var(--glass-border); }
.btn-admin { background: linear-gradient(135deg, #f59e0b, #ef4444); border-color: transparent; color: #fff; }
/* Nút Tải lại 🔄 — chỉ icon, vuông gọn, cạnh nút Đăng nhập */
.btn-refresh { background: var(--bg-elev); border: var(--glass-border); padding: 7px 10px; min-width: 36px; }
.btn-refresh:hover { border-color: var(--accent, #8b3df0); color: #fff; }
.btn-refresh span { font-size: 14px; line-height: 1; }
@media (max-width: 600px) {
  .btn-refresh { padding: 8px 10px; min-width: 36px; }
}

/* ============ SECTION HEADINGS ============ */
.section-heading { padding: 22px 0 8px; }
.section-title { margin: 0; font-size: clamp(22px, 4vw, 30px); font-weight: 800; letter-spacing: -0.02em; }
.section-subtitle { margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }

/* ============ FILTER BAR ============ */
.filter-bar { position: relative; z-index: 30; display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 2px; padding: 4px 8px; border-radius: var(--radius); background: var(--bg-soft); backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); border: var(--glass-border); box-shadow: var(--shadow-soft); }
/* Input trong thanh lọc mỏng, bám sát text → thanh search gọn theo chiều cao */
.filter-bar .input { padding: 4px 10px; font-size: 13px; line-height: 1.35; }
.input { width: 100%; padding: 11px 14px; background: rgba(255, 255, 255, 0.07); border: var(--glass-border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; outline: none; transition: border 0.15s ease, box-shadow 0.15s ease; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2); }
.filter-input { flex: 1 1 220px; min-width: 0; }
/* Ô tìm kiếm + nút ✕ xoá toàn bộ bộ lọc đặt bên trong — co được xuống mức tối thiểu
   để luôn nằm 1 dòng với Sắp xếp + đảo chiều + nút lọc; desktop hiển thị rộng sẵn */
.filter-search-wrap {
  position: relative; flex: 2 1 180px; min-width: 0;
  display: flex; align-items: center;
  transition: flex-basis 0.18s ease;
}
.filter-search-wrap .filter-input { flex: 1 1 auto; min-width: 0; width: 100%; padding-right: 42px; }
/* Desktop: ô tìm kiếm tối đa 480px; đẩy cụm Sắp xếp + nút ra sát mép phải
   → thanh lọc giãn đều 2 bên trái/phải thay vì dồn hết về trái */
@media (min-width: 641px) {
  .filter-search-wrap { flex: 1 1 auto; max-width: 480px; }
  .filter-bar #sortFilter { margin-left: auto; }
}
/* ——— Mobile (< 640px): 4 phần tử (tìm kiếm / Sắp xếp / đảo chiều / lọc) luôn cùng 1 dòng.
       Ô tìm kiếm co nhỏ để nhường chỗ; bấm vào ô tìm kiếm → kéo dài hết thanh lọc,
       tạm ẩn Sắp xếp + nút đảo chiều + nút 🔽, nhấn ra ngoài → quay lại gọn ——— */
@media (max-width: 640px) {
  .filter-bar { gap: 6px; }
  .filter-search-wrap { flex: 1 1 0; min-width: 0; }
  .filter-search-wrap:focus-within { flex: 1 1 100%; }
  .filter-search-wrap:focus-within ~ select,
  .filter-search-wrap:focus-within ~ button { display: none; }
}
.filter-clear-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-faint); font-size: 13px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.filter-clear-btn:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }
/* Nút đảo chiều sắp xếp (▼/▲) — nằm cạnh select Sắp xếp (thấp bằng ô search để không đội cao thanh) */
.sort-dir-btn {
  flex: 0 0 auto; min-width: 36px; padding: 5px 10px;
  background: rgba(255, 255, 255, 0.07); border: var(--glass-border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; line-height: 1.35; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.sort-dir-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--primary); }
.sort-dir-btn:active { transform: translateY(1px); }
/* Nút bộ lọc nâng cao (🔥 hiện panel Mùa/Năm/Thể loại/Trạng thái) + badge đếm bộ lọc đang bật */
.filter-toggle-btn {
  position: relative; flex: 0 0 auto; min-width: 36px; padding: 5px 10px;
  background: rgba(255, 255, 255, 0.07); border: var(--glass-border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; line-height: 1.35; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.filter-toggle-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--primary); }
.filter-toggle-btn.open { background: rgba(168, 85, 247, 0.16); border-color: var(--primary); }
.filter-toggle-btn:active { transform: translateY(1px); }
.filter-badge {
  position: absolute; top: -7px; right: -7px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: var(--danger, #ef4444); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
/* Bộ lọc nâng cao — POPUP nổi ngay dưới thanh lọc, ĐÈ LÊN danh sách anime (không đẩy
   layout → lưới không cần render lại khi mở/đóng → hết chớp chớp) */
.filter-advanced {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  flex-wrap: wrap; gap: 8px;
  padding: 10px; border-radius: var(--radius-sm); background: rgba(11, 15, 25, 0.55);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  animation: filterAdvancedIn 0.18s ease;
}
.filter-advanced.open { display: flex; }
.filter-advanced .filter-select { flex: 1 1 140px; min-width: 120px; }
@keyframes filterAdvancedIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.filter-select { flex: 0 1 auto; width: auto; min-width: 140px; cursor: pointer; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23aab3d0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }

/* ============ ANIME GRID ============ */
/* Grid tự co giãn mượt theo bất kỳ chiều rộng cửa sổ nào:
   number of cột được tính tự động từ bề rộng container, không đổi theo mốc cứng. */
.anime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(135px, 100%), 1fr)); gap: clamp(9px, 1.4vw, 14px); }

/* Card anime: nền trong suốt tuyệt đối, KHÔNG blur — sao/hoa nền xuyên RÕ qua phần chữ */
.anime-card { position: relative; background: transparent; border: var(--glass-border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; box-shadow: var(--shadow-soft); }
.anime-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: rgba(168, 85, 247, 0.4); }
.card-poster { position: relative; aspect-ratio: 3 / 4.2; overflow: hidden; background: var(--bg-soft); }
.card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.anime-card:hover .card-poster img { transform: scale(1.05); }
.card-status { position: absolute; top: 9px; left: 9px; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; background: rgba(11, 15, 25, 0.55); backdrop-filter: blur(8px); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.35); }
.card-status.finish { color: var(--success); border-color: rgba(34, 197, 94, 0.4); }

.card-status-badge {
  position: absolute; bottom: 8px; right: 10px; z-index: 2;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
  background: rgba(11, 15, 25, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text-dim); border: 1px solid rgba(148, 163, 184, 0.3);
}
.card-status-badge.my-watched { color: var(--success); border-color: rgba(34, 197, 94, 0.45); }
.card-status-badge.my-watching { color: var(--accent); border-color: rgba(168, 85, 247, 0.45); }
.card-status-badge.my-planned { color: var(--warning); border-color: rgba(245, 158, 11, 0.45); }
.card-status-badge.my-unwatched { color: var(--text-faint); border-color: rgba(148, 163, 184, 0.28); }

/* Nút 🌸 mở menu trạng thái — góc trên-phải poster (luôn hiển thị, kể cả đã chọn trạng thái) */
.card-sakura {
  position: absolute; top: 7px; right: 7px; z-index: 3;
  width: 27px; height: 27px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(11, 15, 25, 0.62);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(244, 114, 182, 0.42);
  font-size: 13.5px; line-height: 1; cursor: pointer;
  transition: all 0.15s ease;
}
.card-sakura:hover { transform: scale(1.14); border-color: #f472b6; background: rgba(11, 15, 25, 0.85); box-shadow: 0 0 12px rgba(244, 114, 182, 0.4); }
.my-status-chip.my-watched { color: var(--success); border-color: rgba(34, 197, 94, 0.45); }
.my-status-chip.my-watching { color: var(--accent); }
.my-status-chip.my-planned { color: var(--warning); border-color: rgba(245, 158, 11, 0.45); }
.my-status-chip.my-unwatched { color: var(--text-faint); }
.card-status.upcoming { color: var(--warning); border-color: rgba(245, 158, 11, 0.4); }
.card-body { padding: 10px 11px 12px; }
.card-title { margin: 0 0 7px; font-size: 12.5px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.card-rating { display: inline-flex; align-items: center; gap: 4px; color: var(--warning); font-weight: 700; font-size: 12px; }
.card-progress { font-size: 11px; color: var(--text-faint); }
.poster-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--text-faint); }

/* ── Hàng 10 trái tim ♥ chấm điểm nhanh (giữa card; ẩn sẵn, bấm nút "7♥" ở meta để hiện) ── */
.card-heart-row {
  display: flex; align-items: stretch; justify-content: space-between;
  gap: 1px; margin: 5px 0 9px; min-height: 22px;
}
.card-heart-opt {
  flex: 1 1 0; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; padding: 0;
  color: var(--text-faint);
  font-size: clamp(10.5px, 2.8vw, 13px); line-height: 1;
  border-radius: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, color 0.12s ease, text-shadow 0.12s ease;
}
.card-heart-opt:hover { transform: scale(1.15); }
.card-heart-opt:active { transform: scale(0.9); }
.card-heart-opt.on { color: var(--danger); text-shadow: 0 0 9px rgba(244, 63, 94, 0.55); }
.card-heart-opt.clear { font-size: clamp(9px, 2vw, 11px); color: var(--text-faint); }


/* Meta: nút "7♥" (điểm của tôi) mở hàng chấm điểm + số tập đã phát hành — bên phải ★ điểm cộng đồng */
.card-meta-right { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.card-heart-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 8px;
  border: none; border-radius: 999px;
  background: rgba(244, 63, 94, 0.14);
  color: var(--danger); font-size: 12px; font-weight: 800; line-height: 1;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}
.card-heart-btn:hover { background: rgba(244, 63, 94, 0.28); transform: scale(1.08); }
.card-heart-btn:active { transform: scale(0.92); }
/* ============ EMPTY / LOAD STATES ============ */
.empty-state, .load-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
#commentEmpty { padding: 18px 20px; }
#commentEmpty .empty-title { margin: 0; font-size: 14.5px; }
.empty-emoji { font-size: 44px; margin: 0 0 10px; }
.empty-title { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.empty-desc { font-size: 14px; margin: 0; }
.spinner { width: 38px; height: 38px; margin: 0 auto 12px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ MUSIC LAYOUT ============ */
.music-layout { display: grid; grid-template-columns: 1fr; gap: clamp(14px, 2vw, 22px); padding: 16px 0 40px; min-width: 0; }
@media (min-width: 900px) { .music-layout { grid-template-columns: 7fr 5fr; } }
.music-column, .player-column, .playlist-column { min-width: 0; } /* mọi cột music luôn co được, tránh tràn ngang */
.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; border: var(--glass-border); box-shadow: var(--shadow-soft); }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.player-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 30%, rgba(168,85,247,0.22), transparent 55%), radial-gradient(circle at 70% 70%, rgba(6,182,212,0.22), transparent 55%), rgba(17,24,39,0.6); color: var(--text-dim); text-align: center; padding: 20px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ph-icon { font-size: 52px; margin-bottom: 8px; }

.subtitle-overlay { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity 0.2s ease; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-align: center; padding: 0 8px 4px; }
.subtitle-overlay.show { opacity: 1; }
/* Vùng chạm/rê gần góc trên để hiện nút fullscreen — nằm trên iframe YouTube
   (sibling cùng .video-wrap, pointer-events:auto) nên nhận được pointer event
   ngay cả khi iframe phủ kín khung video (desktop lẫn touch). */
.fs-hover-zone {
  position: absolute; top: 0; left: 0; right: 0;
  height: clamp(48px, 14%, 96px);
  z-index: 28; pointer-events: none; background: transparent;
}
/* Nút phóng to video full màn hình (nổi góc phải khung video) */
.video-fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 30;
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(8, 12, 24, 0.55); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  pointer-events: none;
}
/* Hiện nút khi: rê/chạm vùng trên (hover-zone) · đang hover lên nút · nút có
   class .revealed (JS) · nút được focus từ bàn phím. Tự ẩn khi nhàn rỗi (JS). */
.video-wrap:has(.fs-hover-zone:hover) .video-fs-btn,
.video-fs-btn:hover,
.video-fs-btn:focus-visible,
.video-fs-btn.revealed { opacity: 1; pointer-events: auto; }
.video-fs-btn:hover { background: rgba(16, 24, 48, 0.8); transform: scale(1.08); }
.video-fs-btn:active { transform: scale(0.94); }
.video-fs-btn.active { background: rgba(244, 63, 94, 0.75); }
/* Hiệu ứng mờ dần khi ẩn/tự ẩn */
.video-fs-btn.hiding { opacity: 0; pointer-events: none; }
/* Fullscreen: giữ video tỷ lệ 16:9 giữa màn hình (letterbox) để không bị giãn méo
   overlay phụ đề + placeholder cũng nằm trong cùng ô 16:9 nên vị trí % vẫn khớp video */
.video-wrap:fullscreen {
  background: #000; border-radius: 0; border: none;
  overflow: hidden;
}
.video-wrap:fullscreen iframe,
.video-wrap:fullscreen .player-placeholder {
  position: absolute; inset: 0; margin: auto;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}
/* Overlay phụ đề fullscreen: căn giữa khớp với iframe video (letterbox) — giống extension getActiveVideoRect */
.video-wrap:fullscreen .subtitle-overlay {
  position: absolute; inset: 0; margin: auto;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  pointer-events: none; z-index: 5;
}
@media (max-width: 480px) {
  .video-fs-btn { width: 34px; height: 34px; top: 8px; right: 8px; }
}
/* Các dòng cũ (compat) — engine mới render theo từng cue ASS với style riêng */
.sub-line { display: block; margin: 2px auto; line-height: 1.35; background: rgba(0, 0, 0, 0.45); border-radius: 8px; padding: 2px 12px; width: fit-content; max-width: 92%; }
.sub-romaji { font-size: clamp(14px, 2.2vw, 20px); font-weight: 600; letter-spacing: 0.02em; }
.sub-vietsub { font-size: clamp(15px, 2.4vw, 22px); font-weight: 700; color: #ffd54a; }
/* ============ SUB SETTINGS POPUP (port YouTube-Aegisub-Loader) ============ */
.sub-panel { font-family: 'Segoe UI', Roboto, sans-serif; }
.sub-panel * { box-sizing: border-box; background: transparent; }
.sub-panel .g-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sub-panel .g-row label { width: 70px; color: #aaa; font-weight: bold; font-size: .75em; flex-shrink: 0; }
.sub-panel .g-row input[type="range"] { flex: 1; margin: 0 6px; height: 3px; cursor: pointer; flex-shrink: 0; }
.sub-panel .num-in { background: rgba(255,255,255,0.1) !important; border: 1px solid #444; color: #fff; width: auto; min-width: 28px; max-width: 80px; min-height: 24px; text-align: center; border-radius: 3px; padding: 2px 4px; font-size: .85em; }
.sub-panel .k-tabs { display: flex; gap: 2px; margin-bottom: 4px; }
.sub-panel .k-tab-btn { flex: 1; padding: 4px; background: rgba(255,255,255,0.1); border: 1px solid #444; color: #888; cursor: pointer; border-radius: 3px; }
.sub-panel .k-tab-btn.active { background: #3ea6ff; color: #fff; border-color: #3ea6ff; }
.sub-panel .k-tab-content { background: rgba(255,255,255,0.03); padding: 8px; border: 1px solid #444; border-radius: 4px; }
.sub-panel .style-item { border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; margin-bottom: 5px; background: rgba(255,255,255,0.03); overflow: hidden; }
.sub-panel .style-head { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.05); font-size: 11px; }
.sub-panel .style-body { padding: 10px; display: none; border-top: 1px dashed rgba(255,255,255,0.1); }
.sub-panel .one-line { display: flex; align-items: center; justify-content: space-between; gap: 4px; width: 100%; margin-top: 5px; font-size: 0.9em; color: #ccc; }
.sub-panel .format-btn { background: rgba(255,255,255,0.1); border: 1px solid #444; color: #fff; padding: 2px 7px; cursor: pointer; border-radius: 3px; font-weight: bold; font-size: .8em; }
.sub-panel .format-btn.active { background: #3ea6ff !important; border-color: #fff !important; color: #fff !important; }
.sub-panel input[type="color"] { width: 31px; height: 25px; border: 1px solid #444; background: rgba(255,255,255,0.1); padding: 2px; cursor: pointer; border-radius: 3px; }
.sub-panel select { background: #222 !important; color: #fff !important; border: 1px solid #555 !important; border-radius: 3px; font-size: 11px; padding: 2px 4px; }
.sub-panel select option { background: #222; color: #fff; }
.sub-panel .pill-tabs { position: relative; display: flex; gap: 4px; margin-bottom: 8px; }
.sub-panel .pill-ind {
  position: absolute; top: 0; left: 0; height: 100%; z-index: 0;
  background: #3ea6ff; border-radius: 20px; box-shadow: 0 0 12px rgba(62,166,255,0.3);
  transition: transform .3s cubic-bezier(.22,.68,.35,1.08), width .3s cubic-bezier(.22,.68,.35,1.08);
  will-change: transform, width; pointer-events: none;
}
.sub-panel .pill-tab { position: relative; z-index: 1; flex: 1; padding: 6px 4px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); color: #aaa; font-size: 10px; font-weight: bold; cursor: pointer; text-align: center; transition: color .2s ease; user-select: none; }
.sub-panel .pill-tab:hover { color: #fff; }
.sub-panel .pill-tab.active { color: #fff; }
.sub-panel .pill-panel { display: none; animation: subFadeIn .2s ease; }
.sub-panel .pill-panel.open { display: block; }
@keyframes subFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.sub-panel input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; background: #444; border-radius: 4px; outline: none; }
.sub-panel input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: #444; border-radius: 4px; }
.sub-panel input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #3ea6ff; border: 2px solid #fff; cursor: pointer; margin-top: -4px; }
.sub-panel input[type="range"]::-moz-range-track { height: 4px; background: #444; border-radius: 4px; }
.sub-panel input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #3ea6ff; border: 2px solid #fff; cursor: pointer; }
.sub-panel #sub-settings-left, .sub-panel #sub-style-list { scrollbar-width: thin; scrollbar-color: #555 transparent; }

/* ============ POPUP REDESIGN (responsive): layout + helper ============ */
.sub-panel { display: flex; flex-direction: column; }
.sub-panel #sub-settings-header {
  padding: 8px 12px; background: rgba(255,255,255,0.05); cursor: move;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); flex-shrink: 0;
}
.sub-panel .sub-hd-title { font-size: 13px; color: #3ea6ff; white-space: nowrap; }
.sub-panel .sub-hd-ctx {
  font-size: 10px; color: #ffd54a; max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(255,213,74,0.12); border: 1px solid rgba(255,213,74,0.35); padding: 1px 7px; border-radius: 999px;
}
.sub-panel .sub-hd-spacer { flex: 1; }
.sub-panel #sub-settings-reset {
  border: 1px solid #555; color: #ddd; cursor: pointer; background: rgba(255,255,255,0.08);
  font-size: 10px; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.sub-panel #sub-settings-close { cursor: pointer; font-size: 20px; line-height: 20px; color: #aaa; padding: 0 2px; }
.sub-panel #sub-settings-inner { display: flex; flex: 1; overflow: hidden; position: relative; min-height: 320px; }
.sub-panel #sub-settings-left { flex: 1; padding: 10px 12px; overflow-y: auto; min-width: 0; }
.sub-panel #sub-settings-divider {
  width: 4px; cursor: col-resize; background: rgba(255,255,255,0.05);
  border-left: 1px solid rgba(255,255,255,0.12); border-right: 1px solid rgba(255,255,255,0.05);
  user-select: none; flex-shrink: 0;
}
.sub-panel #sub-style-list { flex: 1.25; padding: 10px 12px; overflow-y: auto; min-width: 0; border-left: 1px solid rgba(255,255,255,0.06); }
.sub-panel .sub-tool-row { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; flex-wrap: wrap; }
.sub-panel .sub-tool-row b { font-size: 11px; white-space: nowrap; }
.sub-panel #sub-ts-input {
  background: rgba(255,255,255,0.1); border: 1px solid #ffaa00; color: #ffaa00; font-size: 10px; font-weight: bold;
  width: 58px; min-width: 58px; text-align: center; border-radius: 4px; padding: 2px 3px;
}
.sub-panel #sub-ts-dec, .sub-panel #sub-ts-inc {
  background: rgba(255,255,255,0.1); border: 1px solid #555; color: #ddd; cursor: pointer; border-radius: 4px; padding: 1px 6px; font-size: 10px;
}
.sub-panel .sub-ts-lab { font-size: 9px; color: #ffaa00; white-space: nowrap; }
.sub-panel .sub-color-row > div, .sub-panel .sub-box-row {
  display: flex; align-items: center; gap: 4px; flex: 1; font-size: 10px; color: #ccc;
}
.sub-panel .sub-color-row { background: rgba(255,255,255,0.05); padding: 4px 6px; border-radius: 5px; }
.sub-panel .sub-box-row { background: rgba(255,255,255,0.05); padding: 4px 6px; border-radius: 5px; margin-bottom: 6px; }
.sub-panel .sub-box-row input[type="range"] { flex: 1; }
.sub-panel .sub-fade-arr { color: #888; font-size: 10px; margin: 0 2px; }
.sub-panel .sub-check-row { background: rgba(255,255,255,0.04); padding: 3px 6px; border-radius: 5px; }
.sub-panel .sub-check-row b { font-size: 10px; }
.sub-panel .sub-sep { color: #555; }
.sub-panel .sub-pct { font-size: 9px; color: #888; }
.sub-panel .sub-style-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sub-panel .sub-styles-title { color: #ffaa00; font-weight: bold; font-size: 11px; }
.sub-panel .sub-filter-hint { font-style: normal; font-size: 9px; color: #888; font-weight: normal; }
.sub-panel .sub-style-tools { display: flex; align-items: center; gap: 8px; }
.sub-panel #sub-reset-all-styles { cursor: pointer; font-size: 11px; color: #ffaa00; font-weight: bold; opacity: 0.8; }
.sub-panel .sub-global-lab { display: flex; align-items: center; gap: 3px; font-size: 9.5px; color: #bbb; cursor: pointer; }
.sub-panel #sub-settings-footer {
  padding: 8px 12px; background: rgba(255,255,255,0.03); border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 10px; color: #999; flex-shrink: 0;
}
.sub-panel .sub-foot-lab { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.sub-panel .sub-foot-actions { display: flex; align-items: center; gap: 6px; }
.sub-panel .sub-foot-actions button {
  border: 1px solid #4a5568; color: #ddd; cursor: pointer; background: rgba(255,255,255,0.08);
  font-size: 10px; padding: 3px 9px; border-radius: 6px; white-space: nowrap;
}
.sub-panel .sub-foot-actions button:hover { background: rgba(255,255,255,0.16); }
.sub-panel .sub-foot-brand { color: #3ea6ff; font-weight: bold; font-size: 9px; }
/* Style item: nhãn thông tin style (màu, viền, cỡ, vị trí) bị ẩn trên desktop để gọn; hiện trên mobile khi cần */
.sub-panel .style-item .sub-style-meta { display: none; }

/* Responsive: mobile → 1 cột, bottom sheet toàn bề rộng, tự cuộn */
@media (max-width: 640px) {
  .sub-panel { max-height: 90vh; }
  .sub-panel #sub-settings-inner { flex-direction: column; overflow-y: auto; min-height: 0; }
  .sub-panel #sub-settings-left { overflow-y: visible; padding: 10px; }
  .sub-panel #sub-settings-divider { display: none; }
  .sub-panel #sub-style-list { flex: none; border-left: none; border-top: 1px dashed rgba(255,255,255,0.15); padding: 10px; overflow-y: visible; }
  .sub-panel .sub-hd-ctx { max-width: 50%; }
  .sub-panel .sub-foot-brand { display: none; }
}



/* ============ NOW PLAYING + PLAYLIST ============ */
.now-playing { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; background: var(--bg-card); border: var(--glass-border); border-radius: var(--radius); flex-wrap: wrap; backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); box-shadow: var(--shadow-soft); }
.np-thumb { width: 54px; height: 54px; border-radius: 12px; overflow: hidden; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
.np-thumb img { width: 100%; height: 100%; object-fit: cover; }
.np-info { flex: 1 1 140px; min-width: 0; }
.np-title { margin: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); }

/* ============ THANH ĐIỀU KHIỂN PLAYER (dưới khung video) ============ */
.player-controls {
  position: relative; z-index: 30;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 8px; margin-top: 12px;
  padding: 10px 14px; background: var(--bg-card); border: var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--shadow-soft);
}
/* Nhóm nút con: dàn ngang, không co hẹp để giữ căn đều theo chiều rộng khung video */
.pc-group { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pc-left { justify-self: start; }
.pc-center { justify-self: center; }
.pc-right { justify-self: end; }
.pc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px;
  border: 1px solid transparent; background: rgba(255,255,255,0.06); color: var(--text);
  cursor: pointer; font-size: 12px; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease, border-color 0.15s ease;
}
.pc-btn:hover { background: rgba(255,255,255,0.14); }
.pc-btn:active { transform: scale(0.93); }
.pc-btn svg { display: block; }
/* Nút lặp lại 1 (repeat-one) — icon quay vòng + chấm giữa */
.pc-repeat-one { transform: scale(1); }
.pc-btn.pc-play { min-width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(139,92,246,0.4); }
.pc-btn.pc-play:hover { background: var(--primary); filter: brightness(1.1); }
.pc-btn.pc-toggle.active { background: rgba(168,85,247,0.22); border-color: var(--primary); color: var(--primary); }
.pc-toggle-label { white-space: nowrap; }
/* Nhóm nút phụ đề trong thanh điều khiển */
.pc-subs { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.subs-toggle { min-width: 38px; padding: 0; font-size: 15px; height: 36px; }
/* Nút fullscreen trong nhóm pc-subs (trái nút toggle phụ đề) */
.pc-subs-fs {
  width: 36px; height: 36px; padding: 0; border-radius: 10px; flex-shrink: 0;
  background: rgba(168, 85, 247, 0.1); border: 1px solid rgba(168, 85, 247, 0.3);
}
.pc-subs-fs:hover { background: rgba(168, 85, 247, 0.25); }
.pc-subs-fs.active { background: rgba(168, 85, 247, 0.22); border-color: var(--primary); color: var(--primary); }
/* Ẩn văn bản nhưng vẫn dành cho trình đọc màn hình */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; clip-path: inset(50%);
}
@media (max-width: 480px) {
  .player-controls { gap: 6px; padding: 8px 10px; }
  .pc-btn { min-width: 34px; height: 34px; padding: 0 8px; }
  .pc-btn.pc-play { min-width: 44px; height: 44px; }
}

.playlist-column { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
/* Desktop màn ngang: cột phụ đề giới hạn chiều cao vừa màn hình → cuộn bên trong,
   cả tab Nhạc nằm gọn 1 màn hình không cần kéo trang (footer vẫn nằm dưới như cũ) */
@media (min-width: 900px) and (orientation: landscape) {
  .playlist-column {
    max-height: calc(100vh - 110px);   /* fallback trình duyệt cũ */
    max-height: calc(100dvh - 110px);  /* 110px ≈ header sticky + padding layout */
    overflow-y: auto;
  }
}
.ass-status-card { background: var(--bg-card); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 12px 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ass-status-title { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; }
.ass-status-text { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.ass-search {
  display: block; width: 100%; margin-top: 10px; padding: 7px 10px;
  font-size: 12.5px; background: var(--bg-soft); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); outline: none;
  transition: border-color 0.15s ease;
}
.ass-search:focus { border-color: var(--primary); }
.ass-files { margin-top: 8px; max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ass-file-item { font-size: 12px; color: var(--text-faint); padding: 6px 8px; display: flex; align-items: center; gap: 8px; border-radius: 6px; }
.ass-file-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.ass-file-item.clickable { cursor: pointer; transition: background 0.12s ease; }
.ass-file-item.clickable:hover { background: rgba(255,255,255,0.06); }
.ass-file-item.active { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--text); }
.ass-file-item.active .dot { background: var(--primary); }
.ass-file-thumb { position: relative; width: 52px; height: 30px; border-radius: 4px; overflow: hidden; background: #0d1120; flex-shrink: 0; }
.ass-file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ass-file-thumb.no-img { display: none; }
.ass-thumb-dur { position: absolute; right: 2px; bottom: 1px; font-size: 8px; color: #fff; background: rgba(0,0,0,0.65); border-radius: 3px; padding: 0 3px; line-height: 12px; pointer-events: none; }
.ass-file-item.clickable:hover .ass-thumb-dur { opacity: 1; }
.ass-file-thumb:not(.no-img) + .ass-file-name { color: var(--text); }
.ass-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ass-file-play-btn { color: var(--primary); font-size: 11px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s ease; }
.ass-file-item.clickable:hover .ass-file-play-btn { opacity: 1; }
.ass-file-bad { font-size: 10.5px; color: #f59e0b; flex-shrink: 0; font-weight: 600; opacity: 0.8; }

/* ── Phụ đề Cache (lưu trên máy) ── */
.ass-cache-card { border-style: solid; border-color: rgba(34, 211, 238, 0.35); }
.ass-cache-tag { font-style: normal; font-size: 10px; color: var(--accent); font-weight: 700; margin-left: 4px; }
/* Hàng 1: [link YT] [search sub] [apply icon] [upload icon] */
.ass-cache-row1 { display: flex; gap: 6px; margin-top: 6px; align-items: stretch; }
.ass-cache-row1 .ass-cache-link { flex: 1 1 0; min-width: 0; }
.ass-cache-search-wrap { flex: 1 1 0; min-width: 0; position: relative; }
.ass-cache-search-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); border-radius: 5px;
  color: var(--text); padding: 6px 10px; font-size: 12px; min-height: 34px;
}
.ass-cache-search-input:focus { border-color: var(--accent); outline: none; }
/* Autocomplete dropdown */
.ass-cache-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  max-height: 220px; overflow-y: auto;
  background: rgba(30, 30, 46, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(34,211,238,0.4); border-top: none;
  border-radius: 0 0 8px 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ass-cache-dropdown.hidden { display: none; }
/* Lật dropdown lên trên khi cột phụ đề (có cuộn riêng trên desktop) không đủ chỗ bên dưới */
.ass-cache-dropdown.open-up { top: auto; bottom: 100%; border-radius: 8px 8px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,0.5); }
.ass-cache-dropdown .ac-item {
  padding: 6px 10px; font-size: 11px; color: var(--text); cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; transition: background 0.1s;
}
.ass-cache-dropdown .ac-item:last-child { border-bottom: none; }
.ass-cache-dropdown .ac-item:hover,
.ass-cache-dropdown .ac-item.ac-active { background: rgba(34,211,238,0.15); color: #fff; }
.ass-cache-dropdown .ac-item .ac-match { color: var(--accent); font-weight: 700; }
.ass-cache-dropdown .ac-item .ac-label { font-size: 10px; color: #888; margin-left: 4px; }
/* Icon buttons */
.icon-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; min-height: 34px; border: 1px solid rgba(34,211,238,0.5);
  border-radius: 8px; font-size: 15px; color: var(--accent);
  background: rgba(34,211,238,0.1); cursor: pointer; transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(34,211,238,0.22); }
.ass-cache-upload.icon-btn { border-style: dashed; }
/* Hàng 2: [ID] [tiêu đề] — editable */
.ass-cache-row2 { display: flex; gap: 6px; margin-top: 6px; align-items: stretch; }
.ass-cache-row2 .ass-cache-id { flex: 1 1 130px; min-width: 80px; }
.ass-cache-row2 .ass-cache-title { flex: 2 1 0; min-width: 0; }
.ass-cache-row2 input {
  background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px; padding: 5px 8px; font-size: 12px; outline: none;
}
.ass-cache-row2 input:focus { border-color: var(--accent); }
.ass-cache-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px;
  font-size: 12px; color: var(--text); transition: background 0.12s ease;
}
.ass-cache-row:hover { background: rgba(255,255,255,0.05); }
.ass-cache-row .ass-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ass-cache-row.active { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.ass-cache-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ass-cache-actions button {
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 4px; line-height: 1;
}
.ass-cache-actions button:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.ass-cache-actions button.danger:hover { color: var(--danger); }
.ass-cache-empty { font-size: 12px; color: var(--text-faint); padding: 8px; }


/* ============ CHAT CHUNG ============ */
.chat-layout { max-width: 900px; margin: 0 auto; }
.chat-layout .composer { margin-bottom: 20px; }
#chatList { display: flex; flex-direction: column; gap: 10px; }
/* Bong bóng chat chung */
.chat-bubble-row { display: flex; flex-direction: column; align-items: flex-start; }
.chat-bubble-row.own { align-items: flex-end; }
.chat-bubble {
  position: relative;
  max-width: 82%;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: var(--glass-border);
  border-radius: 16px 16px 16px 4px;
  color: var(--text);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.chat-bubble-row.own .chat-bubble {
  background: color-mix(in srgb, var(--primary) 24%, rgba(255,255,255,0.06));
  border-color: rgba(168, 85, 247, 0.45);
  border-radius: 16px 16px 4px 16px;
}
.chat-bubble.pinned { border-color: rgba(245, 158, 11, 0.55); }
.chat-bubble.silent-tail::after {
  content: ''; position: absolute; bottom: -1px; left: -1px;
  width: 10px; height: 10px; background: inherit;
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 10px;
}
.chat-bubble-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.chat-bubble-author { font-weight: 700; font-size: 13px; color: var(--accent); }
.chat-bubble-time { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.chat-bubble-row.own .chat-bubble-time { margin-left: 0; margin-right: auto; order: 2; }
.chat-bubble .chat-anime-tag { font-size: 10.5px; font-weight: 700; color: var(--accent); background: rgba(255,255,255,0.06); border: var(--glass-border); border-radius: 999px; padding: 1px 8px; cursor: pointer; text-decoration: none; transition: border-color 0.15s ease, color 0.15s ease; }
.chat-bubble .chat-anime-tag:hover { border-color: var(--accent); color: var(--accent); }
.chat-bubble .chat-anime-tag.chat-general { color: var(--text-dim); cursor: default; }
.chat-bubble .chat-anime-tag.chat-general:hover { border-color: var(--border); color: var(--text-dim); }
.chat-bubble-body { font-size: 14px; line-height: 1.55; word-wrap: break-word; overflow-wrap: break-word; }
.chat-bubble-body img { max-width: 100%; border-radius: 10px; }
.chat-bubble .comment-actions { display: inline-flex; gap: 4px; margin-left: 2px; }
.chat-bubble .comment-action-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 6px; }
.chat-bubble .comment-action-btn:hover { background: var(--bg-elev); color: var(--text); }
.chat-bubble .comment-action-btn.danger:hover { color: var(--danger); }
.chat-bubble .pin-badge { font-size: 10.5px; color: #f59e0b; }

@media (max-width: 640px) {
  .chat-layout { max-width: 100%; }
}
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(6, 9, 18, 0.3); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 20px 12px 60px; -webkit-overflow-scrolling: touch; }
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { position: relative; width: 100%; background: rgba(20, 26, 45, 0.32); backdrop-filter: blur(32px) saturate(170%); -webkit-backdrop-filter: blur(32px) saturate(170%); border: var(--glass-border); border-radius: 20px; box-shadow: var(--shadow); padding: 22px 18px; margin-top: 6vh; animation: slideUp 0.24s ease; }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-sm { max-width: 400px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 960px; }
/* Modal chi tiết anime: rộng hơn hẳn để cột chữ đọc thoải mái — áp dụng ngay từ mốc bố cục 2 cột (641px) */
.anime-modal { padding: 16px 16px; }
@media (min-width: 641px) {
  .anime-modal { max-width: min(96vw, 1040px); }
  /* Web: modal chi tiết anime hiển thị sát đỉnh màn hình (thay vì cách ~85px) → thấy nhiều nội dung hơn */
  #animeModal { padding-top: 8px; }
  #animeModal .anime-modal { margin-top: 1vh; }
}
@media (min-width: 1200px) {
  /* Cột poster CỐ ĐỊNH 260px (flex: 0 0 + max-width cứng) — không bao giờ phình theo
     min-content của ảnh poster nên cột chữ luôn giữ đủ độ rộng. */
  .anime-modal .anime-detail .detail-side { flex-basis: 260px; width: 260px; max-width: 260px; }
  /* Poster lấp đầy cột to hơn — tránh khoảng trống lệch làm nhìn "không căn đều" */
  .anime-modal .anime-detail-poster { max-width: 100%; }
}
.modal-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: var(--glass-border); border-radius: 50%; background: rgba(255,255,255,0.06); color: var(--text-dim); cursor: pointer; font-size: 15px; z-index: 5; transition: all 0.15s ease; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-close:hover { color: var(--text); border-color: var(--border-strong); transform: rotate(90deg); }
.modal-title { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.modal-subtitle { margin: 0 0 18px; color: var(--text-dim); font-size: 13.5px; }

/* ── Modal chi tiết anime: nút ✕ dính theo khi cuộn ──
   Zone này cao 0px trong dòng chảy (không đẩy nội dung), nhưng "dính" (position: sticky)
   theo scroll container #animeModal — nút ✕ luôn bấm được dù đã cuộn xuống dưới. */
.anime-modal-sticky {
  position: sticky;
  top: 20px;
  height: 0;
  overflow: visible;
  z-index: 40;
  pointer-events: none;          /* zone vô hình không chặn click nội dung; chỉ riêng nút ✕ được bấm */
}
.anime-modal-sticky .modal-close {
  position: absolute;
  top: -10px;
  right: -6px;
  pointer-events: auto;
}

/* ── Flex chính: mặc định 1 cột (mobile); từ 641px thành 2 cột: poster trái + chữ phải ──
   Dùng flex (không dùng grid) để cột poster khóa cứng bằng flex-basis + max-width,
   không có cơ chế "growth limit" của grid track làm cột chữ bị ép về 0. */
.anime-detail { display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 10px; min-width: 0; align-items: stretch; }

/* Bảo vệ layout modal: chặn style ngoài (CDN inject / extension) làm chữ dựng đứng
   từng ký tự một dòng trong khối thông tin anime. */
.anime-modal .anime-detail .detail-side,
.anime-modal .anime-detail .detail-main {
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  white-space: normal;
}
.anime-modal .anime-detail .detail-synopsis { white-space: pre-wrap; }
.anime-modal .anime-detail .detail-title,
.anime-modal .anime-detail .detail-subtitle,
.anime-modal .anime-detail .detail-side-label { white-space: normal; }

@media (min-width: 641px) {
  /* Chốt chặn quan trọng nhất: cột poster CỐ ĐỊNH 240px. Flex basis fixed + max-width cứng
     không bao giờ bị phình theo min-content, còn cột chữ flex:1 1 0%; min-width:0 luôn
     chiếm phần còn lại — không còn cơ chế ép cột chữ như dải minmax của grid. */
  .anime-detail { flex-direction: row; align-items: flex-start; gap: clamp(14px, 2vw, 24px); width: 100%; }
  .anime-detail .detail-side { flex: 0 0 240px; width: 240px; max-width: 240px; }
  .anime-detail .detail-main { flex: 1 1 0%; width: auto; }
}

/* ── Cột trái: poster + thông tin nhanh ── */
.detail-side { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.anime-detail-poster {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  border: var(--glass-border);
  aspect-ratio: 3 / 4.2;
  background: var(--bg-elev);
  box-shadow: var(--shadow-soft);
}
@media (min-width: 641px) {
  .anime-detail-poster { max-width: 100%; margin: 0; }
}
.anime-detail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-side-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  box-shadow: var(--shadow-soft);
}
.detail-side-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; font-size: 13px; }
.detail-side-label { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.detail-side-value { text-align: right; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.detail-rating { color: var(--warning); }

/* ── Cột phải: nội dung chính — chữ thoáng, căn đều ── */
.detail-main { min-width: 0; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.detail-header { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.detail-title { margin: 0 0 4px; font-size: clamp(20px, 3vw, 27px); font-weight: 800; line-height: 1.28; letter-spacing: -0.01em; }
.detail-subtitle { margin: 0; font-size: 13.5px; color: var(--text-dim); }

.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px;
  background: rgba(255,255,255,0.035);
  border: var(--glass-border);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-dim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.chip-mine { color: var(--danger); border-color: rgba(239, 68, 68, 0.45); }

.detail-section {
  border: var(--glass-border);
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  box-shadow: var(--shadow-soft);
}
.detail-section-title { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--text); }
.detail-synopsis {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: color-mix(in srgb, var(--text) 90%, transparent);
  white-space: pre-wrap;
  text-align: justify;
  overflow-wrap: break-word;
}

/* ── Seiyuu: 1 hàng 3 ô — ô 1 ảnh nhân vật tròn, ô 2 hai dòng tên (NV trái trên / DV phải dưới), ô 3 ảnh diễn viên tròn ── */
.seiyuu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: calc(3 * 60px + 20px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
.seiyuu-card { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seiyuu-img { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--bg-soft); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.seiyuu-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seiyuu-mid { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.seiyuu-char-name { font-size: 11.5px; font-weight: 600; color: var(--text-dim); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seiyuu-card .seiyuu-name { font-size: 12px; font-weight: 700; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Synopsis: tóm tắt ngắn gọn (tối đa 5 dòng) + thanh cuộn dọc ── */
.detail-synopsis-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.detail-synopsis-head > span { min-width: 0; }
.synopsis-translate-btn {
  flex-shrink: 0;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  transition: all 0.15s ease;
}
.synopsis-translate-btn:hover { border-color: var(--accent); color: var(--text); background: rgba(99,102,241,0.16); }
.synopsis-translate-btn:disabled { opacity: 0.6; cursor: wait; }
.detail-synopsis-scroll { max-height: 138px; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }

/* ── Chip click để tìm anime theo thể loại ── */
.chip-btn {
  cursor: pointer;
  border: var(--glass-border);
  background: rgba(255,255,255,0.06);
  transition: all 0.15s ease;
}
.chip-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(99,102,241,0.18);
}

/* ── Thể loại: hiện 5 cái + nút ">" mở/đóng toàn bộ ── */
/* Thể loại + Tag nằm chung một dòng: meta-chips-row chiếm trọn hàng, 2 nhóm chip nằm cạnh nhau */
.meta-chips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; flex-basis: 100%; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chips .chip { display: inline-flex; align-items: center; }
.genre-chips.has-more:not(.open) .chip-btn:nth-child(n+6) { display: none; }
.genre-chips.open .chip-btn { display: inline-flex; }
.chip-more { cursor: pointer; color: var(--accent); border-style: dashed; }
.chip-more:hover { border-color: var(--accent); background: rgba(168, 85, 247, 0.14); color: var(--text); }

/* ── Tag: chip + popup_overflow ── */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chips .chip { display: inline-flex; align-items: center; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.chip-tag { cursor: pointer; border: 1px solid rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.10); color: #6ee7b7; transition: all 0.15s ease; }
.chip-tag:hover { border-color: #10b981; background: rgba(16, 185, 129, 0.22); color: #a7f3d0; }
.chip-tag-prior { border-color: rgba(236, 72, 153, 0.45); background: rgba(236, 72, 153, 0.12); color: #f9a8d4; }
.chip-tag-prior:hover { border-color: #ec4899; background: rgba(236, 72, 153, 0.24); color: #fbcfe8; }
.chip-tag-more {
  position: relative; cursor: pointer; border: 1px dashed rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08); color: #6ee7b7; font-weight: 600;
  transition: all 0.15s ease;
}
.chip-tag-more:hover { border-color: #10b981; background: rgba(16, 185, 129, 0.20); color: #a7f3d0; }
/* Tag xổ inline ngay tại chỗ (giống thể loại): ẩn tag từ thứ 4 trở đi khi chưa mở; nút "+N" ↔ "−" */
.tag-chips.has-more:not(.open) .chip-tag:nth-child(n+4) { display: none; }
.tag-chips.open .chip-tag { display: inline-flex; }

/* ── Khối Dàn diễn viên: bấm tiêu đề mới sổ ra (details/summary) ── */
.detail-collapse summary.detail-collapse-head {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}
.detail-collapse summary.detail-collapse-head::-webkit-details-marker { display: none; }
.detail-collapse summary.detail-collapse-head .detail-section-title { margin: 0; }
.detail-collapse-caret { font-size: 14px; color: var(--text-dim); transition: transform 0.2s ease; transform: rotate(0deg); }
.detail-collapse[open] .detail-collapse-caret { transform: rotate(180deg); }
.detail-collapse .seiyuu-grid { margin-top: 12px; }

/* ── Tên diễn viên click để tìm anime theo diễn viên ── */
.seiyuu-link { cursor: pointer; color: var(--accent); padding: 0; background: none; border: none; text-align: left; }
.seiyuu-link:hover { text-decoration: underline; }

/* ── Liên kết (modal chi tiết — dữ liata lấy async din AniList/Jikan, fără streaming) ── */
.detail-links .detail-section-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-links-title-txt { display: inline-flex; align-items: center; }
.detail-links-body { margin-top: 12px; }
.links-loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 13px;
}
.links-loading::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.3); border-top-color: var(--accent);
  animation: linksSpin 0.7s linear infinite;
}
@keyframes linksSpin { to { transform: rotate(360deg); } }
.links-empty { color: var(--text-dim); font-size: 13px; }
.links-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.ext-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 10px;
  background: var(--bg-card); border: var(--glass-border);
  backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%);
  color: var(--text); text-decoration: none;
  min-width: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ext-link:hover { border-color: var(--accent); background: rgba(99, 102, 241, 0.12); }
.ext-link:active { transform: scale(0.97); }
.ext-link-badge {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; line-height: 1;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
}
.ext-link-fav { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; object-fit: cover; }
.ext-link-txt { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; }
.ext-link-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ext-link-domain {
  font-size: 11px; color: var(--text-dim);
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ext-link-open { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

/* ============ ICON TRẠNG THÁI XEM (ngay dưới ảnh bìa trong modal) ============ */
.watch-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text-dim); font-size: 15px; line-height: 1; cursor: pointer;
  transition: all 0.15s ease;
}
.watch-ico:hover { border-color: var(--accent); color: var(--text); transform: scale(1.12); }

.watch-ico.my-watched.on { color: var(--success); border-color: rgba(34,197,94,0.7); background: rgba(34,197,94,0.18); box-shadow: 0 0 10px rgba(34,197,94,0.35); }
.watch-ico.my-watching.on { color: var(--accent); border-color: rgba(168,85,247,0.7); background: rgba(168,85,247,0.18); box-shadow: 0 0 10px rgba(168,85,247,0.35); }
.watch-ico.my-planned.on { color: var(--warning); border-color: rgba(245,158,11,0.7); background: rgba(245,158,11,0.18); box-shadow: 0 0 10px rgba(245,158,11,0.35); }
.watch-ico.my-unwatched.on { color: var(--text-dim); border-color: rgba(148,163,184,0.55); background: rgba(148,163,184,0.16); }
.watch-ico.heart.on { color: var(--danger); border-color: rgba(244,63,94,0.7); background: rgba(244,63,94,0.18); box-shadow: 0 0 10px rgba(244,63,94,0.35); }
.watch-ico.heart b { font-size: 10px; font-weight: 800; margin-left: 1px; }


/* Dưới ảnh bìa trong modal anime */
.detail-watch-icons {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 12px; margin-top: 12px;
  background: var(--bg-card); border: var(--glass-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%);
  box-shadow: var(--shadow-soft);
}
.detail-watch-icons .watch-ico { width: 34px; height: 34px; font-size: 17px; }
.watch-ico-sep { width: 1px; height: 22px; background: var(--border); margin: 0 3px; }

/* ── Số lần đã xem (chỉ trang chi tiết anime) ── */
.detail-watch { /* kế thừa .detail-section */ }
.detail-watch .detail-section-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-watch-title-txt { display: inline-flex; align-items: center; }
.detail-watch-count {
  min-width: 24px; height: 24px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(168, 85, 247, 0.18); border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--accent);
}
.detail-watch-again { margin-left: auto; }
.detail-watch-body { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.watch-dates-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: none; overflow-y: visible;
}
/* Trên 3 ngày: thu gọn thành khối có thanh trượt dọc */
.watch-dates-list.many {
  max-height: calc(3 * 40px + 12px);
  overflow-y: auto; padding-right: 6px;
  scrollbar-width: thin;
}
.watch-date-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
}
.watch-date-txt { color: var(--text); }
.watch-date-actions { display: inline-flex; align-items: center; gap: 4px; }
.watch-date-edit,
.watch-date-save,
.watch-date-del {
  flex-shrink: 0; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-faint); font-size: 13px;
  transition: all 0.15s ease;
}
.watch-date-edit:hover { background: rgba(168, 85, 247, 0.18); color: var(--accent); }
.watch-date-save:hover { background: rgba(34, 197, 94, 0.18); color: var(--success); }
.watch-date-del:hover { background: rgba(244, 63, 94, 0.18); color: var(--danger); }
.watch-date-input {
  width: 148px; padding: 4px 8px; font-size: 12.5px; font-family: inherit;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); color-scheme: dark;
}
.watch-date-empty { font-size: 13px; color: var(--text-faint); padding: 4px 2px; }
.detail-watch .btn-sm { padding: 5px 12px; font-size: 12px; }


/* ============ COMMENT SECTION ============ */
.comment-section { padding: 6px 4px 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.comment-heading { font-size: 16px; font-weight: 700; margin: 12px 0 14px; }
.composer { background: var(--bg-card); border: var(--glass-border); border-radius: var(--radius); padding: 10px; margin-bottom: 18px; backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); box-shadow: var(--shadow-soft); }
/* Bình luận anime: ô soạn thảo thu gọn 1 dòng — bấm vào mới hiện đủ toolbar + footer
   và giãn ô nhập (giống khung chat, áp riêng cho composer trong modal chi tiết). */
.anime-modal .comment-section .composer-toolbar,
.anime-modal .comment-section .composer-footer { display: none; }
.anime-modal .comment-section .composer:focus-within .composer-toolbar,
.anime-modal .comment-section .composer:focus-within .composer-footer { display: flex; }
.anime-modal .comment-section .composer-input {
  min-height: 24px;        /* 1 dòng khi chưa soạn */
  max-height: 231px;       /* 11 dòng khi đã mở rộng */
  resize: none;            /* không kéo tay được — cao độ do autoResizeComposer quản lý */
  transition: min-height 0.25s ease;
}
.anime-modal .comment-section .composer:focus-within .composer-input { min-height: 78px; }
.composer-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tb-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 14px; transition: all 0.12s ease; }
.tb-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); border-color: var(--border); }
.tb-btn:active { transform: scale(0.94); }
.composer-input { width: 100%; min-height: 78px; resize: vertical; background: transparent; border: none; outline: none; color: var(--text); font-size: 14px; font-family: inherit; line-height: 1.5; max-height: 231px; /* 11 dòng */ }
.composer-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; }
.comment-author-input { flex: 1 1 150px; min-width: 120px; }
.captcha-wrap { display: flex; align-items: center; gap: 8px; }
.captcha-question { padding: 8px 12px; background: var(--bg-elev); border: var(--glass-border); border-radius: var(--radius-sm); font-weight: 700; color: var(--accent); font-size: 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.captcha-input { width: 76px; }
.captcha-refresh { flex-shrink: 0; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text-dim); font-size: 15px; cursor: pointer; transition: border-color .2s, color .2s, transform .2s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.captcha-refresh:hover { border-color: var(--accent); color: var(--accent); transform: rotate(180deg); }
.quote-preview {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--accent, #6c5ce7);
  border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim, #999);
  max-height: 80px;
  overflow-y: auto;
}
.quote-preview .quote-preview-content {
  flex: 1 1 auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.quote-preview .quote-preview-cancel {
  flex: 0 0 auto;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-dim, #999);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.quote-preview .quote-preview-cancel:hover {
  opacity: 1;
  color: var(--danger, #ff4757);
}
.rate-limit-hint { flex-basis: 100%; font-size: 12px; color: var(--warning); }
/* Dòng trạng thái khi đã đăng nhập (composer bình luận & chat) */
.auth-name-line {
  flex: 1 1 100%;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-dim);
  background: var(--bg-soft); border: var(--glass-border); border-radius: 10px;
  padding: 6px 10px;
}
.auth-name-line strong { color: var(--accent); }
.auth-name-edit {
  border: none; background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 12.5px; padding: 2px 6px; border-radius: 6px;
  transition: all 0.12s ease;
}
.auth-name-edit:hover { color: var(--accent); background: rgba(255,255,255,0.07); }
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-item { background: var(--bg-card); border: var(--glass-border); border-radius: var(--radius); padding: 13px 14px; backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%); box-shadow: var(--shadow-soft); }
.comment-item.pinned { border-color: rgba(245, 158, 11, 0.5); background: color-mix(in srgb, rgba(245,158,11,0.07), var(--bg-card)); }
.comment-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; flex-wrap: wrap; }
.comment-author { font-weight: 700; font-size: 14px; color: var(--accent); }
.pin-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.4); }
.comment-time { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.comment-actions { margin-left: auto; display: flex; gap: 6px; }
.comment-action-btn { border: var(--glass-border); background: var(--bg-elev); color: var(--text-dim); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; transition: all 0.12s ease; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.comment-action-btn:hover { color: var(--text); }
.comment-action-btn.danger:hover { color: var(--danger); border-color: rgba(239,68,68,0.4); }
.comment-body { font-size: 14px; line-height: 1.6; word-break: break-word; }
.comment-body p { margin: 0 0 8px; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.comment-body blockquote { margin: 6px 0; padding: 8px 12px; border-left: 3px solid var(--primary); background: var(--bg-soft); border-radius: 0 8px 8px 0; color: var(--text-dim); }
.comment-body code { background: var(--bg-elev); padding: 2px 6px; border-radius: 5px; font-size: 13px; font-family: 'Cascadia Code', 'Consolas', monospace; }
.comment-body pre { background: var(--bg-elev); padding: 12px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--border); }
.comment-body pre code { background: none; padding: 0; }
.comment-body a { color: var(--accent); text-decoration: underline; word-break: break-all; }

/* ============ REPLY THREADING (bình luận trả lời lồng 1 cấp) ============ */
/* Dòng nhắc "đang trả lời @tác giả" hiện ngay trong composer */
.reply-indicator { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; padding: 7px 12px; border-radius: 8px; border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-soft)); font-size: 13px; color: var(--text-dim); }
.reply-indicator-text { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.reply-indicator-author { color: var(--accent); }
.reply-indicator-cancel { border: none; background: none; color: var(--text-faint); cursor: pointer; font-size: 12px; padding: 2px 8px; border-radius: 6px; white-space: nowrap; transition: color 0.12s ease; }
.reply-indicator-cancel:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
/* Reply con lồng dưới bình luận cha */
.comment-replies { margin-left: 34px; margin-top: 10px; display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--border); padding-left: 12px; }
.comment-replies .comment-item { border-color: var(--border); background: color-mix(in srgb, var(--bg-soft) 55%, var(--bg-card)); }
.comment-replies .comment-item:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.comment-replies .comment-item.pinned { border-color: rgba(245,158,11,0.5); background: color-mix(in srgb, rgba(245,158,11,0.07), var(--bg-soft)); }
/* Nhãn "↳ Trả lời @tên cha" trên reply con */
.comment-reply-to { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; display: inline-flex; align-items: center; gap: 4px; }
.reply-to-jump {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent); cursor: pointer; font-size: 12px;
  font-weight: 600; text-decoration: none; transition: opacity 0.12s;
}
.reply-to-jump:hover { opacity: 0.75; text-decoration: underline; }
.reply-to-ghost { color: var(--text-faint); font-style: italic; }
/* Bình luận reply con: thu nhỏ tiêu đề một chút */
.comment-replies .comment-item.is-reply .comment-head { font-size: 13px; }

/* ── Inline reply: composer nằm bên trong comment đang trả lời ── */
/* Highlight viền comment đang được reply */
.comment-item.reply-active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
              0 2px 16px color-mix(in srgb, var(--accent) 12%, transparent);
}
/* Composer bên trong comment: bo tròn dưới, thêm margin trên, */
/* bỏ margin-bottom để khít đáy comment-item */
.comment-item > .composer {
  margin-top: 10px;
  margin-bottom: 0;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  border-radius: 0;
}


/* ============ BÌNH LUẬN / TIN NHẮN DÀI: thu gọn + xem thêm ============ */
.long-text[data-expanded="false"] .long-text-body { max-height: 9.5em; overflow: hidden; }
.long-text[data-expanded="false"] .long-text-body::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em;
  background: linear-gradient(transparent, rgba(14,18,34,0.9));
  pointer-events: none;
}
.long-text-body { position: relative; }
.long-text-toggle {
  margin-top: 6px; border: none; background: none; color: var(--accent);
  font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 2px 4px;
  -webkit-tap-highlight-color: transparent;
}
.long-text-toggle:hover { text-decoration: underline; }



/* ============ ADMIN ============ */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.admin-tab-btn { padding: 8px 14px; border: var(--glass-border); background: var(--bg-elev); color: var(--text-dim); border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 600; transition: all 0.15s ease; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.admin-tab-btn.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(168,85,247,0.4); }
.admin-pane { display: none; }
.admin-pane.active { display: block; animation: fadeIn 0.2s ease; }
.admin-pane-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-pane-title { margin: 0; font-size: 15px; font-weight: 700; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--bg-card); border: var(--glass-border); border-radius: var(--radius-sm); flex-wrap: wrap; backdrop-filter: blur(10px) saturate(150%); -webkit-backdrop-filter: blur(10px) saturate(150%); }
.admin-row-thumb { width: 38px; height: 50px; border-radius: 7px; overflow: hidden; background: var(--bg-soft); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.admin-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-row-info { flex: 1 1 160px; min-width: 0; }
.admin-row-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row-sub { font-size: 12px; color: var(--text-dim); }
.admin-row-actions { display: flex; gap: 6px; margin-left: auto; }
.mini-btn { border: var(--glass-border); background: var(--bg-elev); border-radius: 7px; padding: 5px 9px; font-size: 12px; cursor: pointer; color: var(--text); transition: all 0.12s ease; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.mini-btn:hover { border-color: var(--border-strong); }

/* Toolbar lọc + sắp xếp admin (anime / bình luận) */
.admin-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-search-input { flex: 1 1 220px; min-width: 150px; }
.admin-sort-select { flex: 0 1 auto; width: auto; min-width: 160px; cursor: pointer; }

/* ── Bulk select bar (luôn hiển thị; nút xóa disabled khi chưa chọn) ── */
.admin-bulk-bar { display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin-bottom: 8px; background: color-mix(in srgb, var(--bg-elev) 70%, var(--bg-card)); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.admin-select-all { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }
.admin-select-all:has(.admin-cb-toggle:disabled) { cursor: not-allowed; opacity: 0.55; }
.admin-selected-count { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.admin-bulk-bar .btn-danger:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(80%); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

/* ── Custom checkbox ── */
.admin-cb { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; border: 2px solid var(--border-strong, rgba(255,255,255,0.2)); border-radius: 5px; background: var(--bg-soft); cursor: pointer; flex-shrink: 0; position: relative; transition: all 0.15s ease; vertical-align: middle; }
.admin-cb:hover { border-color: var(--accent); }
.admin-cb:checked { background: var(--accent); border-color: var(--accent); }
.admin-cb:checked::after { content: ''; position: absolute; left: 4px; top: 1px; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.admin-cb-toggle { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid var(--border-strong, rgba(255,255,255,0.2)); border-radius: 4px; background: var(--bg-soft); cursor: pointer; position: relative; transition: all 0.15s ease; vertical-align: middle; }
.admin-cb-toggle:hover { border-color: var(--accent); }
.admin-cb-toggle:checked { background: var(--accent); border-color: var(--accent); }
.admin-cb-toggle:checked::after { content: ''; position: absolute; left: 3px; top: 0px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ── Selected row highlight ── */
.admin-row.selected { border-color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 12%, var(--bg-card)) !important; }

/* Danh sách anime & bình luận: hiển thị tối đa ~5 dòng, phần còn lại cuộn dọc */
#adminAnimeList, #adminCommentList {
  max-height: 380px; /* ~5 dòng admin-row */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-gutter: stable;
}
#adminAnimeList::-webkit-scrollbar, #adminCommentList::-webkit-scrollbar { width: 8px; }
#adminAnimeList::-webkit-scrollbar-track, #adminCommentList::-webkit-scrollbar-track { background: transparent; }
#adminAnimeList::-webkit-scrollbar-thumb, #adminCommentList::-webkit-scrollbar-thumb { background: var(--border-strong, rgba(255,255,255,0.18)); border-radius: 8px; }

/* Quản lý nguồn repo .ass (admin) */
.admin-repo-manager { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }
.admin-repo-desc { margin: 6px 0 10px; font-size: 12.5px; color: var(--text-dim); }
.admin-repo-desc code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; color: var(--accent); }
.admin-repo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.admin-repo-row .input { flex: 1 1 260px; min-width: 0; }
.admin-repo-list { display: flex; flex-direction: column; gap: 6px; }
.repo-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-card); border: var(--glass-border); border-radius: var(--radius-sm); flex-wrap: wrap; }
.repo-item .repo-url { flex: 1 1 200px; min-width: 0; font-size: 12.5px; color: var(--accent); word-break: break-all; }
.repo-item .repo-meta { font-size: 11px; color: var(--text-faint); }
.repo-item .mini-btn.danger { border-color: rgba(244,63,94,0.4); color: var(--danger); }
.mini-btn.primary:hover { background: var(--primary); color: #fff; border-color: transparent; }
.mini-btn.danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
.backup-desc { color: var(--text-dim); font-size: 14px; margin: 0 0 14px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field-span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field textarea.input { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.poster-preview { margin-top: 8px; }
.poster-preview img { max-width: 120px; border-radius: 8px; border: 1px solid var(--border); }
/* Danh sách seiyuu trong form admin có thể rất dài → giới hạn chiều cao + thanh cuộn riêng */
.seiyuu-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
.seiyuu-editor-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seiyuu-editor-row input { flex: 1 1 120px; min-width: 90px; }
.seiyuu-remove { border: var(--glass-border); background: var(--bg-elev); border-radius: 7px; width: 34px; cursor: pointer; color: var(--danger); font-size: 15px; }
.seiyuu-add-btn { align-self: flex-start; border: 1px dashed var(--border-strong); background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px 14px; cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
.seiyuu-add-btn:hover { border-color: var(--accent); }
.jikan-search { margin-bottom: 16px; }
.jikan-search-row { display: flex; gap: 8px; }
.jikan-results { margin-top: 10px; max-height: 240px; overflow-y: auto; border: var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-card); backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%); }
.jikan-result-item { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.12s ease; }
.jikan-result-item:last-child { border-bottom: none; }
.jikan-result-item:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.jikan-result-thumb { width: 42px; height: 58px; border-radius: 6px; overflow: hidden; background: var(--bg-soft); flex-shrink: 0; }
.jikan-result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.jikan-note { margin: 0 0 8px; padding: 8px 10px; border: 1px solid rgba(251, 191, 36, 0.35); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warning) 8%, transparent); color: var(--text-dim); font-size: 12px; line-height: 1.55; }
.jikan-src-tag { display: inline-block; margin-right: 6px; padding: 1px 6px; border: 1px solid rgba(251, 191, 36, 0.4); border-radius: 4px; font-size: 10px; font-weight: 700; color: var(--warning); vertical-align: middle; }
.jikan-result-info { min-width: 0; }
.jikan-result-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jikan-result-sub { font-size: 12px; color: var(--text-dim); }


/* ============ TOAST ============ */
.toast-container { position: fixed; top: 74px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(90vw, 360px); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: rgba(20, 26, 45, 0.65); border: var(--glass-border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 14px; animation: toastIn 0.28s ease; color: var(--text); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.hide { opacity: 0; transform: translateX(30px); transition: all 0.3s ease; }

/* ── Inline Confirm bubble: hiện xác nhận ngay tại nút ── */
.ic-confirm-bubble {
  position: absolute; z-index: 400; max-width: min(320px, 90vw);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 10px; font-size: 11px; line-height: 1.35;
  color: #fff; background: rgba(20, 26, 45, 0.96);
  border: 1px solid rgba(255, 107, 107, 0.45); box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: icPop .16s ease;
}
@keyframes icPop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.ic-confirm-bubble .ic-msg { flex: 1 1 auto; min-width: 150px; color: #ffd9d9; }
.ic-confirm-bubble .ic-yes,
.ic-confirm-bubble .ic-no {
  border: 1px solid rgba(255,255,255,0.2); cursor: pointer; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 6px; white-space: nowrap; flex-shrink: 0;
}
.ic-confirm-bubble .ic-yes { background: rgba(239, 68, 68, 0.9); border-color: rgba(255,255,255,0.25); color: #fff; }
.ic-confirm-bubble .ic-yes:hover { background: rgba(220, 38, 38, 1); }
.ic-confirm-bubble .ic-no { background: rgba(255,255,255,0.12); color: #ddd; }
.ic-confirm-bubble .ic-no:hover { background: rgba(255,255,255,0.22); color: #fff; }

.global-backdrop { position: fixed; inset: 0; z-index: 300; background: rgba(4,7,15,0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; }

/* ============ FORM ERROR ============ */
.form-error { color: var(--danger); font-size: 13.5px; margin: 8px 0; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--primary) 50%, var(--border-strong)); }

/* ============ LOAD MORE (Xem thêm) ============ */
.load-more-wrap { text-align: center; padding: 20px 0 8px; }
.load-more-btn { min-width: 180px; }

/* ============ FOOTER (gọn, bám sát text) ============ */
.app-footer {
  position: relative;
  border-top: var(--glass-border);
  background: transparent;
  padding: 6px 0 12px;
  margin-top: 8px;
}
.footer-inner { text-align: center; }
.footer-brand { margin: 0 0 1px; font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.footer-brand em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.footer-meta { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.footer-meta + .footer-meta { margin-top: 1px; }
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
/* Công tắc hiệu ứng nền — nút icon ghim sát mép phải màn hình, giữa theo chiều dọc footer */
.bg-fx-toggle {
  position: fixed; right: 12px; bottom: 12px;
  background: transparent; border: var(--glass-border); border-radius: 999px;
  color: var(--text-faint); font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 2px 8px; opacity: 0.7; transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  line-height: 1.5;
  z-index: 90;
}
.bg-fx-toggle:hover { opacity: 1; border-color: var(--accent); color: var(--text); }
body.fx-mode-off .bg-fx-toggle { opacity: 0.5; }

/* ── Pháo hoa canvas ── */
#fireworksCanvas {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  width: 100%; height: 100%;
}
body.fx-mode-off #fireworksCanvas,
body.fx-mode-stars #fireworksCanvas { opacity: 0; }


@media (max-width: 640px) {

}

/* ============ CHAT CHUNG — NÚT BONG BÓNG + PANEL NỔI ============ */
/* Nút bong bóng chat (FAB) góc dưới-phải */
.chat-fab {
  position: fixed; left: 20px; bottom: 20px; z-index: 85;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--grad); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(139, 61, 240, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.chat-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 14px 34px rgba(139, 61, 240, 0.65);
  filter: brightness(1.08);
}
.chat-fab:active { transform: scale(0.95); }
.chat-fab-icon { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.chat-fab-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 20px; text-align: center;
  border: 2px solid var(--bg); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* Panel chat nổi (mở khi nhấn bong bóng) */
.chat-panel {
  position: fixed; left: 20px; bottom: 92px; z-index: 84;
  width: min(390px, calc(100vw - 24px));
  height: min(68vh, 600px);
  display: flex; flex-direction: column;
  background: rgba(13, 17, 30, 0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: var(--glass-border); border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: chatPanelIn 0.22s ease;
}
@keyframes chatPanelIn {
  from { transform: translateY(14px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.chat-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}
.chat-panel-title { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.chat-panel-close {
  border: var(--glass-border); background: var(--bg-elev); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s ease; flex-shrink: 0;
}
.chat-panel-close:hover { color: var(--danger); border-color: rgba(239, 68, 68, 0.45); }
.chat-panel-body { padding: 10px 10px 12px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; }
.chat-panel-body .chat-messages { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.chat-panel-body .chat-layout { width: 100%; max-width: 100%; flex-shrink: 0; }
.chat-panel-body .chat-layout .composer { margin-bottom: 0; }
.chat-panel-body .chat-messages .comment-list { padding-right: 4px; }

/* Khung chat: thanh gõ tin gọn, phẳng, tràn hết bề rộng panel.
   Mặc định ô nhập chỉ cao 1 dòng khít chữ — chiều cao do autoResizeComposer
   giãn theo nội dung khi gõ (không nhảy vọt 5 dòng ngay khi focus). */
.chat-panel-body .chat-layout .composer {
  display: block;
  width: 100%; box-sizing: border-box;
  margin: 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: var(--glass-border);
  border-radius: 10px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.chat-panel-body .chat-layout .composer-toolbar { display: none; }
.chat-panel-body .chat-layout .composer-footer { display: none; }
.chat-panel-body .chat-layout .composer:focus-within .composer-toolbar { display: flex; }
.chat-panel-body .chat-layout .composer:focus-within .composer-footer { display: flex; }
/* Thanh công cụ + footer gọn: nút nhỏ, không phình to */
.chat-panel-body .chat-layout .composer-toolbar {
  margin: 0 0 5px; padding: 0 0 5px; gap: 2px;
  border-bottom: 1px solid var(--border);
}
.chat-panel-body .chat-layout .tb-btn { min-width: 26px; height: 26px; padding: 0 6px; font-size: 13px; border-radius: 6px; }
/* Ô nhập: full-width tràn sát 2 bên mép, 1 dòng khít chữ,
   giãn theo nội dung khi gõ, tối đa 4 dòng rồi cuộn trong */
.chat-panel-body .chat-layout .composer-input {
  display: block;
  width: 100%; box-sizing: border-box;
  min-height: 22px; max-height: 88px; resize: none;
  padding: 0 2px; font-size: 14px; line-height: 20px;
  overflow: hidden;
}
.chat-panel-body .chat-layout .composer:focus-within .composer-input { min-height: 22px; } /* không nhảy 5 dòng khi focus */
/* Footer: tên + captcha + gửi xếp 1-2 hàng gọn, item thấp, không che nhau */
.chat-panel-body .chat-layout .composer-footer {
  flex-wrap: wrap; gap: 6px; row-gap: 6px; align-items: center;
}
.chat-panel-body .chat-layout .comment-author-input {
  flex: 1 1 120px; min-width: 90px;
  padding: 6px 10px; font-size: 13px; height: auto;
}
.chat-panel-body .chat-layout .captcha-wrap { gap: 5px; }
.chat-panel-body .chat-layout .captcha-question { padding: 5px 9px; font-size: 13px; }
.chat-panel-body .chat-layout .captcha-input { width: 58px; padding: 6px 8px; font-size: 13px; }
.chat-panel-body .chat-layout .captcha-refresh { width: 30px; height: 30px; font-size: 13px; }
.chat-panel-body .chat-layout .composer-footer .btn { padding: 6px 12px; font-size: 13px; height: auto; }

/* Mobile: bong bóng + panel gọn theo mép */
@media (max-width: 480px) {
  .chat-fab { left: 14px; bottom: 14px; width: 56px; height: 56px; }
  .chat-panel { left: 12px; bottom: 80px; width: calc(100vw - 24px); }
  /* Chat All trên màn hình rất nhỏ: tiện ích gõ tin siêu gọn */
  .chat-panel-body { padding: 8px 8px 10px; gap: 6px; }
  .chat-panel-body .chat-layout .composer { padding: 5px 6px; border-radius: 8px; }
  .chat-panel-body .chat-layout .composer-footer { gap: 5px; row-gap: 5px; }
  .chat-panel-body .chat-layout .comment-author-input { padding: 5px 8px; font-size: 12px; }
  .chat-panel-body .chat-layout .captcha-question { padding: 4px 7px; font-size: 12px; }
  .chat-panel-body .chat-layout .captcha-input { width: 48px; padding: 5px 6px; font-size: 12px; }
  .chat-panel-body .chat-layout .captcha-refresh { width: 28px; height: 28px; font-size: 12px; }
  .chat-panel-body .chat-layout .composer-footer .btn { padding: 5px 10px; font-size: 12px; }
}


/* ============ PANEL SUB SETTINGS (popup sổ xuống che phía dưới, rộng bằng khung video player) ============ */
/* Nằm absolute bên trong .player-controls (position: relative · z-index: 30): mở ra che luôn thanh điều khiển
   (gồm nút cài đặt phụ đề) và sổ xuống che nội dung phía dưới. left/right -1px để che cả đường viền. */
.sub-panel {
  position: absolute; z-index: 70;
  top: -1px; left: -1px; right: -1px;
  width: auto;
  display: flex; flex-direction: column;
  background: rgba(13, 17, 30, 0.78);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: chatPanelIn 0.2s ease;
}
.sub-panel.is-closing { animation: chatPanelOut 0.16s ease forwards; }
@keyframes chatPanelOut {
  from { transform: none; opacity: 1; }
  to { transform: translateY(10px) scale(0.98); opacity: 0; }
}
.sub-panel-header {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 6px;
  padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}
.sub-panel-ctx {
  font-style: normal; font-size: 10px; color: #ffd54a;
  white-space: nowrap; overflow: hidden;
  background: rgba(255, 213, 74, 0.12); border: 1px solid rgba(255, 213, 74, 0.35);
  padding: 2px 6px; border-radius: 999px;
  width: 20ch; flex-shrink: 0;
  cursor: default;
}
.sub-ctx-scroll {
  display: inline-flex; white-space: nowrap;
  animation: sub-marquee 10s linear infinite;
}
.sub-ctx-text {
  padding-right: 30px;
}
@keyframes sub-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.sub-panel-close {
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.06); color: #bbb;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer; font-size: 11px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s ease; flex-shrink: 0;
}
.sub-panel-close:hover { color: var(--danger); border-color: rgba(239, 68, 68, 0.45); }
/* Nhóm nút góc phải header: Reset video này + ✕ đóng (đẩy sát phải) */
.sub-header-actions { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.sub-reset-ctx {
  border: 1px solid rgba(255, 213, 74, 0.4); background: rgba(255, 213, 74, 0.1); color: #ffd54a;
  height: 24px; padding: 0 8px; border-radius: 7px; cursor: pointer;
  font-size: 10px; font-weight: 700; line-height: 1; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; transition: all 0.15s ease;
}
.sub-reset-ctx:hover { background: rgba(255, 213, 74, 0.22); border-color: rgba(255, 213, 74, 0.65); }
/* Nút 🗑️ ALL (đầu header): xoá toàn bộ config tất cả video */
.sub-reset-all-btn {
  border: 1px solid rgba(255, 107, 107, 0.5); background: rgba(255, 68, 68, 0.14); color: #ff8e8e;
  height: 24px; padding: 0 8px; border-radius: 7px; cursor: pointer;
  font-size: 10px; font-weight: 800; line-height: 1; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; transition: all 0.15s ease;
}
.sub-reset-all-btn:hover { background: rgba(255, 68, 68, 0.3); color: #fff; border-color: rgba(255, 107, 107, 0.8); }
.sub-panel-body {
  flex: 0 1 auto; min-height: 0;
  max-height: min(56vh, 460px);
  overflow-y: auto; padding: 6px 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.sub-panel-body::-webkit-scrollbar { width: 6px; }
.sub-panel-body::-webkit-scrollbar-thumb { background: #444; border-radius: 6px; }
/* 2 khối dọc cuộn liên tục: Cài đặt chung + Cài đặt từng style */
.sub-section { flex-shrink: 0; }
.sub-section-title {
  font-size: 11px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase;
  color: #3ea6ff; padding: 4px 8px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
}
.sub-section-title.sub-styles-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.sub-style-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 8px 0; margin-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08);
}
/* ── Footer chung: gộp Fade + Box 1 dòng ── */
.sub-panel-footer {
  display: flex; flex-direction: column; gap: 5px;
  padding: 6px 8px; border-top: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03); flex-shrink: 0; font-size: 10px;
}
.sub-panel-footer .sub-foot-row {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  background: rgba(255,255,255,0.05); padding: 4px 6px; border-radius: 5px;
}
.sub-panel-footer .sub-foot-row label { color: #aaa; font-weight: bold; font-size: .75em; white-space: nowrap; }
.sub-panel-footer .sub-foot-sep { width: 1px; height: 16px; background: rgba(255,255,255,0.15); margin: 0 3px; flex-shrink: 0; }
.sub-panel-footer .sub-box-lab { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding-left: 0; }
.sub-panel-footer .sub-foot-row { max-width: 100%; }
.sub-panel-footer .sub-box-blur { flex: 1 1 auto; min-width: 40px; height: 6px; }
.sub-panel .sub-lsp-lab { color: #aaa; font-weight: bold; font-size: .75em; white-space: nowrap; flex-shrink: 0; }
/* Slider khoảng cách chữ: co/giãn theo dòng để ô giá trị KHÔNG xuống hàng 2 */
.sub-panel .sub-letter-spacing { flex: 1 1 auto; min-width: 30px; height: 6px; }
.sub-panel .sub-lsp-val { width: 46px; min-width: 46px; flex-shrink: 0; }
.sub-panel-footer .sub-foot-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub-panel-footer .sub-foot-actions button {
  border: 1px solid #4a5568; color: #ddd; cursor: pointer; background: rgba(255,255,255,0.08);
  font-size: 10px; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.sub-panel-footer .sub-foot-actions button:hover { background: rgba(255,255,255,0.16); }
/* Hàng Reset chung + Timeshift: cho phép tràn sang hàng kế khi panel hẹp */
.sub-panel-footer .sub-foot-row.sub-ts-row { flex-wrap: wrap; justify-content: flex-start; gap: 6px; align-items: center; }
.sub-panel-footer .sub-reset-global-btn {
  border: 1px solid #5a6ad1; color: #cfd6ff; cursor: pointer; background: rgba(99,102,241,0.14);
  font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 7px; white-space: nowrap; flex-shrink: 0;
  transition: background .15s ease;
}
.sub-panel-footer .sub-reset-global-btn:hover { background: rgba(99,102,241,0.3); color: #fff; }
.sub-panel-footer .sub-ts-row .sub-foot-sep { align-self: center; }
/* Thanh timeshift đặt trong footer: dùng padding đầy đủ như bản gốc */
.sub-panel-footer .sub-ts-bar { flex-shrink: 1; min-width: 0; }
.sub-panel .sub-fade-lab { white-space: nowrap; }
.sub-panel .sub-fade-out-lab { white-space: nowrap; }
/* Hàng Fade + Timeshift: Fade sát trái, Timeshift sát phải */
.sub-panel-footer .sub-ft-fade-ts.sub-ts-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.sub-panel-footer .sub-ft-fade-ts .sub-fade-group { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
/* Nút reset khoảng cách chữ */
.sub-lsp-reset {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px; background: rgba(255,255,255,0.08); color: #aaa;
  cursor: pointer; font-size: 13px; flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.sub-lsp-reset:hover { background: rgba(255,255,255,0.2); color: #fff; }
/* Fade mượt cho từng cue phụ đề (fade in/out) */
.ass-cue { transition: opacity 0.15s ease; }
/* Hàng Cỡ chữ CHUNG (trên 3 tab karaoke) */
.sub-panel .k-fs-row input[type="range"] { flex: 1; }
/* Karaoke sections: stack 3 panels dọc, không còn inner tabs */
.k-section { margin-bottom: 6px; }
.k-section-label {
  display: block; font-size: 10px; font-weight: 800; color: #3ea6ff;
  padding: 3px 6px; margin-bottom: 4px;
  background: rgba(62,166,255,0.08); border-radius: 6px;
}
/* Hàng màu + zoom trong tab karaoke */
.sub-panel .k-colorzoom-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; flex-wrap: nowrap; }
.sub-panel .k-colorzoom-row .k-col { display: flex; align-items: center; gap: 3px; font-size: 9px; color: #ccc; }
.sub-panel .k-colorzoom-row .k-col i { font-style: normal; }
.sub-panel .k-colorzoom-row .k-zoom-lab { width: auto; font-size: 10px; color: #aaa; font-weight: bold; }
.sub-panel .k-inout-lab { font-size: 10px; color: #aaa; font-weight: bold; }
@media (max-width: 480px) {
  .sub-panel-body { max-height: 58vh; }
}

/* ============ NÚT CÀI ĐẶT SUB ⚙️ (trong nhóm .pc-subs của thanh điều khiển player) ============ */
.subs-settings-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: rgba(62, 166, 255, 0.12); border: 1px solid rgba(62, 166, 255, 0.4);
  color: #3ea6ff; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.18s ease; padding: 0;
}
.subs-settings-icon:hover { background: rgba(62, 166, 255, 0.25); transform: scale(1.08); }
.subs-settings-icon:active { transform: scale(0.94); }
.subs-settings-icon.active { background: rgba(62, 166, 255, 0.35); border-color: #3ea6ff; }
@media (max-width: 480px) {
  .subs-settings-icon { width: 34px; height: 34px; font-size: 15px; }
}

/* ============ RESPONSIVE TUNING ============ */
@media (max-width: 640px) {
  .app-header { padding: 4px 0 2px; }
  .header-inner { height: 46px; }
  .brand-name { font-size: 16px; }
  .nav-tab { padding: 8px 10px; font-size: 13px; }
  .nav-tab .tab-label { display: none; }
  .nav-tab .tab-icon { font-size: 18px; }
  .btn .btn-label { display: none; }
  .app-header .btn { padding: 7px 10px; }
  /* Thanh lọc trên mobile: thu nút đảo chiều + nút 🔽 để 1 dòng vừa khít */
  .sort-dir-btn, .filter-toggle-btn { min-width: 36px; padding: 10px 9px; }
  .modal { padding: 18px 14px; margin-top: 2vh; }
  .composer-footer { flex-direction: column; align-items: stretch; }
  .composer-footer .btn { width: 100%; }
  .captcha-wrap { justify-content: space-between; }
  /* Chat All trên mobile: giữ footer bình luận dạng cột nhưng footer chat vẫn xếp
     hàng gọn (1-2 dòng) để không chiếm hết panel, không che captcha/gửi */
  .chat-panel-body .chat-layout .composer-footer { flex-direction: row; align-items: center; }
  .chat-panel-body .chat-layout .composer-footer .btn { width: auto; }
}
@media (min-width: 641px) {
  .nav-tab .tab-label { display: inline; }
  .btn .btn-label { display: inline; }
}

/* ═══════════ MƯỢT Ở VÙNG TRUNG GIAN & MÀN RẤT HẸP ═══════════ */
.main-nav { flex-shrink: 0; }
.header-actions { flex-shrink: 0; }

/* 641–900px: modal anime 2 cột vẫn đủ rộng nhưng thu poster & khoảng cách gọn hơn */
@media (min-width: 641px) and (max-width: 900px) {
  .anime-detail { gap: 18px; }
  .anime-detail .detail-side { flex-basis: 200px; width: 200px; max-width: 200px; }
  .modal { padding: 18px 16px; }
}

/* Màn rất hẹp (< 480px): thu nhỏ mọi khoảng cách, tránh tràn do padding */
@media (max-width: 480px) {
  .header-inner { height: 44px; gap: 6px; padding: 0 10px; }
  .brand-logo { font-size: 21px; }
  .section-heading { padding: 16px 0 6px; }
  .modal { padding: 16px 12px; }
  .modal-overlay { padding: 12px 8px 40px; }
  .anime-detail { padding: 2px; }
  .detail-section { padding: 13px 14px; }
  .filter-bar { padding: 4px 6px; }
  .btn { padding: 8px 10px; font-size: 13px; }
}

/* ============ FINISHING TOUCHES (Glass polish) ============ */
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.anime-card { animation: cardIn 0.4s ease backwards; }
/* Tắt animation card khi render "ẩn ầm ầm" (bật/tắt bộ lọc, resize) — chống chớp chớp */
.anime-grid.no-anim .anime-card { animation: none !important; }
.anime-card:nth-child(1) { animation-delay: 0.02s; }
.anime-card:nth-child(2) { animation-delay: 0.05s; }
.anime-card:nth-child(3) { animation-delay: 0.08s; }
.anime-card:nth-child(4) { animation-delay: 0.11s; }
.anime-card:nth-child(5) { animation-delay: 0.14s; }
.anime-card:nth-child(6) { animation-delay: 0.17s; }
.anime-card:nth-child(7) { animation-delay: 0.2s; }
.anime-card:nth-child(8) { animation-delay: 0.23s; }

/* Vùng chọn text/tiêu đề gradient */
::selection { background: rgba(168, 85, 247, 0.4); color: #fff; }

/* Cải thiện form select option trên nền tối */
select.input option { background: #141a2d; color: var(--text); }

/* Hiệu ứng "liquid" cho nút chính */
.btn-primary, .btn-accent {
  position: relative; overflow: hidden;
}
.btn-primary::after, .btn-accent::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.3) 50%, transparent 60%);
  transform: translateX(-120%); transition: transform 0.6s ease;
}
.btn-primary:hover::after, .btn-accent:hover::after { transform: translateX(120%); }

/* ============ POPUP MINI: CHỌN TẬP ĐÃ XEM / CHẤM ĐIỂM ♥ ============ */
.mini-pop {
  position: fixed;
  z-index: 300;
  background: rgba(14, 18, 34, 0.97);
  border: var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  padding: 12px;
  max-width: min(340px, calc(100vw - 24px));
  animation: miniPopIn 0.16s ease;
}
@keyframes miniPopIn {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.mini-pop-title { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 9px; }
.mini-pop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; max-height: 190px; overflow-y: auto; padding-right: 2px; }
.ep-opt {
  height: 34px; border-radius: 9px;
  border: var(--glass-border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.ep-opt:hover { border-color: var(--accent); color: var(--text); background: rgba(99, 102, 241, 0.16); }
.ep-opt.cur { border-color: var(--accent); color: var(--accent); background: rgba(99, 102, 241, 0.2); }
.mini-pop-statuses { display: flex; flex-direction: column; gap: 6px; }
.status-opt {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: 9px; text-align: left;
  border: var(--glass-border);
  background: var(--bg-elev);
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.12s ease;
}
.status-opt:hover { border-color: var(--accent); color: var(--text); background: rgba(99, 102, 241, 0.16); }
.status-opt.cur { border-color: var(--accent); color: var(--accent); background: rgba(99, 102, 241, 0.2); }
.status-opt .status-opt-txt small { color: var(--text-faint); font-weight: 500; }
.status-opt-ico { width: 22px; text-align: center; font-size: 15px; }
/* ── Popup chấm điểm ♥ 10 trái tim (gradient màu cầu vồng) ── */
.mini-pop-hearts { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; justify-content: center; }
.heart-opt {
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.3s ease, color 0.3s ease, border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.heart-opt svg { width: 20px; height: 20px; fill: currentColor; transition: fill 0.3s ease, transform 0.3s ease; pointer-events: none; }
.heart-opt:hover { transform: scale(1.15); }
.heart-opt:active { transform: scale(0.9); }

/* Hover + .on: mỗi cấp điểm có màu riêng (rainbow gradient) */
.heart-opt[data-val="1"]:hover, .heart-opt[data-val="1"].on, .heart-opt[data-val="1"].hovering { color: #ff0000; }
.heart-opt[data-val="2"]:hover, .heart-opt[data-val="2"].on, .heart-opt[data-val="2"].hovering { color: #ff4d00; }
.heart-opt[data-val="3"]:hover, .heart-opt[data-val="3"].on, .heart-opt[data-val="3"].hovering { color: #ff9900; }
.heart-opt[data-val="4"]:hover, .heart-opt[data-val="4"].on, .heart-opt[data-val="4"].hovering { color: #ccff00; }
.heart-opt[data-val="5"]:hover, .heart-opt[data-val="5"].on, .heart-opt[data-val="5"].hovering { color: #66ff00; }
.heart-opt[data-val="6"]:hover, .heart-opt[data-val="6"].on, .heart-opt[data-val="6"].hovering { color: #00ff4d; }
.heart-opt[data-val="7"]:hover, .heart-opt[data-val="7"].on, .heart-opt[data-val="7"].hovering { color: #00ff99; }
.heart-opt[data-val="8"]:hover, .heart-opt[data-val="8"].on, .heart-opt[data-val="8"].hovering { color: #00ccff; }
.heart-opt[data-val="9"]:hover, .heart-opt[data-val="9"].on, .heart-opt[data-val="9"].hovering { color: #0059ff; }
.heart-opt[data-val="10"]:hover, .heart-opt[data-val="10"].on, .heart-opt[data-val="10"].hovering { color: #9900ff; }

/* Hiệu ứng glow khi .on */
.heart-opt.on { border-color: currentColor; background: rgba(255,255,255,0.06); box-shadow: 0 0 10px currentColor; transform: scale(1.08); }
.heart-opt.on svg { transform: scale(1.1); }

/* Hover nhẹ hơn: border + glow dịu */
.heart-opt:hover { border-color: currentColor; box-shadow: 0 0 8px rgba(255,255,255,0.15); }

/* Nút xoá ✕ */
.heart-clear { font-size: 13px; color: var(--text-faint) !important; border-color: transparent !important; background: transparent !important; box-shadow: none !important; }
.heart-clear:hover { color: var(--danger) !important; border-color: var(--danger) !important; box-shadow: 0 0 6px rgba(239,68,68,0.3) !important; }
.heart-clear svg { display: none; }

/* Nút trong toolbar quản trị anime */
.admin-pane-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ SUB SETTINGS UI HIỆN ĐẠI (timeshift chung + 2 tab lớn) ============ */
.sub-ts-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  background: linear-gradient(135deg, rgba(62,166,255,0.16), rgba(168,85,247,0.16));
  border: 1px solid rgba(62,166,255,0.35);
  border-radius: 12px;
}
.sub-ts-bar .sub-ts-ico { font-size: 11px; line-height: 1; color: #3ea6ff; flex-shrink: 0; cursor: default; }
.sub-ts-bar .sub-ts-ms { font-size: 8px; color: #8ab4cc; white-space: nowrap; }
.sub-ts-bar #sub-ts-input {
  background: rgba(0,0,0,0.35); border: 1px solid rgba(62,166,255,0.5); color: #ffd54a;
  font-size: 10px; font-weight: 700; width: auto; min-width: 40px; max-width: 80px; text-align: center; border-radius: 7px; padding: 2px 4px;
}
.sub-ts-bar button {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); color: #ddd;
  cursor: pointer; border-radius: 7px; padding: 2px 6px; font-size: 10px; font-weight: 700; line-height: 1;
  transition: background .15s ease, transform .1s ease;
}
.sub-ts-bar button:hover { background: rgba(62,166,255,0.28); color: #fff; }
.sub-ts-bar button:active { transform: scale(.94); }
.sub-ts-bar #sub-ts-zero { border-color: rgba(255,107,107,.4); color: #ff8e8e; }

.sub-mtabs {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 3px; padding: 3px; margin-bottom: 4px;
  flex-shrink: 0; /* chống bị co lại thành hình chữ nhật mỏng khi panel style dài (flex column của .sub-panel-body) */
  background: rgba(13,17,30,0.97); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.sub-mtabs::-webkit-scrollbar { display: none; }
.sub-mtab-ind {
  position: absolute; top: 3px; left: 3px; height: calc(100% - 6px); z-index: 0;
  background: linear-gradient(135deg, #3ea6ff, #6366f1); border-radius: 11px;
  box-shadow: 0 4px 14px rgba(62,166,255,0.35);
  transition: transform .3s cubic-bezier(.22,.68,.35,1.08), width .3s cubic-bezier(.22,.68,.35,1.08);
  will-change: transform, width; pointer-events: none;
}
.sub-mtab {
  position: relative; z-index: 1; flex: 1 0 84px; min-width: 84px; padding: 5px 4px; border-radius: 11px; border: none; cursor: pointer;
  background: transparent; color: #9aa3b8; font-size: 11px; font-weight: 700;
  text-align: center; transition: color .18s ease; user-select: none;
  scroll-snap-align: center;
}
.sub-mtab:hover { color: #fff; }
.sub-mtab.active { color: #fff; }
/* Mode-on: luôn highlight 1 trong 2 tab Global/Style theo mode đang chọn (kể cả khi All/Effect mở) */
.sub-mtab.mode-on:not(.active) {
  color: #cfd6ff; background: rgba(62,166,255,0.14);
  box-shadow: inset 0 0 0 1px rgba(62,166,255,0.35);
}
.sub-mtab.mode-on:not(.active)::after {
  content: '●'; position: absolute; top: 50%; right: 8px;
  transform: translateY(-50%); font-size: 7px; line-height: 1;
  color: #3ea6ff; pointer-events: none;
}
/* Thanh tab cuộn ngang: chống ngắn hơn tổng chiều rộng 4 tab khi panel hẹp */
.sub-mtab:last-child { scroll-snap-align: end; }
.sub-mtab-panel { position: relative; z-index: 0; animation: subFadeIn .2s ease; }
/* Căn đều nội dung các tab: thêm padding ngang để nội dung align với timeshift bar + tab header */
.sub-mtab-panel[data-m="styles"] { padding: 4px 2px 0; }
.sub-mtab-panel[data-m="effect"] { padding: 4px 2px 0; }
.sub-mtab-panel[data-m="all"] { padding: 2px 2px 0; }
.sub-mtab-panel[data-m="all"] .sub-panel-footer { border:none; background:transparent; padding: 0; }
#sub-style-items { display: flex; flex-direction: column; gap: 8px; }
/* ---- Tab Effect ---- */
.sub-panel .sub-mtab-panel[data-m="effect"] select {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.18);
  color: #dbe4ff; font-size: 11px; border-radius: 7px; padding: 5px 6px;
}
.sub-panel .sub-mtab-panel[data-m="effect"] select option {
  background: #1a2030; color: #dbe4ff;
}
.sub-effect-hint {
  margin-top: 8px; padding: 6px 8px; font-size: 10px; line-height: 1.5;
  color: #8f9bb8; background: rgba(255,255,255,0.05); border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 8px;
}
.sub-effect-hint b { color: #aab6d6; }

/* Style headbar (nằm DƯỚI toàn bộ danh sách style) + empty state */
.sub-style-headbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 2px 0; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.08);
}
.sub-style-headbar-actions {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
}
.headbar-style-name {
  font-size: 11px; font-weight: 700; color: #ffd54a; white-space: nowrap;
  background: rgba(255,213,74,0.12); border: 1px solid rgba(255,213,74,0.3);
  padding: 2px 7px; border-radius: 999px; max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; flex-shrink: 0;
}
.headbar-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border: 1px solid rgba(255,255,255,0.12); border-radius: 999px;
  background: rgba(255,255,255,0.06); color: #c6cedb; cursor: pointer;
  font-size: 11px; font-weight: 600; white-space: nowrap; transition: background .15s, color .15s;
}
.headbar-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.headbar-vis-btn { border-color: rgba(62,166,255,0.3); }
.headbar-reset-btn { border-color: rgba(255,170,0,0.3); color: #ffaa00; }
.headbar-reset-btn:hover { background: rgba(255,170,0,0.12); color: #ffcc44; }
.sub-style-headbar #sub-reset-all-styles { cursor: pointer; font-size: 11px; color: #ffaa00; font-weight: 700; opacity: .85; transition: opacity .15s; white-space: nowrap; }
.sub-style-headbar #sub-reset-all-styles:hover { opacity: 1; text-decoration: underline; }
.sub-no-style {
  padding: 22px 14px; text-align: center; color: #8892a6; font-size: 11.5px;
  border: 1px dashed rgba(255,255,255,0.15); border-radius: 12px; background: rgba(255,255,255,0.03);
}
.sub-style-headbar:first-child { border-top: none; margin-top: 0; }

/* ====== Thanh tab NGANG các Style (cuộn ngang, ẩn thanh cuộn, kéo chuột/vuốt được) ====== */
.style-tabs {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden;
  padding: 2px 2px 6px; margin-bottom: 8px;
  scrollbar-width: none;              /* Firefox: ẩn thanh cuộn */
  -webkit-overflow-scrolling: touch;  /* iOS: vuốt mượt */
  cursor: grab; user-select: none; touch-action: pan-x;
}
.style-tabs::-webkit-scrollbar { display: none; }  /* Chrome/Edge: ẩn thanh cuộn */
.style-tabs.dragging { cursor: grabbing; }
.style-tabs.dragging .style-chip { pointer-events: none; }

/* Một chip/tab style: pill gọn gàng giống tab điều hướng */
.style-chip {
  position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border: 1px solid rgba(255,255,255,0.12); border-radius: 999px;
  background: rgba(255,255,255,0.05); color: #c6cedb; cursor: pointer;
  font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.style-chip:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(62,166,255,0.45); }
.style-chip.active {
  background: linear-gradient(135deg, #7c5cff, #3ea6ff); color: #fff;
  border-color: transparent; box-shadow: 0 3px 12px rgba(62,166,255,0.35);
}
.style-chip.chip-hidden { opacity: .45; }
.style-chip .style-chip-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.style-chip .style-chip-marquee { width: 10ch; max-width: 10ch; overflow: hidden; display: inline-flex; white-space: nowrap; flex-shrink: 0; }

/* Panel chi tiết cho style đang chọn */
.style-detail {
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  background: rgba(255,255,255,0.03); padding: 10px 12px;
  margin-bottom: 4px;
}


/* Hàng vị trí / kích thước: nhãn + slider + ô số */
.sub-panel .pos-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sub-panel .pos-row .pos-lab {
  width: 16px; height: 20px; flex-shrink: 0; text-align: center; line-height: 20px;
  font-size: 10px; font-weight: 800; color: #3ea6ff;
  background: rgba(62,166,255,0.15); border-radius: 5px;
}
.sub-panel .adv-grid { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: nowrap; }
.sub-panel .adv-grid .adv-cell { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.sub-panel .adv-lab { font-size: 9px; font-weight: 700; color: #9aa3b8; width: 14px; flex-shrink: 0; }
.sub-panel .adv-grid input[type="color"] { width: 24px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.sub-panel .adv-grid input[type="number"] { width: 42px; min-width: 0; padding: 2px 3px; font-size: 10px; text-align: center; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15); border-radius: 5px; color: #eef2ff; flex-shrink: 0; }
/* Hàng số của style (Cỡ chữ / Viền chữ / Blur): tách riêng khỏi hàng 1C/2C/3C màu */
.sub-panel .adv-grid.adv-grid-num { margin-top: 6px; flex-wrap: nowrap; gap: 12px; }
.sub-panel .adv-grid.adv-grid-num .adv-cell-num { flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; }
.sub-panel .adv-grid.adv-grid-num .adv-lab { width: auto; min-width: 0; text-align: center; font-size: 9px; letter-spacing: 0; }
.sub-panel .adv-grid.adv-grid-num .num-stepper { justify-content: stretch; }
.sub-panel .adv-grid.adv-grid-num .num-stepper input[type="number"] { width: auto; flex: 1 1 auto; min-width: 20px; }
/* Nút ▲▼ tăng/giảm nhanh cho ô số không có thanh trượt */
.sub-panel .num-stepper { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sub-panel .num-step {
  width: 18px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05); color: #ffd54a; font-size: 9px; line-height: 1;
  border-radius: 5px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.sub-panel .num-step:hover { background: rgba(255,213,74,0.15); color: #fff; }
.sub-panel .num-step:active { transform: translateY(1px); }
.sub-panel .num-step-dn { color: #9aa3b8; }
.sub-panel .num-step-dn:hover { background: rgba(248,113,113,0.15); color: #f87171; }
/* Ô số bên trong bộ ▲▼: gọn lại nhưng tự động vừa số ký tự */
.sub-panel .num-stepper .num-in { width: auto !important; max-width: 55px !important; min-width: 24px; font-size: 10px; }
/* Zoom/In-out của tab karaoke nay có ▲▼ → cho phép xuống hàng khi hẹp */
.sub-panel .k-colorzoom-row { flex-wrap: wrap; }
/* Slider mảnh → to & bắt mắt hơn */
/* Thanh ngang nằm ở pseudo ::-webkit-slider-runnable-track (đảm bảo hiện thanh trượt rõ,
   không chỉ mỗi quả núm — tránh lỗi thanh nền bị mất trên Chrome/Edge */ 
.sub-panel input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px;
  background: transparent; border-radius: 999px; outline: none; cursor: pointer;
}
.sub-panel input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: rgba(255,255,255,0.20); border-radius: 999px; }
.sub-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -5px;
  border-radius: 50%; border: none;
  background: radial-gradient(circle at 35% 35%, #fff, #3ea6ff 75%);
  box-shadow: 0 0 0 3px rgba(62,166,255,0.28), 0 2px 8px rgba(0,0,0,0.5);
  cursor: grab; transition: transform .12s ease;
}
.sub-panel input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); box-shadow: 0 0 0 5px rgba(62,166,255,0.35), 0 2px 8px rgba(0,0,0,0.5); }
.sub-panel input[type="range"]::-moz-range-track { height: 6px; background: rgba(255,255,255,0.20); border-radius: 999px; }
.sub-panel input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #3ea6ff 75%); box-shadow: 0 0 0 3px rgba(62,166,255,0.28); cursor: grab; }
.sub-panel .g-row input[type="range"], .sub-panel .pos-row input[type="range"] { height: 6px; margin: 0 6px; }
/* Slider X/Y giãn hết chiều ngang (không còn khoảng trống bên phải) */
.sub-panel .pos-row input[type="range"] { flex: 1; min-width: 0; width: auto; }

/* Format row: B I U S trải đều */
.sub-panel .sub-fmt-row { gap: 4px; }
.sub-panel .sub-fmt-row .format-btn { flex: 1; padding: 5px 0; font-size: 11px; border-radius: 8px; }

/* ============ Thanh công cụ CHUNG 1 dòng: Font + B/I/U/S + Cỡ chữ % + reset ============
   Luôn hiển thị phía trên hàng chọn Cài đặt chung / Cài đặt từng style và hoạt động
   kể cả khi đang ở Cài đặt từng style. */
.sub-global-toolbar {
  display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 3px;
  flex-shrink: 0; /* chống bị co lại như .sub-mtabs khi panel style dài */
  padding: 3px 8px;
  background: linear-gradient(135deg, rgba(62,166,255,0.10), rgba(168,85,247,0.10));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
}
.sub-global-toolbar .sub-gtb-lab { font-size: 11px; font-weight: 800; color: #3ea6ff; white-space: nowrap; flex-shrink: 0; }
.sub-global-toolbar .sub-gtb-lab-sm { font-size: 10px; color: #9aa3b8; margin-left: 2px; }
.sub-global-toolbar select {
  flex: 2 1 0; min-width: 0; font-size: 10px; padding: 2px 4px;
}
.sub-global-toolbar .sub-gtb-fmt { display: flex; gap: 2px; flex: 1 1 0; }
.sub-global-toolbar .sub-gtb-fmt .format-btn { flex: 1; padding: 2px 5px; font-size: 10px; border-radius: 6px; }
.sub-global-toolbar .sub-gtb-sep {
  width: 1px; height: 16px; background: rgba(255,255,255,0.15); flex-shrink: 0; margin: 0 2px;
}
.sub-global-toolbar input[type="range"] { flex: 3 1 0; min-width: 40px; }
.sub-global-toolbar .num-in { width: auto; font-size: 10px; padding: 2px 3px; flex-shrink: 0; max-width: 60px; }
.sub-gtb-reset {
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18); color: #ffaa00;
  cursor: pointer; border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 800; line-height: 1;
  transition: background .15s ease, transform .1s ease; flex-shrink: 0;
}
.sub-gtb-reset:hover { background: rgba(255,170,0,0.22); color: #fff; }
.sub-gtb-reset:active { transform: scale(.94); }

/* ============================================================
   MỞ RỘNG THÔNG TIN ANIME (AniList) + PHÂN TRANG BÌNH LUẬN
   ============================================================ */

/* ── Ô thông tin nâng cao trong form admin (details/summary) ── */
.admin-adv-fields { border: var(--glass-border); border-radius: var(--radius-sm); padding: 0; background: rgba(255,255,255,0.03); }
.admin-adv-summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; font-size: 13px; font-weight: 700; color: var(--text);
  user-select: none; border-radius: var(--radius-sm);
}
.admin-adv-summary::-webkit-details-marker { display: none; }
.admin-adv-summary:hover { color: var(--accent); }
.admin-adv-grid { padding: 0 14px 14px; }

/* ── Tên phụ (Native/Romaji) & synonyms trong header chi tiết ── */
.detail-aliases { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 4px; }
.detail-alias { font-size: 13.5px; color: var(--text-dim); }
.detail-alias em {
  font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid rgba(168,85,247,0.4); border-radius: 4px;
  padding: 0 4px; margin-left: 5px; vertical-align: middle;
}
/* Nhãn "(Other)" cạnh mỗi tên khác trong synonyms line */
.detail-alias-tag {
  font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid rgba(168,85,247,0.4); border-radius: 4px;
  padding: 0 4px; margin-left: 4px; vertical-align: middle;
}

/* ── Link bấm được trong cột meta (Season/Source/Studio) ── */
.detail-side-link {
  cursor: pointer; text-align: right; font-weight: 700; color: var(--accent);
  border: none; background: none; padding: 0; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 3px; transition: color .15s ease;
}
.detail-side-link:hover { color: var(--text); text-decoration-color: var(--accent); }

/* ── Producers trong cột meta — xếp dọc từng nút ── */
.detail-side-producers { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.detail-producer-link {
  cursor: pointer; text-align: right; font-weight: 700; color: var(--accent);
  border: none; background: none; padding: 0; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 3px; transition: color .15s ease;
}
.detail-producer-link:hover { color: var(--text); text-decoration-color: var(--accent); }

/* ── Chip hashtag ── */
.chip-hashtag { color: var(--text-dim); border-color: var(--border); background: rgba(255,255,255,0.03); }

/* ── Thanh phân trang ‹ 1 2 3 … › (bình luận + lưới tab Anime) — gọn, bám sát text ── */
.comment-pagination, .anime-pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 0 0; margin-bottom: 0; flex-wrap: wrap;
}
.comment-pagination.hidden, .anime-pagination.hidden { display: none; }
.comment-page-btn, .anime-page-btn {
  cursor: pointer; min-width: 26px; height: 26px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: var(--glass-border); background: rgba(255,255,255,0.06);
  color: var(--text); border-radius: 6px; font-size: 12.5px; font-weight: 700; line-height: 1;
  transition: all .15s ease;
}
.comment-page-btn:hover:not(.disabled):not(.current),
.anime-page-btn:hover:not(.disabled):not(.current) { border-color: var(--accent); background: rgba(99,102,241,0.18); }
.comment-page-btn.current, .anime-page-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.comment-page-btn.disabled, .anime-page-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.comment-page-ellipsis, .anime-page-ellipsis { color: var(--text-dim); padding: 0 2px; }