/* reference_library.css - 2-Level Tabbed Architecture with High Polish Glassmorphism */

.hw-ref-container {
    width: min(1440px, 100%);
    max-width: 1440px;
    margin: 0 auto;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
}

/* Header & Glassmorphic Hero */
.hw-ref-header {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.75) 0%, rgba(15, 23, 42, 0.85) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 1.25rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(14px);
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.hw-ref-header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

/* Category Badges */
.hw-ref-badge-cat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.1;
    white-space: nowrap;
    flex-shrink: 0;
}

.hw-ref-badge-eps { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.hw-ref-badge-topik { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.hw-ref-badge-general { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }
.hw-ref-badge-academic { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.hw-ref-badge-tanbien { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.hw-ref-badge-integration { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.hw-ref-badge-academy { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
.hw-ref-badge-practical { background: rgba(20, 184, 166, 0.15); color: #2dd4bf; border: 1px solid rgba(20, 184, 166, 0.3); }

/* EPS-TOPIK MASTER Callout Banner */
.hw-ref-eps-banner {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 1rem;
    padding: 0.85rem 1.15rem;
    position: relative;
    overflow: hidden;
}

.hw-ref-eps-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.hw-ref-btn-eps-jump {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    border: 1px solid rgba(52, 211, 153, 0.4);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.hw-ref-btn-eps-jump:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

/* ==========================================================================
   LEVEL 1: MAIN TABS (THEO CHỦ ĐỀ)
   ========================================================================== */
.hw-ref-main-tabs-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.4rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(51, 65, 85, 0.6);
    backdrop-filter: blur(10px);
}

.hw-ref-main-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: 0.95rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: #94a3b8;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    user-select: none;
}

.hw-ref-main-tab:hover {
    color: #f1f5f9;
    background: rgba(30, 41, 59, 0.5);
}

.hw-ref-main-tab.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.9) 0%, rgba(99, 102, 241, 0.85) 100%);
    border-color: rgba(129, 140, 248, 0.5);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

.hw-ref-main-tab#hw-ref-main-tab-sieu-topik.is-active {
    background: linear-gradient(135deg, rgba(126, 34, 206, 0.9) 0%, rgba(168, 85, 247, 0.85) 100%);
    border-color: rgba(192, 132, 252, 0.5);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
}

.hw-ref-main-tab-count {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.3);
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .hw-ref-main-tabs-wrapper {
        gap: 0.35rem;
        padding: 0.3rem;
        border-radius: 1rem;
    }

    .hw-ref-main-tab {
        padding: 0.65rem 0.5rem;
        gap: 0.35rem;
        font-size: 0.78rem;
        flex-wrap: wrap;
        min-width: 0;
        text-align: center;
    }

    .hw-ref-main-tab-count {
        font-size: 0.65rem;
        padding: 0.14rem 0.45rem;
    }
}

/* ==========================================================================
   LEVEL 1: CURRICULA CARDS
   ========================================================================== */
.hw-ref-curricula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.hw-ref-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 1.15rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.hw-ref-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 12px 28px -10px rgba(79, 70, 229, 0.35);
    background: rgba(30, 41, 59, 0.75);
}

.hw-ref-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.hw-ref-card-icon {
    width: 2.85rem;
    height: 2.85rem;
    border-radius: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.hw-ref-card-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 0.35rem;
    line-height: 1.35;
}

.hw-ref-card-sub {
    font-size: 0.8125rem;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hw-ref-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(51, 65, 85, 0.5);
}

.hw-ref-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #cbd5e1;
    background: rgba(30, 41, 59, 0.85);
    padding: 0.25rem 0.55rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
}

/* ==========================================================================
   LEVEL 1: ACCORDION GROUPS (SINGLE-LAYER CLEAN DESIGN, NO NESTED BORDERS)
   ========================================================================== */
.hw-ref-accordion-group {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.55);
    border-radius: 1rem;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hw-ref-accordion-group.is-open {
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 8px 22px -12px rgba(0, 0, 0, 0.45);
}

.hw-ref-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s ease;
}

.hw-ref-accordion-header:hover {
    background: rgba(51, 65, 85, 0.28);
}

.hw-ref-accordion-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
}

.hw-ref-accordion-chevron {
    color: #94a3b8;
    transition: transform 0.22s ease;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.hw-ref-accordion-group.is-open .hw-ref-accordion-chevron {
    transform: rotate(180deg);
    color: #818cf8;
}

.hw-ref-accordion-content {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid rgba(51, 65, 85, 0.4);
    background: transparent;
}

/* ==========================================================================
   LEVEL 2: BOOK TABS (TỪ VỰNG vs NGỮ PHÁP)
   ========================================================================== */
.hw-ref-book-tabs-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem;
    border-radius: 1.15rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.6);
    width: fit-content;
    max-width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
}

.hw-ref-book-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 0.85rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #94a3b8;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.hw-ref-book-tab:hover {
    color: #f1f5f9;
    background: rgba(51, 65, 85, 0.5);
}

.hw-ref-book-tab.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border-color: #818cf8;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.hw-ref-book-tab#hw-ref-book-tab-grammar.is-active {
    background: linear-gradient(135deg, #7e22ce 0%, #a855f7 100%);
    border-color: #c084fc;
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
}

.hw-ref-tab-count-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.25);
    font-weight: 600;
}

/* ==========================================================================
   LEVEL 2 & 3: LESSON CARDS
   ========================================================================== */
.hw-ref-lesson-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(51, 65, 85, 0.55);
    border-radius: 0.95rem;
    padding: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.hw-ref-lesson-card:hover {
    border-color: #6366f1;
    background: rgba(30, 41, 59, 0.75);
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.hw-ref-lesson-card.is-grammar-card:hover {
    border-color: #a855f7;
}

.hw-ref-lesson-num {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.65rem;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    font-weight: 800;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hw-ref-btn-quick-study {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transition: all 0.2s ease;
}

.hw-ref-btn-quick-study:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

/* ==========================================================================
   LEVEL 3: VOCABULARY DETAIL CARDS
   ========================================================================== */
.hw-ref-word-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 1rem;
    padding: 1.25rem;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hw-ref-word-card:hover {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(30, 41, 59, 0.7);
    box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
}

.hw-ref-word-kr {
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    font-family: 'Pretendard', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.01em;
}

.hw-ref-word-meaning {
    font-size: 0.95rem;
    color: #38bdf8;
    font-weight: 700;
    margin-top: 0.35rem;
}

.hw-ref-word-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 0.65rem;
    margin-top: 0.65rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
}

/* ==========================================================================
   LEVEL 3: GRAMMAR DETAIL CARDS (ROBUST & BILINGUAL)
   ========================================================================== */
.hw-ref-grammar-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 1.15rem;
    padding: 1.4rem;
    margin-bottom: 1.25rem;
    position: relative;
    box-shadow: 0 4px 20px -8px rgba(126, 34, 206, 0.25);
    transition: border-color 0.2s;
}

.hw-ref-grammar-card:hover {
    border-color: rgba(192, 132, 252, 0.6);
}

.hw-ref-grammar-card.is-learned {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(15, 23, 42, 0.85);
}

.hw-ref-grammar-pattern {
    font-size: 1.55rem;
    font-weight: 900;
    color: #c084fc;
    letter-spacing: -0.015em;
    font-family: 'Pretendard', system-ui, sans-serif;
}

.hw-ref-grammar-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: 1px solid rgba(51, 65, 85, 0.7);
    background: rgba(30, 41, 59, 0.6);
    color: #94a3b8;
}

.hw-ref-grammar-toggle-btn:hover {
    background: rgba(51, 65, 85, 0.8);
    color: #ffffff;
}

.hw-ref-grammar-toggle-btn.is-learned {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    color: #34d399;
}

.hw-ref-example-box {
    background: rgba(30, 41, 59, 0.55);
    border-left: 3px solid #818cf8;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 0.6rem;
}

.hw-ref-audio-btn {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hw-ref-audio-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    transform: scale(1.1);
}

.hw-ref-cat-pill {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.hw-ref-cat-pill:hover {
    color: #f1f5f9;
    background: rgba(51, 65, 85, 0.8);
    border-color: rgba(99, 102, 241, 0.4);
}

.hw-ref-cat-pill.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}


/* =========================================================================
   TOPIK MULTI-MODE LEARNING SUITE & STUDY MODAL
   ========================================================================= */
.hw-study-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(11, 15, 25, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: hwFadeIn 0.25s ease-out;
}

@keyframes hwFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.hw-study-dialog {
    width: 100%;
    max-width: 52rem;
    max-height: 94vh;
    background: #0f172a;
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.hw-study-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
    background: rgba(15, 23, 42, 0.95);
    gap: 1rem;
    flex-wrap: wrap;
}

.hw-study-mode-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.25rem 0;
}

.hw-study-mode-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.hw-study-mode-btn:hover {
    color: #ffffff;
    background: rgba(51, 65, 85, 0.8);
}

.hw-study-mode-btn.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.hw-study-progress-wrap {
    height: 4px;
    width: 100%;
    background: rgba(51, 65, 85, 0.5);
    overflow: hidden;
}

.hw-study-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #10b981);
    transition: width 0.3s ease;
}

.hw-study-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
}

/* 3D Flashcard */
.hw-study-perspective {
    perspective: 1200px;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
}

.hw-flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 310px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

.hw-flashcard-inner.is-flipped {
    transform: rotateY(180deg);
}

.hw-flashcard-front, .hw-flashcard-back {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 1.25rem;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.hw-flashcard-front {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
    border: 2px solid rgba(99, 102, 241, 0.4);
}

.hw-flashcard-back {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.95) 100%);
    border: 2px solid rgba(16, 185, 129, 0.4);
    transform: rotateY(180deg);
}

/* SuperMemo SM-2 Rating Controls */
.hw-srs-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    width: 100%;
    max-width: 40rem;
    margin-top: 1.25rem;
}

.hw-srs-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.5rem;
    border-radius: 0.85rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease;
    user-select: none;
}

.hw-srs-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hw-srs-btn-again {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.4);
    color: #fb7185;
}
.hw-srs-btn-again:hover {
    background: #e11d48;
    color: #ffffff;
}

.hw-srs-btn-hard {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}
.hw-srs-btn-hard:hover {
    background: #d97706;
    color: #ffffff;
}

.hw-srs-btn-good {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}
.hw-srs-btn-good:hover {
    background: #059669;
    color: #ffffff;
}

.hw-srs-btn-easy {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: #38bdf8;
}
.hw-srs-btn-easy:hover {
    background: #0284c7;
    color: #ffffff;
}

/* Quiz 4 Choices */
.hw-quiz-choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    width: 100%;
    max-width: 40rem;
    margin-top: 1.25rem;
}

@media (max-width: 640px) {
    .hw-quiz-choices-grid {
        grid-template-columns: 1fr;
    }
    .hw-srs-controls {
        grid-template-columns: repeat(2, 1fr);
    }
}

.hw-quiz-choice-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(71, 85, 105, 0.6);
    border-radius: 1rem;
    color: #f1f5f9;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.hw-quiz-choice-btn:hover:not(:disabled) {
    border-color: #818cf8;
    background: rgba(51, 65, 85, 0.8);
    transform: translateY(-1px);
}

.hw-quiz-choice-btn.is-correct {
    background: rgba(16, 185, 129, 0.25) !important;
    border-color: #10b981 !important;
    color: #34d399 !important;
}

.hw-quiz-choice-btn.is-wrong {
    background: rgba(244, 63, 94, 0.25) !important;
    border-color: #f43f5e !important;
    color: #fb7185 !important;
}

/* Korean Typing / Dictation */
.hw-typing-box {
    width: 100%;
    max-width: 32rem;
    margin: 1.25rem auto 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hw-typing-input {
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(99, 102, 241, 0.5);
    border-radius: 1rem;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.hw-typing-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.35);
}

/* Audio wave animation */
.hw-listening-visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    height: 3rem;
    margin: 1rem 0;
}

.hw-audio-bar {
    width: 4px;
    height: 10px;
    background: #6366f1;
    border-radius: 9999px;
    animation: hwSoundWave 1.2s ease-in-out infinite;
}
.hw-audio-bar:nth-child(2) { animation-delay: 0.15s; }
.hw-audio-bar:nth-child(3) { animation-delay: 0.3s; }
.hw-audio-bar:nth-child(4) { animation-delay: 0.45s; }
.hw-audio-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes hwSoundWave {
    0%, 100% { height: 8px; }
    50% { height: 32px; background: #10b981; }
}

/* =========================================================================
   LIGHT THEME DESIGN TOKENS (html[data-theme="light"] & html:not(.dark))
   ========================================================================= */
html[data-theme="light"] .hw-ref-container,
html:not(.dark) .hw-ref-container {
    color: #1e293b;
}

/* Global text contrast fix: convert white text to deep slate in light mode (except solid colored buttons/badges) */
html[data-theme="light"] .hw-ref-container .hw-text-white:not(button):not(.hw-ref-badge-cat):not(.hw-ref-btn-eps-jump):not(.hw-ref-btn-quick-study):not([class*="hw-bg-indigo"]):not([class*="hw-bg-purple"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-rose"]),
html:not(.dark) .hw-ref-container .hw-text-white:not(button):not(.hw-ref-badge-cat):not(.hw-ref-btn-eps-jump):not(.hw-ref-btn-quick-study):not([class*="hw-bg-indigo"]):not([class*="hw-bg-purple"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-rose"]) {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-study-dialog .hw-text-white:not(button):not(.hw-ref-badge-cat):not([class*="hw-bg-indigo"]):not([class*="hw-bg-rose"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-teal"]):not([class*="hw-bg-gradient"]),
html:not(.dark) .hw-study-dialog .hw-text-white:not(button):not(.hw-ref-badge-cat):not([class*="hw-bg-indigo"]):not([class*="hw-bg-rose"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-teal"]):not([class*="hw-bg-gradient"]) {
    color: #0f172a !important;
}

/* Header & Glassmorphic Hero in Light Mode */
html[data-theme="light"] .hw-ref-header,
html:not(.dark) .hw-ref-header {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .hw-ref-header::before,
html:not(.dark) .hw-ref-header::before {
    display: none !important;
}

html[data-theme="light"] .hw-ref-header h1,
html:not(.dark) .hw-ref-header h1 {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-header p,
html:not(.dark) .hw-ref-header p {
    color: #475569 !important;
}

html[data-theme="light"] #hw-ref-search-input,
html:not(.dark) #hw-ref-search-input {
    background: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #0f172a !important;
}

html[data-theme="light"] #hw-ref-search-input:focus,
html:not(.dark) #hw-ref-search-input:focus {
    background: #ffffff !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* EPS Banner in Light Mode */
html[data-theme="light"] .hw-ref-eps-banner,
html:not(.dark) .hw-ref-eps-banner {
    background: #f0fdf4 !important;
    border: 1px solid #bbf7d0 !important;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.08) !important;
}

html[data-theme="light"] .hw-ref-eps-banner h3,
html:not(.dark) .hw-ref-eps-banner h3 {
    color: #065f46 !important;
}

html[data-theme="light"] .hw-ref-eps-banner p,
html:not(.dark) .hw-ref-eps-banner p {
    color: #166534 !important;
}

html[data-theme="light"] .hw-ref-eps-icon,
html:not(.dark) .hw-ref-eps-icon {
    background: #dcfce7 !important;
    color: #059669 !important;
}

/* High Contrast Badges in Light Mode */
html[data-theme="light"] .hw-ref-badge-eps, html:not(.dark) .hw-ref-badge-eps { background: #ecfdf5 !important; color: #065f46 !important; border-color: #a7f3d0 !important; }
html[data-theme="light"] .hw-ref-badge-topik, html:not(.dark) .hw-ref-badge-topik { background: #fdf4ff !important; color: #7e22ce !important; border-color: #f5d0fe !important; }
html[data-theme="light"] .hw-ref-badge-general, html:not(.dark) .hw-ref-badge-general { background: #f0f9ff !important; color: #0369a1 !important; border-color: #bae6fd !important; }
html[data-theme="light"] .hw-ref-badge-academic, html:not(.dark) .hw-ref-badge-academic { background: #fff1f2 !important; color: #be123c !important; border-color: #fecdd3 !important; }
html[data-theme="light"] .hw-ref-badge-tanbien, html:not(.dark) .hw-ref-badge-tanbien { background: #fffbeb !important; color: #b45309 !important; border-color: #fde68a !important; }
html[data-theme="light"] .hw-ref-badge-integration, html:not(.dark) .hw-ref-badge-integration { background: #fdf2f8 !important; color: #be185d !important; border-color: #fbcfe8 !important; }
html[data-theme="light"] .hw-ref-badge-academy, html:not(.dark) .hw-ref-badge-academy { background: #eef2ff !important; color: #4338ca !important; border-color: #c7d2fe !important; }
html[data-theme="light"] .hw-ref-badge-practical, html:not(.dark) .hw-ref-badge-practical { background: #f0fdfa !important; color: #0f766e !important; border-color: #99f6e4 !important; }

/* Level 1 Main Tabs Bar */
html[data-theme="light"] .hw-ref-main-tabs-wrapper,
html:not(.dark) .hw-ref-main-tabs-wrapper {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .hw-ref-main-tab,
html:not(.dark) .hw-ref-main-tab {
    color: #475569 !important;
    background: transparent !important;
    border-color: transparent !important;
}

html[data-theme="light"] .hw-ref-main-tab:hover,
html:not(.dark) .hw-ref-main-tab:hover {
    color: #0f172a !important;
    background: rgba(255, 255, 255, 0.7) !important;
}

html[data-theme="light"] .hw-ref-main-tab.is-active,
html:not(.dark) .hw-ref-main-tab.is-active {
    background: #ffffff !important;
    color: #4338ca !important;
    border: 1.5px solid #c7d2fe !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15) !important;
}

html[data-theme="light"] .hw-ref-main-tab#hw-ref-main-tab-sieu-topik.is-active,
html:not(.dark) .hw-ref-main-tab#hw-ref-main-tab-sieu-topik.is-active {
    background: #ffffff !important;
    color: #6b21a8 !important;
    border: 1.5px solid #e9d5ff !important;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15) !important;
}

html[data-theme="light"] .hw-ref-main-tab-count,
html:not(.dark) .hw-ref-main-tab-count {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

html[data-theme="light"] .hw-ref-main-tab.is-active .hw-ref-main-tab-count,
html:not(.dark) .hw-ref-main-tab.is-active .hw-ref-main-tab-count {
    background: #e0e7ff !important;
    color: #4338ca !important;
}

html[data-theme="light"] .hw-ref-main-tab#hw-ref-main-tab-sieu-topik.is-active .hw-ref-main-tab-count,
html:not(.dark) .hw-ref-main-tab#hw-ref-main-tab-sieu-topik.is-active .hw-ref-main-tab-count {
    background: #f3e8ff !important;
    color: #7e22ce !important;
}

/* Curricula Cards & Accordions in Light Mode */
html[data-theme="light"] .hw-ref-card,
html[data-theme="light"] .hw-ref-lesson-card,
html[data-theme="light"] .hw-ref-word-card,
html[data-theme="light"] .hw-ref-grammar-card,
html:not(.dark) .hw-ref-card,
html:not(.dark) .hw-ref-lesson-card,
html:not(.dark) .hw-ref-word-card,
html:not(.dark) .hw-ref-grammar-card {
    background: #ffffff !important;
    backdrop-filter: none !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .hw-ref-card:hover,
html[data-theme="light"] .hw-ref-lesson-card:hover,
html:not(.dark) .hw-ref-card:hover,
html:not(.dark) .hw-ref-lesson-card:hover {
    border-color: #818cf8 !important;
    box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.12) !important;
    background: #ffffff !important;
}

html[data-theme="light"] .hw-ref-card-title,
html:not(.dark) .hw-ref-card-title {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-card-sub,
html:not(.dark) .hw-ref-card-sub {
    color: #475569 !important;
}

html[data-theme="light"] .hw-ref-card-stats,
html:not(.dark) .hw-ref-card-stats {
    border-top-color: #e2e8f0 !important;
}

html[data-theme="light"] .hw-ref-card [class*="hw-bg-slate-900"],
html:not(.dark) .hw-ref-card [class*="hw-bg-slate-900"] {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
}

html[data-theme="light"] .hw-ref-card [class*="hw-bg-slate-950"],
html:not(.dark) .hw-ref-card [class*="hw-bg-slate-950"] {
    background-color: #e2e8f0 !important;
    background: #e2e8f0 !important;
}

html[data-theme="light"] .hw-ref-card strong.hw-text-sky-300,
html:not(.dark) .hw-ref-card strong.hw-text-sky-300 {
    color: #0284c7 !important;
}

html[data-theme="light"] .hw-ref-card strong.hw-text-purple-300,
html:not(.dark) .hw-ref-card strong.hw-text-purple-300 {
    color: #7e22ce !important;
}

html[data-theme="light"] .hw-ref-card button[class*="hw-bg-slate-800"],
html:not(.dark) .hw-ref-card button[class*="hw-bg-slate-800"] {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

html[data-theme="light"] .hw-ref-card button[class*="hw-bg-slate-800"]:hover,
html:not(.dark) .hw-ref-card button[class*="hw-bg-slate-800"]:hover {
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #ffffff !important;
}

html[data-theme="light"] .hw-ref-card .hw-ref-card-icon,
html:not(.dark) .hw-ref-card .hw-ref-card-icon {
    background: #f1f5f9 !important;
}

html[data-theme="light"] .hw-ref-stat-pill,
html:not(.dark) .hw-ref-stat-pill {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

html[data-theme="light"] .hw-ref-accordion-group,
html:not(.dark) .hw-ref-accordion-group {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
}

html[data-theme="light"] .hw-ref-accordion-group.is-open,
html:not(.dark) .hw-ref-accordion-group.is-open {
    border-color: #818cf8 !important;
    box-shadow: 0 8px 20px -12px rgba(99, 102, 241, 0.18) !important;
}

html[data-theme="light"] .hw-ref-accordion-header,
html:not(.dark) .hw-ref-accordion-header {
    background: transparent !important;
    border: none !important;
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-accordion-header:hover,
html:not(.dark) .hw-ref-accordion-header:hover {
    background: #f8fafc !important;
}

html[data-theme="light"] .hw-ref-accordion-title,
html:not(.dark) .hw-ref-accordion-title {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-accordion-content,
html:not(.dark) .hw-ref-accordion-content {
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
}

/* Breadcrumb back buttons */
html[data-theme="light"] #hw-ref-back-to-catalog,
html[data-theme="light"] #hw-ref-back-to-book,
html:not(.dark) #hw-ref-back-to-catalog,
html:not(.dark) #hw-ref-back-to-book {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #4338ca !important;
}

html[data-theme="light"] #hw-ref-back-to-catalog:hover,
html[data-theme="light"] #hw-ref-back-to-book:hover,
html:not(.dark) #hw-ref-back-to-catalog:hover,
html:not(.dark) #hw-ref-back-to-book:hover {
    background: #e2e8f0 !important;
    color: #312e81 !important;
}

/* Level 2 & 3 Hero Cards & Progress Blocks */
html[data-theme="light"] .hw-ref-container [class*="hw-bg-slate-900"],
html:not(.dark) .hw-ref-container [class*="hw-bg-slate-900"] {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .hw-ref-container [class*="hw-bg-slate-800"],
html:not(.dark) .hw-ref-container [class*="hw-bg-slate-800"] {
    background-color: #f8fafc !important;
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
}

html[data-theme="light"] .hw-ref-container [class*="hw-bg-slate-950"],
html:not(.dark) .hw-ref-container [class*="hw-bg-slate-950"] {
    background-color: #e2e8f0 !important;
    background: #e2e8f0 !important;
}

html[data-theme="light"] #hw-ref-curr-title,
html[data-theme="light"] #hw-ref-lesson-title,
html:not(.dark) #hw-ref-curr-title,
html:not(.dark) #hw-ref-lesson-title {
    color: #0f172a !important;
}

html[data-theme="light"] #hw-ref-curr-desc,
html[data-theme="light"] #hw-ref-lesson-sub,
html:not(.dark) #hw-ref-curr-desc,
html:not(.dark) #hw-ref-lesson-sub {
    color: #475569 !important;
}

html[data-theme="light"] #hw-ref-curr-progress-num,
html:not(.dark) #hw-ref-curr-progress-num {
    color: #059669 !important;
}

/* Level 2 Book Tabs (Từ Vựng vs Ngữ Pháp) */
html[data-theme="light"] .hw-ref-book-tabs-bar,
html:not(.dark) .hw-ref-book-tabs-bar {
    display: inline-flex !important;
    width: fit-content !important;
    max-width: 100% !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0.35rem !important;
    border-radius: 1.15rem !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.02) !important;
    gap: 0.35rem !important;
}

html[data-theme="light"] .hw-ref-book-tab,
html:not(.dark) .hw-ref-book-tab {
    background: transparent !important;
    border: 1px solid transparent !important;
    color: #64748b !important;
    border-radius: 0.85rem !important;
    padding: 0.6rem 1.25rem !important;
}

html[data-theme="light"] .hw-ref-book-tab:hover,
html:not(.dark) .hw-ref-book-tab:hover {
    background: rgba(255, 255, 255, 0.85) !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

html[data-theme="light"] .hw-ref-book-tab.is-active,
html:not(.dark) .hw-ref-book-tab.is-active {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    border-color: #818cf8 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25) !important;
}

html[data-theme="light"] .hw-ref-book-tab#hw-ref-book-tab-grammar.is-active,
html:not(.dark) .hw-ref-book-tab#hw-ref-book-tab-grammar.is-active {
    background: linear-gradient(135deg, #7e22ce 0%, #a855f7 100%) !important;
    border-color: #c084fc !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(126, 34, 206, 0.25) !important;
}

html[data-theme="light"] .hw-ref-book-tab.is-active i,
html:not(.dark) .hw-ref-book-tab.is-active i {
    color: #ffffff !important;
}

html[data-theme="light"] .hw-ref-book-tab:not(.is-active) i.hw-text-indigo-400,
html:not(.dark) .hw-ref-book-tab:not(.is-active) i.hw-text-indigo-400 {
    color: #4f46e5 !important;
}

html[data-theme="light"] .hw-ref-book-tab:not(.is-active) i.hw-text-purple-400,
html:not(.dark) .hw-ref-book-tab:not(.is-active) i.hw-text-purple-400 {
    color: #7e22ce !important;
}

html[data-theme="light"] .hw-ref-tab-count-badge,
html:not(.dark) .hw-ref-tab-count-badge,
html[data-theme="light"] .hw-ref-book-tab:not(.is-active) .hw-ref-tab-count-badge,
html:not(.dark) .hw-ref-book-tab:not(.is-active) .hw-ref-tab-count-badge {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

html[data-theme="light"] .hw-ref-book-tab.is-active .hw-ref-tab-count-badge,
html:not(.dark) .hw-ref-book-tab.is-active .hw-ref-tab-count-badge {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
}
}

html[data-theme="light"] .hw-ref-book-tab.is-active .hw-ref-tab-count-badge,
html:not(.dark) .hw-ref-book-tab.is-active .hw-ref-tab-count-badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
}

/* Lesson Numbers and Titles */
html[data-theme="light"] .hw-ref-lesson-card .hw-ref-lesson-num,
html:not(.dark) .hw-ref-lesson-card .hw-ref-lesson-num {
    background: #e0e7ff !important;
    color: #4338ca !important;
}

html[data-theme="light"] .hw-ref-lesson-card.is-grammar-card .hw-ref-lesson-num,
html:not(.dark) .hw-ref-lesson-card.is-grammar-card .hw-ref-lesson-num {
    background: #f3e8ff !important;
    color: #7e22ce !important;
}

html[data-theme="light"] .hw-ref-lesson-card h4,
html:not(.dark) .hw-ref-lesson-card h4 {
    color: #0f172a !important;
}

/* Words & Grammar Detail View */
html[data-theme="light"] .hw-ref-word-kr,
html:not(.dark) .hw-ref-word-kr {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-word-meaning,
html:not(.dark) .hw-ref-word-meaning {
    color: #047857 !important;
}

html[data-theme="light"] .hw-ref-grammar-pattern,
html:not(.dark) .hw-ref-grammar-pattern {
    color: #6b21a8 !important;
}

html[data-theme="light"] .hw-ref-grammar-toggle-btn,
html:not(.dark) .hw-ref-grammar-toggle-btn {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}

html[data-theme="light"] .hw-ref-grammar-toggle-btn.is-learned,
html:not(.dark) .hw-ref-grammar-toggle-btn.is-learned {
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    color: #059669 !important;
}

html[data-theme="light"] .hw-ref-example-box,
html:not(.dark) .hw-ref-example-box {
    background: #f8fafc !important;
    border-left-color: #6366f1 !important;
    border: 1px solid #e2e8f0 !important;
    border-left-width: 3px !important;
}

html[data-theme="light"] .hw-ref-example-box .hw-text-slate-100,
html[data-theme="light"] .hw-ref-example-box .hw-text-slate-200,
html:not(.dark) .hw-ref-example-box .hw-text-slate-100,
html:not(.dark) .hw-ref-example-box .hw-text-slate-200 {
    color: #1e293b !important;
}

html[data-theme="light"] .hw-ref-example-box .hw-text-slate-300,
html[data-theme="light"] .hw-ref-example-box .hw-text-slate-400,
html:not(.dark) .hw-ref-example-box .hw-text-slate-300,
html:not(.dark) .hw-ref-example-box .hw-text-slate-400 {
    color: #64748b !important;
}

html[data-theme="light"] .hw-ref-audio-btn,
html:not(.dark) .hw-ref-audio-btn {
    background: #eef2ff !important;
    border: 1px solid #c7d2fe !important;
    color: #4338ca !important;
}

html[data-theme="light"] .hw-ref-audio-btn:hover,
html:not(.dark) .hw-ref-audio-btn:hover {
    background: #4338ca !important;
    color: #ffffff !important;
}

html[data-theme="light"] .hw-ref-cat-pill,
html:not(.dark) .hw-ref-cat-pill {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}

html[data-theme="light"] .hw-ref-cat-pill.is-active,
html:not(.dark) .hw-ref-cat-pill.is-active {
    background: #e0e7ff !important;
    border-color: #818cf8 !important;
    color: #4338ca !important;
}

/* =========================================================================
   STUDY SUITE MODAL (Clean Light Mode Design)
   ========================================================================= */
html[data-theme="light"] .hw-study-dialog,
html:not(.dark) .hw-study-dialog {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] .hw-study-topbar,
html:not(.dark) .hw-study-topbar {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

html[data-theme="light"] #hw-study-modal-title,
html:not(.dark) #hw-study-modal-title {
    color: #0f172a !important;
}

html[data-theme="light"] #hw-study-modal-sub,
html:not(.dark) #hw-study-modal-sub {
    color: #64748b !important;
}

html[data-theme="light"] .hw-study-progress-wrap,
html:not(.dark) .hw-study-progress-wrap {
    background: #e2e8f0 !important;
}

/* Mode Switch Tabs */
html[data-theme="light"] .hw-study-mode-btn,
html:not(.dark) .hw-study-mode-btn {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}

html[data-theme="light"] .hw-study-mode-btn:hover,
html:not(.dark) .hw-study-mode-btn:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

html[data-theme="light"] .hw-study-mode-btn.is-active,
html:not(.dark) .hw-study-mode-btn.is-active {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    border-color: #818cf8 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}

/* Flashcard Front & Back */
html[data-theme="light"] .hw-flashcard-front,
html:not(.dark) .hw-flashcard-front {
    background: #ffffff !important;
    border: 2px solid #c7d2fe !important;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.1) !important;
}

html[data-theme="light"] .hw-flashcard-front .hw-text-white,
html:not(.dark) .hw-flashcard-front .hw-text-white,
html[data-theme="light"] .hw-flashcard-kr-word,
html:not(.dark) .hw-flashcard-kr-word {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-flashcard-front .hw-text-slate-400,
html:not(.dark) .hw-flashcard-front .hw-text-slate-400 {
    color: #64748b !important;
}

html[data-theme="light"] .hw-flashcard-back,
html:not(.dark) .hw-flashcard-back {
    background: #f0fdf4 !important;
    border: 2px solid #a7f3d0 !important;
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.1) !important;
}

html[data-theme="light"] .hw-flashcard-back .hw-text-emerald-400,
html:not(.dark) .hw-flashcard-back .hw-text-emerald-400 {
    color: #047857 !important;
}

/* SuperMemo SM-2 SRS Buttons */
html[data-theme="light"] .hw-srs-btn-again,
html:not(.dark) .hw-srs-btn-again {
    background: #fff1f2 !important;
    border: 1px solid #fecdd3 !important;
    color: #e11d48 !important;
}
html[data-theme="light"] .hw-srs-btn-again:hover,
html:not(.dark) .hw-srs-btn-again:hover {
    background: #e11d48 !important;
    color: #ffffff !important;
}

html[data-theme="light"] .hw-srs-btn-hard,
html:not(.dark) .hw-srs-btn-hard {
    background: #fffbeb !important;
    border: 1px solid #fde68a !important;
    color: #d97706 !important;
}
html[data-theme="light"] .hw-srs-btn-hard:hover,
html:not(.dark) .hw-srs-btn-hard:hover {
    background: #d97706 !important;
    color: #ffffff !important;
}

html[data-theme="light"] .hw-srs-btn-good,
html:not(.dark) .hw-srs-btn-good {
    background: #ecfdf5 !important;
    border: 1px solid #a7f3d0 !important;
    color: #059669 !important;
}
html[data-theme="light"] .hw-srs-btn-good:hover,
html:not(.dark) .hw-srs-btn-good:hover {
    background: #059669 !important;
    color: #ffffff !important;
}

html[data-theme="light"] .hw-srs-btn-easy,
html:not(.dark) .hw-srs-btn-easy {
    background: #f0f9ff !important;
    border: 1px solid #bae6fd !important;
    color: #0284c7 !important;
}
html[data-theme="light"] .hw-srs-btn-easy:hover,
html:not(.dark) .hw-srs-btn-easy:hover {
    background: #0284c7 !important;
    color: #ffffff !important;
}

/* Quiz Mode */
html[data-theme="light"] .hw-quiz-choices-grid .hw-quiz-choice-btn,
html:not(.dark) .hw-quiz-choices-grid .hw-quiz-choice-btn {
    background: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #1e293b !important;
}

html[data-theme="light"] .hw-quiz-choices-grid .hw-quiz-choice-btn:hover:not(:disabled),
html:not(.dark) .hw-quiz-choices-grid .hw-quiz-choice-btn:hover:not(:disabled) {
    background: #f1f5f9 !important;
    border-color: #6366f1 !important;
    transform: translateY(-1px);
}

html[data-theme="light"] .hw-quiz-choice-btn span[class*="hw-bg-slate-800"],
html:not(.dark) .hw-quiz-choice-btn span[class*="hw-bg-slate-800"] {
    background: #e0e7ff !important;
    border-color: #c7d2fe !important;
    color: #4338ca !important;
}

/* General Text inside Study Content for Light Mode (Excluding all colored buttons & badges) */
html[data-theme="light"] #hw-study-content .hw-text-white:not(button):not([class*="hw-bg-indigo"]):not([class*="hw-bg-rose"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-purple"]):not([class*="hw-bg-blue"]):not([class*="hw-bg-gradient"]):not(.hw-ref-badge-cat),
html:not(.dark) #hw-study-content .hw-text-white:not(button):not([class*="hw-bg-indigo"]):not([class*="hw-bg-rose"]):not([class*="hw-bg-emerald"]):not([class*="hw-bg-purple"]):not([class*="hw-bg-blue"]):not([class*="hw-bg-gradient"]):not(.hw-ref-badge-cat) {
    color: #0f172a !important;
}

html[data-theme="light"] #hw-study-content .hw-text-slate-400,
html:not(.dark) #hw-study-content .hw-text-slate-400 {
    color: #64748b !important;
}

/* Ensure buttons and elements with solid colored/gradient backgrounds ALWAYS have pure white text in all themes */
html[data-theme="light"] #hw-study-content button[class*="hw-bg-rose"],
html[data-theme="light"] #hw-study-content button[class*="hw-bg-indigo"],
html[data-theme="light"] #hw-study-content button[class*="hw-bg-emerald"],
html[data-theme="light"] #hw-study-content button[class*="hw-bg-purple"],
html[data-theme="light"] #hw-study-content button[class*="hw-bg-blue"],
html[data-theme="light"] #hw-study-content [class*="hw-bg-gradient"],
html[data-theme="light"] #hw-study-content [class*="hw-from-emerald"],
html:not(.dark) #hw-study-content button[class*="hw-bg-rose"],
html:not(.dark) #hw-study-content button[class*="hw-bg-indigo"],
html:not(.dark) #hw-study-content button[class*="hw-bg-emerald"],
html:not(.dark) #hw-study-content button[class*="hw-bg-purple"],
html:not(.dark) #hw-study-content button[class*="hw-bg-blue"],
html:not(.dark) #hw-study-content [class*="hw-bg-gradient"],
html:not(.dark) #hw-study-content [class*="hw-from-emerald"] {
    color: #ffffff !important;
}

html[data-theme="light"] #hw-study-content [class*="hw-from-emerald"] i,
html[data-theme="light"] #hw-study-content [class*="hw-from-emerald"] svg,
html[data-theme="light"] #hw-study-content button[class*="hw-bg-rose"] i,
html[data-theme="light"] #hw-study-content button[class*="hw-bg-indigo"] i,
html:not(.dark) #hw-study-content [class*="hw-from-emerald"] i,
html:not(.dark) #hw-study-content [class*="hw-from-emerald"] svg,
html:not(.dark) #hw-study-content button[class*="hw-bg-rose"] i,
html:not(.dark) #hw-study-content button[class*="hw-bg-indigo"] i {
    color: #ffffff !important;
}

html[data-theme="light"] .hw-typing-input,
html:not(.dark) .hw-typing-input {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 2px solid #818cf8 !important;
}

html[data-theme="light"] .hw-typing-input:focus,
html:not(.dark) .hw-typing-input:focus {
    background: #ffffff !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2) !important;
}

/* Completion Screen */
html[data-theme="light"] #hw-study-content [class*="hw-bg-slate-800"],
html:not(.dark) #hw-study-content [class*="hw-bg-slate-800"] {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
}

/* Curriculum Detail View (Level 2) Light Theme Polish */
html[data-theme="light"] #hw-ref-curriculum-view > div[class*="hw-bg-slate-900"],
html:not(.dark) #hw-ref-curriculum-view > div[class*="hw-bg-slate-900"] {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] #hw-ref-curr-title,
html:not(.dark) #hw-ref-curr-title {
    color: #0f172a !important;
}

html[data-theme="light"] #hw-ref-curr-desc,
html:not(.dark) #hw-ref-curr-desc {
    color: #475569 !important;
}

html[data-theme="light"] #hw-ref-back-to-catalog,
html:not(.dark) #hw-ref-back-to-catalog {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #4f46e5 !important;
}

html[data-theme="light"] #hw-ref-back-to-catalog:hover,
html:not(.dark) #hw-ref-back-to-catalog:hover {
    background: #e2e8f0 !important;
    color: #4338ca !important;
}

html[data-theme="light"] #hw-ref-curriculum-view div[class*="hw-bg-slate-800"],
html:not(.dark) #hw-ref-curriculum-view div[class*="hw-bg-slate-800"] {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
}

html[data-theme="light"] #hw-ref-curriculum-view div[class*="hw-bg-slate-800"] span,
html:not(.dark) #hw-ref-curriculum-view div[class*="hw-bg-slate-800"] span {
    color: #64748b !important;
}

html[data-theme="light"] #hw-ref-curriculum-view div[class*="hw-bg-slate-950"],
html:not(.dark) #hw-ref-curriculum-view div[class*="hw-bg-slate-950"] {
    background: #e2e8f0 !important;
}


/* Lesson cards & buttons in curriculum view */
html[data-theme="light"] .hw-ref-lesson-card,
html:not(.dark) .hw-ref-lesson-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .hw-ref-lesson-card:hover,
html:not(.dark) .hw-ref-lesson-card:hover {
    border-color: #818cf8 !important;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.1) !important;
}

html[data-theme="light"] .hw-ref-lesson-card h4,
html:not(.dark) .hw-ref-lesson-card h4 {
    color: #0f172a !important;
}

html[data-theme="light"] .hw-ref-lesson-card span.hw-text-slate-400,
html:not(.dark) .hw-ref-lesson-card span.hw-text-slate-400 {
    color: #64748b !important;
}

html[data-theme="light"] .hw-ref-lesson-num,
html:not(.dark) .hw-ref-lesson-num {
    background: #e0e7ff !important;
    color: #4338ca !important;
    border: 1px solid #c7d2fe !important;
}

html[data-theme="light"] .hw-ref-lesson-card button[class*="hw-bg-indigo"],
html:not(.dark) .hw-ref-lesson-card button[class*="hw-bg-indigo"] {
    background: #4f46e5 !important;
    color: #ffffff !important;
}

/* Tab 2 (Theo chủ đề) High Contrast Polish */
html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card:hover,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card:hover {
    border-color: #818cf8 !important;
    box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.12) !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card-title,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card-title {
    color: #0f172a !important;
    font-weight: 700 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card-sub,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card-sub {
    color: #64748b !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card [class*="hw-bg-slate-900"],
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card [class*="hw-bg-slate-900"] {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card [class*="hw-bg-slate-950"],
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card [class*="hw-bg-slate-950"] {
    background: #e2e8f0 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card strong.hw-text-sky-300,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card strong.hw-text-sky-300 {
    color: #0284c7 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-stat-pill,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-stat-pill {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card button[class*="hw-bg-slate-800"],
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card button[class*="hw-bg-slate-800"] {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

html[data-theme="light"] #hw-ref-panel-theo-chu-de .hw-ref-card button[class*="hw-bg-slate-800"]:hover,
html:not(.dark) #hw-ref-panel-theo-chu-de .hw-ref-card button[class*="hw-bg-slate-800"]:hover {
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #ffffff !important;
}

/* =========================================================================
   DEFINITIVE HIGH-SPECIFICITY OVERRIDES FOR FLASHCARDS & STUDY SUITE
   ========================================================================= */

/* Korean Word on Flashcards */
.hw-flashcard-kr-word {
    color: #f8fafc !important;
}
html[data-theme="light"] .hw-flashcard-kr-word,
html:not(.dark) .hw-flashcard-kr-word,
html[data-theme="light"] .hw-flashcard-front .hw-flashcard-kr-word,
html:not(.dark) .hw-flashcard-front .hw-flashcard-kr-word {
    color: #0f172a !important;
}

/* Quiz, Typing & Reading Korean Words */
.hw-quiz-kr-word,
.hw-typing-kr-word,
.hw-reading-sentence {
    color: #f8fafc !important;
}
html[data-theme="light"] .hw-quiz-kr-word,
html:not(.dark) .hw-quiz-kr-word,
html[data-theme="light"] .hw-typing-kr-word,
html:not(.dark) .hw-typing-kr-word,
html[data-theme="light"] .hw-reading-sentence,
html:not(.dark) .hw-reading-sentence {
    color: #0f172a !important;
}

/* Completion Dialog Elements */
.hw-completion-title {
    color: #f8fafc !important;
}
html[data-theme="light"] .hw-completion-title,
html:not(.dark) .hw-completion-title {
    color: #0f172a !important;
}

/* Always preserve white text on colored action buttons */
.hw-study-dialog button[class*="hw-bg-rose"],
.hw-study-dialog button[class*="hw-bg-rose"] *,
.hw-study-dialog button[class*="hw-bg-indigo"],
.hw-study-dialog button[class*="hw-bg-indigo"] * {
    color: #ffffff !important;
}

/* Study Mode Tab Switcher in Light Mode */
html[data-theme="light"] .hw-study-mode-tabs .hw-study-mode-btn,
html:not(.dark) .hw-study-mode-tabs .hw-study-mode-btn {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}
html[data-theme="light"] .hw-study-mode-tabs .hw-study-mode-btn:hover,
html:not(.dark) .hw-study-mode-tabs .hw-study-mode-btn:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
html[data-theme="light"] .hw-study-mode-tabs .hw-study-mode-btn.is-active,
html:not(.dark) .hw-study-mode-tabs .hw-study-mode-btn.is-active {
    background: #4f46e5 !important;
    border-color: #6366f1 !important;
    color: #ffffff !important;
}

/* Light Mode Curriculum Hero & Progress Box */
html[data-theme="light"] #hw-ref-curriculum-view [class*="hw-bg-slate-900/80"],
html:not(.dark) #hw-ref-curriculum-view [class*="hw-bg-slate-900/80"] {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
}
html[data-theme="light"] #hw-ref-curriculum-view [class*="hw-min-w-[200px]"],
html:not(.dark) #hw-ref-curriculum-view [class*="hw-min-w-[200px]"] {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
}
html[data-theme="light"] #hw-ref-back-to-catalog,
html:not(.dark) #hw-ref-back-to-catalog {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #4f46e5 !important;
}

/* =========================================================================
   LIGHT MODE DEFINITIVE OVERRIDES FOR CARDS, LESSONS & ACCORDIONS
   ========================================================================= */

/* Lesson Cards & Details in Light Mode */
html[data-theme="light"] .hw-ref-lesson-card,
html:not(.dark) .hw-ref-lesson-card,
body:not(.dark) .hw-ref-lesson-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
}
html[data-theme="light"] .hw-ref-lesson-card:hover,
html:not(.dark) .hw-ref-lesson-card:hover,
body:not(.dark) .hw-ref-lesson-card:hover {
    border-color: #6366f1 !important;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.1) !important;
    transform: translateY(-1px);
}
html[data-theme="light"] .hw-ref-lesson-card .hw-ref-lesson-num,
html:not(.dark) .hw-ref-lesson-card .hw-ref-lesson-num,
body:not(.dark) .hw-ref-lesson-card .hw-ref-lesson-num {
    background: rgba(99, 102, 241, 0.15) !important;
    color: #4338ca !important;
    font-weight: 800 !important;
}
html[data-theme="light"] .hw-ref-lesson-card.is-grammar-card .hw-ref-lesson-num,
html:not(.dark) .hw-ref-lesson-card.is-grammar-card .hw-ref-lesson-num,
body:not(.dark) .hw-ref-lesson-card.is-grammar-card .hw-ref-lesson-num {
    background: rgba(168, 85, 247, 0.15) !important;
    color: #7e22ce !important;
    font-weight: 800 !important;
}
html[data-theme="light"] .hw-ref-lesson-card h4,
html:not(.dark) .hw-ref-lesson-card h4,
body:not(.dark) .hw-ref-lesson-card h4 {
    color: #0f172a !important;
}

/* Accordion Headers in Light Mode (no duplicate inner border) */
html[data-theme="light"] .hw-ref-accordion-header,
html:not(.dark) .hw-ref-accordion-header,
body:not(.dark) .hw-ref-accordion-header {
    background: transparent !important;
    border: none !important;
    color: #0f172a !important;
}
html[data-theme="light"] .hw-ref-accordion-header:hover,
html:not(.dark) .hw-ref-accordion-header:hover,
body:not(.dark) .hw-ref-accordion-header:hover {
    background: #f8fafc !important;
    border: none !important;
}
html[data-theme="light"] .hw-ref-accordion-title .hw-text-white,
html:not(.dark) .hw-ref-accordion-title .hw-text-white,
body:not(.dark) .hw-ref-accordion-title .hw-text-white {
    color: #0f172a !important;
}

/* Word Cards & Grammar Cards in Light Mode */
html[data-theme="light"] .hw-ref-word-card,
html:not(.dark) .hw-ref-word-card,
body:not(.dark) .hw-ref-word-card,
html[data-theme="light"] .hw-ref-grammar-card,
html:not(.dark) .hw-ref-grammar-card,
body:not(.dark) .hw-ref-grammar-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03) !important;
}
html[data-theme="light"] .hw-ref-word-card .hw-ref-word-kr,
html:not(.dark) .hw-ref-word-card .hw-ref-word-kr,
body:not(.dark) .hw-ref-word-card .hw-ref-word-kr {
    color: #0f172a !important;
}
html[data-theme="light"] .hw-ref-grammar-card .hw-ref-grammar-pattern,
html:not(.dark) .hw-ref-grammar-card .hw-ref-grammar-pattern,
body:not(.dark) .hw-ref-grammar-card .hw-ref-grammar-pattern {
    color: #4338ca !important;
}
html[data-theme="light"] .hw-ref-example-box,
html:not(.dark) .hw-ref-example-box,
body:not(.dark) .hw-ref-example-box {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
}

/* Responsive adjustments for Level 2 Book Tabs */
@media (max-width: 640px) {
    .hw-ref-book-tabs-bar,
    html[data-theme="light"] .hw-ref-book-tabs-bar,
    html:not(.dark) .hw-ref-book-tabs-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
    }
    .hw-ref-book-tab {
        justify-content: center !important;
        padding: 0.55rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
}

/* ==========================================================================
   TOPIK PROFESSIONAL FLASHCARD SYSTEM & VOCABULARY LIST
   ========================================================================== */

.hw-ref-flashcard-box {
    background: #0d111a;
    border: 1px solid #1e2638;
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 20px 45px -12px rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] .hw-ref-flashcard-box,
html:not(.dark) .hw-ref-flashcard-box,
body:not(.dark) .hw-ref-flashcard-box {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

/* 3D Flashcard Perspective & Scene */
.hw-ref-flashcard-scene {
    perspective: 1200px;
    width: 100%;
    height: 380px;
    min-height: 380px;
    max-height: 380px;
    cursor: pointer;
    user-select: none;
    position: relative;
    border-radius: 1.25rem;
    flex-shrink: 0;
}

.hw-ref-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 380px;
    max-height: 380px;
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: 1.25rem;
}

.hw-ref-card-inner.is-flipped {
    transform: rotateY(180deg);
}

.hw-ref-card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 1.25rem;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.25rem;
    text-align: center;
    background: #141824;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

html[data-theme="light"] .hw-ref-card-face,
html:not(.dark) .hw-ref-card-face,
body:not(.dark) .hw-ref-card-face {
    background: #f8fafc;
    border-color: #e2e8f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.hw-ref-flashcard-scene:hover .hw-ref-card-face {
    border-color: rgba(99, 102, 241, 0.4);
}

/* Card Front Elements */
.hw-ref-card-front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.25rem;
    box-sizing: border-box;
    height: 100%;
}

.hw-ref-card-img-wrap {
    width: 130px;
    height: 130px;
    min-width: 130px;
    min-height: 130px;
    max-width: 130px;
    max-height: 130px;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 0.5rem;
    background: #1c2233;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

html[data-theme="light"] .hw-ref-card-img-wrap,
html:not(.dark) .hw-ref-card-img-wrap,
body:not(.dark) .hw-ref-card-img-wrap {
    background: #e2e8f0;
    border-color: #cbd5e1;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.hw-ref-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.hw-ref-card-img-fallback {
    font-size: 2.5rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hw-ref-card-kr {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
    line-height: 1.2;
    margin: auto 0;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

html[data-theme="light"] .hw-ref-card-kr,
html:not(.dark) .hw-ref-card-kr,
body:not(.dark) .hw-ref-card-kr {
    color: #0f172a;
}

.hw-ref-card-flip-hint {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-top: auto;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Card Audio Button */
.hw-ref-card-audio-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #818cf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.hw-ref-card-audio-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    color: #ffffff;
    transform: scale(1.08);
}

/* Card Back Elements */
.hw-ref-card-back {
    transform: rotateY(180deg);
    padding: 1.25rem 1rem;
    box-sizing: border-box;
    overflow-y: auto;
}

.hw-ref-card-back-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    min-height: 100%;
}

.hw-ref-card-back-kr {
    font-size: 1.85rem;
    font-weight: 800;
    color: #ffffff;
}

html[data-theme="light"] .hw-ref-card-back-kr,
html:not(.dark) .hw-ref-card-back-kr,
body:not(.dark) .hw-ref-card-back-kr {
    color: #0f172a;
}

.hw-ref-card-pos-badge {
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.hw-ref-card-example-box {
    width: 100%;
    max-width: 480px;
    padding: 0.65rem 0.95rem;
    border-radius: 0.875rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin: auto 0;
    flex-shrink: 0;
}

html[data-theme="light"] .hw-ref-card-example-box,
html:not(.dark) .hw-ref-card-example-box,
body:not(.dark) .hw-ref-card-example-box {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Exactly 4 Control Buttons in Order */
.hw-ref-fc-controls-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    margin-top: 1.25rem;
    flex-shrink: 0;
}

.hw-ref-fc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 0.5rem;
    border-radius: 0.875rem;
    font-size: 0.825rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: pointer;
    outline: none;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hw-ref-fc-btn:active {
    transform: scale(0.97);
}

/* Button 1: TRƯỚC */
.hw-ref-btn-prev {
    background: #181d2a;
    border: 1px solid #2a3449;
    color: #cbd5e1;
}
.hw-ref-btn-prev:hover:not(:disabled) {
    background: #22293b;
    border-color: #3b4764;
    color: #ffffff;
}

/* Button 2: CHƯA THUỘC */
.hw-ref-btn-learning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
}
.hw-ref-btn-learning:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.6);
    color: #fef3c7;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.25);
}

/* Button 3: ĐÃ THUỘC */
.hw-ref-btn-mastered {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
}
.hw-ref-btn-mastered:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.6);
    color: #ecfdf5;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

/* Button 4: SAU */
.hw-ref-btn-next {
    background: #181d2a;
    border: 1px solid #2a3449;
    color: #cbd5e1;
}
.hw-ref-btn-next:hover:not(:disabled) {
    background: #22293b;
    border-color: #3b4764;
    color: #ffffff;
}

.hw-ref-fc-btn:disabled,
.hw-ref-fc-btn.is-disabled {
    opacity: 0.38;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Light Theme overrides for 4 Buttons */
html[data-theme="light"] .hw-ref-btn-prev,
html:not(.dark) .hw-ref-btn-prev,
body:not(.dark) .hw-ref-btn-prev,
html[data-theme="light"] .hw-ref-btn-next,
html:not(.dark) .hw-ref-btn-next,
body:not(.dark) .hw-ref-btn-next {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
html[data-theme="light"] .hw-ref-btn-prev:hover:not(:disabled),
html:not(.dark) .hw-ref-btn-prev:hover:not(:disabled),
body:not(.dark) .hw-ref-btn-prev:hover:not(:disabled),
html[data-theme="light"] .hw-ref-btn-next:hover:not(:disabled),
html:not(.dark) .hw-ref-btn-next:hover:not(:disabled),
body:not(.dark) .hw-ref-btn-next:hover:not(:disabled) {
    background: #e2e8f0;
    color: #0f172a;
}

/* Filter Pills */
.hw-ref-filter-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #2a3449;
    background: #141824;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hw-ref-filter-pill:hover {
    border-color: #475569;
    color: #e2e8f0;
}

.hw-ref-filter-pill.is-active {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    color: #a5b4fc;
}

html[data-theme="light"] .hw-ref-filter-pill,
html:not(.dark) .hw-ref-filter-pill,
body:not(.dark) .hw-ref-filter-pill {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}
html[data-theme="light"] .hw-ref-filter-pill.is-active,
html:not(.dark) .hw-ref-filter-pill.is-active,
body:not(.dark) .hw-ref-filter-pill.is-active {
    background: #e0e7ff;
    border-color: #6366f1;
    color: #4338ca;
}

/* Vocabulary List Rows legacy hook (Forward-compatible redirect to 2-Row Image 9 design) */
.hw-ref-word-row {
    box-sizing: border-box;
}

/* 1:1 Square Thumbnail (56px) */
.hw-ref-word-thumb {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #1a202c;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

html[data-theme="light"] .hw-ref-word-thumb,
html:not(.dark) .hw-ref-word-thumb,
body:not(.dark) .hw-ref-word-thumb {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.hw-ref-word-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hw-ref-word-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.25rem;
}

/* Status Badges on List Row */
.hw-ref-row-badge-mastered {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.hw-ref-row-badge-learning {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

/* ==========================================================================
   CONSOLIDATED TOPIK VOCABULARY & FLASHCARD DESIGN
   ========================================================================== */

/* Lesson View Container (Clean FlipVocab Theme, Image 1 Desktop Aligned) */
#hw-ref-lesson-view {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    padding: 1.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
}

html.dark #hw-ref-lesson-view,
[data-theme="dark"] #hw-ref-lesson-view {
    background-color: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);
}

/* Lesson Top Navigation Bar */
.hw-ref-lesson-top-bar {
    margin-bottom: 0.85rem;
}

.hw-ref-nav-back-btn,
.hw-ref-top-btn {
    background: #ffffff;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.hw-ref-nav-back-btn:hover,
.hw-ref-top-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    transform: translateY(-1px);
}

html.dark .hw-ref-nav-back-btn,
html.dark .hw-ref-top-btn,
[data-theme="dark"] .hw-ref-nav-back-btn,
[data-theme="dark"] .hw-ref-top-btn {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

html.dark .hw-ref-nav-back-btn:hover,
html.dark .hw-ref-top-btn:hover,
[data-theme="dark"] .hw-ref-nav-back-btn:hover,
[data-theme="dark"] .hw-ref-top-btn:hover {
    background: #334155;
    color: #ffffff;
}

.hw-ref-pill-badge {
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.hw-ref-pill-badge.hw-badge-green {
    background: #10b981;
    color: #ffffff;
    border: 1px solid #059669;
}

.hw-ref-pill-badge.hw-badge-white {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

html.dark .hw-ref-pill-badge.hw-badge-white,
[data-theme="dark"] .hw-ref-pill-badge.hw-badge-white {
    background: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}

/* Lesson Title Bar */
.hw-ref-lesson-title-bar {
    margin-bottom: 1.5rem;
}

.hw-ref-lesson-mascot {
    width: 44px;
    height: 44px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #d97706;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
    flex-shrink: 0;
}

html.dark .hw-ref-lesson-mascot,
[data-theme="dark"] .hw-ref-lesson-mascot {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.hw-ref-lesson-main-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

html.dark .hw-ref-lesson-main-title,
[data-theme="dark"] .hw-ref-lesson-main-title {
    color: #f8fafc;
}

.hw-ref-lesson-sub-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 0.2rem;
}

html.dark .hw-ref-lesson-sub-title,
[data-theme="dark"] .hw-ref-lesson-sub-title {
    color: #94a3b8;
}

/* Flashcard Container Box */
.hw-ref-flashcard-box {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 48rem; /* max-w-3xl */
    margin: 0 auto;
    width: 100%;
}

/* Flashcard Toolbar */
.hw-ref-fc-toolbar {
    margin-bottom: 0.85rem;
}

.hw-ref-seg-switch {
    display: inline-flex;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 3px;
    gap: 3px;
}

html.dark .hw-ref-seg-switch,
[data-theme="dark"] .hw-ref-seg-switch {
    background: #1e293b;
    border-color: #334155;
}

.hw-ref-seg-btn {
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

html.dark .hw-ref-seg-btn,
[data-theme="dark"] .hw-ref-seg-btn {
    color: #94a3b8;
}

.hw-ref-seg-btn.is-active {
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html.dark .hw-ref-seg-btn.is-active,
[data-theme="dark"] .hw-ref-seg-btn.is-active {
    background: #334155;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.hw-ref-counter-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html.dark .hw-ref-counter-box,
[data-theme="dark"] .hw-ref-counter-box {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.hw-ref-tool-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.15s ease;
}

.hw-ref-tool-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

html.dark .hw-ref-tool-btn,
[data-theme="dark"] .hw-ref-tool-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

html.dark .hw-ref-tool-btn:hover,
[data-theme="dark"] .hw-ref-tool-btn:hover {
    background: #334155;
    color: #ffffff;
}

.hw-ref-tool-btn.is-active {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #2563eb;
}

html.dark .hw-ref-tool-btn.is-active,
[data-theme="dark"] .hw-ref-tool-btn.is-active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
    color: #93c5fd;
}

/* 3D Flashcard Scene & Card Faces (Clean Native Theme) */
.hw-ref-flashcard-scene {
    position: relative;
    height: 380px;
    min-height: 380px;
    max-height: 380px;
    perspective: 1200px;
    cursor: pointer;
    user-select: none;
    border-radius: 1.25rem;
    flex-shrink: 0;
}

.hw-ref-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 380px;
    max-height: 380px;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    background-color: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
}

html.dark .hw-ref-card-inner,
[data-theme="dark"] .hw-ref-card-inner {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.hw-ref-card-inner.is-flipped {
    transform: rotateY(180deg);
}

.hw-ref-card-corner-tools {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hw-ref-corner-btn {
    width: 34px;
    height: 34px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hw-ref-corner-btn:hover {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transform: scale(1.05);
}

html.dark .hw-ref-corner-btn,
[data-theme="dark"] .hw-ref-corner-btn {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

html.dark .hw-ref-corner-btn:hover,
[data-theme="dark"] .hw-ref-corner-btn:hover {
    background: #1e293b;
    border-color: #475569;
    color: #ffffff;
}

.hw-ref-card-front,
.hw-ref-card-back {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    box-sizing: border-box;
}

.hw-ref-card-back {
    transform: rotateY(180deg);
}

.hw-ref-card-img-wrap {
    width: 120px;
    height: 120px;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

html.dark .hw-ref-card-img-wrap,
[data-theme="dark"] .hw-ref-card-img-wrap {
    border-color: #334155;
    background: #0f172a;
}

.hw-ref-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hw-ref-card-kr {
    font-size: 2.25rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.dark .hw-ref-card-kr,
[data-theme="dark"] .hw-ref-card-kr {
    color: #f8fafc;
}

.hw-ref-card-pos-badge {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
    display: inline-block;
}

html.dark .hw-ref-card-pos-badge,
[data-theme="dark"] .hw-ref-card-pos-badge {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

.hw-ref-card-flip-hint {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.dark .hw-ref-card-flip-hint,
[data-theme="dark"] .hw-ref-card-flip-hint {
    color: #64748b;
}

/* 4 Control Buttons bar */
.hw-ref-fc-controls-bar {
    margin-top: 1rem;
    max-width: 48rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.hw-ref-fc-controls-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
}

.hw-ref-fc-btn {
    height: 48px;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.hw-ref-fc-btn:active {
    transform: scale(0.98);
}

.hw-ref-btn-prev, .hw-ref-btn-next {
    background: #ffffff;
    color: #334155;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.hw-ref-btn-prev:hover, .hw-ref-btn-next:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

html.dark .hw-ref-btn-prev,
html.dark .hw-ref-btn-next,
[data-theme="dark"] .hw-ref-btn-prev,
[data-theme="dark"] .hw-ref-btn-next {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid #334155;
}

html.dark .hw-ref-btn-prev:hover,
html.dark .hw-ref-btn-next:hover,
[data-theme="dark"] .hw-ref-btn-prev:hover,
[data-theme="dark"] .hw-ref-btn-next:hover {
    background: #334155;
    color: #ffffff;
}

.hw-ref-btn-learning {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border: 1px solid #b91c1c !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25) !important;
}

.hw-ref-btn-learning:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    transform: translateY(-1px);
}

.hw-ref-btn-mastered {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #ffffff !important;
    border: 1px solid #047857 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}

.hw-ref-btn-mastered:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-1px);
}

/* Mode Selector Section: "Chọn chế độ học" (6 in 1 row on Desktop) */
.hw-ref-modes-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 1.5rem;
    margin-top: 2rem;
}

html.dark .hw-ref-modes-section,
[data-theme="dark"] .hw-ref-modes-section {
    border-color: #334155;
}

@media (min-width: 1024px) {
    #hw-ref-modes-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

.hw-ref-mode-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.hw-ref-mode-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

html.dark .hw-ref-mode-card,
[data-theme="dark"] .hw-ref-mode-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

html.dark .hw-ref-mode-card:hover,
[data-theme="dark"] .hw-ref-mode-card:hover {
    border-color: #475569;
    background: #243247;
}

.hw-ref-mode-card.is-active {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6, 0 4px 12px rgba(59, 130, 246, 0.1);
}

html.dark .hw-ref-mode-card.is-active,
[data-theme="dark"] .hw-ref-mode-card.is-active {
    background: rgba(99, 102, 241, 0.15);
    border-color: #818cf8;
    box-shadow: 0 0 0 1px #818cf8, 0 4px 12px rgba(99, 102, 241, 0.2);
}

.hw-ref-mode-icon {
    width: 36px;
    height: 36px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #3b82f6;
    flex-shrink: 0;
}

html.dark .hw-ref-mode-icon,
[data-theme="dark"] .hw-ref-mode-icon {
    background: #0f172a;
    border-color: #334155;
    color: #818cf8;
}

.hw-ref-mode-name {
    font-weight: 700;
    font-size: 0.8rem;
    color: #0f172a;
}

html.dark .hw-ref-mode-name,
[data-theme="dark"] .hw-ref-mode-name {
    color: #ffffff;
}

.hw-ref-mode-badge {
    display: inline-block;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    font-size: 0.65rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
    margin-top: 0.2rem;
}

html.dark .hw-ref-mode-badge,
[data-theme="dark"] .hw-ref-mode-badge {
    border-color: #334155;
    background: #0f172a;
    color: #94a3b8;
}

.hw-ref-mode-badge.hw-badge-yellow {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
    font-weight: 700;
}

html.dark .hw-ref-mode-badge.hw-badge-yellow,
[data-theme="dark"] .hw-ref-mode-badge.hw-badge-yellow {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.hw-ref-mode-badge.hw-badge-blue {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

/* Button: Thêm cả bài vào ôn tập */
.hw-ref-btn-add-review {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 0.625rem;
    padding: 0.6rem 1.25rem;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
    transition: all 0.15s ease;
}

.hw-ref-btn-add-review:hover {
    background: #fde68a;
    border-color: #f59e0b;
    transform: translateY(-1px);
}

html.dark .hw-ref-btn-add-review,
[data-theme="dark"] .hw-ref-btn-add-review {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

html.dark .hw-ref-btn-add-review:hover,
[data-theme="dark"] .hw-ref-btn-add-review:hover {
    background: rgba(245, 158, 11, 0.25);
    border-color: #fbbf24;
}

/* 2-Column Word List Cards (Standard FlipVocab Sleek Design - Không tô đậm) */
.hw-ref-word-item-card,
.hw-ref-word-row {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.75rem !important;
    padding: 0 !important;
    overflow: hidden !important;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

.hw-ref-word-item-card:hover,
.hw-ref-word-row:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1 !important;
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .hw-ref-word-item-card,
html:not(.dark) .hw-ref-word-item-card,
body:not(.dark) .hw-ref-word-item-card,
html[data-theme="light"] .hw-ref-word-row,
html:not(.dark) .hw-ref-word-row,
body:not(.dark) .hw-ref-word-row {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .hw-ref-word-item-card:hover,
html:not(.dark) .hw-ref-word-item-card:hover,
body:not(.dark) .hw-ref-word-item-card:hover,
html[data-theme="light"] .hw-ref-word-row:hover,
html:not(.dark) .hw-ref-word-row:hover,
body:not(.dark) .hw-ref-word-row:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.08) !important;
}

html.dark .hw-ref-word-item-card,
[data-theme="dark"] .hw-ref-word-item-card,
html.dark .hw-ref-word-row,
[data-theme="dark"] .hw-ref-word-row {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) !important;
}

html.dark .hw-ref-word-item-card:hover,
[data-theme="dark"] .hw-ref-word-item-card:hover,
html.dark .hw-ref-word-row:hover,
[data-theme="dark"] .hw-ref-word-row:hover {
    border-color: #475569 !important;
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.45) !important;
}

.hw-ref-word-item-card.is-current,
.hw-ref-word-row.is-current {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 1.5px #3b82f6, 0 4px 12px rgba(59, 130, 246, 0.12) !important;
}

html.dark .hw-ref-word-item-card.is-current,
[data-theme="dark"] .hw-ref-word-item-card.is-current,
html.dark .hw-ref-word-row.is-current,
[data-theme="dark"] .hw-ref-word-row.is-current {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 1.5px #60a5fa, 0 4px 14px rgba(96, 165, 250, 0.25) !important;
}

/* Row 1: Word Information */
.hw-ref-word-main-row {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.75rem 1rem !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

html.dark .hw-ref-word-main-row,
[data-theme="dark"] .hw-ref-word-main-row {
    background: #1e293b !important;
}

.hw-ref-word-index {
    font-weight: 700;
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1;
}

html.dark .hw-ref-word-index,
[data-theme="dark"] .hw-ref-word-index {
    color: #94a3b8;
}

.hw-ref-word-kr {
    font-weight: 800;
    font-size: 1.4rem;
    color: #0f172a;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

html.dark .hw-ref-word-kr,
[data-theme="dark"] .hw-ref-word-kr {
    color: #f8fafc;
}

.hw-ref-pos-tag {
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    padding: 1.5px 6px !important;
    font-size: 0.68rem !important;
    font-weight: 600 !important;
    color: #2563eb !important;
    display: inline-block;
}

html.dark .hw-ref-pos-tag,
[data-theme="dark"] .hw-ref-pos-tag {
    background: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
    box-shadow: none !important;
    color: #93c5fd !important;
}

.hw-ref-word-rom {
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
    line-height: 1.3;
}

html.dark .hw-ref-word-rom,
[data-theme="dark"] .hw-ref-word-rom {
    color: #94a3b8;
}

.hw-ref-word-hanja {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ea580c;
    line-height: 1.3;
}

html.dark .hw-ref-word-hanja,
[data-theme="dark"] .hw-ref-word-hanja {
    color: #fbbf24;
}

.hw-ref-word-vi {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1d4ed8;
    line-height: 1.3;
}

html.dark .hw-ref-word-vi,
[data-theme="dark"] .hw-ref-word-vi {
    color: #60a5fa;
}

/* Row 2: Example Sentence & Thumbnail */
.hw-ref-word-ex-row {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.75rem !important;
    padding: 0.65rem 1rem !important;
    border-top: 1px solid #f1f5f9 !important;
    background: #f8fafc !important;
    box-sizing: border-box !important;
}

html.dark .hw-ref-word-ex-row,
[data-theme="dark"] .hw-ref-word-ex-row {
    border-top-color: #334155 !important;
    background: #0f172a !important;
}

.hw-ref-word-thumb {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    border-radius: 8px !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    background: #ffffff !important;
}

html.dark .hw-ref-word-thumb,
[data-theme="dark"] .hw-ref-word-thumb {
    border-color: #334155 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    background: #1e293b !important;
}

.hw-ref-word-thumb-fallback {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    border-radius: 8px !important;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    flex-shrink: 0 !important;
}

.hw-ref-word-thumb-fallback:not(.hw-hidden) {
    display: flex !important;
}

html.dark .hw-ref-word-thumb-fallback,
[data-theme="dark"] .hw-ref-word-thumb-fallback {
    background: #0f172a !important;
    border-color: #334155 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    color: #64748b !important;
}

.hw-ref-word-ex-kr {
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    line-height: 1.35 !important;
}

html.dark .hw-ref-word-ex-kr,
[data-theme="dark"] .hw-ref-word-ex-kr {
    color: #f1f5f9 !important;
}

.hw-ref-word-ex-vi {
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    color: #64748b !important;
    line-height: 1.35 !important;
}

html.dark .hw-ref-word-ex-vi,
[data-theme="dark"] .hw-ref-word-ex-vi {
    color: #94a3b8 !important;
}

/* Action Buttons (Phát âm & Menu) */
.hw-ref-item-btn {
    width: 32px !important;
    height: 32px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    border-radius: 0.5rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.82rem !important;
    color: #64748b !important;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0 !important;
}

.hw-ref-item-btn:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06) !important;
    transform: none !important;
}

html.dark .hw-ref-item-btn,
[data-theme="dark"] .hw-ref-item-btn {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    color: #94a3b8 !important;
}

html.dark .hw-ref-item-btn:hover,
[data-theme="dark"] .hw-ref-item-btn:hover {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #ffffff !important;
}

/* Modals */
.hw-ref-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.hw-ref-modal-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    max-width: 480px;
    width: 100%;
    padding: 1.25rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

html.dark .hw-ref-modal-card,
[data-theme="dark"] .hw-ref-modal-card {
    background: #0f172a;
    border-color: #334155;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hw-ref-setting-btn {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

html.dark .hw-ref-setting-btn,
[data-theme="dark"] .hw-ref-setting-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.hw-ref-setting-btn.is-active {
    background: #10b981;
    border-color: #059669;
    color: #ffffff;
}

/* Fullscreen / Zen Mode */
body.hw-zen-active {
    overflow: hidden !important;
}

.hw-ref-zen-close-btn {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    z-index: 10005;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 9999px;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.hw-ref-zen-close-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.45);
}

.hw-ref-zen-close-btn:active {
    transform: translateY(0);
}

.is-zen-mode .hw-ref-zen-close-btn {
    display: inline-flex !important;
}

.is-zen-mode {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    background: #f8fafc !important;
    max-width: 100% !important;
    height: 100vh !important;
    padding: 2.5rem 1.5rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .is-zen-mode {
        padding: 3.75rem 0.75rem 2rem 0.75rem !important;
    }
    .hw-ref-zen-close-btn {
        top: 0.625rem;
        right: 0.625rem;
        padding: 0.4rem 0.875rem;
        font-size: 0.75rem;
    }
}

html.dark .is-zen-mode,
[data-theme="dark"] .is-zen-mode {
    background: #0b1329 !important;
}

/* Print Stylesheet */
@media print {
    body * {
        visibility: hidden !important;
    }
    #hw-ref-lesson-view,
    #hw-ref-lesson-view * {
        visibility: visible !important;
    }
    #hw-ref-lesson-view {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #ffffff !important;
        border: none !important;
        padding: 0 !important;
    }
    .hw-ref-lesson-top-bar,
    .hw-ref-fc-toolbar,
    #hw-ref-study-surface,
    .hw-ref-fc-controls-bar,
    .hw-ref-modes-section,
    #hw-ref-btn-fullscreen,
    #hw-ref-btn-print,
    .hw-ref-item-btn {
        display: none !important;
    }
    #hw-ref-words-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    .hw-ref-word-item-card {
        border: 1px solid #e2e8f0 !important;
        page-break-inside: avoid;
    }
}

/* Mobile Responsive */
@media (max-width: 640px) {
    #hw-ref-lesson-view {
        padding: 0.75rem !important;
        border-radius: 1rem !important;
    }
    .hw-ref-flashcard-scene,
    .hw-ref-card-inner {
        height: 350px !important;
        min-height: 350px !important;
        max-height: 350px !important;
    }
    .hw-ref-card-face {
        padding: 1rem 0.75rem !important;
    }
    .hw-ref-card-img-wrap {
        width: 110px !important;
        height: 110px !important;
        margin-bottom: 0.35rem !important;
    }
    .hw-ref-card-kr {
        font-size: 1.85rem !important;
        min-height: 38px !important;
    }
    /* Mobile 5 segments row with center counter pill (Matching Image 5) */
    .hw-ref-fc-controls-grid {
        grid-template-columns: 46px 46px 1fr 46px 46px !important;
        gap: 6px !important;
        height: 46px !important;
        min-height: 46px !important;
        max-height: 46px !important;
    }
    .hw-ref-fc-btn {
        height: 46px !important;
        padding: 0 !important;
        font-size: 1rem !important;
    }
    .hw-ref-fc-btn .hw-btn-label {
        display: none !important;
    }
    .hw-ref-mobile-counter {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 0.625rem;
        font-weight: 700;
        font-size: 0.85rem;
        color: #0f172a;
        height: 46px;
    }
    html.dark .hw-ref-mobile-counter,
    [data-theme="dark"] .hw-ref-mobile-counter {
        background: #1e293b;
        border-color: #334155;
        color: #ffffff;
    }
}


/* ==========================================================================
   AI VOCABULARY EXPLAINER & CONTEXTUAL Q&A STYLES (FLIPVOCAB DESIGN SYSTEM)
   ========================================================================== */

.hw-ref-ai-modal-card {
    max-width: 780px !important;
    width: 95% !important;
    max-height: 88vh !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 1.25rem !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.25s ease-in-out !important;
}

html.dark .hw-ref-ai-modal-card,
[data-theme="dark"] .hw-ref-ai-modal-card {
    background: #0f172a !important;
    border-color: #334155 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

.hw-ref-ai-modal-card.is-expanded {
    max-width: 95vw !important;
    width: 95vw !important;
    max-height: 94vh !important;
}

.hw-ref-ai-hdr-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.625rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hw-ref-ai-hdr-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

html.dark .hw-ref-ai-hdr-btn,
[data-theme="dark"] .hw-ref-ai-hdr-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

html.dark .hw-ref-ai-hdr-btn:hover,
[data-theme="dark"] .hw-ref-ai-hdr-btn:hover {
    background: #334155;
    color: #ffffff;
    border-color: #475569;
}

/* HERO WORD BANNER */
.hw-ref-ai-hero-card {
    padding: 1.2rem;
    border-radius: 1rem;
    border: 2px solid #e0e7ff;
    background: linear-gradient(135deg, rgba(238, 242, 255, 0.9) 0%, rgba(245, 243, 255, 0.8) 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.06);
}

html.dark .hw-ref-ai-hero-card,
[data-theme="dark"] .hw-ref-ai-hero-card {
    border-color: #312e81;
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);
    box-shadow: none;
}

.hw-ref-ai-audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    background: #4f46e5;
    color: #ffffff;
    font-weight: 800;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
    transition: transform 0.1s ease, background 0.15s ease;
}

.hw-ref-ai-audio-btn:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.hw-ref-ai-audio-btn:active {
    transform: translateY(1px);
}

/* STRUCTURED CARDS */
.hw-ref-ai-card {
    padding: 1rem;
    border-radius: 0.875rem;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: all 0.15s ease;
}

html.dark .hw-ref-ai-card,
[data-theme="dark"] .hw-ref-ai-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: none;
}

.hw-ref-ai-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 0.8rem;
    color: #1e293b;
    margin-bottom: 0.65rem;
    letter-spacing: 0.01em;
}

html.dark .hw-ref-ai-card-title,
[data-theme="dark"] .hw-ref-ai-card-title {
    color: #f1f5f9;
}

/* QUICK QUESTION CHIPS */
.hw-ref-ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hw-ref-ai-chip:hover {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #818cf8;
    transform: translateY(-1px);
}

html.dark .hw-ref-ai-chip,
[data-theme="dark"] .hw-ref-ai-chip {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}

html.dark .hw-ref-ai-chip:hover,
[data-theme="dark"] .hw-ref-ai-chip:hover {
    background: #312e81;
    border-color: #6366f1;
    color: #e0e7ff;
}

/* POPOVER ACTION MENU (FOR CARD ⋯ BUTTON) */
.hw-ref-word-popover-menu {
    position: fixed;
    z-index: 1050;
    width: 220px;
    padding: 0.375rem;
    border-radius: 0.875rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    animation: hwRefPopoverFade 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark .hw-ref-word-popover-menu,
[data-theme="dark"] .hw-ref-word-popover-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

@keyframes hwRefPopoverFade {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.hw-ref-popover-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.625rem;
    border: none;
    background: transparent;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: all 0.12s ease;
}

.hw-ref-popover-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

html.dark .hw-ref-popover-item,
[data-theme="dark"] .hw-ref-popover-item {
    color: #e2e8f0;
}

html.dark .hw-ref-popover-item:hover,
[data-theme="dark"] .hw-ref-popover-item:hover {
    background: #334155;
    color: #ffffff;
}

.hw-ref-popover-item.is-primary {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.06);
}

.hw-ref-popover-item.is-primary:hover {
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
}

html.dark .hw-ref-popover-item.is-primary,
[data-theme="dark"] .hw-ref-popover-item.is-primary {
    color: #818cf8;
    background: rgba(99, 102, 241, 0.15);
}

html.dark .hw-ref-popover-item.is-primary:hover,
[data-theme="dark"] .hw-ref-popover-item.is-primary:hover {
    background: rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
}


/* ==========================================================================
   EPS-TOPIK MASTER 2025 (2 BOOKS · 5 TABS · LIGHT & DARK THEME SAFE)
   Zero dirty gray backgrounds, crisp WCAG AA+ contrast in Light & Dark modes
   ========================================================================== */

/* Card Progress Box & CTA Button (Light & Dark Clean Fix) */
.hw-ref-card-progress-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.hw-ref-card-progress-label { color: #475569; }
.hw-ref-card-progress-val { color: #0284c7; }
.hw-ref-card-progress-track {
    background: #e2e8f0;
    height: 6px !important;
    overflow: hidden !important;
    border-radius: 9999px !important;
}
.hw-ref-card-progress-track > div,
#hw-ref-curr-progress-bar,
#view-reference .hw-h-full.hw-bg-gradient-to-r {
    padding: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    border-radius: 9999px !important;
}

html.dark .hw-ref-card-progress-box,
[data-theme="dark"] .hw-ref-card-progress-box {
    background: rgba(15, 23, 42, 0.72);
    border-color: #334155;
}
html.dark .hw-ref-card-progress-label,
[data-theme="dark"] .hw-ref-card-progress-label { color: #94a3b8; }
html.dark .hw-ref-card-progress-val,
[data-theme="dark"] .hw-ref-card-progress-val { color: #38bdf8; }
html.dark .hw-ref-card-progress-track,
[data-theme="dark"] .hw-ref-card-progress-track { background: #020617; }

.hw-ref-card-cta-btn {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}
.hw-ref-card-cta-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}
html.dark .hw-ref-card-cta-btn,
[data-theme="dark"] .hw-ref-card-cta-btn {
    background: rgba(30, 41, 59, 0.9);
    color: #e2e8f0;
    border-color: #334155;
}
html.dark .hw-ref-card-cta-btn:hover,
[data-theme="dark"] .hw-ref-card-cta-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #6366f1;
}

/* Level 2: 5-Tab Bar Layout for EPS-TOPIK 2025 Books */
.hw-ref-book-tabs-bar.is-eps-5-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.45rem;
}
.hw-ref-book-tabs-bar.is-eps-5-tabs .hw-ref-book-tab {
    padding: 0.65rem 0.6rem;
    font-size: 0.78rem;
    gap: 0.4rem;
    justify-content: center;
    flex-wrap: wrap;
}
@media (max-width: 960px) {
    .hw-ref-book-tabs-bar.is-eps-5-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 560px) {
    .hw-ref-book-tabs-bar.is-eps-5-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Level 3: Quick Section Switcher Pill Bar */
.hw-eps-section-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.45rem;
    border-radius: 0.95rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}
html.dark .hw-eps-section-switcher,
[data-theme="dark"] .hw-eps-section-switcher {
    background: #0f172a;
    border-color: #334155;
}

.hw-eps-sec-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.7rem;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: all 0.16s ease;
}
.hw-eps-sec-pill:hover {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
}
.hw-eps-sec-pill.is-active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
html.dark .hw-eps-sec-pill,
[data-theme="dark"] .hw-eps-sec-pill {
    color: #94a3b8;
}
html.dark .hw-eps-sec-pill:hover,
[data-theme="dark"] .hw-eps-sec-pill:hover {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}
html.dark .hw-eps-sec-pill.is-active,
[data-theme="dark"] .hw-eps-sec-pill.is-active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #6366f1;
}

/* Loading & Empty states */
.hw-eps-loading,
.hw-eps-empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    border-radius: 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}
html.dark .hw-eps-loading,
html.dark .hw-eps-empty,
[data-theme="dark"] .hw-eps-loading,
[data-theme="dark"] .hw-eps-empty {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

/* Primary Content Cards (Grammar / Dialogue / Quiz) */
.hw-eps-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1.1rem;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    color: #1e293b;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}
html.dark .hw-eps-card,
[data-theme="dark"] .hw-eps-card {
    background: #0f172a;
    border-color: #334155;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    color: #e2e8f0;
}

.hw-eps-card-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}
html.dark .hw-eps-card-head,
[data-theme="dark"] .hw-eps-card-head {
    border-bottom-color: #1e293b;
}

.hw-eps-card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.35;
}
html.dark .hw-eps-card-title,
[data-theme="dark"] .hw-eps-card-title {
    color: #f8fafc;
}

.hw-eps-order-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.24rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.hw-eps-order-pill.is-purple { background: #f3e8ff; color: #7e22ce; border: 1px solid #d8b4fe; }
.hw-eps-order-pill.is-sky    { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.hw-eps-order-pill.is-teal   { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.hw-eps-order-pill.is-rose   { background: #ffe4e6; color: #be123c; border: 1px solid #fecdd3; }
.hw-eps-order-pill.is-amber  { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

html.dark .hw-eps-order-pill.is-purple, [data-theme="dark"] .hw-eps-order-pill.is-purple { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.35); }
html.dark .hw-eps-order-pill.is-sky,    [data-theme="dark"] .hw-eps-order-pill.is-sky    { background: rgba(14, 165, 233, 0.18); color: #7dd3fc; border-color: rgba(14, 165, 233, 0.35); }
html.dark .hw-eps-order-pill.is-teal,   [data-theme="dark"] .hw-eps-order-pill.is-teal   { background: rgba(20, 184, 166, 0.18); color: #5eead4; border-color: rgba(20, 184, 166, 0.35); }
html.dark .hw-eps-order-pill.is-rose,   [data-theme="dark"] .hw-eps-order-pill.is-rose   { background: rgba(244, 63, 94, 0.18); color: #fda4af; border-color: rgba(244, 63, 94, 0.35); }
html.dark .hw-eps-order-pill.is-amber,  [data-theme="dark"] .hw-eps-order-pill.is-amber  { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }

/* Clean Prose & Theme-Safe Semantic Highlights */
.hw-eps-prose {
    font-size: 0.94rem;
    line-height: 1.72;
    color: #1e293b;
    word-break: break-word;
}
.hw-eps-prose * {
    background-color: transparent;
}
.hw-eps-prose h2,
.hw-eps-prose h3,
.hw-eps-prose h4 {
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0.75rem 0 0.35rem;
}
.hw-eps-prose p,
.hw-eps-prose div {
    margin-bottom: 0.35rem;
    color: inherit;
}
.hw-eps-prose ul,
.hw-eps-prose ol {
    margin: 0.35rem 0 0.65rem 1.25rem;
    padding: 0;
    list-style: disc;
}
.hw-eps-prose li {
    margin-bottom: 0.28rem;
}
.hw-eps-prose strong,
.hw-eps-prose b {
    font-weight: 800;
    color: #0f172a;
}
.hw-eps-prose .hw-eps-hl {
    color: #dc2626 !important;
    font-weight: 700;
}
.hw-eps-prose .hw-eps-hl-blue {
    color: #2563eb !important;
    font-weight: 700;
}
.hw-eps-prose .hw-eps-hl-green {
    color: #047857 !important;
    font-weight: 700;
}
.hw-eps-prose .hw-eps-hl-pill {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    padding: 0.08rem 0.4rem;
    border-radius: 0.35rem;
    font-weight: 700;
}

html.dark .hw-eps-prose,
[data-theme="dark"] .hw-eps-prose {
    color: #e2e8f0;
}
html.dark .hw-eps-prose h2,
html.dark .hw-eps-prose h3,
html.dark .hw-eps-prose h4,
html.dark .hw-eps-prose strong,
html.dark .hw-eps-prose b,
[data-theme="dark"] .hw-eps-prose h2,
[data-theme="dark"] .hw-eps-prose h3,
[data-theme="dark"] .hw-eps-prose h4,
[data-theme="dark"] .hw-eps-prose strong,
[data-theme="dark"] .hw-eps-prose b {
    color: #f8fafc;
}
html.dark .hw-eps-prose .hw-eps-hl,
[data-theme="dark"] .hw-eps-prose .hw-eps-hl {
    color: #fb7185 !important;
}
html.dark .hw-eps-prose .hw-eps-hl-blue,
[data-theme="dark"] .hw-eps-prose .hw-eps-hl-blue {
    color: #38bdf8 !important;
}
html.dark .hw-eps-prose .hw-eps-hl-green,
[data-theme="dark"] .hw-eps-prose .hw-eps-hl-green {
    color: #34d399 !important;
}
html.dark .hw-eps-prose .hw-eps-hl-pill,
[data-theme="dark"] .hw-eps-prose .hw-eps-hl-pill {
    background-color: rgba(244, 63, 94, 0.22) !important;
    color: #fda4af !important;
}

.hw-eps-dialogue-body > div {
    padding: 0.55rem 0.8rem;
    border-radius: 0.7rem;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0;
    margin-bottom: 0.5rem;
}
html.dark .hw-eps-dialogue-body > div,
[data-theme="dark"] .hw-eps-dialogue-body > div {
    background: #1e293b !important;
    border-color: #334155;
}

.hw-eps-sub-block {
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.hw-eps-sub-block h4 {
    margin: 0 0 0.45rem;
    font-size: 0.8rem;
    font-weight: 800;
    color: #4f46e5;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
html.dark .hw-eps-sub-block,
[data-theme="dark"] .hw-eps-sub-block {
    background: #1e293b;
    border-color: #334155;
}
html.dark .hw-eps-sub-block h4,
[data-theme="dark"] .hw-eps-sub-block h4 {
    color: #818cf8;
}

/* Audio Player Box */
.hw-eps-audio-box {
    padding: 0.75rem 0.95rem;
    border-radius: 0.85rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
html.dark .hw-eps-audio-box,
[data-theme="dark"] .hw-eps-audio-box {
    background: #1e293b;
    border-color: #334155;
}
.hw-eps-audio-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.hw-eps-audio-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.hw-eps-audio-label i { color: #4f46e5; }
html.dark .hw-eps-audio-label,
[data-theme="dark"] .hw-eps-audio-label { color: #cbd5e1; }
html.dark .hw-eps-audio-label i,
[data-theme="dark"] .hw-eps-audio-label i { color: #818cf8; }

.hw-eps-speed-group {
    display: inline-flex;
    gap: 0.25rem;
}
.hw-eps-speed-btn {
    padding: 0.2rem 0.5rem;
    border-radius: 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
}
.hw-eps-speed-btn.is-active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}
html.dark .hw-eps-speed-btn,
[data-theme="dark"] .hw-eps-speed-btn {
    background: #0f172a;
    border-color: #475569;
    color: #cbd5e1;
}
html.dark .hw-eps-speed-btn.is-active,
[data-theme="dark"] .hw-eps-speed-btn.is-active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #6366f1;
}

.hw-eps-audio-el {
    width: 100%;
    height: 38px;
    border-radius: 9999px;
}

/* Images — Always White Stage so Textbook Line-Art is 100% Crisp in Dark Mode Too */
.hw-eps-img-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}
.hw-eps-img-frame {
    position: relative;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.85rem;
    padding: 0.5rem;
    cursor: zoom-in;
    max-width: 100%;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.hw-eps-img-frame:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.hw-eps-img-frame img,
.hw-eps-inline-img {
    display: block;
    max-width: 100%;
    max-height: 360px;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 0.5rem;
    object-fit: contain;
    background: #ffffff;
}
.hw-eps-img-zoom-hint {
    position: absolute;
    right: 0.65rem;
    bottom: 0.65rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    pointer-events: none;
}

/* Interactive Reading / Listening Quiz Toolbar & Options */
.hw-eps-quiz-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1.05rem;
    border-radius: 0.95rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
html.dark .hw-eps-quiz-toolbar,
[data-theme="dark"] .hw-eps-quiz-toolbar {
    background: #0f172a;
    border-color: #334155;
}
.hw-eps-quiz-score,
.hw-eps-quiz-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.hw-eps-score-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
}
.hw-eps-score-chip.is-correct {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}
html.dark .hw-eps-score-chip,
[data-theme="dark"] .hw-eps-score-chip {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}
html.dark .hw-eps-score-chip.is-correct,
[data-theme="dark"] .hw-eps-score-chip.is-correct {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.35);
}

.hw-eps-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.8rem;
    border-radius: 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
    background: #f8fafc;
    color: #334155;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    transition: all 0.15s ease;
}
.hw-eps-action-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}
html.dark .hw-eps-action-btn,
[data-theme="dark"] .hw-eps-action-btn {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}
html.dark .hw-eps-action-btn:hover,
[data-theme="dark"] .hw-eps-action-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #6366f1;
}

.hw-eps-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 700;
}
.hw-eps-status-tag.is-right { background: #dcfce7; color: #166534; }
.hw-eps-status-tag.is-wrong { background: #fee2e2; color: #991b1b; }
html.dark .hw-eps-status-tag.is-right, [data-theme="dark"] .hw-eps-status-tag.is-right { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
html.dark .hw-eps-status-tag.is-wrong, [data-theme="dark"] .hw-eps-status-tag.is-wrong { background: rgba(244, 63, 94, 0.2); color: #fda4af; }

.hw-eps-question-prompt {
    font-size: 0.98rem;
    font-weight: 600;
    padding: 0.75rem 0.95rem;
    border-radius: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
html.dark .hw-eps-question-prompt,
[data-theme="dark"] .hw-eps-question-prompt {
    background: #1e293b;
    border-color: #334155;
}

.hw-eps-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}
@media (max-width: 640px) {
    .hw-eps-options-grid {
        grid-template-columns: 1fr;
    }
}

.hw-eps-opt-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 0.8rem;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}
.hw-eps-opt-btn:hover {
    border-color: #6366f1;
    background: #eef2ff;
}
.hw-eps-opt-btn.is-correct {
    border-color: #10b981 !important;
    background: #ecfdf5 !important;
    color: #065f46 !important;
}
.hw-eps-opt-btn.is-wrong {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
}

html.dark .hw-eps-opt-btn,
[data-theme="dark"] .hw-eps-opt-btn {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
html.dark .hw-eps-opt-btn:hover,
[data-theme="dark"] .hw-eps-opt-btn:hover {
    border-color: #818cf8;
    background: #312e81;
}
html.dark .hw-eps-opt-btn.is-correct,
[data-theme="dark"] .hw-eps-opt-btn.is-correct {
    border-color: #10b981 !important;
    background: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}
html.dark .hw-eps-opt-btn.is-wrong,
[data-theme="dark"] .hw-eps-opt-btn.is-wrong {
    border-color: #f43f5e !important;
    background: rgba(244, 63, 94, 0.2) !important;
    color: #fda4af !important;
}

.hw-eps-opt-marker {
    flex-shrink: 0;
    font-weight: 800;
    font-size: 1rem;
    color: #4f46e5;
}
html.dark .hw-eps-opt-marker,
[data-theme="dark"] .hw-eps-opt-marker {
    color: #818cf8;
}
.hw-eps-opt-btn.is-correct .hw-eps-opt-marker { color: inherit; }
.hw-eps-opt-btn.is-wrong .hw-eps-opt-marker { color: inherit; }

.hw-eps-opt-img {
    max-height: 96px;
    border-radius: 0.45rem;
    background: #ffffff;
    padding: 4px;
    border: 1px solid #cbd5e1;
}

/* Explanation Toggle & Box */
.hw-eps-explain-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-top: 0.35rem;
}
.hw-eps-explain-toggle {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.76rem;
    font-weight: 700;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    cursor: pointer;
}
.hw-eps-explain-toggle:hover {
    background: #e0e7ff;
}
html.dark .hw-eps-explain-toggle,
[data-theme="dark"] .hw-eps-explain-toggle {
    background: rgba(99, 102, 241, 0.16);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.35);
}
html.dark .hw-eps-explain-toggle:hover,
[data-theme="dark"] .hw-eps-explain-toggle:hover {
    background: rgba(99, 102, 241, 0.28);
}

.hw-eps-explain-body {
    padding: 0.9rem 1.05rem;
    border-radius: 0.8rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #6366f1;
}
html.dark .hw-eps-explain-body,
[data-theme="dark"] .hw-eps-explain-body {
    background: #1e293b;
    border-color: #334155;
    border-left-color: #818cf8;
}

/* Image Lightbox Modal */
.hw-eps-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.hw-eps-lightbox.hw-hidden { display: none !important; }
.hw-eps-lightbox-box {
    position: relative;
    background: #ffffff;
    border-radius: 1rem;
    padding: 0.85rem;
    max-width: min(92vw, 900px);
    max-height: 90vh;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45);
}
.hw-eps-lightbox-box img {
    display: block;
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 0.5rem;
}
.hw-eps-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    background: #ef4444;
    color: #ffffff;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
