/* ==========================================================================
 *  themes.css — HỆ THỐNG CHỦ ĐỀ (5 THEME) CHO "NGÔI NHÀ NHỎ"
 *  -------------------------------------------------------------------------
 *  Người làm: Alya (06/12/2026) · điều khiển bởi theme.js
 *
 *  CÁCH HOẠT ĐỘNG
 *  ---------------
 *  `theme.js` gắn `data-theme="dark|light|space|sakura|meadow"` lên <html>.
 *  File này làm đúng 2 việc:
 *    1. Khai báo bộ biến màu `--t-*` cho từng chủ đề.
 *    2. Map các class utility Tailwind (đang hard-code màu) sang biến đó.
 *
 *  BA LUẬT KHÔNG ĐƯỢC PHÁ
 *  ----------------------
 *  A. TỜ PHIẾU VÀNG (section đầu tiên của <main>) BẤT KHẢ XÂM PHẠM.
 *     Không một selector nào trong file này trỏ vào section tờ phiếu hoặc con
 *     của nó. Mọi remap utility đều scope trong 2 vùng an toàn:
 *        #historyDrawer                    (ngăn kéo + 10 panel)
 *        [id$="Modal"]                     (các hộp thoại)
 *     cộng thêm vài phần tử ở <main> được gọi TÊN bằng id (thanh dưới đáy,
 *     2 nút chuyển màn hình, nút Hồi hướng) — không dùng utility trong main.
 *
 *  B. THEME "dark" KHÔNG BỊ OVERRIDE.
 *     Mọi rule đổi màu đều có tiền tố:
 *        html[data-theme]:not([data-theme="dark"])
 *     ⇒ giao diện tối hôm nay giữ nguyên từng pixel (cả khi JS không chạy
 *       vì không có data-theme thì rule không khớp).
 *
 *  C. ƯU TIÊN BIẾN, HẠN CHẾ !important.
 *     Chỉ dùng !important ở đúng 1 nhóm: `.drawer-tab-btn.is-active` vì
 *     style.css đã đặt `color: … !important` ở đó (dòng 1734) và không sửa
 *     được style.css theo ràng buộc. Tất cả chỗ khác thắng bằng specificity
 *     (id + attribute > class đơn của Tailwind), nên chữ/nền giữ đúng thứ tự
 *     cascade của Tailwind.
 * ========================================================================== */

/* ==========================================================================
 *  1. BỘ BIẾN — MẶC ĐỊNH (= theme tối hiện tại, dùng cho UI chọn chủ đề)
 * ========================================================================== */
:root {
  --t-bg: #1a1410;
  --t-text: #f5efe6;

  --t-panel: #111118;
  --t-surface: #161026;
  --t-surface-2: #13131a;
  --t-card-1: #241838;
  --t-card-2: #161026;

  --t-border: rgba(255, 255, 255, 0.10);
  --t-border-2: rgba(255, 255, 255, 0.22);
  --t-border-accent: rgba(251, 191, 36, 0.28);
  --t-shadow: rgba(0, 0, 0, 0.75);

  --t-accent: #fcd34d;
  --t-accent-text: #fcd34d;
  --t-accent-soft: rgba(251, 191, 36, 0.14);

  --t-amber-strong: #fcd34d;
  --t-amber-mid: #fde68a;
  --t-amber-soft: #fef3c7;
  --t-title: #d8b4fe;
  --t-muted: #e9d5ff;
  --t-muted-soft: #c4b5fd;
  --t-muted-dim: #a78bfa;

  --t-tab-text: #ddd0f5;
  --t-tab-hover: #ffffff;
  --t-tab-active-1: #ded7fe;
  --t-tab-active-2: #a5b4fc;
  --t-tab-active-text: #1b1430;
  --t-tab-active-glow: rgba(255, 255, 255, 0.55);

  /* thẻ chọn chủ đề trong #panelTheme */
  --t-card-ui-bg: #1b1330;
  --t-card-ui-border: rgba(168, 85, 247, 0.32);
  --t-card-ui-desc: #c4b5fd;
  --t-check-bg: #fcd34d;
  --t-check-fg: #1b1430;
  --t-selected-ring: #fbbf24;
  --t-swatch-border: rgba(255, 255, 255, 0.16);
}

/* ==========================================================================
 *  2. THEME "SÁNG" — nền kem ấm, chữ nâu đậm, thẻ trắng viền nhạt
 * ========================================================================== */
html[data-theme="light"] {
  --t-scheme: light;

  --t-bg: #f5efe4;
  --t-bg-image: radial-gradient(130% 95% at 50% -18%, #fffdf9 0%, #f6f0e5 46%, #ebe0cf 100%);
  --t-bg-size: 100% 100%;
  --t-bg-repeat: no-repeat;
  --t-text: #3b2a1a;

  --t-drawer: #f3ece1;
  --t-strip: #ece3d5;
  --t-head-1: #fffdf9;
  --t-head-2: #f3ece1;
  --t-panel: #faf6ef;
  --t-surface: #fffdfa;
  --t-surface-2: #f4ecdf;
  --t-card-1: #fffdf8;
  --t-card-2: #f4ebdc;
  --t-tint: rgba(138, 90, 0, 0.08);
  --t-soft: rgba(60, 40, 15, 0.05);
  --t-soft-2: rgba(60, 40, 15, 0.09);

  --t-border: rgba(90, 62, 28, 0.16);
  --t-border-2: rgba(90, 62, 28, 0.30);
  --t-border-accent: rgba(160, 110, 20, 0.34);
  --t-shadow: rgba(80, 55, 20, 0.22);

  --t-accent: #b45309;
  --t-accent-text: #8a5a00;
  --t-accent-soft: rgba(180, 83, 9, 0.12);
  --t-band-1: #fbecd2;
  --t-band-2: #f6e2c2;

  --t-amber-strong: #8a5a00;
  --t-amber-mid: #7b4f06;
  --t-amber-soft: #6a4a1e;
  --t-title: #7a4a12;
  --t-muted: #5c4630;
  --t-muted-soft: #6a5340;
  --t-muted-dim: #77604a;

  --t-tab-text: #4a3723;
  --t-tab-hover: #23180c;
  --t-tab-active-1: #ffe7ba;
  --t-tab-active-2: #f0c877;
  --t-tab-active-text: #3a2500;
  --t-tab-active-glow: rgba(255, 255, 255, 0.72);

  --t-pill-bg: #fffdfa;
  --t-pill-border: #d9cbb3;
  --t-pill-text: #4a3723;
  --t-pill-icon: #8a5a00;
  --t-pill-active-bg: #40301d;
  --t-pill-active-border: #6b563b;
  --t-pill-active-text: #fdf6e9;
  --t-pill-active-icon: #f6c95e;

  --t-dark-btn-bg: #40301d;
  --t-dark-btn-border: #6b563b;
  --t-dark-btn-text: #fdf6e9;
  --t-strong-btn-bg: #e0a92b;
  --t-strong-btn-text: #3a2500;

  --t-emerald-strong: #065f46;
  --t-emerald-text: #047857;
  --t-sky-strong: #075985;
  --t-sky-text: #0369a1;

  --t-card-ui-bg: #fffdfa;
  --t-card-ui-border: #ddcfb8;
  --t-card-ui-desc: #6a5340;
  --t-check-bg: #f0c877;
  --t-check-fg: #3a2500;
  --t-selected-ring: #b45309;
  --t-swatch-border: rgba(90, 62, 28, 0.18);
}

/* ==========================================================================
 *  3. THEME "VŨ TRỤ" — #060b18 + sao tĩnh (CSS gradient), accent cyan/tím
 * ========================================================================== */
html[data-theme="space"] {
  --t-scheme: dark;

  --t-bg: #060b18;
  --t-bg-image:
    radial-gradient(1.5px 1.5px at 26px 34px, rgba(255, 255, 255, 0.92) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 148px 96px, rgba(186, 230, 253, 0.85) 50%, transparent 51%),
    radial-gradient(1.9px 1.9px at 84px 158px, rgba(255, 255, 255, 0.75) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 196px 44px, rgba(196, 181, 253, 0.85) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 54px 212px, rgba(255, 255, 255, 0.65) 50%, transparent 51%),
    radial-gradient(circle at 50% -12%, rgba(34, 211, 238, 0.18) 0%, rgba(99, 102, 241, 0.10) 38%, rgba(6, 11, 24, 0) 72%),
    radial-gradient(circle at 88% 108%, rgba(129, 140, 248, 0.16) 0%, rgba(6, 11, 24, 0) 52%);
  --t-bg-size: 240px 240px, 180px 180px, 300px 300px, 220px 220px, 260px 260px, 100% 100%, 100% 100%;
  --t-bg-repeat: repeat, repeat, repeat, repeat, repeat, no-repeat, no-repeat;
  --t-text: #e2ecff;

  --t-drawer: #070d1c;
  --t-strip: #0a1226;
  --t-head-1: #0d1830;
  --t-head-2: #070d1c;
  --t-panel: #081022;
  --t-surface: #0c1529;
  --t-surface-2: #0a1223;
  --t-card-1: #101d3a;
  --t-card-2: #0a1226;
  --t-tint: rgba(34, 211, 238, 0.10);
  --t-soft: rgba(148, 197, 255, 0.07);
  --t-soft-2: rgba(148, 197, 255, 0.12);

  --t-border: rgba(122, 178, 255, 0.16);
  --t-border-2: rgba(122, 178, 255, 0.30);
  --t-border-accent: rgba(34, 211, 238, 0.34);
  --t-shadow: rgba(0, 0, 0, 0.62);

  --t-accent: #22d3ee;
  --t-accent-text: #67e8f9;
  --t-accent-soft: rgba(34, 211, 238, 0.12);
  --t-band-1: #0e2b3d;
  --t-band-2: #0b1a33;

  --t-amber-strong: #67e8f9;
  --t-amber-mid: #a5f3fc;
  --t-amber-soft: #bae6fd;
  --t-title: #c4b5fd;
  --t-muted: #a9bcdd;
  --t-muted-soft: #9aafd2;
  --t-muted-dim: #8ba0c4;

  --t-tab-text: #b9cbe8;
  --t-tab-hover: #ffffff;
  --t-tab-active-1: #22d3ee;
  --t-tab-active-2: #818cf8;
  --t-tab-active-text: #041220;
  --t-tab-active-glow: rgba(255, 255, 255, 0.55);

  --t-pill-bg: #0b1426;
  --t-pill-border: rgba(122, 178, 255, 0.28);
  --t-pill-text: #cfe0fb;
  --t-pill-icon: #67e8f9;
  --t-pill-active-bg: #0c2c46;
  --t-pill-active-border: #22d3ee;
  --t-pill-active-text: #eaf7ff;
  --t-pill-active-icon: #a5f3fc;

  --t-dark-btn-bg: #10243d;
  --t-dark-btn-border: #1d4f73;
  --t-dark-btn-text: #eaf7ff;
  --t-strong-btn-bg: #0e7490;
  --t-strong-btn-text: #eafcff;

  --t-emerald-strong: #6ee7b7;
  --t-emerald-text: #34d399;
  --t-sky-strong: #7dd3fc;
  --t-sky-text: #38bdf8;

  --t-card-ui-bg: #0c1529;
  --t-card-ui-border: rgba(122, 178, 255, 0.24);
  --t-card-ui-desc: #9aafd2;
  --t-check-bg: #22d3ee;
  --t-check-fg: #041220;
  --t-selected-ring: #22d3ee;
  --t-swatch-border: rgba(122, 178, 255, 0.25);
}

/* ==========================================================================
 *  4. THEME "HOA ANH ĐÀO" — nền hồng phấn/kem, accent #d6336c
 * ========================================================================== */
html[data-theme="sakura"] {
  --t-scheme: light;

  --t-bg: #fff5f7;
  --t-bg-image: radial-gradient(130% 95% at 50% -18%, #fffdfe 0%, #fff1f5 45%, #fbe4ec 100%);
  --t-bg-size: 100% 100%;
  --t-bg-repeat: no-repeat;
  --t-text: #46212f;

  --t-drawer: #fdeff3;
  --t-strip: #fbe4ea;
  --t-head-1: #fffbfd;
  --t-head-2: #fdeff3;
  --t-panel: #fff8fa;
  --t-surface: #ffffff;
  --t-surface-2: #fdedf2;
  --t-card-1: #fffafc;
  --t-card-2: #fce7ee;
  --t-tint: rgba(214, 51, 108, 0.09);
  --t-soft: rgba(120, 40, 70, 0.05);
  --t-soft-2: rgba(120, 40, 70, 0.09);

  --t-border: rgba(160, 70, 110, 0.16);
  --t-border-2: rgba(160, 70, 110, 0.30);
  --t-border-accent: rgba(214, 51, 108, 0.34);
  --t-shadow: rgba(150, 40, 80, 0.20);

  --t-accent: #d6336c;
  --t-accent-text: #a81d52;
  --t-accent-soft: rgba(214, 51, 108, 0.12);
  --t-band-1: #ffe3ec;
  --t-band-2: #fbd3de;

  --t-amber-strong: #a81d52;
  --t-amber-mid: #9c2f5a;
  --t-amber-soft: #7d4459;
  --t-title: #8f2b56;
  --t-muted: #6b4553;
  --t-muted-soft: #7a5463;
  --t-muted-dim: #86636f;

  --t-tab-text: #5d3341;
  --t-tab-hover: #2a0d17;
  --t-tab-active-1: #f9c6d6;
  --t-tab-active-2: #f091ac;
  --t-tab-active-text: #4a0f2a;
  --t-tab-active-glow: rgba(255, 255, 255, 0.7);

  --t-pill-bg: #ffffff;
  --t-pill-border: #e9c6d2;
  --t-pill-text: #5d3341;
  --t-pill-icon: #a81d52;
  --t-pill-active-bg: #a81d52;
  --t-pill-active-border: #d6336c;
  --t-pill-active-text: #fff5f8;
  --t-pill-active-icon: #ffd7e4;

  --t-dark-btn-bg: #6d2a44;
  --t-dark-btn-border: #a84a6b;
  --t-dark-btn-text: #fff2f6;
  --t-strong-btn-bg: #b02257;
  --t-strong-btn-text: #fff5f8;

  --t-emerald-strong: #065f46;
  --t-emerald-text: #047857;
  --t-sky-strong: #075985;
  --t-sky-text: #0369a1;

  --t-card-ui-bg: #ffffff;
  --t-card-ui-border: #e9c6d2;
  --t-card-ui-desc: #7a5463;
  --t-check-bg: #d6336c;
  --t-check-fg: #fff5f8;
  --t-selected-ring: #d6336c;
  --t-swatch-border: rgba(160, 70, 110, 0.20);
}

/* ==========================================================================
 *  5. THEME "ĐỒNG CỎ" — nền #f1f7ee, accent #2f7d32, chữ rêu đậm
 * ========================================================================== */
html[data-theme="meadow"] {
  --t-scheme: light;

  --t-bg: #f1f7ee;
  --t-bg-image: radial-gradient(130% 95% at 50% -18%, #fbfdf8 0%, #eff6ea 45%, #e3efdd 100%);
  --t-bg-size: 100% 100%;
  --t-bg-repeat: no-repeat;
  --t-text: #1f3a24;

  --t-drawer: #ebf4e6;
  --t-strip: #e3efdc;
  --t-head-1: #f9fdf6;
  --t-head-2: #ebf4e6;
  --t-panel: #f5faf1;
  --t-surface: #ffffff;
  --t-surface-2: #eef6e8;
  --t-card-1: #fbfdf8;
  --t-card-2: #edf6e7;
  --t-tint: rgba(47, 125, 50, 0.09);
  --t-soft: rgba(30, 70, 30, 0.05);
  --t-soft-2: rgba(30, 70, 30, 0.09);

  --t-border: rgba(45, 90, 45, 0.16);
  --t-border-2: rgba(45, 90, 45, 0.28);
  --t-border-accent: rgba(47, 125, 50, 0.34);
  --t-shadow: rgba(30, 70, 30, 0.20);

  --t-accent: #2f7d32;
  --t-accent-text: #2a6a2d;
  --t-accent-soft: rgba(47, 125, 50, 0.12);
  --t-band-1: #e2f2db;
  --t-band-2: #d6ecce;

  --t-amber-strong: #2a6a2d;
  --t-amber-mid: #2f6b32;
  --t-amber-soft: #3f6042;
  --t-title: #356b2f;
  --t-muted: #44603e;
  --t-muted-soft: #4f6d48;
  --t-muted-dim: #5a7752;

  --t-tab-text: #33502f;
  --t-tab-hover: #10240f;
  --t-tab-active-1: #c4e8ba;
  --t-tab-active-2: #86cb84;
  --t-tab-active-text: #10300c;
  --t-tab-active-glow: rgba(255, 255, 255, 0.7);

  --t-pill-bg: #ffffff;
  --t-pill-border: #cadcc3;
  --t-pill-text: #33502f;
  --t-pill-icon: #2f7d32;
  --t-pill-active-bg: #2f7d32;
  --t-pill-active-border: #4c9a4f;
  --t-pill-active-text: #f6fdf3;
  --t-pill-active-icon: #d7f5cf;

  --t-dark-btn-bg: #2b4a2c;
  --t-dark-btn-border: #4c7449;
  --t-dark-btn-text: #f2fbee;
  --t-strong-btn-bg: #2f7d32;
  --t-strong-btn-text: #f6fdf3;

  --t-emerald-strong: #065f46;
  --t-emerald-text: #047857;
  --t-sky-strong: #075985;
  --t-sky-text: #0369a1;

  --t-card-ui-bg: #ffffff;
  --t-card-ui-border: #cadcc3;
  --t-card-ui-desc: #4f6d48;
  --t-check-bg: #2f7d32;
  --t-check-fg: #f6fdf3;
  --t-selected-ring: #2f7d32;
  --t-swatch-border: rgba(45, 90, 45, 0.20);
}

/* ==========================================================================
 *  6. TOKEN BỔ SUNG (thêm sau, cho gọn phần trên)
 * ========================================================================== */
html[data-theme="light"] {
  --t-bar-bg: #fffdfa;
  --t-input-bg: #ffffff;
  --t-btn-2-bg: #f6eee2;
  --t-danger-text: #b3261e;
  --t-danger-soft: rgba(179, 38, 30, 0.10);
  /* nút chính tông vàng kim (bg-amber-400/500 + text-stone-950) */
  --t-primary-1: #f7cb62;
  --t-primary-2: #dda01f;
  --t-primary-fg: #3a2500;
}
html[data-theme="space"] {
  --t-bar-bg: #0b1426;
  --t-input-bg: #0a1223;
  --t-btn-2-bg: #0e1a30;
  --t-danger-text: #fca5a5;
  --t-danger-soft: rgba(248, 113, 113, 0.14);
  --t-primary-1: #38e0f2;
  --t-primary-2: #6d8bf5;
  --t-primary-fg: #041220;
}
html[data-theme="sakura"] {
  --t-bar-bg: #ffffff;
  --t-input-bg: #ffffff;
  --t-btn-2-bg: #fdeef3;
  --t-danger-text: #a52a3a;
  --t-danger-soft: rgba(165, 42, 58, 0.10);
  --t-primary-1: #c2275d;
  --t-primary-2: #a51d50;
  --t-primary-fg: #fff5f8;
}
html[data-theme="meadow"] {
  --t-bar-bg: #ffffff;
  --t-input-bg: #ffffff;
  --t-btn-2-bg: #eef7e8;
  --t-danger-text: #b3261e;
  --t-danger-soft: rgba(179, 38, 30, 0.10);
  --t-primary-1: #2f7d32;
  --t-primary-2: #276a29;
  --t-primary-fg: #f6fdf3;
}

/* ==========================================================================
 *  7. KHUNG TRANG + NGĂN KÉO
 *  Tiền tố dùng chung:  html[data-theme]:not([data-theme="dark"])
 *  ⇒ theme tối không khớp ⇒ giao diện cũ nguyên vẹn.
 * ========================================================================== */

/* 7.1 Nền trang (style.css: body { background: radial-gradient(tối) })
 *     CHỦ Ý: KHÔNG đặt `color` trên body. Màu chữ body hiện tại là
 *     #f5efe6 và nó ĐANG được kế thừa vào tờ phiếu vàng; đổi nó ở đây là
 *     gián tiếp làm tờ phiếu đổi màu ⇒ chỉ đổi nền, còn màu chữ do từng
 *     vùng tự khai báo (#historyDrawer, panel, modal). */
html[data-theme]:not([data-theme="dark"]) body {
  background-color: var(--t-bg);
  background-image: var(--t-bg-image);
  background-size: var(--t-bg-size, 100% 100%);
  background-repeat: var(--t-bg-repeat, no-repeat);
  background-attachment: fixed;
}

/* 7.1b Màu chữ cho vùng hộp thoại (root overlay không vẽ gì, chỉ để kế thừa) */
html[data-theme]:not([data-theme="dark"]) [id$="Modal"] {
  color: var(--t-text);
}

/* 7.1c color-scheme — CHỈ trong ngăn kéo và hộp thoại, KHÔNG đặt trên <html>.
 * Lý do đã đo: color-scheme đổi cách trình duyệt vẽ form control mặc định,
 * mà tờ phiếu vàng có <textarea>/<input> bên trong ⇒ ảnh chụp lệch tới
 * 11/255 ở các ô tên/ngày. Để mặc định như cũ ⇒ tờ phiếu y nguyên 100%. */
html[data-theme]:not([data-theme="dark"]) #historyDrawer,
html[data-theme]:not([data-theme="dark"]) [id$="Modal"] {
  color-scheme: var(--t-scheme);
}

/* 7.2 Chế độ Diễn Đàn — social.css tự đặt nền #0f0d15 nên phải đè (2 attr) */
html[data-theme]:not([data-theme="dark"])[data-app-mode="forum"] body {
  background-color: var(--t-bg);
  background-image: var(--t-bg-image);
  background-size: var(--t-bg-size, 100% 100%);
  background-repeat: var(--t-bg-repeat, no-repeat);
  background-attachment: fixed;
}

/* 7.3 <main> chỉ giữ nền trong suốt để thấy nền chủ đề; tờ phiếu tự có nền
 *     riêng của nó và KHÔNG bị rule này ảnh hưởng (không set thuộc tính con) */
html[data-theme]:not([data-theme="dark"]) main {
  background-color: transparent;
}

/* 7.4 Ngăn kéo: nền + viền + chữ gốc
 *     KHÔNG đặt box-shadow ở đây: ngăn kéo nằm `fixed` và khi đóng thì
 *     translate-x-full ra ngoài; bóng đổ của nó vẫn lem vào mép trái màn
 *     hình, đè lên rìa tờ phiếu. Giữ shadow mặc định của Tailwind
 *     (`shadow-2xl`) như cũ ⇒ tờ phiếu không bị đổi sắc độ ở mép. */
html[data-theme]:not([data-theme="dark"]) #historyDrawer {
  background-color: var(--t-drawer);
  border-right-color: var(--t-border);
  color: var(--t-text);
}

/* 7.5 Header ngăn kéo (gradient from-[#171122] to-[#0f0d15]) */
html[data-theme]:not([data-theme="dark"]) #historyDrawer > div[class*="from-[#171122]"] {
  background-image: linear-gradient(180deg, var(--t-head-1) 0%, var(--t-head-2) 100%);
  border-bottom-color: var(--t-border);
}

/* 7.6 Dải 10 tab (#historyDrawer > div.p-2.bg-[#12101a]) */
html[data-theme]:not([data-theme="dark"]) #historyDrawer > div[class*="bg-[#12101a]"] {
  background-color: var(--t-strip);
  border-bottom-color: var(--t-border);
}

/* 7.7 Tab: trạng thái thường / hover / đang chọn */
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn {
  color: var(--t-tab-text);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn:hover {
  color: var(--t-tab-hover);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn:active {
  color: var(--t-tab-hover);
}

/* !important BẮT BUỘC: style.css dòng 1734 đặt
 * `.drawer-tab-btn.is-active { color:#1b1430 !important }` — không có
 * !important thì chữ tab đang chọn vẫn là màu tím đậm cũ trên mọi theme. */
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn.is-active {
  background: linear-gradient(135deg, var(--t-tab-active-1) 0%, var(--t-tab-active-2) 100%);
  background-color: var(--t-tab-active-2);
  color: var(--t-tab-active-text) !important;
  box-shadow: 0 8px 18px -12px var(--t-shadow), inset 0 1px 0 var(--t-tab-active-glow);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn.is-active > span {
  color: var(--t-tab-active-text);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .drawer-tab-btn.is-active .ic {
  color: var(--t-tab-active-text);
}

/* 7.8 10 panel trong ngăn kéo: nền + chữ
 *     Dùng 2 id (#historyDrawer #panelX) để thắng rule remap bg-[#111118]
 *     ở mục 9.1 (vốn có specificity cao hơn 1 id + 1 class). */
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelHistory,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelSutras,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelAudio,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelLang,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelDonate,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelProfile,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelChat,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelTheme,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelLienHoa,
html[data-theme]:not([data-theme="dark"]) #historyDrawer #panelHome {
  background-color: var(--t-panel);
  color: var(--t-text);
}

/* ==========================================================================
 *  8. THANH DƯỚI ĐÁY + 2 NÚT CHUYỂN MÀN HÌNH + NÚT HỒI HƯỚNG
 *  Ở <main> ta CHỈ gọi tên bằng id / phần tử cụ thể, không remap utility
 *  ⇒ không thể chạm vào section tờ phiếu đó.
 * ========================================================================== */

/* 8.1 Khung thanh thao tác (div.bg-stone-900/80 ngay dưới 2 <section>) */
html[data-theme]:not([data-theme="dark"]) main > div[class*="bg-stone-900"] {
  background-color: var(--t-bar-bg);
  border-color: var(--t-border-accent);
  color: var(--t-amber-soft);
  box-shadow: inset 0 1px 0 var(--t-soft);
}
html[data-theme]:not([data-theme="dark"]) #bottomTotalLabel {
  color: var(--t-amber-soft);
}
html[data-theme]:not([data-theme="dark"]) #totalDotsSummary {
  color: var(--t-amber-strong);
}

/* 8.2 Hai nút phụ "Chấm đầy" / "Làm mới" (bg-stone-800 + text-amber-200) */
html[data-theme]:not([data-theme="dark"]) #fillAllBtn,
html[data-theme]:not([data-theme="dark"]) #resetCurrentBtn {
  background-color: var(--t-btn-2-bg);
  border-color: var(--t-border-accent);
  color: var(--t-amber-mid);
}

/* 8.3 Nút mở ngăn kéo — giữ nền tối để hoa sen (SVG trắng/hồng) còn nổi */
html[data-theme]:not([data-theme="dark"]) #drawerToggleBtn {
  background-color: var(--t-dark-btn-bg);
  border-color: var(--t-dark-btn-border);
  color: var(--t-dark-btn-text);
}
html[data-theme]:not([data-theme="dark"]) #drawerToggleBtn:hover {
  background-color: var(--t-dark-btn-bg);
  border-color: var(--t-pill-active-border);
  filter: brightness(1.12);
}

/* 8.4 Nút Hồi hướng (bg-amber-900) */
html[data-theme]:not([data-theme="dark"]) #bottomDedicateBtn {
  background-color: var(--t-strong-btn-bg);
  color: var(--t-strong-btn-text);
}
html[data-theme]:not([data-theme="dark"]) #bottomDedicateBtn:hover {
  background-color: var(--t-strong-btn-bg);
  filter: brightness(1.12);
}

/* 8.5 Hai nút Ngôi Nhà Nhỏ / Diễn Đàn (.mode-pill trong social.css) */
html[data-theme]:not([data-theme="dark"]) .mode-pill {
  background-color: var(--t-pill-bg);
  border-color: var(--t-pill-border);
  color: var(--t-pill-text);
}
html[data-theme]:not([data-theme="dark"]) .mode-pill:hover {
  background-color: var(--t-pill-bg);
  border-color: var(--t-selected-ring);
  color: var(--t-pill-text);
}
html[data-theme]:not([data-theme="dark"]) .mode-pill .ic {
  color: var(--t-pill-icon);
}
html[data-theme]:not([data-theme="dark"]) .mode-pill.is-mode-active {
  background-color: var(--t-pill-active-bg);
  border-color: var(--t-pill-active-border);
  color: var(--t-pill-active-text);
  box-shadow: inset 0 0 0 1px var(--t-pill-active-border);
}
html[data-theme]:not([data-theme="dark"]) .mode-pill.is-mode-active .ic {
  color: var(--t-pill-active-icon);
}

/* ==========================================================================
 *  9. REMAP UTILITY TAILWIND → BIẾN CHỦ ĐỀ
 *  Scope:  html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"])
 *          ↑ chỉ ngăn kéo (10 panel) và các hộp thoại.
 *  Dùng [class~="…"] (khớp đúng 1 token class) để không phải escape
 *  ký tự [#/] của Tailwind, và để không lỡ khớp class khác.
 * ========================================================================== */

/* --- 9.1 Nền thẻ tối → bề mặt chủ đề -------------------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#111118]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#1c1917]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#1a1a24]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#130c20]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#0d0a14]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#241c15]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#2b2219]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950/85"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950/80"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-950/50"] {
  background-color: var(--t-surface);
}

/* --- 9.2 Nền thẻ tối cấp 2 → bề mặt phụ ----------------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#13131A]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#24173e]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-900"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-900/80"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-900/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-900/95"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-stone-800"] {
  background-color: var(--t-surface-2);
}

/* --- 9.3 Mảng trắng mờ / tím nhạt / vàng nhạt ------------------------ */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-white/5"] {
  background-color: var(--t-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-white/10"] {
  background-color: var(--t-soft-2);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-purple-950/30"] {
  background-color: var(--t-tint);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-900/50"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-900/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-500/15"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-500/10"] {
  background-color: var(--t-accent-soft);
}

/* --- 9.4 Thẻ gradient: from-[#241838]→to-[#161026] (và biến thể) ----- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#241838]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#2b1d4a]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-stone-900"] {
  background-image: linear-gradient(135deg, var(--t-card-1) 0%, var(--t-card-2) 100%);
}

/* --- 9.5 Dải header hộp thoại (from-amber-900 … to-stone-900) -------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-r"][class*="from-amber-900"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class*="from-amber-900"] {
  background-image: linear-gradient(135deg, var(--t-band-1) 0%, var(--t-band-2) 100%);
}

/* --- 9.6 Nút chính vàng kim → màu nhấn của chủ đề ------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-stone-950"][class~="bg-amber-400"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-stone-950"][class~="bg-amber-500"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-stone-950"][class*="from-amber-400"] {
  background-color: var(--t-primary-1);
  background-image: linear-gradient(135deg, var(--t-primary-1) 0%, var(--t-primary-2) 100%);
  color: var(--t-primary-fg);
}

/* --- 9.7 Chữ vàng hổ phách ------------------------------------------ */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-300"] {
  color: var(--t-amber-strong);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-300/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-300/80"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-300/75"] {
  color: var(--t-amber-mid);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/80"] {
  color: var(--t-amber-mid);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-100"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-100/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-100/85"] {
  color: var(--t-amber-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-50"] {
  color: var(--t-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-500"] {
  color: var(--t-accent-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-500/55"] {
  color: var(--t-muted-soft);
}

/* --- 9.8 Chữ tím (nhãn phụ trong ngăn kéo) --------------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-50"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-100"] {
  color: var(--t-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-100/80"] {
  color: var(--t-muted);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/80"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/70"] {
  color: var(--t-muted);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/55"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/70"] {
  color: var(--t-muted-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/45"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/50"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/45"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/30"] {
  color: var(--t-muted-dim);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/80"] {
  color: var(--t-title);
}

/* --- 9.9 Chữ xanh ngọc / xanh trời trên nền sáng --------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-100"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-200"] {
  color: var(--t-emerald-strong);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-300/75"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-300/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-400/80"] {
  color: var(--t-emerald-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-100"] {
  color: var(--t-sky-strong);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-400/80"] {
  color: var(--t-sky-text);
}

/* --- 9.10 Viền ------------------------------------------------------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-white/10"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-white/5"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-white/20"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-purple-500/10"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-purple-500/20"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-purple-500/25"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-purple-500/30"] {
  border-color: var(--t-border);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-500/25"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-500/20"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-500/30"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-500/40"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-400/30"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-800/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-amber-900/90"] {
  border-color: var(--t-border-accent);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-stone-600"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-stone-700"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-stone-800"] {
  border-color: var(--t-border-2);
}

/* --- 9.11 Hover ------------------------------------------------------ */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="hover:bg-white/5"]:hover {
  background-color: var(--t-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="hover:bg-white/10"]:hover {
  background-color: var(--t-soft-2);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="hover:bg-stone-700"]:hover {
  background-color: var(--t-soft-2);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="hover:text-white"]:hover {
  color: var(--t-tab-hover);
}

/* --- 9.12 Placeholder ------------------------------------------------ */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="placeholder-amber-500/35"]::placeholder,
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="placeholder:text-purple-300/30"]::placeholder {
  color: var(--t-muted-dim);
}

/* --- 9.13 Ô nhập trong ngăn kéo (bỏ qua range/checkbox/radio/file) ---- */
html[data-theme]:not([data-theme="dark"]) #historyDrawer textarea,
html[data-theme]:not([data-theme="dark"]) #historyDrawer select,
html[data-theme]:not([data-theme="dark"]) #historyDrawer input[type="text"],
html[data-theme]:not([data-theme="dark"]) #historyDrawer input[type="search"],
html[data-theme]:not([data-theme="dark"]) #historyDrawer input[type="number"],
html[data-theme]:not([data-theme="dark"]) #historyDrawer input[type="email"],
html[data-theme]:not([data-theme="dark"]) #historyDrawer input:not([type]) {
  background-color: var(--t-input-bg);
  color: var(--t-text);
  border-color: var(--t-border);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer input::placeholder,
html[data-theme]:not([data-theme="dark"]) #historyDrawer textarea::placeholder {
  color: var(--t-muted-dim);
}

/* --- 9.14 Các biến thể độ mờ còn lại (audit tương phản tìm ra) -------- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-300/70"] {
  color: var(--t-amber-mid);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-400"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-400/90"] {
  color: var(--t-accent-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-100/70"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-100/90"] {
  color: var(--t-muted);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/50"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-200/85"] {
  color: var(--t-muted-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-purple-300/60"] {
  color: var(--t-muted-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-stone-300"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-stone-400"] {
  color: var(--t-muted);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-red-400"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-red-200"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-red-100/85"] {
  color: var(--t-danger-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-red-950/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-red-900/60"] {
  background-color: var(--t-danger-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-950/80"] {
  background-color: var(--t-accent-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-200"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-200/90"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-300"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-300/80"] {
  color: var(--t-sky-strong);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-300/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-sky-300/75"] {
  color: var(--t-sky-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-300"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-400"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-emerald-200/60"] {
  color: var(--t-emerald-text);
}

/* --- 9.15 Biến thể do JS sinh ra (script.js / media-hub.js) ------------ */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/65"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/75"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/85"] {
  color: var(--t-amber-mid);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/50"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-200/40"] {
  color: var(--t-amber-soft);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="text-amber-400/50"] {
  color: var(--t-accent-text);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-950"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-950/60"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-amber-950/70"] {
  background-color: var(--t-accent-soft);
}

/* Nền hex tối còn lại (một số do script.js / media-hub.js dựng bằng JS) */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#110c1c]/80"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#141020]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#170e26]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#1a1327]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#1a1430]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#0b0714]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#0c0817]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#100c1d]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#08060f]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#0f0b1c]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#182232]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#18261f]"] {
  background-color: var(--t-surface-2);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-[#3a1d1d]"] {
  background-color: var(--t-danger-soft);
}

/* --- 9.16 Tab chọn nguồn media (.mnp-media-tab) trong panel Audio ------ */
html[data-theme]:not([data-theme="dark"]) #historyDrawer .mnp-media-tab:not(.active) {
  color: var(--t-muted);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .chip-country,
html[data-theme]:not([data-theme="dark"]) #historyDrawer .chip-auto {
  color: var(--t-muted);
  background-color: var(--t-accent-soft);
  border-color: var(--t-border-accent);
}
html[data-theme]:not([data-theme="dark"]) #historyDrawer .chip-country.active,
html[data-theme]:not([data-theme="dark"]) #historyDrawer .chip-auto.active {
  color: var(--t-primary-fg);
  background-color: var(--t-primary-1);
  border-color: var(--t-primary-2);
}

/* --- 9.17 Các thẻ gradient tối khác (đã quét hết trong index.html) ---- */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#1d1747]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#1f1633]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#241c15]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#261a44]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-[#2a1f18]"],
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-br"][class~="from-gray-700/50"] {
  background-image: linear-gradient(135deg, var(--t-card-1) 0%, var(--t-card-2) 100%);
}
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="border-gray-400/30"] {
  border-color: var(--t-border-accent);
}

/* Dải header Google Play (from-emerald-900 … to-stone-900) → dải màu chủ đề */
html[data-theme]:not([data-theme="dark"]) :is(#historyDrawer, [id$="Modal"]) [class~="bg-gradient-to-r"][class*="from-emerald-900"] {
  background-image: linear-gradient(135deg, var(--t-band-1) 0%, var(--t-band-2) 100%);
}

/* Thanh mini-player media: nền tối để chữ trắng vẫn đọc được ở theme sáng */
html[data-theme]:not([data-theme="dark"]) #historyDrawer [class~="bg-gradient-to-r"][class~="from-indigo-500/25"] {
  background-image: linear-gradient(135deg, var(--t-dark-btn-bg) 0%, var(--t-pill-active-bg) 100%);
}

/* ==========================================================================
 *  10. UI CHỌN CHỦ ĐỀ TRONG #panelTheme
 *  Dùng biến --t-* nên hiển thị ĐÚNG ở cả 5 chủ đề (kể cả theme tối).
 *  Đây là class riêng (.theme-…), không phải utility Tailwind ⇒ không xung
 *  đột với phần remap ở mục 9.
 * ========================================================================== */

/* 10.1 Khối giới thiệu */
.theme-hero {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 16px;
  background-image: linear-gradient(135deg, var(--t-card-1) 0%, var(--t-card-2) 100%);
  border: 1px solid var(--t-border-accent);
  box-shadow: 0 14px 28px -22px var(--t-shadow);
}

.theme-hero__icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  background-color: var(--t-check-bg);
  color: var(--t-check-fg);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.theme-hero__body {
  min-width: 0;
}

.theme-hero__title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--t-amber-strong);
}

.theme-hero__sub {
  margin: 3px 0 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--t-card-ui-desc);
}

/* 10.2 Lưới thẻ: 2 cột trên mobile, tự giãn khi rộng hơn */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  border: 0;
}

@media (min-width: 430px) {
  .theme-grid {
    grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  }
}

/* 10.3 Thẻ chủ đề */
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 7px 7px 9px;
  border-radius: 14px;
  border: 1.5px solid var(--t-card-ui-border);
  background-color: var(--t-card-ui-bg);
  color: var(--t-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.18s ease;
}

.theme-card:hover {
  border-color: var(--t-selected-ring);
  transform: translateY(-1px);
}

.theme-card:active {
  transform: scale(0.985);
}

.theme-card:focus-visible {
  outline: 2px solid var(--t-selected-ring);
  outline-offset: 2px;
}

.theme-card.is-selected {
  border-color: var(--t-selected-ring);
  box-shadow: 0 0 0 2px var(--t-card-ui-bg), 0 0 0 3.5px var(--t-selected-ring),
    0 12px 22px -18px var(--t-shadow);
}

/* 10.4 Ô xem trước 4 sọc màu */
.theme-swatch {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--t-swatch-border);
  background-color: #000;
}

.theme-swatch > i {
  display: block;
  height: 100%;
}

.theme-card[data-theme-option="dark"] .theme-swatch > i:nth-child(1) { background-color: #0f0d15; }
.theme-card[data-theme-option="dark"] .theme-swatch > i:nth-child(2) { background-color: #241838; }
.theme-card[data-theme-option="dark"] .theme-swatch > i:nth-child(3) { background-color: #fcd34d; }
.theme-card[data-theme-option="dark"] .theme-swatch > i:nth-child(4) { background-color: #a5b4fc; }

.theme-card[data-theme-option="light"] .theme-swatch > i:nth-child(1) { background-color: #f5efe4; }
.theme-card[data-theme-option="light"] .theme-swatch > i:nth-child(2) { background-color: #fffdfa; }
.theme-card[data-theme-option="light"] .theme-swatch > i:nth-child(3) { background-color: #b45309; }
.theme-card[data-theme-option="light"] .theme-swatch > i:nth-child(4) { background-color: #3b2a1a; }

.theme-card[data-theme-option="space"] .theme-swatch > i:nth-child(1) { background-color: #060b18; }
.theme-card[data-theme-option="space"] .theme-swatch > i:nth-child(2) { background-color: #0c1529; }
.theme-card[data-theme-option="space"] .theme-swatch > i:nth-child(3) { background-color: #22d3ee; }
.theme-card[data-theme-option="space"] .theme-swatch > i:nth-child(4) { background-color: #a78bfa; }

.theme-card[data-theme-option="sakura"] .theme-swatch > i:nth-child(1) { background-color: #fff5f7; }
.theme-card[data-theme-option="sakura"] .theme-swatch > i:nth-child(2) { background-color: #ffffff; }
.theme-card[data-theme-option="sakura"] .theme-swatch > i:nth-child(3) { background-color: #d6336c; }
.theme-card[data-theme-option="sakura"] .theme-swatch > i:nth-child(4) { background-color: #46212f; }

.theme-card[data-theme-option="meadow"] .theme-swatch > i:nth-child(1) { background-color: #f1f7ee; }
.theme-card[data-theme-option="meadow"] .theme-swatch > i:nth-child(2) { background-color: #ffffff; }
.theme-card[data-theme-option="meadow"] .theme-swatch > i:nth-child(3) { background-color: #2f7d32; }
.theme-card[data-theme-option="meadow"] .theme-swatch > i:nth-child(4) { background-color: #1f3a24; }

/* 10.5 Tên + mô tả */
.theme-card__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.theme-card__name {
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--t-text);
}

.theme-card__badge {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--t-border-accent);
  background-color: var(--t-accent-soft);
  color: var(--t-amber-strong);
  white-space: nowrap;
}

.theme-card__desc {
  display: block;
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--t-card-ui-desc);
}

/* 10.6 Dấu ✓ chỉ hiện ở thẻ đang chọn */
.theme-card__check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 17px;
  height: 17px;
  padding: 2.5px;
  border-radius: 999px;
  background-color: var(--t-check-bg);
  color: var(--t-check-fg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.theme-card.is-selected .theme-card__check {
  opacity: 1;
  transform: scale(1);
}

/* 10.7 Dòng ghi chú cuối panel */
.theme-foot {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--t-muted-soft);
}

.theme-foot .ic {
  width: 12px;
  height: 12px;
  margin-top: 2px;
  color: var(--t-amber-strong);
}



