    /* Popup styling (Z-Index Fixed) */
    span.meaning {
        display: block;
        position: absolute;
        background-color: #ffd;
        background-image: url('../images/imgbk.png');
        color: #333;
        padding: 10px;
        border-radius: 5px;
        z-index: 2000;
        font-size: 16px;
        line-height: 1.4;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        max-width: 550px;
        text-align: left;
        margin-top: 1px; /* Tăng khoảng cách ra một chút */
        border: 1px solid #d4a373;
        min-width: 250px;
        transition: 100ms;
    }

    [data-theme="dark"] span.meaning {
        display: block;
        position: absolute;
        background-color: #333;
        background-image: url('../images/imgbk.png');
        color: #fff;
        padding: 10px;
        border-radius: 5px;
        z-index: 2000;
        font-size: 16px;
        line-height: 1.4;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        max-width: 550px;
        text-align: left;
        margin-top: 1px; /* Tăng khoảng cách ra một chút */
        border: 1px solid #d4a373;
        min-width: 250px;
        transition: 100ms;
        /* --- DÒNG QUAN TRỌNG ĐỂ SỬA LỖI GIẬT --- */
    }
    /* Highlight word when lookup is active */
    .word.lookup-enabled {
        cursor: help;
        border-bottom: 1px dotted #888;
    }
    .word.lookup-enabled:hover {
        background-color: rgba(255, 215, 0, 0.2);
    }

        /* --- CẤU HÌNH MÀU SẮC --- */
        :root {
            --primary-color: #8B4513;
            --bg-color: #ffd;
            --text-color: #333;
            --box-bg: #e0e0e0;
            --box-border: #999;
            --footer-bg: #ffd;
            --highlight-color: #d35400;
            --recitation-bg-active: #ffd;
            --recitation-text-active: #8B4513;
        }

        [data-theme="dark"] {
            --primary-color: #d4a373;
            --bg-color: #1a1a1a;
            --text-color: #e0e0e0;
            --box-bg: #333;
            --box-border: #555;
            --footer-bg: rgba(45, 45, 45, 0.95);
            --highlight-color: #f39c12;
            --recitation-bg-active: #2d2d2d;
            --recitation-text-active: #f39c12;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--bg-color);
			background-image: url('../images/imgbk.png');
            color: var(--text-color);
            margin: 0;
            padding: 15px;
            padding-bottom: 120px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .container { max-width: 800px; width: 100%; }

        /* --- TOP NAV --- */
.top-nav {
    /* Sticky Positioning Logic */
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0;
    z-index: 2050; /* Keeps it above the scrolling text */

    /* Visuals: Background is required so text hides behind it */
    background-color: var(--bg-color);
    background-image: url('../images/imgbk.png'); /* Keeps your paper texture */

    /* Layout */
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;

    /* Adjustments to fit flush against the top of the screen */
    /* Since body has padding: 15px, we use negative margin to pull nav up */
    margin-top: -15px; 
    padding-top: 15px; /* Add internal padding to compensate */
    padding-bottom: 10px;
    margin-bottom: 15px; /* Push content down slightly */
}

        .nav-controls { display: flex; gap: 5px; flex-grow: 1; justify-content: center; }

        select {
            padding: 6px; font-size: 16px; border-radius: 5px;
            border: 1px solid var(--box-border);
            background-color: var(--bg-color); background-image: url('../images/imgbk.png'); color: var(--text-color);
            max-width: 200px;
        }

        .btn-nav, .btn-darkmode {
            background: transparent; border: 1px solid var(--primary-color);
            color: var(--primary-color); padding: 7px 7px; border-radius: 5px; cursor: pointer;
        }
        .btn-darkmode { background: #34495e; color: #fff; border: none; font-size: 14px; }

        h2 { text-align: center; color: var(--primary-color); margin: 5px 0 15px 0; font-size: 20px; }

        /* --- TEXT CONTENT --- */
        .text-content {
            font-size: 18px; text-align: center; line-height: 1.8; position: relative;
        }
        
        /* Ẩn văn bản gốc khi Recitation bật */
        .text-content.recitation-active > .line-break { display: none; }

        /* Hiện dòng Recitation */
        .text-content.recitation-active .line-recitation-show {
            display: block !important;
            font-size: 22px; font-weight: bold;
            color: var(--recitation-text-active);
            background-color: var(--recitation-bg-active);
			background-image: url('../images/imgbk.png');
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            animation: fadeIn 0.4s;
            border: 2px solid var(--primary-color);
            margin-top: 20px;
            position: relative;
        }

        .line-recitation-show[data-has-custom-time="true"]::after {
            position: absolute; top: 5px; right: 5px; font-size: 12px; opacity: 0.5;
        }

        .word { display: inline-block; margin: 0 2px; padding: 1px 2px; }
        .word.hidden {
            color: transparent; background-color: var(--box-bg);
            border: 1px solid var(--box-border); cursor: pointer; min-width: 1.2em;
        }
        .word.revealed { color: var(--highlight-color); border-bottom: 1px dashed var(--highlight-color); }
        .line-break { display: block; margin-bottom: 8px; }

        /* --- BOTTOM BAR --- */
        .bottom-bar {
            position: fixed; bottom: 0; left: 0; width: 100%;
            background-color: var(--footer-bg); background-image: url('../images/imgbk.png'); color: var(--text-color);
            box-shadow: 0 -2px 10px rgba(0,0,0,0.2); z-index: 1000;
            border-top: 2px solid var(--primary-color);
            backdrop-filter: blur(5px);
        }

        .bar-main-row {
            display: flex; align-items: center; justify-content: space-between;
            padding: 8px 10px; gap: 10px; max-width: 800px; margin: 0 auto;
        }

        audio { height: 32px; flex-grow: 1; max-width: 100%; border-radius: 15px; }

        .controls-cluster { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

        .icon-btn {
            background-color: var(--primary-color); color: #fff; border: none;
            width: 36px; height: 36px; border-radius: 50%;
            font-size: 16px; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: transform 0.1s;
        }
        .icon-btn:active { transform: scale(0.95); }
        
        /* Trạng thái nút Recitation */
        .btn-recitation { background-color: #2e8b57; transition: all 0.3s ease; }
        .btn-recitation.active-auto { background-color: #2e8b57; animation: pulse-green 2s infinite; }
        .btn-recitation.active-manual { background-color: #3566d0; }
        
        /* Nút Exit mới */
        #btn-exit-recitation {
            background-color: #c0392b; /* Màu đỏ */
            display: none; /* Mặc định ẩn */
        }
   /* --- CSS CHO PHẦN DỊCH VIỆT --- */
.translation-line {
    display: none; /* Mặc định ẩn */
    font-size: 16px;
    color: #666;
    font-style: italic;
    margin-bottom: 12px;
    font-family: 'Segoe UI', sans-serif;
}

/* Khi class 'show-translation' được thêm vào display-area, hiện dòng dịch */
.text-content.show-translation .translation-line {
    display: block;
}

/* Trong chế độ Tối */
[data-theme="dark"] .translation-line {
    color: #aaa;
}

/* Ẩn dòng dịch khi đang trong chế độ Tụng Đọc (Recitation Mode) để tránh rối */
.text-content.recitation-active .translation-line {
    display: none !important;
}

/* --- LOGIC ẨN/HIỆN NÚT --- */

/* Mặc định: Nút Exit ẩn, Nút VN hiện */
#btn-exit-recitation { display: none; }
#btn-viet-toggle, #btn-english-toggle { font-weight: bold;
    font-size: 13px;
    background-color: #4a69bd;
    display: flex; }


/* Khi vào chế độ Tụng Đọc: Nút Exit hiện, Nút VN ẩn */
.recitation-active-mode #btn-exit-recitation { display: flex; }
.recitation-active-mode #btn-viet-toggle { display: none; }
.recitation-active-mode #btn-english-toggle { display: none; }
.recitation-active-mode #btn-stats { display: none; }

/* Trạng thái nút VN khi đang bật */
.btn-viet-active, .btn-english-active {
    background-color: #4a69bd !important;
   box-shadow: 0 0 10px rgba(39, 174, 96, 0.5);
    border: 2px solid #fff;
}

        @keyframes pulse-green {
            0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.4); }
            70% { box-shadow: 0 0 0 6px rgba(39, 174, 96, 0); }
            100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
        }
        
        .btn-settings { background-color: #7f8c8d; }
        .settings-panel {
            max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;
            background-color: rgba(0,0,0,0.03); border-top: 1px dashed var(--box-border);
        }
        .settings-panel.open { max-height: 200px; }
        .settings-content { padding: 10px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap;}
        .setting-group { display: flex; align-items: center; gap: 8px; }

        /* Nút nhỏ trong setting */
        .btn-sm {
            border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
        }

        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        @media (max-width: 600px) {
            .bar-main-row { flex-direction: column; }
            .controls-cluster { width: 100%; justify-content: center; gap: 15px; }
        }
	
	@media (max-width: 600px) {
/* FIX 1: Tighten the top navigation bar */
.top-nav {
gap: 9px; /* Smaller gap between the Dark Mode button and main controls */
}
.nav-controls {
gap: 7px; /* Tighter gap for the navigation arrows and select */
justify-content: flex-end; /* Ensure controls are aligned right */
}
.btn-nav, .btn-darkmode {
padding: 7px 7px; /* Slightly reduced button padding */
}
#section-select {
max-width: 180px; /* Force the select box to be much narrower on mobile */
font-size: 14px; /* Smaller font to save space */
padding: 6px; /* Tighter padding */
}
/* FIX 2: Ensure the Help button fits without being cut off */
#top-right-controls {
gap: 3px; /* Tighter gap for the rightmost controls */
}
/* End FIX for top bar */

/* Keep the bottom bar layout fix */
.bar-main-row { flex-direction: column; }
.controls-cluster { width: 100%; justify-content: center; gap: 15px; }
}

/* --- BUTTON VISIBILITY LOGIC (Nav vs Random) --- */

/* Default State (Not Recitation Mode): */
/* Hide the Previous/Next buttons */
.btn-nav-recitation {
    display: none;
}
/* Show the Random button */
#btn-random {
    display: flex;
    background-color: #9b59b6; /* Purple color for distinction */
}

/* Recitation Mode Active: */
/* When body has class 'recitation-active-mode' */
.recitation-active-mode .btn-nav-recitation {
    display: flex; /* Show Prev/Next */
}
.recitation-active-mode #btn-random {
    display: none; /* Hide Random to make room */
}
/* --- RECITAION DASHBOARD & SLIDER --- */

/* Container for the boxes */
#recitation-dashboard {
    display: none; /* Hidden by default */
    width: 90%;
    max-width: 800px;
    background-color: var(--box-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--box-border);
    animation: fadeIn 0.5s;
}
/* Tablet/Desktop scale */
@media (min-width: 768px) {
    #recitation-dashboard { width: 96%; }
}
/* Recitation active? Show dashboard */
.recitation-active-mode #recitation-dashboard {
    display: block;
}

/* The Grid of Boxes */
.dashboard-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 15px;
}

.progress-box {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background-color: #ebedf0; /* Default empty */
    border: 1px solid #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #555;
    transition: transform 0.1s;
	-webkit-user-select: none; /* Safari / Chrome */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE 10+ */
    user-select: none;         /* Standard */
    
    -webkit-touch-callout: none; /* iOS Safari: Disables the system menu */
    -webkit-tap-highlight-color: transparent; /* Removes the blue flash on tap */
}

[data-theme="dark"] .progress-box {
    background-color: #2d333b;
    border-color: #444;
    color: #aaa;
}

.progress-box:hover { transform: scale(1.15); border-color: #888; }
.progress-box.active-box { border: 2px solid var(--highlight-color); transform: scale(1.1); }

/* Heatmap Colors (GitHub style Green) */
.heatmap-0 { background-color: #ebedf0; }
.heatmap-1 { background-color: #9be9a8; color: #222; } /* 1-25% */
.heatmap-2 { background-color: #40c463; color: #fff; } /* 26-50% */
.heatmap-3 { background-color: #30a14e; color: #fff; } /* 51-75% */
.heatmap-4 { background-color: #216e39; color: #fff; } /* 76-100% */

/* Dark mode overrides for colors */
[data-theme="dark"] .heatmap-0 { background-color: #2d333b; }
[data-theme="dark"] .heatmap-1 { background-color: #0e4429; color: #ccc; }
[data-theme="dark"] .heatmap-2 { background-color: #006d32; }
[data-theme="dark"] .heatmap-3 { background-color: #26a641; }
[data-theme="dark"] .heatmap-4 { background-color: #39d353; color: #000; }

/* Progress Bars Area */
.dashboard-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.progress-track {
    flex-grow: 1;
    height: 8px;
   background-color: rgba(0, 0, 0, 0.1); /* Visible track */
    border-radius: 4px;
    overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .progress-track {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* --- CHECKBOX UNDER SENTENCE --- */
.memorize-slider-container {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed var(--primary-color);
    text-align: center;
    animation: fadeIn 0.3s;
    display: flex;           /* Flexbox to center content */
    justify-content: center;
    align-items: center;
}

/* Label styling for the checkbox */
.memorize-checkbox-label {
    font-size: 16px;
    font-weight: bold;
    color: var(--highlight-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;               /* Space between box and text */
    user-select: none;       /* Prevent text selection on click */
}

/* The actual checkbox styling */
.memorize-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--highlight-color); /* Uses your theme color (Orange/Yellow) */
}
/* --- BUTTON VISIBILITY LOGIC --- */
        
        /* 1. Default State (Normal Mode) */
        #btn-loop, #btn-exit-recitation, .btn-nav-recitation { 
            display: none; 
        }
        #btn-dictionary, #btn-viet-toggle, #btn-english-toggle, #btn-random { 
            display: flex; 
        }

        /* 2. Recitation Mode Active */
        .recitation-active-mode #btn-loop,
        .recitation-active-mode #btn-exit-recitation,
        .recitation-active-mode .btn-nav-recitation {
            display: flex; /* Show these */
        }

        .recitation-active-mode #btn-dictionary,
        .recitation-active-mode #btn-english-toggle,
        .recitation-active-mode #btn-random {
            display: none; /* Hide these to save space */
        }
        
        /* Loop Button Active State */
       #btn-loop.active-loop {
    background-color: #9b59b6 !important; /* Gold/Orange */
    color: #fff;
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.6);
    border: 1px solid #fff;
}

/* --- MULTI-LOOP SELECTION STYLE --- */
.progress-box.multi-loop-selected {
    border: 2px solid #e74c3c !important; /* Red Border */
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.6);
    background-color: rgba(231, 76, 60, 0.1);
    transform: scale(1.05);
    z-index: 5; /* Ensure it sits above others */
}

/* Dark mode adjustment */
[data-theme="dark"] .progress-box.multi-loop-selected {
    border-color: #ff6b6b !important;
    background-color: rgba(255, 107, 107, 0.2);
}

/* --- ACHIEVEMENT BANNER (SECTION LEVEL) --- */
#section-achievement-banner {
    display: none;
    background: #fffdf0; /* Màu giấy chứng chỉ nhẹ */
    color: #5d4037;
    width: 90%;
    max-width: 800px;
    text-align: center;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    /* Viền kép tạo nét cổ điển trang trọng */
    border: 4px double #FDB931; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    animation: slideDown 0.5s ease-out;
    position: relative;
	
}
@media (min-width: 768px) {
    #section-achievement-banner { width: 96%; }
}
[data-theme="dark"] #section-achievement-banner {
    background-color: #2d2d2d;
    color: #fff;
    border-color: #d4a373;
}
#section-achievement-banner h3 {
    color: #b35900;
    font-family: "Times New Roman", serif;
    font-size: 18px;
    margin: 0;
    text-transform: uppercase;
}
[data-theme="dark"] #section-achievement-banner h3 {
    color: #e67300;
}


/* --- GRAND ACHIEVEMENT MODAL (GLOBAL LEVEL) --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.5s;
}

.modal-content {
    background: #fff;
    background-image: url('../images/imgbk.png');
    padding: 20px; /* Reduced slightly for mobile comfort */
    border-radius: 15px;
    text-align: center;
    
    /* FIX STARTS HERE */
    box-sizing: border-box;     /* Includes padding/border in the width calculation */
    width: 90%;                /* Takes up 90% of screen width on small devices */
    max-width: 400px;          /* Won't grow larger than 400px on tablets/PC */
    /* FIX ENDS HERE */

    border: 4px solid #FDB931;
    box-shadow: 0 0 30px rgba(253, 185, 49, 0.6);
    position: relative;
    animation: popIn 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

[data-theme="dark"] .modal-content {
    background-color: #2d2d2d;
    color: #fff;
    border-color: #d4a373;
}

.medal-icon {
    font-size: 80px;
    color: #e39802;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(253, 185, 49, 0.8));
    animation: floatMedal 3s ease-in-out infinite;
}
[data-theme="dark"] .modal-icon { color: #FDB931;}

.modal-title {
    font-size: 24px;
    color: #d35400;
    margin-bottom: 10px;
    font-weight: bold;
    text-transform: uppercase;
}
[data-theme="dark"] .modal-title { color: #f39c12; }

.modal-text {
    font-size: 16px;
    margin-bottom: 25px;
    line-height: 1.5;
}

.btn-close-modal {
    background: #d35400;
    color: white;
    border: none;
    padding: 10px 25px;
    font-size: 16px;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s;
    font-weight: bold;
}
.btn-close-modal:hover { transform: scale(1.05); background: #e67e22; }

/* Animations */
@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes floatMedal {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* --- SECTION TITLE & INFO ICON LAYOUT --- */
.section-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 5px 0 15px 0;
}

#section-title {
    margin: 0; /* Reset margin since wrapper handles it */
}

.btn-info-icon {
    font-size: 15px;
    color: var(--primary-color);
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    display: none; /* Hidden by default until JS enables it */
	vertical-align: middle;      /* Aligns to the middle of the text line */
    line-height: 1;              /* Removes extra spacing around the icon */
    position: relative;          /* Allows for micro-adjustments */
    top: 2px;                   /* Manually nudge it down if it still looks 'high' */
}

.btn-info-icon:hover {
    transform: scale(1.1);
    color: var(--highlight-color);
}
.simple-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Simple dark dim */
    z-index: 10000; /* Very high z-index */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px); /* Slight blur, not too heavy */
}

.simple-modal-content {
    background-color: var(--bg-color); /* Matches theme */
    background-image: url('../images/imgbk.png'); /* Keeps texture if you want, or remove */
    color: var(--text-color);
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative; /* For absolute positioning of X button */
    display: flex;
    flex-direction: column;
    border: 1px solid var(--box-border);
}

/* Header Area */
.simple-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--box-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.simple-modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 18px;
}

/* The X Close Icon */
.btn-close-simple {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-close-simple:hover {
    opacity: 1;
    color: var(--highlight-color);
}

/* Scrollable Body */
.simple-modal-body {
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 16px;
}

/* Scrollbar styling */
.simple-modal-body::-webkit-scrollbar { width: 8px; }
.simple-modal-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }
.simple-modal-body::-webkit-scrollbar-thumb { background: #999; border-radius: 4px; }

/* Content specific styling */
.simple-modal-body h4 {
    color: var(--highlight-color);
    border-bottom: 1px dashed #ccc;
    padding-bottom: 5px;
    margin-top: 3px;
    margin-bottom: 15px;
}
.simple-modal-body ul { padding-left: 20px; }
.simple-modal-body li { margin-bottom: 10px; }

/* Dark mode tweaks */
[data-theme="dark"] .simple-modal-content {
    background-color: #2d2d2d;
    border-color: #555;
}
/* --- HELP MODAL STYLES --- */
.help-modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 3000; /* High z-index to sit on top of everything */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Dimmed background */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s;
}

/* --- UPDATED HELP MODAL STYLES --- */

.help-modal-content {
    background-color: var(--box-bg);
    background-image: url('../images/imgbk.png');
    color: var(--text-color);
    border: 1px solid var(--box-border);
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh; /* Limits the height of the whole modal */
    
    /* FLEXBOX MAGIC: This makes the header stay and body scroll */
    display: flex;
    flex-direction: column; 
    overflow: hidden; /* Prevents double scrollbars */
    padding: 0; /* Padding is now moved inside header/body */
    
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    line-height: 1.6;
}

/* New: Sticky Header Container */
.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Pushes Title to left, X to right */
    padding: 15px 20px;
    border-bottom: 1px solid var(--box-border);
    background-color: rgba(255, 255, 255, 0.1); /* Slight highlight */
    flex-shrink: 0; /* Prevents header from shrinking */
}

/* Ensure title doesn't have extra margins messing up alignment */
.help-modal-header h3 {
    margin: 0; 
    font-size: 18px;
}
.help-modal-content a {
        /* Đặt màu liên kết cố định */
        color: #007bff; /* Màu xanh dương sáng */
        text-decoration: underline;
    }

    /* Quy tắc cho chế độ Tối (Dark Mode) */
    [data-theme="dark"] .help-modal-content a {
        /* Màu liên kết trong Dark Mode */
        color: #90CAF9; /* Màu xanh sáng hơn */
    }

    /* Định dạng khi di chuột qua */
    .help-modal-content a:hover {
        color: var(--highlight-color); /* Sử dụng màu nổi bật đã có của bạn */
    }
/* The X Close Button - Updated */
.btn-close-help {
    /* No longer absolute position! It is now part of the flex header */
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.2s;
    line-height: 1;
    padding: 0;
    margin-left: 15px;
}

.btn-close-help:hover {
    color: var(--highlight-color);
}

/* New: Scrollable Body Container */
.help-modal-body {
    padding: 20px;
	padding-top: 5px;
    overflow-y: auto; /* Scroll only this part */
    flex-grow: 1; /* Takes up remaining space */
}

/* Dark mode adjustment (Ensure header border matches) */
[data-theme="dark"] .help-modal-header {
    border-bottom-color: #555;
    background-color: rgba(0, 0, 0, 0.2);
}

.btn-bottom-close {
    display: block;
    /* Change from 100% to fit-content */
    width: fit-content; 
    /* This centers the button horizontally */
    margin: auto;
    /* Add horizontal padding (30px) so it's not too cramped */
    padding: 10px 30px; 
    
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-bottom-close:hover {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-close-help i {
    font-size: 1rem;
    pointer-events: none; /* This is an alternative fix that makes clicks "pass through" the icon to the button */
}

/* --- QUIZ MODAL STYLES --- */
.quiz-content {
    max-width: 600px;
    width: 95%;
    text-align: left;
	overflow-y: auto;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.quiz-sentence-area {
    font-size: 20px;
    line-height: 2;
    margin-bottom: 25px;
    background: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--box-border);
}

.quiz-blank {
    display: inline-block;
    min-width: 60px;
    /* Remove fixed height and bottom alignment */
    border-bottom: 2px dashed var(--highlight-color);
    margin: 0 5px;
    padding: 0 4px; /* Give a little space on sides */
    cursor: pointer;
    color: var(--highlight-color);
    font-weight: bold;
    text-align: center;
    /* Use baseline to align with neighboring text */
    vertical-align: baseline; 
    /* Prevent the border from shifting line height */
    line-height: 1; 
}

.quiz-blank.filled {
    border-bottom: 2px solid #27ae60;
    color: #27ae60;
}

.quiz-blank.error {
    border-bottom: 2px solid #c0392b;
    color: #c0392b;
    animation: shake 0.3s;
}

/* Ensure the sentence area has consistent line-height */
.quiz-sentence-area {
    line-height: 2.2; /* Slightly increased for better readability with underlined blanks */
}

.quiz-options-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.quiz-option {
    background-color: var(--box-bg);
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
    transition: all 0.2s;
}

.quiz-option:hover {
    background-color: var(--primary-color);
    color: #fff;
    transform: translateY(-2px);
}

.quiz-option.used {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
}

.quiz-footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #ccc;
    padding-top: 15px;
}

.btn-primary, .btn-secondary, .btn-warning {
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.btn-primary { background: var(--highlight-color); color: white; }
.btn-primary:disabled { background: #95a5a6; cursor: not-allowed; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-warning { background: #f39c12; color: white; }

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* Final Exam Button Area */
#final-exam-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background-color: rgba(255, 215, 0, 0.1);
    border: 2px solid #f1c40f;
    border-radius: 8px;
    display: none; /* Hidden by default */
}


/* Button Luyện Tập */
.btn-practice {
    margin-left: 15px; /* Space from the checkbox */
    padding: 6px 12px;
    background-color: #3566d0;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-practice:hover {
    background-color: #4a69bd;
    transform: translateY(-1px);
}
/* --- Bổ sung cho Câu hỏi Dịch tiếng Việt --- */
.quiz-option.translation-option {
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    white-space: normal; /* Cho phép rớt dòng đối với các câu dài */
    line-height: 1.5;
    box-sizing: border-box;
}
/* --- LÀM LẠI GIAO DIỆN BIỂU ĐỒ (Giống renderreport.js) --- */
.stats-content {
    background-color: var(--bg-color); 
}

/* Card Style */
.card {
    background: #1f2937; /* Màu xám đậm từ Tailwind/renderreport */
    border-color: #374151;
    color: #f3f4f6;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 15px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] .card {
    background: #1f2937; /* Màu xám đậm từ Tailwind/renderreport */
    border-color: #374151;
    color: #f3f4f6;
}

/* Các Nút Điều Hướng & Select */
.btn-secondary {
    background-color: #4b5563;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-secondary:hover {
    background-color: #6b7280;
}

.form-control {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
    border: 1px solid var(--box-border);
    border-radius: 4px;
    outline: none;
}
[data-theme="dark"] .form-control {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Pen icon hover effect */
.fa-pen:hover {
    color: var(--highlight-color) !important;
    transform: scale(1.2);
}

.calendar-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 5px; 
    margin-top: 10px; 
}

.calendar-header { display: contents; }

.cal-head-day {
    text-align: center; font-size: 12px; color: #e0e0e0; font-weight: bold; padding-bottom: 5px; opacity: 0.8;
}

.calendar-day { 
    aspect-ratio: 1; 
    background: #333; 
    border-radius: 4px; 
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; cursor: pointer; position: relative; border: 1px solid var(--box-border);
    color: #e0e0e0;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Các cấp độ dựa trên XP */
.calendar-day.level-1 { background: rgba(99, 102, 241, 0.3); border-color: rgba(99, 102, 241, 0.3); color: white; } 
.calendar-day.level-2 { background: rgba(99, 102, 241, 0.6); border-color: rgba(99, 102, 241, 0.5); color: white; } 
.calendar-day.level-3 { background: rgba(99, 102, 241, 1); border-color: #818cf8; color: white; } 
.calendar-day.level-4 { 
    background: #4d5eff; 
    border: 1px solid rgba(255,255,255,0.2);
    color: white; 
}
.calendar-day.level-5 { 
    background: #818cf8; 
	border-color: #6366f1;
    color: white; 
} 
.calendar-day.level-6 { 
background:  linear-gradient(135deg, #818cf8, #a78bfa);    box-shadow: inset 0 0 8px rgba(255,255,255,0.3);  border: 1px solid rgba(255,255,255,0.2);
	    color: white; 
			border-color: gold;
box-shadow: 0 0 20px #ffffff, 0 0 40px #818cf8;	}

.calendar-day.level-7 { 
background: linear-gradient(135deg, #a78bfa, #f472b6);
    border: 1px solid rgba(255,255,255,0.4);
box-shadow: 0 0 12px rgba(198, 180, 253, 0.6);	    color: white; 

border-color: rgba(251, 191, 36, 1);
animation: pulse-silver 2s infinite;
}
.calendar-day.level-8 { 
    background: linear-gradient(135deg, #6d28d9, #8b5cf6);
    border: 1px solid #a78bfa;
	color: white; 
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
	border-color: gold;
	animation: pulse-gold 2s infinite;
}

@keyframes pulse-silver {
    0% { transform: scale(1); }
    50% { box-shadow: 0 0 20px rgba(198, 180, 253); }
    100% { transform: scale(1); }
}

@keyframes pulse-gold {
    0% { transform: scale(1); }
    50% { box-shadow: 0 0 20px rgba(251, 191, 36, 1); }
    100% { transform: scale(1); }
}

.calendar-day:hover { 
    transform: scale(1.15); 
    z-index: 2; 
    box-shadow: 0 0 10px var(--highlight-color); 
    border: 1px solid white; 
}



