/* ═══════════════════════════════════════════════════════════════════════
   GIAO DIỆN B "PHẲNG SÁNG, NỔI NHẸ" — 11/9/2026
   Hiến chương: tu-vi-ban-sac-thiet-ke.md mục 2, 4, 12.
   Bản vẽ gốc: thiet-ke/giao-dien-tu-tru/BNheMayTinh.dc.html, BNheDienThoai.dc.html.
   Nạp SAU khối <style> của tu-vi-thienban.html (cùng độ ưu tiên thì file này thắng).
   Màu chỉ lấy từ token. Token mới khai báo ngay dưới đây, đủ bốn trạng thái theme.
   ═══════════════════════════════════════════════════════════════════════ */

/* ═══ TOKEN MỚI ═══ */
:root {
  /* Chiều sâu: MỘT bộ bóng nhẹ. Muốn thêm phong cách "nổi khối" sau này: thêm khối
     :root[data-phong="noi"] đổi giá trị các token này, không sửa quy tắc nào bên dưới. */
  --bong-nhe:  0 1px 2px rgba(60, 40, 10, .08), 0 6px 14px -8px rgba(60, 40, 10, .3);
  --bong-son:  0 1px 2px rgba(166, 40, 40, .12), 0 8px 18px -8px rgba(166, 40, 40, .38);
  --bong-vang: 0 1px 2px rgba(138, 109, 31, .12), 0 6px 14px -8px rgba(138, 109, 31, .45);
  --r-khoi: 6px;
  --son-chu: #A62828;              /* chữ son nhỏ (nhãn "Nhật chủ", biểu tượng cảnh báo) */
  /* 24/9/2026 (N3-8): đổi tên từ --hanh-* — trước đây khai báo trùng tên với trang chính, nạp sau nên đè bộ màu hành gói C */
  --cham-kim: #9A8F7E; --cham-moc: #4F7D5A; --cham-thuy: #3D6A8F; --cham-hoa: #B14A3E; --cham-tho: #8A6D1F;
  --chim-mau: #8A6D1F; --chim-do-mo: .13;
  --trien-son: #A62828; --trien-giay: #FBF8F1; --trien-tron: multiply;
  --dap-nen: rgba(112, 88, 64, .10); --dap-chu: rgba(255, 255, 255, .62);
  --dap-bong: drop-shadow(0 1px 0 rgba(255, 255, 255, .85)) drop-shadow(0 -1px 0 rgba(90, 60, 20, .18));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bong-nhe:  0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px -8px rgba(0, 0, 0, .8);
    --bong-son:  0 1px 2px rgba(0, 0, 0, .5), 0 8px 18px -8px rgba(218, 108, 86, .45);
    --bong-vang: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px -8px rgba(201, 154, 58, .35);
    /* 13/9/2026 — bản tối cho B: dùng chung màu với --menh-bdr mới (#DA6C56) thay vì giá trị
       riêng cũ #E06A5E. Trước đây phải tách riêng vì --menh-bdr tối #BC4038 không đạt 4,5:1 cho
       chữ nhỏ; nay --menh-bdr đã đo lại đạt 5,05:1 trên nền thẻ Nhật chủ nên gộp về một giá trị. */
    --son-chu: #DA6C56;
    --chim-mau: #C8A04A; --chim-do-mo: .07;
    --trien-son: #BC4038; --trien-giay: #F3EDE0; --trien-tron: normal;
    --dap-nen: rgba(200, 160, 74, .08); --dap-chu: rgba(226, 216, 200, .22); --dap-bong: none;
  }
}
:root[data-theme="light"] {
  --bong-nhe:  0 1px 2px rgba(60, 40, 10, .08), 0 6px 14px -8px rgba(60, 40, 10, .3);
  --bong-son:  0 1px 2px rgba(166, 40, 40, .12), 0 8px 18px -8px rgba(166, 40, 40, .38);
  --bong-vang: 0 1px 2px rgba(138, 109, 31, .12), 0 6px 14px -8px rgba(138, 109, 31, .45);
  --son-chu: #A62828;
  --chim-mau: #8A6D1F; --chim-do-mo: .13;
  --trien-son: #A62828; --trien-giay: #FBF8F1; --trien-tron: multiply;
  --dap-nen: rgba(112, 88, 64, .10); --dap-chu: rgba(255, 255, 255, .62);
  --dap-bong: drop-shadow(0 1px 0 rgba(255, 255, 255, .85)) drop-shadow(0 -1px 0 rgba(90, 60, 20, .18));
}
:root[data-theme="dark"] {
  --bong-nhe:  0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px -8px rgba(0, 0, 0, .8);
  --bong-son:  0 1px 2px rgba(0, 0, 0, .5), 0 8px 18px -8px rgba(188, 64, 56, .45);
  --bong-vang: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px -8px rgba(200, 160, 74, .35);
  --son-chu: #DA6C56;
  --chim-mau: #C8A04A; --chim-do-mo: .07;
  --trien-son: #BC4038; --trien-giay: #F3EDE0; --trien-tron: normal;
  --dap-nen: rgba(200, 160, 74, .08); --dap-chu: rgba(226, 216, 200, .22); --dap-bong: none;
}

/* ═══ NỔI NHẸ CHO CÁC KHỐI ĐANG CÓ (hiến chương mục 4: chỉ những chỗ này có bóng) ═══ */
.tb-cuon { padding-bottom: 8px; }                 /* chừa chỗ cho bóng, khung cuộn ngang cắt mất nếu không */
.thienban-grid { border-radius: var(--r-khoi); box-shadow: var(--bong-nhe); }
.cung-cell.is-menh { box-shadow: var(--bong-son); }
.mb-the { box-shadow: var(--bong-nhe); }
.mb-the.is-menh { box-shadow: var(--bong-son); }

/* ═══ CHỮ ẨN CHO TRÌNH ĐỌC MÀN HÌNH ═══ */
.bt-an {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ═══ TRIỆN ═══ */
.trien-o-dap > svg, .trien-o-son > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trien-son { transform: rotate(-3deg); mix-blend-mode: var(--trien-tron); }
.trien-son .nen { fill: var(--trien-son); }
.trien-son .chu { fill: var(--trien-giay); }
.trien-son .vien { stroke: var(--trien-giay); }
.trien-dap { filter: var(--dap-bong); }
.trien-dap .nen { fill: var(--dap-nen); }
.trien-dap .chu { fill: var(--dap-chu); }
.trien-dap .vien { stroke: var(--dap-chu); }

/* Tựa đầu trang 命書: cùng bộ chữ với triện (Noto Serif TC chỉ tải đúng các ký tự cần) */

/* Dập chìm ở cuối dải thông tin người xem */
.person-strip { position: relative; }
.person-strip .trien-o-dap { margin-left: auto; flex: 0 0 auto; width: 40px; height: 40px; }

/* Chân trang: câu định vị + "Lập bởi" + triện son (một triện mỗi màn hình) */
.chan-trang {
  width: 100%; max-width: 880px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px;
  margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--border-cell);
}
.chan-dinh-vi { max-width: 620px; font-size: 13px; line-height: 1.5; color: var(--text-dim); }
/* Lối vào trang "Vì sao tin được" (21/9/2026) — đặt cạnh câu định vị, không phải nút mời mua */
.chan-tin-duoc { color: var(--menh-bdr); text-decoration: none; border-bottom: 1px solid currentColor; white-space: nowrap; }
.chan-tin-duoc:hover { opacity: .8; }
.chan-lap { display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
.chan-lap-chu { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.chan-lap-ten { font-family: 'Cormorant Garamond', Cambria, Constantia, serif; font-size: 21px; font-weight: 700; line-height: 1.2; color: var(--text); }
.chan-lap-web { margin-top: 2px; font-size: 12px; color: var(--menh-bdr); text-decoration: none; border-bottom: 1px solid transparent; }
.chan-lap-web:hover { border-bottom-color: currentColor; }
.trien-o-son { width: 76px; height: 76px; flex: 0 0 auto; }

/* ═══ MÀN TỨ TRỤ — chuyển chế độ ═══ */
#tutru-panel { display: none; width: 100%; max-width: 1200px; }
body.mode-tutru #tutru-panel { display: block; }
body.mode-tutru .thienban-wrap,
body.mode-tutru .legend-strip { display: none !important; }
body.mode-tutru .chan-trang,
body.mode-tutru .person-strip { max-width: 1200px; }

/* ═══ MÀN TỨ TRỤ — khung chung ═══ */
.bt-khung { display: flex; flex-direction: column; gap: 16px; font-size: 15px; line-height: 1.5; color: var(--text); }
.bt-the {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--bg-cell); border: 1px solid var(--border); border-radius: var(--r);
}
.bt-serif { font-family: 'Cormorant Garamond', Cambria, Constantia, serif; }
.bt-nhan { font-size: 12px; font-weight: 600; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.bt-phu { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.bt-chu { font-size: 15px; line-height: 1.5; }
.bt-dau { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
.bt-nguon { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.bt-rong { padding: 20px 22px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

/* Hình chìm: dưới nội dung, lệch ra ngoài mép thẻ, không nhận chạm */
.bt-chim { position: absolute; z-index: -1; pointer-events: none; color: var(--chim-mau); opacity: var(--chim-do-mo); }
.bt-chim .nen { fill: var(--bg-cell); }

/* Cảnh báo lịch pháp: luôn đứng trước Bát tự (hiến chương mục 5, 12.1) */
.bt-canh-bao {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px;
  background: var(--menh-bg); border: 1px solid var(--menh-bdr); border-radius: var(--r);
  font-size: 15px; line-height: 1.55;
}
.bt-canh-bao-dau { flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px; color: var(--son-chu); }
.bt-canh-bao-than { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bt-vi-sao summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-cell); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; list-style: none;
}
.bt-vi-sao summary::-webkit-details-marker { display: none; }
.bt-vi-sao p { margin-top: 10px; font-size: 14px; line-height: 1.6; }

/* ═══ Hàng 1: Tử Vi tóm tắt + Tứ Trụ ═══ */
.bt-hang1 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1240px) { .bt-hang1 { grid-template-columns: 340px minmax(0, 1fr); } }

.bt-tuvi { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.bt-tuvi > .bt-chim { right: -90px; bottom: -90px; width: 300px; height: 300px; }
.bt-menh { display: flex; align-items: baseline; gap: 8px; }
.bt-menh .bt-serif { font-size: 24px; font-weight: 700; line-height: 1.1; }
.bt-sao-ds { display: flex; flex-direction: column; gap: 6px; }
.bt-sao { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 15px; }
.bt-sao .sao-dot { width: 8px; height: 8px; }
.bt-hoa { display: flex; flex-wrap: wrap; gap: 6px; }
.bt-hoa .hoa-badge { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 3px; line-height: 1.5; }
.bt-ke { height: 1px; background: var(--border-cell); }
.bt-bang { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; }
.bt-bang dt { font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.bt-bang dd { font-size: 15px; }

.bt-battu { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.bt-battu .bt-chim { right: -120px; top: 70px; width: 470px; height: 470px; }
.bt-tru-luoi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 2px 2px 8px; }
.bt-tru {
  min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px;
  background: var(--bg-cell); border: 1px solid var(--border-cell); border-radius: var(--r-khoi);
  box-shadow: var(--bong-nhe);
}
.bt-tru.la-nhat-chu { background: var(--menh-bg); border: 1.5px solid var(--menh-bdr); box-shadow: var(--bong-son); }
.bt-tru-dau {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0 6px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-cell);
}
.bt-tru-dau b { font-size: 15px; }
.bt-tru-dau span { font-size: 13px; color: var(--text-dim); }
.bt-tru-dau .bt-la-nc { font-weight: 600; color: var(--son-chu); }
.bt-tru-than { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* Cỡ can chi đo bằng canvas trên cả 60 hoa giáp (11/9/2026): rộng nhất "Nhâm Thân" = 177px ở 38px.
   Ô trụ máy tính hai cột còn 163px cho chữ → tối đa 35px, chọn 34px. Khổ 701–1239px ô trụ co theo
   bề ngang → cỡ chữ co theo (công thức giữ "Nhâm Thân" vừa ô, sàn 24px). */
.bt-canchi { font-size: 34px; font-weight: 700; line-height: 1.05; }
@media (max-width: 1239px) { .bt-canchi { font-size: clamp(24px, calc(5.3vw - 12px), 38px); } }
.bt-hanh { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: 13px; color: var(--text-dim); }
.bt-hanh-o { display: inline-flex; align-items: center; gap: 6px; }
.bt-cham { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
.bt-cham.h-kim { background: var(--cham-kim); }
.bt-cham.h-moc { background: var(--cham-moc); }
.bt-cham.h-thuy { background: var(--cham-thuy); }
.bt-cham.h-hoa { background: var(--cham-hoa); }
.bt-cham.h-tho { background: var(--cham-tho); }
.bt-tang { font-size: 14px; line-height: 1.5; }
.bt-tang-nhan { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.bt-napam { font-size: 13px; font-style: italic; color: var(--text-dim); }

.bt-thongtin { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (min-width: 701px) and (max-width: 900px) { .bt-thongtin { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bt-muc { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bt-noidung { font-size: 14px; line-height: 1.55; }

/* ═══ Nhịp thời gian ═══ */
.bt-nhip { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.bt-cuon-ngang { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 2px 10px; }
.bt-luoi-nhip { display: grid; grid-template-columns: 120px repeat(10, minmax(88px, 1fr)); gap: 6px; align-items: stretch; }
.bt-hang-ten { grid-row: var(--h); grid-column: var(--c); align-self: center; font-size: 13px; color: var(--text-dim); }
.bt-chang {
  grid-row: var(--h); grid-column: var(--c); min-width: 0;
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px;
  background: var(--bg-cell); border: 1px solid var(--border-cell); border-radius: var(--r);
}
.bt-chang-ten { font-size: 14px; line-height: 1.35; }
.bt-chang.dang-di { background: var(--dh-bg); border: 1.5px solid var(--dh-bdr); box-shadow: var(--bong-vang); }

/* ═══ Đối chiếu 8 chủ đề ═══ */
.bt-dc-dau { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 16px; margin-top: 8px; }
.bt-dc-dau h2 { font-size: 26px; font-weight: 700; line-height: 1.2; }
.bt-dc-luoi { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 900px) { .bt-dc-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bt-dc { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bt-dc-tieude { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.bt-dc-tieude h3 { font-size: 20px; font-weight: 700; line-height: 1.2; }
.bt-dc-nhan { display: flex; flex-wrap: wrap; gap: 6px; }
.bt-dc-hai { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bt-nhan-dc {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px;
  border: 1px solid var(--border-cell); border-radius: 3px;
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text);
}
.bt-nhan-dc.cung-chieu { background: var(--dh-bg); border-color: var(--dh-bdr); }
.bt-nhan-dc.khac-chieu { background: var(--than-bg); border-color: var(--than-bdr); }
.bt-nhan-dc.chua-du { background: transparent; border-style: dashed; border-color: var(--text-xs); color: var(--text-dim); }
.bt-gd { display: flex; flex-direction: column; gap: 10px; }
.bt-gd-hang { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.bt-gd-hang .bt-nhan-dc { justify-self: start; }

/* ═══ Điện thoại dọc ═══ */
@media (max-width: 700px) {
  .person-strip { padding-right: 58px; }
  .person-strip .trien-o-dap { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; margin: 0; }

  .chan-trang { flex-direction: column; align-items: stretch; gap: 14px; padding-top: 16px; }
  .chan-lap { justify-content: flex-end; gap: 12px; }
  .chan-lap-nhan { display: none; }
  .chan-lap-ten { font-size: 18px; }
  .trien-o-son { width: 58px; height: 58px; }

  .bt-khung { gap: 12px; }
  .bt-tuvi { padding: 12px 14px; gap: 8px; }
  .bt-tuvi > .bt-chim { right: -80px; bottom: -80px; width: 230px; height: 230px; }
  .bt-menh .bt-serif { font-size: 22px; }
  .bt-bang { grid-template-columns: 96px minmax(0, 1fr); gap: 2px 10px; }

  /* Bốn trụ thành bốn thẻ ngang; khung Tứ Trụ trong suốt */
  .bt-battu { padding: 0; gap: 12px; background: none; border: 0; overflow: visible; isolation: auto; }
  .bt-battu > .bt-dau { margin-top: 6px; }
  .bt-battu > .bt-dau .bt-nhan {
    font-family: 'Cormorant Garamond', Cambria, Constantia, serif; font-size: 24px; font-weight: 700;
    letter-spacing: 0; text-transform: none; color: var(--text);
  }
  .bt-tru-luoi { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 0; }
  .bt-tru { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 4px 12px; padding: 12px 14px; }
  .bt-tru-dau { flex-direction: column; justify-content: flex-start; align-items: flex-start; padding-bottom: 0; border-bottom: 0; }
  .bt-tru-than { gap: 4px; }
  .bt-canchi { font-size: 30px; }
  .bt-tang-nhan { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; color: var(--text-dim); }

  /* Thần sát, xung hình, không vong, cân bằng thành một thẻ nhiều dòng kẻ mảnh */
  .bt-thongtin {
    position: relative; overflow: hidden; isolation: isolate;
    grid-template-columns: minmax(0, 1fr); gap: 0; padding: 4px 14px;
    background: var(--bg-cell); border: 1px solid var(--border); border-radius: var(--r);
  }
  .bt-battu .bt-thongtin > .bt-chim { right: -150px; top: -20px; width: 320px; height: 320px; }
  .bt-muc { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 4px 10px; padding: 12px 0; }
  .bt-muc + .bt-muc { border-top: 1px solid var(--border-cell); }

  /* Nhịp thời gian thành bảng hai cột: đại hạn | đại vận */
  .bt-nhip { padding: 4px 14px 10px; gap: 6px; }
  .bt-nhip > .bt-dau { padding-top: 10px; }
  .bt-cuon-ngang { overflow: visible; padding: 0; }
  .bt-luoi-nhip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .bt-hang-ten { grid-row: var(--h-dt); grid-column: var(--c-dt); padding: 10px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
  .bt-chang { grid-row: var(--h-dt); grid-column: var(--c-dt); padding: 8px 0; background: none; border: 0; border-top: 1px solid var(--border-cell); border-radius: 0; }
  .bt-chang.dang-di { padding: 8px 6px; border: 0; border-top: 2px solid var(--dh-bdr); border-radius: 0 0 4px 4px; background: var(--dh-bg); box-shadow: var(--bong-vang); }

  .bt-dc-dau { flex-direction: column; margin-top: 6px; }
  .bt-dc-dau h2 { font-size: 24px; }
  .bt-dc { padding: 12px 14px; gap: 8px; }
  .bt-dc-hai { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .bt-gd-hang { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

@media print {
  /* Nền lớn của B (--bg/--bg-cell/--menh-bg...) đã bị tắt ở khối @media print gốc trong
     tu-vi-thienban.html — mọi thẻ .bt-the/.bt-tru ở đây dùng chung token nên tự động trắng
     theo, không cần lặp lại. Ở đây chỉ xử lý riêng của màn Tứ Trụ: bỏ bóng nổi, mở khung cuộn
     ngang (nhịp thời gian) kẻo bị cắt mất khi in, và ẩn nút chỉ có nghĩa lúc tương tác. */
  .thienban-grid, .cung-cell.is-menh, .mb-the, .bt-tru, .bt-chang { box-shadow: none !important; }
  .bt-vi-sao summary { display: none; }
  .bt-rong .btn-primary { display: none; } /* nút "An lá số theo ngày giờ trong form" */
  .bt-cuon-ngang { overflow: visible; }
  .bt-khung { break-inside: avoid-page; }
  .chan-trang { break-inside: avoid; }
}


/* ═══ ĐIỀU HƯỚNG THEO MÔN + KHUNG BÀI LUẬN AI — 13/9/2026 ═══
   Hai loại bài luận ở hai chỗ riêng (chị Thẩm yêu cầu): môn (Tử Vi · Tứ Trụ · Phối hợp) ở đầu trang,
   phần xem (Lá số · Bài luận · Hỏi đáp) ở hàng thứ hai. Màu chỉ lấy token nên tự khớp sáng/tối. */
.mon-nav { display: flex; gap: 6px; }
.xem-nav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 8px 20px; border-bottom: 1px solid var(--border-cell); background: var(--bg);
}
.xem-nhom { display: flex; flex-wrap: wrap; gap: 4px; }
.xem-nhom[hidden] { display: none; }
.xem-btn, .kieu-btn {
  font: inherit; font-size: 14px; line-height: 1.3; min-height: 36px; padding: 6px 14px; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--text-dim);
}
.kieu-btn { font-size: 13px; }
.xem-btn:hover, .kieu-btn:hover { color: var(--text); border-color: var(--border); }
.xem-btn.active { color: var(--text); font-weight: 600; background: var(--bg-cell); border-color: var(--menh-bdr); box-shadow: var(--bong-nhe); }
.kieu-btn.active { color: var(--text); font-weight: 600; background: var(--bg-cell); border-color: var(--border); }
.xem-btn:focus-visible, .kieu-btn:focus-visible, .ai-nut-phu:focus-visible, .ai-chip:focus-visible,
.ai-o input:focus-visible, .ai-o textarea:focus-visible { outline: 2px solid var(--than-bdr); outline-offset: 2px; }

/* Chế độ "ai" (Tứ Trụ / Phối hợp → Bài luận, Hỏi đáp) và các phần ẩn theo môn */
#ai-panel { display: none; width: 100%; max-width: 760px; margin: 16px auto 0; }
body.co-ai #ai-panel { display: block; }
body.mode-ai .thienban-wrap, body.mode-ai .legend-strip, body.mode-ai .phi-panel,
body.mode-ai #sky3d-wrap, body.mode-ai #diban-bar { display: none !important; }
/* Lá số Tứ Trụ: bỏ "Tử Vi · tóm tắt" và "Đối chiếu 8 chủ đề" — hai phần đó thuộc Phối hợp */
body.mon-tu_tru #tutru-panel .bt-tuvi,
body.mon-tu_tru #tutru-panel section[aria-labelledby="bt-dc-tieude"],
body.mon-tu_tru #diban-bar { display: none !important; }
@media (min-width: 1240px) { body.mon-tu_tru .bt-hang1 { grid-template-columns: minmax(0, 1fr); } }

/* Khung bài luận */
.ai-khung {
  padding: 18px 22px 16px; color: var(--text);
  background: var(--bg-cell); border: 1px solid var(--border); border-radius: var(--r-khoi); box-shadow: var(--bong-nhe);
}
.ai-dau { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.ai-tieu-de { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.25; color: var(--text); }
.ai-goi { font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.ai-nut-phu {
  font: inherit; font-size: 13px; line-height: 1.3; min-height: 36px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r); background: transparent; color: var(--text-dim);
}
.ai-dau .ai-nut-phu { margin-left: auto; }
.ai-nut-phu:hover { color: var(--text); border-color: var(--text-dim); }
.ai-cai {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; gap: 10px 14px;
  margin-top: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--r);
}
.ai-cai[hidden], .ai-hoi[hidden], .ai-cua[hidden] { display: none; }
.ai-o { display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.ai-o input, .ai-o textarea {
  font: inherit; font-size: 15px; line-height: 1.5; min-height: 40px; padding: 8px 10px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r);
}
.ai-o textarea { resize: vertical; }
.ai-dinh-vi { margin: 10px 0 0; font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.ai-hoi { margin-top: 14px; }
.ai-goi-y { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-chip {
  font: inherit; font-size: 13px; line-height: 1.3; min-height: 32px; padding: 5px 11px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text-dim);
}
.ai-chip:hover { color: var(--text); border-color: var(--accent-b); }
.ai-hanh-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }
.ai-hanh-dong .btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.ai-trang-thai { font-size: 13px; line-height: 1.45; color: var(--text-dim); }
.ai-cua {
  margin-top: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.55; color: var(--text);
  background: var(--dh-bg); border-left: 3px solid var(--dh-bdr); border-radius: 0 var(--r) var(--r) 0;
}
.ai-cua p { margin: 0; }
.ai-cua p + p { margin-top: 6px; }
.ai-cua code { font-size: 13px; padding: 1px 5px; border-radius: 3px; background: var(--bg-cell); }

/* Chữ bài luận: serif dễ đọc tiếng Việt (Cambria trước — Georgia vỡ dấu chồng), dòng rộng vừa mắt */
.ai-bai { margin-top: 6px; font-family: Cambria, Constantia, 'Cormorant Garamond', serif; font-size: 17px; line-height: 1.7; color: var(--text); }
.ai-bai:empty { display: none; }
.ai-bai h3 { margin: 26px 0 8px; font-family: 'Cormorant Garamond', Cambria, Constantia, serif; font-size: 24px; font-weight: 700; line-height: 1.3; color: var(--text); }
.ai-bai h4 { margin: 20px 0 6px; font-size: 18px; font-weight: 700; line-height: 1.35; }
.ai-bai p { margin: 0 0 12px; }
.ai-bai blockquote { margin: 12px 0; padding: 2px 0 2px 14px; font-style: italic; color: var(--text-dim); border-left: 2px solid var(--dh-bdr); }
.ai-bai ul { margin: 0 0 12px; padding-left: 22px; }

/* ═══ CĂN ĐỀU + GIÃN DÒNG THỐNG NHẤT cho THÂN VĂN XUÔI (đồng bộ MÀN HÌNH ↔ mọi bản PDF) — chủ dự án
   yêu cầu "chữ căn đều, lề trái phải đều nhau, giãn dòng thống nhất". line-height 1.7 · justify
   inter-word · hyphens:none (tiếng Việt không ngắt gạch nối; dòng cuối đoạn tự canh trái nên không
   giãn chữ). CHỈ áp đoạn văn ĐỌC; KHÔNG áp tiêu đề, nhãn, badge, blockquote (giữ nghiêng canh trái),
   bảng lá số, hay dòng dùng flex. ═══ */
.ai-bai, .ai-bai p, .ai-dinh-vi, p.bt-phu, .bt-noidung,
.bt-vi-sao p, .bt-canh-bao-than p, .ai-cua p { line-height: 1.7; }
.ai-bai p, .ai-bai li, .ai-dinh-vi, p.bt-phu, .bt-noidung,
.bt-vi-sao p, .bt-canh-bao-than p, .ai-cua p,
.bt-nguon, .ai-rieng-tu, .chan-dinh-vi {
  text-align: justify; text-justify: inter-word; hyphens: none;
}
.ai-bai.dang-viet > :last-child::after { content: '▍'; margin-left: 2px; color: var(--dh-bdr); animation: ai-nhay 1s steps(2) infinite; }
@keyframes ai-nhay { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ai-bai.dang-viet > :last-child::after { animation: none; } }
.ai-can-cu { margin-top: 20px; padding-top: 12px; font-family: inherit; font-size: 14px; line-height: 1.5; color: var(--text-dim); border-top: 1px solid var(--border-cell); }
.ai-bai .ai-can-cu { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.ai-can-cu summary { min-height: 32px; font-weight: 600; cursor: pointer; }
.ai-can-cu ul { margin: 6px 0 0; padding-left: 20px; }
.ai-rieng-tu { margin: 16px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
/* Tùy chọn "Nói thẳng điều sách luận" (nội dung mức 2 của kho Tử Vi) — cả dòng là vùng bấm */
.ai-noi-thang { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; max-width: 68ch; min-height: 44px; font-size: 13px; line-height: 1.5; color: var(--text-dim); cursor: pointer; }
.ai-noi-thang b { color: var(--text); font-weight: 600; }
.ai-noi-thang input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; cursor: pointer; }

@media (max-width: 700px) {
  .xem-nav { flex-wrap: nowrap; overflow-x: auto; padding: 6px 12px; scrollbar-width: none; }
  .xem-nav::-webkit-scrollbar { display: none; }
  .xem-nhom { flex-wrap: nowrap; }
  .xem-btn, .kieu-btn, .ai-nut-phu, .ai-chip { min-height: 44px; white-space: nowrap; }
  .ai-khung { padding: 14px 14px 12px; }
  .ai-tieu-de { font-size: 21px; }
  .ai-dau .ai-nut-phu { margin-left: 0; }
}

@media print {
  .xem-nav, .ai-cai, .ai-hoi, .ai-hanh-dong, .ai-cua, #ai-mo-cai, .ai-rieng-tu, .ai-noi-thang { display: none !important; }
  .ai-khung { padding: 0; border: 0; box-shadow: none !important; }
  .ai-bai.dang-viet > :last-child::after { content: none; }
}

/* Điện thoại: thanh đọc của bài tóm lược không ghim đáy màn hình khi đang xem Bài luận/Hỏi đáp — nếu ghim, nó che bài luận AI
   và dễ bị hiểu nhầm là nút đọc bài AI (thử trên 375px, 13/9/2026). */
@media (max-width: 700px) {
  body.co-ai #lg-panel > .lg-audio, body.co-ai #cd-audio { position: static; box-shadow: none; }
  body.co-ai.mode-luangiai .main, body.co-ai.mode-chude .main { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

/* Đọc bài luận AI (13/9/2026): đoạn đang đọc tô nền vàng nhạt cùng họ cửa gói, đoạn đã đọc giữ nguyên màu chữ (không làm mờ — mờ thì trượt tương phản) */
.ai-doc { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.ai-doc[hidden] { display: none; }
.ai-bai .speaking { background: var(--dh-bg); box-shadow: -8px 0 0 var(--dh-bg), 8px 0 0 var(--dh-bg); border-radius: 2px; }
.ai-bai h3.speaking, .ai-bai h4.speaking { box-shadow: -8px 0 0 var(--dh-bg), 8px 0 0 var(--dh-bg), inset 3px 0 0 var(--dh-bdr); }
@media print { .ai-doc { display: none !important; } .ai-bai .speaking { background: none; box-shadow: none; } }

/* ═══ Vùng chạm ≥ 44px và chữ ký hiệu trên điện thoại (kiểm định N3-16, 25/9/2026) ═══
   Link chân trang: gạch chân bằng text-decoration (viền dưới sẽ trôi theo phần đệm), phần đệm dọc mở rộng vùng chạm
   mà không đổi dòng chữ (link nội dòng) hoặc bù bằng lề âm (link khối). */
.chan-tin-duoc { border-bottom: none; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.chan-lap-web { border-bottom: none; text-underline-offset: 3px; }
.chan-lap-web:hover { text-decoration: underline; }
@media (pointer: coarse), (max-width: 767px) {
  .chan-tin-duoc { padding: 14px 2px; }
  .chan-lap-web { padding: 14px 0; margin-top: -12px; margin-bottom: -14px; }
  #btn-tts { min-width: 44px; }
  .sao-ds { font-size: 12px; min-width: 12px; }
  .sao-hai-mat { font-size: 10px; }
}

/* Triện-logo đầu trang giữ 42px (hiến chương 12.3 masthead) — .trien-o-son (triện đóng chân trang 76/58px) nạp sau
   từng đè lên thành 76/58px, đầu trang cao 103/131px (kiểm định N3-13, 25/9/2026). */
.title-trien.trien-o-son { width: 42px; height: 42px; }

/* So lá số hai người (25/9/2026): khối lời mời trong khung bài luận AI — token hiện hành, vùng chạm ≥ 44px */
.ai-slm { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-cell); padding: 14px 16px; margin: 10px 0 14px; }
.ai-slm-dan { font-size: 14px; color: var(--text-dim); margin: 0 0 10px; line-height: 1.6; }
.ai-slm-tao { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.ai-slm-tao select { min-height: 44px; }
.ai-slm-cua-toi { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.ai-slm-cua-toi input { width: 20px; height: 20px; accent-color: var(--menh-bdr); }
.ai-slm-link { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--dh-bdr); background: var(--dh-bg); border-radius: 0 8px 8px 0; font-size: 14px; }
.ai-slm-link p { margin: 0 0 8px; }
.ai-slm-link-hang { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-slm-link-hang input { flex: 1 1 240px; min-width: 0; min-height: 44px; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.ai-slm-td { font-size: 15px; margin: 16px 0 6px; }
.ai-slm-ds p { font-size: 14px; color: var(--text-dim); margin: 4px 0; }
.ai-slm-muc { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; align-items: center; border-top: 1px solid var(--border-cell); padding: 10px 0; font-size: 14px; }
.ai-slm-phu { font-size: 13px; color: var(--text-dim); }
.ai-slm-nut { display: flex; gap: 8px; flex-wrap: wrap; }
