/* ==================================================
   1. RESET & PHÔNG CHỮ CHUNG
   ================================================== */
#tu-vi-form-container, .laso-wrapper, .luan-giai-wrapper {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ==================================================
   2. GIAO DIỆN FORM NHẬP LIỆU
   ================================================== */
#tu-vi-form-container {
    max-width: 850px;
    margin: 20px auto;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    text-align: justify;
}
.form-header {
    background: #8B0000;
    color: #fff;
    text-align: center;
    padding: 15px;
}
.form-header h2 { margin: 0; font-size: 20px; text-transform: uppercase; font-weight: 700; }
#tu-vi-form { padding: 25px; background: #fdfbf7; }
.form-row { display: flex; gap: 15px; margin-bottom: 15px; }
.form-group { flex: 1; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; color: #444; font-size: 14px; }
#tu-vi-form select, #tu-vi-form input[type="text"] {
    width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;
}
.select-group { display: flex; gap: 5px; }
.radio-group { display: flex; gap: 15px; padding: 10px; background: #fff; border: 1px solid #eee; border-radius: 4px; }
.radio-group label { font-weight: normal; margin: 0; cursor: pointer; display: flex; align-items: center; font-size: 14px; }
.radio-group input { margin-right: 5px; }
.form-footer { text-align: center; padding-top: 10px; }
#tu-vi-form button {
    padding: 12px 60px; background: #8B0000; color: white; border: none; 
    cursor: pointer; border-radius: 5px; font-size: 16px; font-weight: bold; transition: 0.3s;
}

#tuvi-svg-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Rất quan trọng: để không chặn click vào cung */
    z-index: 100;
}

.laso-grid-container {
    position: relative; /* Đảm bảo SVG tọa độ chuẩn */
}

/* Hiệu ứng mờ các cung khác */
.laso-grid-container.dim-others .cung-box:not(.highlight) {
    opacity: 0.4;
    filter: grayscale(50%);
    transition: all 0.2s ease;
}

.cung-box.highlight {
    background: #fff;
    box-shadow: inset 0 0 10px rgba(139, 0, 0, 0.1);
    z-index: 10;
    border: 1px solid #8B0000 !important;
}

/* ==================================================
   3. GIAO DIỆN LÁ SỐ (GRID 4x4)
   ================================================== */
.laso-wrapper {
    max-width: 900px;
    margin: 20px auto;
    padding: 10px;
    background-color: #fff;
}
.laso-grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    border: 2px solid #63422b;
    background-color: #fff;
    min-width: 750px;
    aspect-ratio: 1 / 1;
    position: relative;
    /* Đã xóa đường kẻ chéo tĩnh để không bị lộ khi làm mờ ô */
}

.cung-box {
    border: 0.5px solid #c0a890;
    position: relative;
    background: #fffaf0;
    display: flex;
    flex-direction: column;
    padding: 28px 2px 5px 2px !important;
}

/* Header cung - Chia làm 3 phần rõ rệt */
.cung-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 22px;
    background: #f4ece2;
    border-bottom: 1px solid #d2b48c;
    display: flex;
    align-items: center;
    padding: 0 4px;
    z-index: 5;
    font-size: 11px;
}
.ten-dia-ban {
    font-size: 8px !important;
    color: #8b8b8b;
    background: #f0f0f0; /* Nền xám nhạt */
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
}
.ten-cung-chuc { 
    flex-grow: 1; 
    text-align: center; 
    font-weight: 800; 
    color: #27ae60 !important;
}
.dai-van-so { 
    width: 40px; 
    text-align: right; 
    color: #333; 
    font-weight: 600;
}
/* Fix lỗi tràn chữ cung */
.cung-content-new {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1.1fr; /* Nới rộng 2 cột sao phụ */
    height: calc(100% - 40px);
    padding: 2px;
}

/* Định dạng cột sao cho thoáng */
.cot-trai, .cot-phai {
    font-size: 9.5px !important;
    line-height: 1.3;
}

.cot-trai { text-align: left; padding-left: 2px; }
.cot-phai { text-align: right; padding-right: 2px; }

.cot-giua {
    padding-top: 5px;
}

/* Kiểu dáng Chính Tinh trung tâm */
.chinh-tinh-vinh {
    font-size: 13px !important;
    font-weight: 800 !important;
    line-height: 1.2;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.sao-kim { color: #555555 !important; } /* Xám đậm */
.sao-moc { color: #008000 !important; } /* Xanh lục */
.sao-thuy { color: #0000FF !important; } /* Xanh biển */
.sao-hoa { color: #FF0000 !important; } /* Đỏ */
.sao-tho { color: #FF9900 !important; } /* Cam vàng */

/* Đặc trị cho Tứ Hóa */
.sao-tu-hoa {
    font-weight: bold;
    background: rgba(255, 234, 167, 0.4);
    border-radius: 2px;
    padding: 0 1px;
}

/* Chính tinh rực rỡ */
.chinh-tinh-vinh {
    font-size: 14px !important;
    font-weight: 900 !important;
    line-height: 1.2 !important;
    margin-bottom: 4px;
    text-shadow: 0.5px 0.5px 0px #eee;
}
/* Thiên Bàn */
.thien-ban {
    grid-column: 2 / 4; grid-row: 2 / 4;
    background-color: #fdfaf6; border: 1px solid #a08c79; padding: 12px;
}
.thien-ban-title { font-size: 20px; margin: 0 0 5px 0; color: #000; font-weight: 800; text-align: center; }
.thien-ban-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.thien-ban-table td { padding: 3px 5px; border-bottom: 1px dashed #e0d5c5; }

/* GỢI Ý XEM NHANH - DẠNG THẺ PILL */
.tu-vi-sidebar {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.sidebar-header {
    background: #8B0000; /* Màu đỏ đô của bạn */
    color: #fff;
    padding: 10px 15px;
    font-weight: bold;
    text-align: center;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    text-transform: uppercase;
}

.sidebar-content {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.toc-pill {
    background: #f5f5f5;
    color: #444;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    display: inline-block;
}

.toc-pill:hover {
    background: #8B0000;
    color: #fff;
    border-color: #8B0000;
    transform: translateY(-2px);
}
/* ==================================================
   5. NỘI DUNG BÌNH GIẢI
   ================================================== */
.tu-vi-main-content { width: 100%; }

/* BANNER TIÊU ĐỀ CHUYÊN NGHIỆP */
.section-banner, .sidebar-header, .section-banner-tong-quan {
    background: #8B0000; /* Màu đỏ đô chuẩn */
    color: #fff;
    padding: 15px 20px;
    text-align: center;
    font-weight: 800;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 3px solid #ffd700; /* Viền vàng kim dưới chân tạo điểm nhấn */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 30px 0 15px 0;
    border-radius: 4px;
    position: relative;
}

/* Thêm họa tiết nhỏ hai bên tiêu đề (tùy chọn cho sang) */
.section-banner::before, .section-banner::after {
    content: "◈";
    color: rgba(255, 215, 0, 0.6);
    margin: 0 15px;
    font-size: 14px;
}

/* Grid Đại vận & Tiểu vận */
.van-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    background: #d2b48c;
    border: 1px solid #d2b48c;
}
.van-item {
    background: #fff;
    padding: 15px 5px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}
.van-item.active { background: #8B4513; color: #fff; }

.content-display-box {
    border: 2px solid #8B4513;
    padding: 20px;
    background: #fff;
    margin-top: 5px;
    min-height: 80px;
}

/* Căn giữa tin nhắn loading */
.loading-message {
    text-align: center;
    padding: 50px 20px;
    font-size: 16px;
    color: #8B0000;
    font-weight: 600;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* ACCORDION 12 CUNG */
#section-12-cung .section-banner {
    background: #8B0000;
    color: #fff;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 5px;
    border-radius: 4px;
}

details.cung-detail {
    border: 1px solid #eee;
    margin-bottom: 2px; /* Sát nhau như trong hình */
    background: #fff;
    transition: all 0.3s;
}

/* ACCORDION 12 CUNG - CĂN TRÁI TOÀN BỘ */
details.cung-detail summary {
    padding: 12px 15px;
    cursor: pointer;
    font-size: 15px;
    color: #333;
    display: flex;
    align-items: center; /* Căn giữa các thành phần theo chiều dọc */
    list-style: none;
    border-bottom: 1px solid #f0f0f0;
}

details.cung-detail summary::-webkit-details-marker {
    display: none;
}

/* Icon hình thoi bên trái */
details.cung-detail summary::before {
    content: "◆";
    color: #8b8b8b;
    margin-right: 20px; /* Tạo khoảng cách rộng với chữ */
    font-size: 12px;
    flex-shrink: 0;
}

/* Khối chứa tên cung và chữ phụ */
.summary-left {
    display: flex;
    align-items: center;
    flex-grow: 1; /* Chiếm hết không gian để đẩy nút Xem chi tiết về bên phải */
    text-align: left;
}

.summary-name {
    font-weight: 500;
    margin-right: 10px;
    min-width: 100px; /* Giúp các tên cung thẳng hàng nhau */
}

.summary-subtext {
    color: #999;
    font-size: 14px;
    font-weight: normal;
}

/* Nút Xem chi tiết bên phải */
.summary-action {
    color: #34495e;
    font-size: 12px;
    margin-left: auto; /* Đẩy về cuối bên phải */
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.summary-action::after {
    content: "▼";
    font-size: 9px;
    margin-left: 8px;
    transition: transform 0.3s;
}

details[open].cung-detail .summary-action::after {
    transform: rotate(180deg);
}

.luan-giai-content {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #fff;
    line-height: 1.8;
}

.luan-giai-content h4 {
    color: #8B0000;
    margin-top: 20px;
    border-left: 4px solid #8B0000;
    padding-left: 10px;
    font-weight: 600;
}

/* ==================================================
   6. MÀU SẮC SAO & TUẦN TRIỆT
   ================================================== */
   

/* Độ vinh hãm (M, V, Đ, B, H) */
.vinh-ham {
    font-size: 10px;
    font-weight: normal;
    font-style: italic;
    margin-left: 2px;
    color: #666;
}

/* Tăng mật độ hiển thị sao */
.cot-trai, .cot-phai {
    display: flex;
    flex-direction: column;
    gap: 0px; /* Sát nhau hơn */
}
/* Thu nhỏ cỡ chữ sao phụ khi quá nhiều sao */
.cot-trai div, .cot-phai div {
    font-size: 9px !important; /* Cực nhỏ để hiện đủ 114 sao */
    line-height: 1;
    margin-bottom: 0px;
    letter-spacing: -0.3px;
}

/* Sao Lưu (L.) cho màu khác để dễ phân biệt */
div[class*="sao-"]:contains('L.') {
    font-style: italic;
    text-decoration: underline rgba(0,0,0,0.1);
}

/* Các sao quan trọng (Tứ Hóa, Khôi Việt, Đào Hồng) in đậm hơn */
.sao-tu-hoa, .sao-quan-trong {
    font-weight: 800 !important;
    font-size: 10.5px !important;
}

/* Tạo đường kẻ mờ phân tách các sao nếu cần */
.cot-trai div { border-bottom: 0.1px solid rgba(0,0,0,0.03); }

.chinh-tinh-vinh {
    font-size: 14px !important;
    line-height: 1.2 !important;
    margin-bottom: 3px;
}

.nhan-dv-text, .nhan-ln-text {
    width: 35px; /* Giới hạn độ rộng 2 nhãn bên cạnh */
    white-space: nowrap;
}

/* Bỏ margin thủ công bạn vừa thêm, dùng cái này */
.nhan-dv-text {
    color: #8B4513;
    font-size: 9px;
    flex: 1;
    text-align: left;
    margin: 2px;
}
.nhan-ln-text {
    color: #555;
    font-size: 9px;
    flex: 1;
    text-align: right;
    font-style: italic;
}

/* Tuần - Triệt: Nằm đè lên vạch ngăn cung */
.nhan-triet, .nhan-tuan {
    position: absolute;
    background: #000;
    color: #fff;
    padding: 2px 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 10; /* Luôn nằm trên cùng */
    pointer-events: none;
}

/* Vị trí Tuần Triệt chuyên nghiệp hơn */
.nhan-triet {
    bottom: -8px; /* Nằm trên vạch kẻ dưới */
    left: 50%;
    transform: translateX(-50%);
    background: #4a4a4a;
    font-size: 8px;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #fff;
}

.nhan-tuan {
    top: 50%;
    right: -13px; /* Nằm trên vạch kẻ phải */
    transform: translateY(-50%);
    background: #4a4a4a;
    font-size: 8px;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #fff;
}

/* Số thứ tự cung ở góc dưới */
.cung-index-number {
    position: absolute;
    bottom: 15px;
    left: 4px;
    font-size: 10px;
    font-weight: bold;
    color: #b0aead;
}
.cung-luu-nien {
    position: absolute;
    bottom: 2px;
    font-size: 9px;
    color: #bbb;
    font-style: italic;
}
/* 3. Footer cung: Dùng Flexbox để phân bổ 3 thành phần */
.cung-footer-info {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px; /* Padding nhỏ để không đè vào số thứ tự góc */
}

.trang-sinh-text {
    color: #333;
    font-size: 9px;
    flex: 2;
    text-align: center;
    font-weight: bold;
}

.than-text {
    color: #d35400;
    font-size: 9px;
    margin-left: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .laso-grid-container { min-width: 650px; }
    .van-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; gap: 0; }
}

/* 2. Tối ưu lại ô Thiên Bàn (Ô giữa) */
.thien-ban {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background-color: #fdfaf6;
    border: 1px solid #a08c79;
    padding: 5px 10px !important; /* Giảm padding để tiết kiệm diện tích */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Căn giữa nội dung theo chiều dọc */
    z-index: 2;
}

.thien-ban-title {
    font-size: 20px;
    color: #000;
    font-weight: 900;
    text-align: center;
}

/* 3. Tối ưu bảng dữ liệu bên trong Thiên Bàn */
.thien-ban-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px; /* Thu nhỏ chữ để vừa khung */
}

.thien-ban-table td {
    padding: 2px 4px; /* Giảm khoảng cách giữa các dòng */
    border-bottom: 1px dashed #d2b48c;
    line-height: 1.6;
}

.thien-ban-table td.label {
    width: 30%; /* Thu hẹp cột nhãn */
    white-space: nowrap;
}

.thien-ban-table td.value {
    text-align: left;
    font-weight: bold;
    color: #000;
}

.thien-ban-table td.value-num {
    text-align: left;
    font-weight: bold;
    color: #000;
}

.thien-ban-table td.value-canchi {
    text-align: right;
    font-weight: bold;
    color: #000;
}

.name-highlight {
    color: #c0392b !important;
    font-size: 16px;
    text-transform: uppercase;
}

.la-nhan-text {
    color: #1e90ff !important; /* Màu xanh cho lai nhân cung */
}

.spacer {
    height: 10px;
    border: none !important;
}


/* Container tổng của phần bình giải */
#section-tong-quan {
    background: #fff;
    border: 2px solid #8B4513;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

/* Banner tiêu đề */
.section-banner-tong-quan {
    background: linear-gradient(135deg, #8B4513 0%, #5d4037 100%);
    color: #ffd700; /* Màu vàng kim */
    padding: 18px;
    text-align: center;
    font-weight: 800;
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 3px solid #ffd700;
}

/* Từng mục bình giải */
.tong-quan-item {
    padding: 20px;
    border-bottom: 1px double #e0d5c5;
    background: #fdfaf6; /* Nền màu giấy cũ nhẹ */
    transition: background 0.3s;
    position: relative;
}

.tong-quan-item:last-child { border-bottom: none; }

.tong-quan-item:hover {
    background: #fffdf0;
}

/* Tiêu đề của từng mục (Cung Thân, Lai Nhân Cung...) */
.tong-quan-item h4 {
    color: #8B0000;
    font-size: 17px;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    font-weight: 700;
}

/* Thêm icon giả lập bằng CSS hoặc dấu hiệu nhận biết */
.tong-quan-item h4::before {
    content: "◈";
    margin-right: 10px;
    color: #ffd700;
}

/* Nội dung văn bản */
.tong-quan-item p {
    font-size: 15px;
    color: #444;
    line-height: 1.7;
    margin: 0;
    text-align: justify;
}

/* Nguồn trích dẫn */
.source-text {
    display: block;
    text-align: right;
    font-size: 12px;
    font-style: italic;
    color: #a08c79;
    margin-top: 10px;
}
/* Hiệu ứng khi hover vào 1 cung */
.cung-box {
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Làm mờ các cung không liên quan */
.laso-grid-container.dim-others .cung-box:not(.highlight) {
    opacity: 0.3;
    filter: grayscale(80%);
}

/* Làm nổi bật cung đang chọn và cung liên kết */
.cung-box.highlight {
    z-index: 15;
    box-shadow: inset 0 0 15px rgba(139, 0, 0, 0.2);
    border: 2px solid #8B0000 !important;
    background: #fff;
}

/* Đường kẻ SVG */
#tuvi-svg-line line {
    stroke: rgba(139, 0, 0, 0.6);
    stroke-width: 2;
    stroke-dasharray: 5;
    animation: dash 1s linear infinite;
}

@keyframes dash {
    to { stroke-dashoffset: -10; }
}


.tieu-van-table-wrapper {
    margin-top: 10px;
    border: 1px solid #eee;
}
.btn-xem-tv:hover {
    background: #5d4037 !important;
}
.tv-sao-item {
    padding: 10px;
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Hiệu ứng xoay cho Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading message chuyên nghiệp hơn */
.loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px !important;
}
.loading-message .big-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #8B0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- MỤC LỤC CHI TIẾT (NÂNG CẤP ACCORDION) --- */
#floating-toc {
    position: fixed;
    right: 15px;
    top: 100px;
    width: 250px;
    background: #fff;
    border: 1px solid #dcdcdc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 999;
    border-radius: 6px;
    font-family: 'Segoe UI', sans-serif;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

#floating-toc .toc-header {
    background: #8B0000; /* Màu đỏ đậm như yêu cầu */
    color: #fff;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    border-radius: 5px 5px 0 0;
    flex-shrink: 0;
}

#floating-toc .toc-body {
    overflow-y: auto;
    padding: 0;
    flex-grow: 1;
}

#floating-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Item cấp 1 (Cha) */
.toc-item-parent {
    border-bottom: 1px solid #f0f0f0;
}

.toc-link-parent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #444;
    font-size: 14px;
    background: #fff;
    transition: 0.2s;
    text-decoration: none;
}

.toc-link-parent:hover {
    background: #fff5f5;
    color: #8B0000;
}

.toc-icon {
    color: #e67e22; /* Màu cam cho hình thoi */
    margin-right: 8px;
    font-size: 10px;
}

.toc-arrow {
    font-size: 10px;
    color: #999;
    transition: transform 0.3s;
}

/* Item cấp 2 (Con) */
.toc-sub {
    display: none; /* Mặc định ẩn */
    background: #fdfbf7;
    padding: 5px 0;
    border-top: 1px solid #eee;
}

.toc-sub li a {
    display: block;
    padding: 6px 15px 6px 35px; /* Thụt đầu dòng */
    font-size: 13px;
    color: #666;
    text-decoration: none;
    position: relative;
    transition: 0.2s;
}

.toc-sub li a:hover {
    color: #8B0000;
    background: #fff;
    padding-left: 40px;
}

.toc-sub li a::before {
    content: "•";
    position: absolute;
    left: 20px;
    color: #999;
}

/* Trạng thái mở */
.toc-item-parent.active .toc-sub {
    display: block;
}

.toc-item-parent.active .toc-arrow {
    transform: rotate(180deg);
}

.toc-footer {
    padding: 10px;
    text-align: center;
    border-top: 1px solid #eee;
    background: #f9f9f9;
    border-radius: 0 0 5px 5px;
}

.toc-footer a {
    color: #333;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

/* Ẩn trên mobile */
@media (max-width: 1300px) { 
    #floating-toc { display: none !important; } 
}

/* --- FOOTER & DISCLAIMER STYLE --- */
.tu-vi-footer-info {
    margin-top: 50px;
    background: #fff;
    border: 1px solid #d2b48c; /* Viền màu nâu nhạt */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    font-family: 'Segoe UI', sans-serif;
}

.footer-header {
    background: #5d4037; /* Màu nâu đất đậm */
    color: #ffd700; /* Chữ vàng kim */
    padding: 12px;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
    border-bottom: 3px solid #bcaaa4;
}

.footer-content {
    padding: 20px;
    background: #fffaf0; /* Nền màu giấy cũ/kem */
    display: grid;
    gap: 15px;
}

.footer-item {
    font-size: 13.5px;
    color: #444;
    line-height: 1.6;
    text-align: justify;
    padding-left: 15px;
    border-left: 3px solid #d2b48c; /* Đường kẻ chỉ mục bên trái */
}

.footer-item strong {
    display: block;
    color: #8B0000;
    margin-bottom: 4px;
    font-size: 14px;
}

.footer-item p {
    margin: 0;
}

/* Mục Lời khuyên làm nổi bật hơn */
.footer-item.highlight {
    background: rgba(39, 174, 96, 0.05); /* Nền xanh lá cực nhạt */
    border-left-color: #27ae60;
}
.footer-item.highlight strong {
    color: #27ae60;
}

.footer-copyright {
    text-align: center;
    font-size: 11px;
    color: #999;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #eee;
}

/* Mobile: Giữ nguyên padding */
@media (max-width: 768px) {
    .footer-content { padding: 15px; }
}

/* ==================================================
   7. TỐI ƯU GIAO DIỆN (RESPONSIVE)
   ================================================== */
@media (max-width: 768px) {

    /* --- 7.1. Tối ưu Form nhập liệu --- */
    #tu-vi-form-container {
        margin: 10px; /* Sát lề hơn */
        max-width: none;
    }
    #tu-vi-form {
        padding: 15px;
    }
    .form-row {
        flex-direction: column; /* Chuyển thành 1 cột */
        gap: 15px;
        margin-bottom: 15px;
    }
    .form-header h2 {
        font-size: 18px;
    }
    #tu-vi-form button {
        width: 100%;
        padding: 14px 20px;
    }

    /* --- 7.2. Tối ưu Grid Lá Số (Vuốt ngang) --- */
    .laso-wrapper {
        padding: 5px;
    }
    .laso-scroll-wrapper {
        overflow-x: auto; /* Cho phép vuốt ngang */
        -webkit-overflow-scrolling: touch; /* Hiệu ứng vuốt mượt trên iOS */
        border: 1px solid #dcdcdc;
        border-radius: 4px;
        position: relative;
    }
    /* Thêm chỉ dẫn vuốt cho người dùng */
    .laso-scroll-wrapper::before {
        content: "⟵ Vuốt sang để xem toàn bộ lá số ⟶";
        position: absolute;
        top: -25px;
        left: 50%;
        transform: translateX(-50%);
        background: #fffbe9;
        color: #744210;
        padding: 4px 10px;
        border-radius: 10px;
        font-size: 11px;
        font-style: italic;
        white-space: nowrap;
        border: 1px solid #f9e6af;
    }
    .laso-grid-container {
        min-width: 800px; /* Giữ nguyên kích thước để chữ không bị co lại */
    }

/* --- 7.3. Tối ưu các phần Luận giải (Cỡ chữ nhỏ hơn) --- */
    .section-banner, .section-banner-tong-quan {
        font-size: 16px;
        padding: 12px 15px;
        letter-spacing: 1px;
    }
    .section-banner::before, .section-banner::after {
        margin: 0 10px;
        font-size: 12px;
    }
    .van-grid {
        grid-template-columns: repeat(2, 1fr); /* Chuyển Đại Vận thành 2 cột */
    }
    .van-item {
        font-size: 13px; /* Thu nhỏ chữ trong ô Đại Vận */
        padding: 12px 5px;
    }
    .content-display-box {
        padding: 15px; /* Giảm padding */
        font-size: 14px; /* Thu nhỏ chữ trong ô hiển thị luận giải */
    }
    .content-display-box h4 {
        font-size: 15px;
    }

    /* Accordion 12 Cung */
    details.cung-detail summary {
        flex-direction: column; /* Cho tiêu đề cung xuống dòng cho gọn */
        align-items: flex-start;
        gap: 8px; /* Tăng khoảng cách cho thoáng */
        padding: 10px;
    }
    .summary-left {
        width: 100%;
    }
    .summary-name {
        min-width: 0;
        font-size: 14px; /* Giảm cỡ chữ tên cung */
    }
    .summary-subtext {
        font-size: 13px; /* Giảm cỡ chữ subtext */
    }
    .summary-action {
        margin-left: 0;
        background: #f1f1f1;
        padding: 5px 12px;
        border-radius: 5px;
        width: 100%;
        justify-content: center;
        font-size: 12px;
    }
    .luan-giai-content {
        padding: 15px;
        font-size: 14px; /* Giảm cỡ chữ toàn bộ nội dung luận giải */
        line-height: 1.7; /* Giảm nhẹ line-height */
    }
    .luan-giai-content h4 {
        font-size: 15px; /* Giảm cỡ chữ tiêu đề trong luận giải */
    }

    /* Bình giải tổng quan */
    .tong-quan-item {
        padding: 15px;
    }
    .tong-quan-item h4 {
        font-size: 16px;
    }
    .tong-quan-item p {
        font-size: 14px;
    }
    
    /* --- 7.4. Tối ưu Mục lục & các thành phần khác --- */
    #floating-toc {
        display: none !important; /* Ẩn mục lục nổi trên mobile */
    }
    .footer-content {
        padding: 15px;
    }
    .nang-luong-container {
        margin: 10px;
    }
}

/* ==================================================
   8. GIAO DIỆN CÂN XƯƠNG TÍNH SỐ (TINH CHỈNH)
   ================================================== */
.cxts-form-container {
    background-color: #8B0000;
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    margin: 20px auto;
    color: #fff;
    /* Có thể thêm ảnh nền họa tiết nếu muốn */
    /* background-image: url('...'); */
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
.cxts-form-group {
    margin-bottom: 20px;
}
.cxts-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}
.cxts-form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #A52A2A;
    border-radius: 4px;
    font-size: 16px;
    background: #fff;
    color: #333;
}
.cxts-date-group {
    display: grid;
    grid-template-columns: 1fr 2fr 1.5fr;
    gap: 10px;
}
.cxts-submit-btn {
    width: 100%;
    padding: 15px;
    background-color: #BDB76B;
    color: #000;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cxts-submit-btn:hover {
    background-color: #9b965b;
}

/* --- KẾT QUẢ (THIẾT KẾ MỚI) --- */
.cxts-result-wrapper {
    margin: 30px auto;
    max-width: 800px;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    overflow: hidden;
}
.cxts-result-title {
    background: #8B0000;
    color: #ffd700; /* Vàng kim */
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 15px;
    margin: 0;
    letter-spacing: 1px;
    border-bottom: 3px solid #ffd700;
}
.cxts-result-content {
    padding: 25px;
    color: #333;
    line-height: 1.8;
}
.cxts-result-content strong {
    color: #8B0000;
}
.cxts-poem {
    text-align: center;
    font-style: italic;
    margin: 25px 0;
    color: #555;
    padding: 20px;
    background: #fffaf0; /* Màu giấy cũ */
    border-left: 4px solid #d2b48c;
    border-radius: 4px;
}
.cxts-poem p {
    margin: 0;
    line-height: 2;
}

@media (max-width: 768px) {
    .cxts-date-group { grid-template-columns: 1fr; }
    .cxts-result-content { padding: 15px; }
     /* --- TỐI ƯU CÂN XƯƠNG TÍNH SỐ TRÊN MOBILE --- */
    .cxts-form-container {
        padding: 20px;
    }
    .cxts-date-group { 
        grid-template-columns: 1fr; /* Chuyển ngày/tháng/năm thành 1 cột */
    }
    .cxts-result-content { 
        padding: 15px;
        font-size: 15px; /* Tăng nhẹ cỡ chữ cho dễ đọc */
    }
    .cxts-result-title {
        font-size: 16px;
        padding: 12px;
    }
    .cxts-poem {
        padding: 15px;
    }
    .cxts-disclaimer {
        margin-left: 10px;
        margin-right: 10px;
    }
}

/* Miễn trừ trách nhiệm */
.cxts-disclaimer {
    max-width: 800px;
    margin: 20px auto;
    background: #fffbe6;
    border: 1px solid #f9e6af;
    border-radius: 6px;
    font-size: 14px;
    color: #744210;
}
.cxts-disclaimer-header {
    background: #f9e6af;
    padding: 8px 15px;
    font-weight: bold;
    border-bottom: 1px solid #f6e0a0;
}
.cxts-disclaimer p {
    padding: 15px;
    margin: 0;
    line-height: 1.7;
}

/* Nút chuyển qua Lá Số Tử Vi */
.cxts-next-action {
    text-align: center;
    margin: 30px 0 10px 0;
}
.cxts-next-action-btn {
    display: inline-block;
    padding: 12px 30px;
    background: #8B0000;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: 0.3s;
}
.cxts-next-action-btn:hover {
    background: #5d4037;
    color: #fff;
}