/* ============================================================
   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.
   ============================================================ */

:root {
  /* ── Glassmorphism design tokens ── */
  --bg: #0a0e1a;
  --bg-soft: rgba(255, 255, 255, 0.04);
  --bg-card: rgba(255, 255, 255, 0.055);
  --bg-elev: rgba(255, 255, 255, 0.085);
  --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.12);
  --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%);
}

html[data-theme="light"] {
  --bg: #eef1fb;
  --bg-soft: rgba(255, 255, 255, 0.5);
  --bg-card: rgba(255, 255, 255, 0.62);
  --bg-elev: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --text-dim: #475569;
  --text-faint: #7d8aa3;
  --shadow: 0 18px 50px rgba(2, 6, 23, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  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;
}

/* ═══════════ AURORA / LIQUID GLASS BACKGROUND ═══════════ */
.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.5; 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, transparent 65%); top: -12%; left: -8%; }
.blob-2 { width: 40vw; height: 40vw; background: radial-gradient(circle at 60% 40%, #2563eb, transparent 65%); top: 8%; right: -10%; animation-delay: -6s; }
.blob-3 { width: 44vw; height: 44vw; background: radial-gradient(circle at 50% 50%, #22d3ee, transparent 65%); bottom: -14%; left: 18%; animation-delay: -12s; }
.blob-4 { width: 34vw; height: 34vw; background: radial-gradient(circle at 50% 50%, #ec4899, transparent 65%); bottom: 4%; right: 6%; animation-delay: -18s; opacity: 0.38; }
@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); }
}
.aurora-grain { position: absolute; inset: 0; opacity: 0.5; background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px); background-size: 4px 4px; }

/* 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 ============ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  padding: 10px 0;
  background: transparent;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 58px;
  padding: 0 clamp(10px, 2vw, 16px);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: var(--glass-border);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.brand { display: inline-flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text); min-width: 0; }
.brand-name { font-weight: 800; font-size: 18px; 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: 24px; line-height: 1; filter: drop-shadow(0 0 8px rgba(168,85,247,0.6)); flex-shrink: 0; }

.main-nav { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.06); padding: 4px; border-radius: 14px; border: var(--glass-border); }
.nav-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: none; background: transparent; color: var(--text-dim); border-radius: 11px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.18s ease; white-space: nowrap; }
.nav-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-tab.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(168, 85, 247, 0.45); }
.nav-tab .tab-icon { font-size: 16px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ============ 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; }

/* ============ 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 { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 22px; padding: 12px; 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 { 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 260px; min-width: 160px; }
.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(150px, 100%), 1fr)); gap: clamp(10px, 1.6vw, 16px); }

.anime-card { position: relative; background: var(--bg-card); 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; backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); 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: 10px; left: 10px; padding: 4px 9px; border-radius: 999px; font-size: 11px; 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: 8px; right: 8px; z-index: 3;
  width: 30px; height: 30px; 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: 15px; 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: 11px 12px 13px; }
.card-title { margin: 0 0 8px; font-size: 14px; 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: 13px; }
.card-progress { font-size: 12px; color: var(--text-faint); }
.poster-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 44px; 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); }
.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: 43px; max-width: 43px; min-height: 24px; text-align: center; border-radius: 3px; padding: 2px 3px; 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 { display: flex; gap: 4px; margin-bottom: 8px; }
.sub-panel .pill-tab { 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: all .2s ease; user-select: none; }
.sub-panel .pill-tab:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sub-panel .pill-tab.active { background: #3ea6ff; border-color: #3ea6ff; color: #fff; box-shadow: 0 0 12px rgba(62,166,255,0.3); }
.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 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; }
.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: 260px; 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: #1e1e2e; 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; }
.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 đề] (readonly) */
.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[readonly] {
  background: rgba(255,255,255,0.04); color: var(--text-dim); cursor: default; opacity: .75;
}
.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.07);
  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.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); 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.72); backdrop-filter: blur(28px) saturate(170%); -webkit-backdrop-filter: blur(28px) saturate(170%); border: var(--glass-border); border-radius: 20px; box-shadow: var(--shadow); padding: 22px 18px; margin-top: 6vh; animation: slideUp 0.24s ease; }
html[data-theme="light"] .modal { background: rgba(255, 255, 255, 0.72); }
@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) */
@media (min-width: 641px) {
  .anime-modal { max-width: min(96vw, 1040px); }
}
@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; }

/* ── 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: 20px; 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(18px, 3vw, 34px); 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: 14px; }
.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); }
.detail-side-progress { grid-template-columns: 1fr; gap: 6px; }
.progress-bar { flex: 1; height: 8px; background: rgba(255,255,255,0.1); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); }
.progress-fill { height: 100%; border-radius: 999px; background: var(--grad); }
.detail-progress-text { font-size: 12px; color: var(--text-faint); }

/* ── 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: 18px; }
.detail-header { border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.detail-title { margin: 0 0 6px; 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: 8px; }
.chip {
  padding: 5px 12px;
  background: rgba(255,255,255,0.06);
  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: 16px 18px;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  box-shadow: var(--shadow-soft);
}
.detail-section-title { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--text); }
.detail-synopsis {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.9;
  color: color-mix(in srgb, var(--text) 90%, transparent);
  white-space: pre-wrap;
  text-align: justify;
  overflow-wrap: break-word;
}

/* ── Seiyuu ── */
.seiyuu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.seiyuu-card { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seiyuu-avatar { 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; position: relative; }
.seiyuu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.seiyuu-avatar .seiyuu-va-badge { position: absolute; bottom: -3px; right: -3px; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 2px solid var(--bg-card); background: var(--bg-soft); }
.seiyuu-avatar .seiyuu-va-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seiyuu-info { min-width: 0; }
.seiyuu-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seiyuu-char { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Synopsis: tóm tắt ngắn gọn + thanh cuộn dọc ── */
.detail-synopsis-scroll { max-height: 190px; 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ộ ── */
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.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); }

/* ── 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; }

/* ============ 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; }


/* ============ 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); }
.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; }
.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); }
.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; }

/* ============ 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; }

/* 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); }
.seiyuu-list { display: flex; flex-direction: column; gap: 8px; }
.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-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.85); 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 ============ */
.app-footer {
  border-top: var(--glass-border);
  background: transparent;
  padding: 20px 0 32px;
  margin-top: 30px;
}
.footer-inner { text-align: center; }
.footer-brand { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.footer-brand em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.footer-meta { margin: 0; font-size: 12.5px; color: var(--text-faint); line-height: 1.9; }
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ============ 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));
  max-height: min(68vh, 600px);
  display: flex; flex-direction: column;
  background: rgba(13, 17, 30, 0.9);
  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: 12px 14px 16px; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.chat-panel-body .chat-messages { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.chat-panel-body .chat-layout { max-width: none; flex-shrink: 0; }
.chat-panel-body .chat-layout .composer { margin-bottom: 0; }
.chat-panel-body .chat-messages .comment-list { padding-right: 4px; }

/* Khung chat: mặc định chỉ hiện ô nhập 1 dòng gọn; khi bấm vào ô nhập mới hiện thanh công cụ (đậm/nghiêng/...) */
.chat-layout .composer-toolbar { display: none; }
.chat-layout .composer:focus-within .composer-toolbar { display: flex; }
.chat-layout .composer-input { min-height: 40px; resize: none; max-height: 180px; }
.chat-layout .composer:focus-within .composer-input { min-height: 78px; resize: vertical; }

/* 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); }
}


/* ============ 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): sổ xuống đè lên phần nội dung phía dưới
   (now-playing, playlist...) thay vì đẩy in-flow. left:0; right:0 → rộng đúng chiều rộng thanh điều khiển = khung video. */
.sub-panel {
  position: absolute; z-index: 70;
  top: calc(100% + 8px); left: 0; right: 0;
  width: auto;
  display: flex; flex-direction: column;
  background: rgba(13, 17, 30, 0.97);
  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: 12px 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.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: nowrap;
  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 { border-left: 1px solid rgba(255,255,255,0.15); padding-left: 6px; }
.sub-panel-footer .sub-foot-row { max-width: 100%; }
.sub-panel-footer .sub-box-blur { flex: 0 1 90px; min-width: 40px; height: 6px; }
.sub-panel .sub-lsp-lab { color: #aaa; font-weight: bold; font-size: .75em; white-space: nowrap; border-left: 1px solid rgba(255,255,255,0.15); padding-left: 6px; 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; }
/* 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) {
  .header-inner { height: 56px; }
  .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; }
  .btn { padding: 9px 11px; }
  .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; }
}
@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: 54px; 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: 10px; }
  .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; }
.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; }
.mini-pop-hearts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.heart-opt {
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%;
  border: var(--glass-border);
  background: var(--bg-elev);
  color: var(--text-faint);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  transition: all 0.12s ease;
}
.heart-opt:hover { transform: scale(1.12); border-color: var(--danger); }
.heart-opt.on { color: var(--danger); border-color: rgba(239, 68, 68, 0.55); background: rgba(239, 68, 68, 0.14); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.heart-clear { font-size: 12px; color: var(--text-faint); }
.heart-clear:hover { color: var(--danger); border-color: var(--danger); }

/* 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: 46px; min-width: 40px; max-width: 70px; text-align: center; border-radius: 7px; padding: 2px 3px;
}
.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 {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 10px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
}
.sub-mtab {
  flex: 1; padding: 8px 4px; border-radius: 11px; border: none; cursor: pointer;
  background: transparent; color: #9aa3b8; font-size: 11px; font-weight: 700;
  text-align: center; transition: all .18s ease; user-select: none;
}
.sub-mtab:hover { color: #fff; background: rgba(255,255,255,0.07); }
.sub-mtab.active {
  background: linear-gradient(135deg, #3ea6ff, #6366f1); color: #fff;
  box-shadow: 0 4px 14px rgba(62,166,255,0.35);
}
.sub-mtab-panel { animation: subFadeIn .2s ease; }
/* Căn đều nội dung cả 2 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-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 + empty state */
.sub-style-headbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px 8px; margin-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sub-style-headbar .sub-styles-title { color: #ffaa00; font-weight: 800; font-size: 11px; display: flex; align-items: center; gap: 6px; }
.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);
}
.style-hidden-tag { font-size: 9px; color: #ff8e8e; padding: 2px 12px 0; font-weight: 600; }

/* Style item hiện đại */
.sub-panel .style-item { border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; margin-bottom: 8px; background: rgba(255,255,255,0.035); overflow: hidden; transition: border-color .15s ease; }
.sub-panel .style-item:hover { border-color: rgba(62,166,255,0.4); }
.sub-panel .style-head {
  padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(90deg, rgba(62,166,255,0.12), rgba(255,255,255,0.04));
  font-size: 11.5px; font-weight: 700; color: #eef2ff; gap: 8px;
}
.sub-panel .style-head .style-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-panel .style-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sub-panel .sub-reset-style { cursor: pointer; font-size: 11px; color: #ffaa00; }
.sub-panel .sub-eye { cursor: pointer; font-size: 12px; }
.sub-panel .style-chev { font-size: 8px; color: #9aa3b8; transition: transform .18s ease; }
.sub-panel .style-chev.open { transform: rotate(180deg); }
.sub-panel .style-body { padding: 10px 12px; border-top: 1px dashed rgba(255,255,255,0.1); }

/* 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; }
/* 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: 4px;
  padding: 5px 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: 3px 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: 42px; font-size: 10px; padding: 2px 3px; flex-shrink: 0; }
.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); }