body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    margin: 0;
    padding: 20px;
}

#bookSelect {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50px;
    padding: 10px 40px 10px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#bookSelect:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#bookSelect option {
    background: #1e3c72;
    color: white;
    font-weight: 600;
}

.container {
    max-width: 900px;
    margin: auto;
}

.card {
    background: white;
    color: black;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    /* margin-top: 10px; */
}

.primary {
    background: #2a5298;
    color: white;
}

.success {
    background: #28a745;
    color: white;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.flashcard-container {
    background: #f0f4ff;
    border-radius: 10px;
    border: 1px dashed #a0b4e0;
    padding: 10px;
    margin: 10px 0;
}

.flashcard {
    font-size: 40px;
    text-align: center;
    padding: 20px;
}

#kanjiDisplay {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 10px;
    padding: 8px 10px;
}

.kanji-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: white;
    border: 1.5px solid #c0cdee;
    border-radius: 8px;
    padding: 6px 14px;
    min-width: 48px;
    box-shadow: 0 2px 6px rgba(42, 82, 152, 0.08);
}

.kanji-char {
    font-size: 25px;
    font-weight: 400;
    color: #1e3c72;
    line-height: 1.2;
}

.kanji-hanviet {
    font-size: 20px;
    color: #7a8db5;
    margin-top: 2px;
    font-style: italic;
}

.small {
    font-size: 16px;
    color: gray;
}

.correct-answer {
    background: green;
    color: white;
}

.wrong-answer {
    border: 1px solid red;
}

.progress-bar {
    height: 10px;
    background: #ddd;
    border-radius: 10px;
    margin-top: 10px;
}

.progress-fill {
    height: 10px;
    width: 0%;
    background: #28a745;
    border-radius: 10px;
}

/* ===== DESKTOP / MOBILE SHARED ===== */

/* Trên desktop, tab-pane luôn hiện như block bình thường */
.main-content .tab-pane {
    display: block !important;
    opacity: 1 !important;
}

/* Tab Nav chỉ hiện trên mobile */
.mobile-tab-nav {
    display: none;
}

/* Card chỉ desktop */
.desktop-only-card {
    display: block;
}

/* Btn row cho flashcard: đơn giản trên desktop */
.btn-row {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.btn-full {
    width: 100%;
    margin-top: 10px;
}

/* Star button */
.star-btn {
    background: #f0f0f0;
    color: #555;
    border: 1.5px solid #ccc;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.star-btn.starred {
    background: #fff3cd;
    color: #c8820a;
    border-color: #f5c842;
    font-weight: 600;
}
.star-btn:hover {
    background: #ffe9a0;
    border-color: #f5c842;
    color: #a86a00;
}

/* Badge số từ chưa thuộc */
.star-count {
    display: inline-block;
    background: #f5c842;
    color: #7a4e00;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 2px;
    vertical-align: middle;
}

/* Flashcard swipe hint cursor */
.flashcard {
    cursor: grab;
}
.flashcard:active {
    cursor: grabbing;
}

.flashcard-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 15px;
    margin-top: 5px;
}

.autorun-controls {
    margin: 10px 0 0 10px;
    padding-top: 10px;
    border-top: 1px dashed #eee;
}

.form-check-input {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    cursor: pointer;
}

#speedControl input[type="range"] {
    cursor: pointer;
    width: 150px;
}

.exam-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

#flashRangeSelect,
#quizRangeSelect,
#examRangeSelect {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 14px;
}

/* ===== MOBILE (≤768px) ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    /* Ẩn các card chỉ dành cho desktop */
    .desktop-only-card {
        display: none;
    }

    /* Hiện tab nav */
    .mobile-tab-nav {
        display: flex;
        border-bottom: none;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 14px 14px 0 0;
        overflow: hidden;
        gap: 2px;
        /* padding: 4px 4px 0 4px; */
    }

    .mobile-tab-nav .nav-link {
        color: rgba(255, 255, 255, 0.7);
        background: rgba(255, 255, 255, 0.08);
        border: none;
        border-radius: 10px 10px 0 0;
        font-size: 13px;
        font-weight: 600;
        padding: 10px 6px;
        transition: background 0.2s, color 0.2s;
    }

    .mobile-tab-nav .nav-link.active {
        background: white;
        color: #1e3c72;
    }

    .mobile-tab-nav .nav-link:hover {
        background: rgba(255, 255, 255, 0.2);
        color: white;
    }

    /* Trên mobile, Bootstrap tab hoạt động bình thường: chỉ active hiện */
    .main-content .tab-pane {
        display: none !important;
        opacity: 0 !important;
    }

    .main-content .tab-pane.show.active {
        display: block !important;
        opacity: 1 !important;
    }

    .main-content .tab-pane .card {
        border-radius: 0 0 15px 15px;
        margin-bottom: 10px;
    }

    /* Btn row mobile */
    .btn-row {
        gap: 6px;
        margin-top: 12px;
    }

    .btn-row button {
        flex: 1;
        font-size: 14px;
        padding: 10px 4px;
    }

    .flashcard-option {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin-left: 0;
        margin-top: 10px;
        font-size: 13px;
    }

    /* Quiz / Exam options mobile */
    #quizOptions button,
    #examOptions button {
        width: 100%;
        margin-bottom: 8px;
        padding: 12px;
        font-size: 14px;
    }

    .exam-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

#roadmap label,
.exam-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    cursor: pointer;
}

.facebook-float {
    position: fixed;
    bottom: 80px;
    /* cao hơn nút scroll-top nếu có */
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: #1877f2;
    /* màu Facebook */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    transition: all 0.3s ease;
    z-index: 999;
}

.facebook-float:hover {
    background-color: #145dbf;
    transform: scale(1.2);
}