/* ============================================================
   HỌC XANH — Giao diện học kiểu Duolingo (mobile + desktop)
   - Thanh trạng thái (lớp · bài đã học · điểm · avatar)
     mobile: dính trên cùng nội dung; desktop: đầu cột phải
   - Banner chủ đề dính, đổi theo vị trí cuộn
   - Đường học uốn lượn, nút tròn 3D, mascot, cúp cuối chủ đề
   - Mobile: thanh điều hướng icon + bảng "Thêm"
   - Desktop: menu trái có icon màu
   ============================================================ */

.hxd-icon-fill {
    font-variation-settings: 'FILL' 1, 'wght' 600;
}

/* Phần tử chỉ dùng cho mobile */
.hx-navbar {
    display: none;
}

/* ---------- Bảng màu theo chủ đề ---------- */
.hxd-c1 { --c: #58cc02; --c-dark: #46a302; --c-light: #d7ffb8; }
.hxd-c2 { --c: #1cb0f6; --c-dark: #1899d6; --c-light: #ddf4ff; }
.hxd-c3 { --c: #ff9600; --c-dark: #e08600; --c-light: #ffebcc; }
.hxd-c4 { --c: #ce82ff; --c-dark: #a568cc; --c-light: #f4e6ff; }

/* ---------- Trang học: bỏ khối cũ ---------- */
body.page-dashboard .duo-map-header,
body.page-dashboard .dashboard-mobile-carousel-wrap,
body.page-dashboard .duo-select-container,
body.page-dashboard .duo-round-banner,
body.page-dashboard .duo-round-divider,
body.page-dashboard .duo-node-ring,
body.page-dashboard .duo-node-check,
body.page-dashboard .duo-map-node-mascot {
    display: none !important;
}

/* ---------- Thanh trạng thái ---------- */
.hxd-statbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: #fff;
}
.hxd-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 40px;
    padding: 0 6px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 900;
    color: var(--duo-dark);
    text-decoration: none;
    border-radius: 12px;
    cursor: default;
    -webkit-tap-highlight-color: transparent;
}
button.hxd-stat,
a.hxd-stat { cursor: pointer; }
button.hxd-stat:hover,
a.hxd-stat:hover,
.hxd-stat:active { background: var(--duo-gray-light); }
.hxd-stat .material-symbols-outlined { font-size: 26px; }
.hxd-grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--duo-green);
    box-shadow: 0 3px 0 var(--duo-green-border);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
}
.hxd-grade .material-symbols-outlined { font-size: 20px; color: var(--duo-gray-border); }
.hxd-done { color: var(--duo-yellow-border); }
.hxd-done .material-symbols-outlined { color: var(--duo-yellow); }
.hxd-points { color: var(--duo-green-border); }
.hxd-points .material-symbols-outlined { color: var(--duo-green); }
.hxd-avatar {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
}

/* ---------- Tab môn học ---------- */
body.page-dashboard .duo-subject-tabs {
    margin-bottom: 8px;
    padding-bottom: 6px;
}
body.page-dashboard .duo-subject-tab {
    border-radius: 999px;
}

/* ---------- Banner chủ đề dính trên cùng ---------- */
.hxd-unit {
    display: flex;
    align-items: stretch;
    position: sticky;
    top: var(--hxd-bar-h, 58px);
    z-index: 200;
    margin: 4px 0 8px;
    border-radius: 16px;
    background: var(--c, #58cc02);
    box-shadow: 0 4px 0 var(--c-dark, #46a302);
    color: #fff;
    transition: background-color .25s, box-shadow .25s;
}
.hxd-unit.hidden { display: none; }
.hxd-unit-text {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
}
.hxd-unit-label {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .6px;
    text-transform: uppercase;
    opacity: .8;
}
.hxd-unit-title {
    margin-top: 2px;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hxd-unit-guide {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-left: 2px solid rgba(0, 0, 0, .12);
    background: none;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-radius: 0 16px 16px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.hxd-unit-guide:hover,
.hxd-unit-guide:active { background: rgba(0, 0, 0, .08); }
.hxd-unit-guide .material-symbols-outlined { font-size: 28px; }
.hxd-unit-guide-text { display: none; }

/* ---------- Đường học ---------- */
body.page-dashboard .duo-map-path {
    padding: 8px 0 32px;
}
body.page-dashboard .duo-round-section {
    overflow: visible;
}
/* Luôn mở mọi chủ đề — cuộn liên tục như Duolingo */
body.page-dashboard .duo-round-section .duo-round-lessons {
    display: flex !important;
    gap: 18px;
    padding: 28px 0 20px;
    overflow: visible !important;
}
body.page-dashboard .duo-round-lessons .duo-map-node-wrapper {
    margin-left: 0 !important;
    transform: translateX(calc(var(--x, 0) * var(--hxd-amp, 74px)));
}

.hxd-unit-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 22px 0 4px;
    color: var(--duo-gray-border);
    font-size: 15px;
    font-weight: 800;
}
.hxd-unit-divider::before,
.hxd-unit-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: var(--duo-border-color);
}
.hxd-unit-divider span {
    max-width: 70%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nút tròn 3D */
body.page-dashboard .duo-map-node {
    width: 72px;
    height: 66px;
    border-radius: 50%;
    border-bottom: none !important;
    transition: transform .08s, box-shadow .08s, filter .15s;
}
body.page-dashboard .duo-map-node .duo-node-icon {
    font-size: 34px !important;
    font-variation-settings: 'FILL' 1, 'wght' 700;
}
body.page-dashboard .duo-map-node-unlocked {
    background: var(--c, var(--duo-green));
    box-shadow: 0 8px 0 var(--c-dark, var(--duo-green-border));
    color: #fff;
}
body.page-dashboard .duo-map-node-completed {
    background: var(--duo-yellow);
    box-shadow: 0 8px 0 var(--duo-yellow-border);
    color: #fff;
}
body.page-dashboard .duo-map-node-locked {
    background: #e5e5e5;
    box-shadow: 0 8px 0 #b7b7b7;
    color: #afafaf;
}
body.page-dashboard .duo-map-node-unlocked:hover,
body.page-dashboard .duo-map-node-completed:hover {
    filter: brightness(1.06);
}
body.page-dashboard .duo-map-node-unlocked:active,
body.page-dashboard .duo-map-node-completed:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 var(--c-dark, var(--duo-green-border));
}
body.page-dashboard .duo-map-node-completed:active {
    box-shadow: 0 2px 0 var(--duo-yellow-border);
}
/* Ánh sáng phía trên nút */
body.page-dashboard .duo-map-node:not(.duo-map-node-locked)::before {
    content: '';
    position: absolute;
    top: 9px;
    left: 15px;
    width: 22px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .35);
    transform: rotate(-25deg);
    pointer-events: none;
}

/* Nút hiện tại: vòng sáng + bong bóng BẮT ĐẦU */
body.page-dashboard .duo-round-lessons .hxd-current {
    margin-top: 52px;
    margin-bottom: 8px;
}
body.page-dashboard .hxd-current .duo-map-node {
    outline: 7px solid var(--duo-gray);
    outline-offset: 5px;
}
.hxd-start-bubble {
    position: absolute;
    bottom: calc(100% + 18px);
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 14px;
    border: 2px solid var(--duo-border-color);
    border-radius: 12px;
    background: #fff;
    color: var(--c, var(--duo-green));
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .5px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 6;
    animation: hxdBounce 1.1s ease-in-out infinite;
}
.hxd-start-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    background: #fff;
    border-right: 2px solid var(--duo-border-color);
    border-bottom: 2px solid var(--duo-border-color);
    transform: translateX(-50%) rotate(45deg);
}
@keyframes hxdBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

/* Cúp cuối chủ đề */
.hxd-trophy {
    width: 72px;
    height: 66px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5e5;
    box-shadow: 0 8px 0 #b7b7b7;
    color: #afafaf;
}
.hxd-trophy .material-symbols-outlined {
    font-size: 36px;
    font-variation-settings: 'FILL' 1, 'wght' 700;
}
.hxd-trophy.done {
    background: var(--duo-yellow);
    box-shadow: 0 8px 0 var(--duo-yellow-border);
    color: #fff;
}

/* Rương cuối chủ đề */
.hxd-chest {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 86px;
    height: 86px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.hxd-chest img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: grayscale(1) opacity(.45);
    transition: transform .15s;
}
.hxd-chest.done img {
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .08));
    animation: hxdChestGlow 2s ease-in-out infinite alternate;
}
.hxd-chest:active img { transform: scale(.94); }
@keyframes hxdChestGlow {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

/* Nhân vật đứng cạnh đường đi */
.hxd-mascot {
    position: absolute;
    top: 50%;
    width: 130px;
    pointer-events: none;
    z-index: 1;
    transform: translateY(-35%);
}
.hxd-mascot img {
    display: block;
    width: 100%;
    height: auto;
    animation: floatMascot 2.4s ease-in-out infinite alternate;
}

/* Icon minh hoạ cho menu */
.duo-nav-icon-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}
.hx-nav-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}
.hx-sheet-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

/* Thẻ nhiệm vụ hôm nay */
.hxd-card-head h3 {
    margin-bottom: 6px;
    font-size: 18px;
    font-weight: 900;
    color: var(--duo-dark);
}
.hxd-quest {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
}
.hxd-quest + .hxd-quest { border-top: 2px solid var(--duo-border-color); }
.hxd-quest > img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
}
.hxd-quest-body { flex: 1; min-width: 0; }
.hxd-quest-name {
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 800;
    color: var(--duo-dark);
}
.hxd-quest-bar {
    position: relative;
    height: 18px;
    border-radius: 999px;
    background: var(--duo-gray);
    overflow: hidden;
}
.hxd-quest-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 999px;
    background: var(--duo-yellow);
    transition: width .4s ease;
}
.hxd-quest.done .hxd-quest-bar span { background: var(--duo-green); }
.hxd-quest-bar em {
    position: relative;
    display: block;
    text-align: center;
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
    line-height: 18px;
    color: var(--duo-dark-muted);
}
.hxd-quest.done .hxd-quest-bar em { color: #fff; }
.hxd-mascot.left { right: calc(50% + 46px); }
.hxd-mascot.right { left: calc(50% + 46px); }
.hxd-mascot.dim img {
    filter: grayscale(1);
    opacity: .35;
    animation: none;
}

/* Popup bài học — hiện bên dưới nút, màu theo chủ đề */
body.page-dashboard .duo-node-tooltip {
    top: calc(100% + 16px);
    bottom: auto;
    width: min(300px, calc(100vw - 32px));
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: var(--c, var(--duo-green));
    color: #fff;
    text-align: left;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
    transform: translateX(calc(-50% + var(--tt-shift, 0px))) scale(.92);
    transform-origin: top center;
}
body.page-dashboard .duo-node-tooltip.show {
    transform: translateX(calc(-50% + var(--tt-shift, 0px))) scale(1);
}
body.page-dashboard .duo-node-tooltip::before {
    display: none;
}
body.page-dashboard .duo-node-tooltip::after {
    top: auto;
    bottom: 100%;
    left: calc(50% - var(--tt-shift, 0px));
    border-color: transparent transparent var(--c, var(--duo-green)) transparent;
}
body.page-dashboard .duo-tooltip-title {
    color: #fff;
    font-size: 17px;
    font-weight: 900;
}
body.page-dashboard .duo-tooltip-sub {
    color: rgba(255, 255, 255, .9);
    font-weight: 700;
    margin-bottom: 14px;
}
.duo-tooltip-step {
    margin: 2px 0 6px;
    font-size: 13px;
    font-weight: 800;
    opacity: .85;
}
body.page-dashboard .duo-node-tooltip .duo-btn {
    background: #fff !important;
    color: var(--c, var(--duo-green)) !important;
    border-color: #fff !important;
    box-shadow: 0 4px 0 rgba(0, 0, 0, .15) !important;
    text-transform: uppercase;
    font-weight: 900;
}

/* ---------- Bottom sheet (mobile) / popup giữa màn hình (desktop) ---------- */
.hx-sheet {
    position: fixed;
    inset: 0;
    z-index: 6000;
    visibility: hidden;
    pointer-events: none;
}
.hx-sheet.show {
    visibility: visible;
    pointer-events: auto;
}
.hx-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .2s;
}
.hx-sheet.show .hx-sheet-backdrop { opacity: 1; }
.hx-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    overflow-y: auto;
    padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
    background: #fff;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform .25s ease;
}
.hx-sheet.show .hx-sheet-panel { transform: translateY(0); }
.hx-sheet-grip {
    width: 44px;
    height: 5px;
    margin: 0 auto 12px;
    border-radius: 3px;
    background: var(--duo-border-color);
}
.hx-sheet-title {
    margin-bottom: 14px;
    font-size: 18px;
    font-weight: 900;
    color: var(--duo-dark);
}
.hx-sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.hx-sheet-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 84px;
    padding: 10px 6px;
    border: 2px solid var(--duo-border-color);
    border-bottom-width: 4px;
    border-radius: 16px;
    background: #fff;
    color: var(--duo-dark);
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.hx-sheet-tile:hover { background: var(--duo-gray-light); }
.hx-sheet-tile:active { transform: translateY(2px); border-bottom-width: 2px; }
.hx-sheet-tile .material-symbols-outlined {
    font-size: 30px;
    font-variation-settings: 'FILL' 1, 'wght' 600;
}
.hx-sheet-tile.active,
.hx-sheet-tile.selected {
    border-color: var(--duo-blue);
    background: var(--duo-blue-light);
    color: var(--duo-blue-border);
}
.hx-sheet-tile.hidden { display: none; }
.hx-sheet-tile .hx-grade-num {
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}
.hx-sheet-tile small {
    font-size: 11px;
    font-weight: 700;
    color: var(--duo-dark-muted);
}

/* Danh sách bài trong chủ đề (nút sách trên banner) */
.hxd-guide-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hxd-guide-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 2px solid var(--duo-border-color);
    border-radius: 14px;
    background: #fff;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.hxd-guide-row:not(:disabled):hover { background: var(--duo-gray-light); }
.hxd-guide-row:disabled { cursor: default; opacity: .6; }
.hxd-guide-dot {
    flex: 0 0 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c, var(--duo-green));
    color: #fff;
}
.hxd-guide-dot.done { background: var(--duo-yellow); }
.hxd-guide-dot.locked { background: #e5e5e5; color: #afafaf; }
.hxd-guide-dot .material-symbols-outlined {
    font-size: 24px;
    font-variation-settings: 'FILL' 1, 'wght' 700;
}
.hxd-guide-name {
    font-size: 15px;
    font-weight: 900;
    color: var(--duo-dark);
}
.hxd-guide-desc {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--duo-dark-muted);
}

/* ============================================================
   DESKTOP (≥769px)
   ============================================================ */
@media (min-width: 769px) {
    /* Menu trái: icon màu, logo gọn */
    .duo-sidebar .duo-logo {
        padding: 0 12px;
        margin-bottom: 24px;
        gap: 8px;
    }
    .duo-sidebar .duo-logo-img {
        width: 48px;
        height: 48px;
    }
    .duo-sidebar .duo-logo-text {
        font-size: 28px;
        text-transform: none;
        letter-spacing: -0.8px;
    }
    .duo-sidebar .duo-nav-list { gap: 4px; }
    .duo-sidebar .duo-nav-item a {
        gap: 18px;
        padding: 9px 14px;
        letter-spacing: .6px;
    }
    .duo-sidebar .duo-nav-icon {
        width: 32px;
        font-size: 30px;
        text-align: center;
        font-variation-settings: 'FILL' 1, 'wght' 600;
    }

    /* Trang học: thanh trạng thái ở đầu cột phải, cột phải dính khi cuộn */
    body.page-dashboard .duo-stats-col {
        position: sticky;
        top: 0;
        align-self: flex-start;
        max-height: 100vh;
        overflow-y: auto;
        scrollbar-width: none;
        gap: 16px;
    }
    body.page-dashboard .duo-stats-col::-webkit-scrollbar { display: none; }
    body.page-dashboard .duo-stats-col .hxd-statbar {
        margin-bottom: -4px;
    }
    body.page-dashboard .duo-stats-col .duo-card {
        border-radius: 16px;
        margin-bottom: 0;
    }
    body.page-dashboard .duo-content-col {
        max-width: 640px;
        padding-top: 16px;
    }
    body.page-dashboard .hxd-unit {
        top: 16px;
        margin-top: 8px;
    }
    body.page-dashboard .hxd-unit-title { font-size: 20px; }
    body.page-dashboard .hxd-unit-guide {
        flex-basis: auto;
        padding: 0 20px;
    }
    body.page-dashboard .hxd-unit-guide-text { display: inline; }
    body.page-dashboard { --hxd-amp: 88px; }
    .hxd-mascot { width: 170px; }
    .hxd-mascot.left { right: calc(50% + 70px); }
    .hxd-mascot.right { left: calc(50% + 70px); }
    body.page-dashboard .duo-map-node,
    .hxd-trophy {
        width: 78px;
        height: 70px;
    }

    /* Popup giữa màn hình thay cho bottom sheet */
    .hx-sheet-panel {
        top: 50%;
        bottom: auto;
        left: 50%;
        right: auto;
        width: min(520px, calc(100vw - 48px));
        padding: 24px;
        border-radius: 20px;
        opacity: 0;
        transform: translate(-50%, -46%);
        transition: transform .2s ease, opacity .2s ease;
    }
    .hx-sheet.show .hx-sheet-panel {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    .hx-sheet-grip { display: none; }
    .hx-sheet-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   MOBILE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    body.app-shell.page-dashboard {
        background: #fff;
    }
    body.app-shell.page-dashboard .hx-topbar {
        display: none !important;
    }
    body.app-shell.page-dashboard .duo-content-col {
        padding-top: 0 !important;
    }

    .hxd-statbar {
        position: sticky;
        top: 0;
        z-index: 210;
        margin: 0 -12px;
        padding: 8px 16px;
        padding-top: calc(8px + env(safe-area-inset-top));
        border-bottom: 2px solid var(--duo-border-color);
    }

    body.app-shell.page-dashboard .duo-subject-tabs {
        margin-top: 10px;
    }
    body.app-shell.page-dashboard .duo-subject-tab {
        padding: 8px 14px !important;
    }

    /* Thanh điều hướng dưới (icon) */
    body.app-shell .hx-tabbar {
        display: none !important;
    }
    body.app-shell .hx-navbar {
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        padding: 6px 4px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 2px solid var(--duo-border-color);
    }
    .hx-nav-item {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 48px;
        border: 2px solid transparent;
        border-radius: 14px;
        background: none;
        padding: 0;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .hx-nav-item .material-symbols-outlined {
        font-size: 32px;
        font-variation-settings: 'FILL' 1, 'wght' 600;
    }
    .hx-nav-item.active {
        border-color: #84d8ff;
        background: var(--duo-blue-light);
    }
    .hx-nav-item:active { transform: scale(.94); }
    #hxn-learn .material-symbols-outlined { color: #ff9600; }
    #hxn-study .material-symbols-outlined { color: #1cb0f6; }
    #hxn-recycle .material-symbols-outlined { color: #58cc02; }
    #hxn-leaderboard .material-symbols-outlined { color: #ffc800; }
    #hxn-aitutor .material-symbols-outlined { color: #ce82ff; }
    #hxn-more .material-symbols-outlined { color: #ff4b4b; }

    body.immersive-open .hx-navbar,
    body.keyboard-open .hx-navbar {
        display: none !important;
    }

    /* Nút gia sư nổi: nằm trên thanh điều hướng mới */
    body.app-shell #floating-tutor-btn {
        bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 380px) {
    body.app-shell.page-dashboard { --hxd-amp: 58px; }
    .hxd-stat { font-size: 14px; padding: 0 4px; }
    .hxd-stat .material-symbols-outlined { font-size: 22px; }
    .hxd-mascot { width: 104px; }
    .hxd-mascot.left { right: calc(50% + 40px); }
    .hxd-mascot.right { left: calc(50% + 40px); }
    .hx-nav-item { width: 46px; }
    .hx-nav-item .material-symbols-outlined { font-size: 28px; }
}

/* ============================================================
   MÀN LÀM BÀI — kiểu Duolingo
   ============================================================ */
#lesson-player .duo-player-header {
    max-width: 1040px;
    padding: 20px 24px 8px;
    gap: 18px;
}
#lesson-player .duo-player-close {
    font-size: 34px;
    line-height: 1;
    color: #afafaf;
}
#lesson-player .duo-progress-container {
    height: 16px;
    border-radius: 999px;
    background: #e5e5e5;
}
#lesson-player .duo-progress-bar {
    border-radius: 999px;
    background: var(--duo-green);
    min-width: 16px;
}
#lesson-player .duo-progress-bar::after {
    top: 4px;
    left: 10px;
    right: 10px;
    height: 4px;
    background: rgba(255, 255, 255, .35);
}
#lesson-player .duo-stat-hearts {
    background: none;
    border: none;
    padding: 0;
    color: var(--duo-pink);
    font-size: 18px;
    font-weight: 900;
}
#lesson-player .duo-stat-hearts .material-symbols-outlined {
    font-size: 28px !important;
    font-variation-settings: 'FILL' 1, 'wght' 600;
}

#lesson-player .duo-player-body {
    max-width: 640px;
    padding: 12px 20px 140px;
    justify-content: center;
}
.hxd-q-title {
    margin: 0 0 20px;
    font-size: 28px;
    font-weight: 900;
    line-height: 1.2;
    color: var(--duo-dark);
}
.hxd-q-title[hidden] { display: none; }

/* Nhân vật + bong bóng thoại */
#lesson-player .duo-mascot-row {
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 26px;
}
#lesson-player .duo-mascot-avatar {
    width: 118px;
    height: auto;
    flex-shrink: 0;
    border: none;
    border-radius: 0;
    background: none;
}
#lesson-player .duo-mascot-avatar img {
    width: 100%;
    height: auto;
    display: block;
}
#lesson-player .duo-bubble {
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 18px;
    line-height: 1.45;
}
#lesson-player .duo-bubble::before,
#lesson-player .duo-bubble::after {
    top: auto;
    bottom: 18px;
}
#lesson-player .duo-bubble::before { bottom: 16px; }

/* Thẻ đáp án */
#lesson-player .duo-choices-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 0;
}
#lesson-player .duo-choice-card {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 17px;
    line-height: 1.35;
    transition: background-color .1s, border-color .1s, transform .05s;
}
#lesson-player .duo-choice-key {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 2px solid #e5e5e5;
    border-radius: 9px;
    font-size: 14px;
    color: #afafaf;
}
#lesson-player .duo-choice-card.selected {
    border-color: #84d8ff;
    border-bottom-color: #84d8ff;
    background: #ddf4ff;
    color: #1899d6;
}
#lesson-player .duo-choice-card.selected .duo-choice-key {
    border-color: #84d8ff;
    color: #1899d6;
}

/* Thanh nút dưới */
#lesson-player .duo-player-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 22px 24px calc(22px + env(safe-area-inset-bottom));
}
#lesson-player .duo-footer-inner {
    max-width: 1000px;
}
#lesson-player .duo-player-footer .duo-btn,
#lesson-player .duo-feedback-btn-next {
    min-width: 150px;
    height: 50px;
    padding: 0 26px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: .6px;
    text-transform: uppercase;
}
#lesson-player #player-skip-btn {
    background: #fff;
    color: #afafaf;
    border: 2px solid #e5e5e5;
    box-shadow: 0 4px 0 #e5e5e5;
}
#lesson-player #player-action-btn {
    margin-left: auto;
    background: var(--duo-green);
    color: #fff;
    border: none;
    box-shadow: 0 4px 0 var(--duo-green-border);
}
#lesson-player #player-action-btn:disabled {
    background: #e5e5e5;
    color: #afafaf;
    box-shadow: none;
    cursor: default;
}
#lesson-player .duo-player-footer .duo-btn:not(:disabled):active,
#lesson-player .duo-feedback-btn-next:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Thanh báo đúng / sai: nền nhạt, chữ đậm, icon tròn */
#lesson-player .duo-feedback-panel {
    border-top: none;
}
#lesson-player .duo-feedback-bar {
    max-width: 1000px;
    min-height: 0;
    padding: 22px 24px calc(22px + env(safe-area-inset-bottom));
    gap: 20px;
}
#lesson-player .duo-feedback-correct { background: #d7ffb8; color: #58a700; }
#lesson-player .duo-feedback-wrong { background: #ffdfe0; color: #ea2b2b; }
#lesson-player .duo-feedback-status-icon {
    width: 72px;
    height: 72px;
    background: #fff;
}
#lesson-player .duo-feedback-correct .duo-feedback-status-icon { color: #58cc02; }
#lesson-player .duo-feedback-wrong .duo-feedback-status-icon { color: #ff4b4b; }
#lesson-player .duo-feedback-status-icon .material-symbols-outlined {
    font-size: 48px;
    font-variation-settings: 'wght' 700;
}
#lesson-player .duo-feedback-title {
    font-size: 24px;
    font-weight: 900;
}
#lesson-player .duo-feedback-desc {
    margin-top: 6px;
    font-size: 15px;
    font-weight: 700;
    opacity: 1;
    -webkit-line-clamp: 3;
}
#lesson-player .duo-feedback-correct .duo-feedback-btn-next {
    background: var(--duo-green);
    color: #fff;
    box-shadow: 0 4px 0 var(--duo-green-border);
}
#lesson-player .duo-feedback-wrong .duo-feedback-btn-next {
    background: var(--duo-pink);
    color: #fff;
    box-shadow: 0 4px 0 var(--duo-pink-border);
}
#lesson-player .duo-feedback-wrong .duo-feedback-btn-tutor {
    height: 50px;
    padding: 0 18px;
    border-radius: 16px;
    background: #fff;
    color: #ea2b2b;
    border: 2px solid #ffc1c1;
    box-shadow: 0 4px 0 #ffc1c1;
    font-size: 14px;
    font-weight: 900;
}

/* Nút gia sư nổi: nằm trên thanh nút dưới */
#lesson-player #floating-tutor-btn {
    bottom: calc(112px + env(safe-area-inset-bottom)) !important;
}

/* Đáp án sau khi chấm: ô chữ cái theo màu của thẻ */
#lesson-player .duo-choice-card.hxd-marked .duo-choice-key {
    border-color: currentColor;
    color: inherit;
}

/* Màn hoàn thành */
#lesson-player.hxd-done .duo-mascot-row,
#lesson-player.hxd-done #floating-tutor-btn { display: none !important; }
.hxd-victory {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    grid-column: 1 / -1;
    padding-top: 8px;
}
.hxd-victory-img {
    width: min(260px, 60vw);
    height: auto;
    animation: floatMascot 1.6s ease-in-out infinite alternate;
}
.hxd-victory-title {
    margin: 18px 0 4px;
    font-size: 32px;
    font-weight: 900;
    color: #ffc800;
}
.hxd-victory-sub {
    margin: 0 0 24px;
    font-size: 16px;
    font-weight: 700;
    color: var(--duo-dark-muted);
}
.hxd-victory-stats {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 480px;
}
.hxd-vstat {
    flex: 1;
    overflow: hidden;
    border: 2px solid var(--vs);
    border-radius: 16px;
    background: var(--vs);
}
.hxd-vstat-points { --vs: #ffc800; }
.hxd-vstat-acc { --vs: #58cc02; }
.hxd-vstat-time { --vs: #1cb0f6; }
.hxd-vstat-label {
    padding: 6px 4px 5px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #fff;
}
.hxd-vstat-val {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 6px;
    border-radius: 14px;
    background: #fff;
    font-size: 20px;
    font-weight: 900;
    color: var(--vs);
}
.hxd-vstat-val img { width: 26px; height: 26px; }

@media (min-width: 769px) {
    #lesson-player .duo-choices-grid { grid-template-columns: 1fr 1fr; }
    #lesson-player .duo-mascot-avatar { width: 150px; }
}

@media (max-width: 768px) {
    #lesson-player .duo-player-header { padding: 14px 16px 6px; gap: 12px; }
    #lesson-player .duo-player-body { padding: 8px 16px 120px; justify-content: flex-start; }
    .hxd-q-title { font-size: 22px; margin-bottom: 14px; }
    #lesson-player .duo-mascot-avatar { width: 92px; }
    #lesson-player .hxd-q-title { padding-right: 56px; }
    #lesson-player #floating-tutor-btn {
        top: calc(var(--hx-safe-top, 0px) + 64px) !important;
        bottom: auto !important;
        right: 16px !important;
        width: 44px !important;
        height: 44px !important;
    }
    .hxd-victory-img { width: min(200px, 52vw); }
    #lesson-player .duo-bubble { font-size: 16px; padding: 12px 14px; }
    #lesson-player .duo-choices-grid { grid-template-columns: 1fr !important; }
    #lesson-player .duo-choice-card { font-size: 16px; padding: 12px 14px; }
    #lesson-player .duo-player-footer { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
    #lesson-player #player-skip-btn { display: none !important; }
    #lesson-player #player-action-btn { width: 100%; }
    #lesson-player .duo-feedback-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    }
    #lesson-player .duo-feedback-status-icon { width: 44px; height: 44px; }
    #lesson-player .duo-feedback-status-icon .material-symbols-outlined { font-size: 30px; }
    #lesson-player .duo-feedback-title { font-size: 20px; }
    #lesson-player .duo-feedback-trail { width: 100%; }
    #lesson-player .duo-feedback-btn-next { flex: 1; }
    .hxd-victory-title { font-size: 26px; }
    .hxd-vstat-val { font-size: 17px; padding: 12px 4px; }
}

/* ============================================================
   CÁC TRANG CON — bộ style chung kiểu Duolingo
   (banner có hình minh hoạ, thẻ bo tròn, thanh trạng thái cột phải)
   ============================================================ */
body.app-shell:not(.page-dashboard) .duo-map-header {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    min-height: 128px;
    padding: 22px 168px 22px 26px !important;
    border-radius: 18px !important;
}
body.app-shell:not(.page-dashboard) .duo-map-header h1 {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: .3px;
}
body.app-shell:not(.page-dashboard) .duo-map-header h1 .material-symbols-outlined {
    display: none;
}
body.app-shell:not(.page-dashboard) .duo-map-header p {
    font-size: 15px;
    line-height: 1.5;
}
body.app-shell:not(.page-dashboard) .duo-map-header::after {
    content: '';
    position: absolute;
    right: 22px;
    top: 50%;
    width: 128px;
    height: 112px;
    transform: translateY(-50%);
    background: var(--hx-hero, none) center / contain no-repeat;
    filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .12));
    pointer-events: none;
}
body[data-page="recycle"]     { --hx-hero: url('/static/img/hx/char-recycle.png'); }
body[data-page="stations"]    { --hx-hero: url('/static/img/hx/hero-stations.png'); }
body[data-page="shop"]        { --hx-hero: url('/static/img/hx/hero-shop.png'); }
body[data-page="nutrition"]   { --hx-hero: url('/static/img/hx/char-bike.png'); }
body[data-page="focus"]       { --hx-hero: url('/static/img/hx/hero-focus.png'); }
body[data-page="hoc-tap"]     { --hx-hero: url('/static/img/hx/hero-study.png'); }
body[data-page="history"]     { --hx-hero: url('/static/img/hx/hero-history.png'); }
body[data-page="users"]       { --hx-hero: url('/static/img/hx/hero-admin.png'); }
body[data-page="quy"]         { --hx-hero: url('/static/img/hx/hero-fund.png'); }
body[data-page="aitutor"]     { --hx-hero: url('/static/img/hx/char-robot.png'); }
/* Ảnh quầy hàng dáng cao → thu nhỏ để không chạm mép banner */
body[data-page="shop"].app-shell .duo-map-header::after { height: 88px; }
/* Dinh dưỡng: hình nhỏ hơn để tiêu đề dài nằm trên một dòng */
body[data-page="nutrition"].app-shell .duo-map-header { padding-right: 104px !important; }
body[data-page="nutrition"].app-shell .duo-map-header::after { width: 80px; height: 80px; right: 16px; }
@media (min-width: 769px) {
    body[data-page="nutrition"].app-shell .duo-map-header h1 {
        font-size: 20px;
        white-space: nowrap;
    }
}
/* Xếp hạng: không có hình minh hoạ, tiêu đề nằm giữa */
body[data-page="leaderboard"].app-shell .duo-map-header,
body[data-page="profile"].app-shell .duo-map-header { padding: 22px 26px !important; }
body[data-page="leaderboard"].app-shell .duo-map-header::after,
body[data-page="profile"].app-shell .duo-map-header::after { display: none; }

/* Thẻ: viền 2px, bo 16, không đổ bóng mờ */
body.app-shell:not(.page-dashboard) .duo-card {
    border-radius: 16px;
    box-shadow: none;
}
body.app-shell:not(.page-dashboard) .duo-card-interactive:hover {
    background: var(--duo-gray-light);
}

/* Trang chat Lynco: avatar tròn, bong bóng giống khung chat trong bài học */
.duo-chat-msg .duo-chat-avatar {
    width: 44px !important;
    height: 44px !important;
    padding: 3px;
    border: none !important;
    border-radius: 50% !important;
    background: none !important;
    overflow: hidden;
}
.duo-chat-msg.bot .duo-chat-avatar { background: var(--duo-blue-light) !important; }
.duo-chat-msg .duo-chat-text {
    border-radius: 18px !important;
    font-weight: 700;
}
.duo-chat-msg.bot .duo-chat-text {
    border: 2px solid var(--duo-border-color) !important;
    border-bottom-left-radius: 6px !important;
    background: #fff !important;
}
.duo-chat-msg.user .duo-chat-text {
    border: none !important;
    border-bottom-right-radius: 6px !important;
    background: var(--duo-blue) !important;
    color: #fff !important;
}

/* Thanh trạng thái đầu cột phải (desktop) */
.hx-page-statbar .hx-stat-collect,
.hx-page-statbar .hx-stat-rank {
    color: var(--duo-dark);
}
.hx-page-statbar .hx-stat-collect { color: #46a302; }
.hx-page-statbar .hx-stat-rank { color: #e6a700; font-size: 14px; }
.hx-page-statbar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

@media (min-width: 769px) {
    body.app-shell:not(.page-dashboard) .duo-stats-col {
        position: sticky;
        top: 0;
        align-self: flex-start;
        max-height: 100vh;
        overflow-y: auto;
        scrollbar-width: none;
    }
    body.app-shell:not(.page-dashboard) .duo-stats-col::-webkit-scrollbar { display: none; }
    .hx-page-statbar { margin-bottom: -4px; }
}

@media (max-width: 768px) {
    .hx-page-statbar { display: none !important; }
    body.app-shell:not(.page-dashboard) .duo-map-header {
        min-height: 104px;
        margin-bottom: 14px !important;
        padding: 16px 112px 16px 18px !important;
    }
    /* Banner luôn ở đầu trang: nội dung chính trước, cột phụ sau */
    body.app-shell.page-aside-first .duo-stats-col {
        order: 1 !important;
        padding-top: 0 !important;
    }
    /* Mọi trang có cột phụ hiện trên mobile: nội dung chính không chiếm cả màn hình
       → cột phụ nằm ngay bên dưới, không bị đẩy xuống đáy */
    body.app-shell:not(.page-dashboard):not(.page-shop) .duo-main-container:has(> .duo-stats-col) .duo-content-col {
        flex: 0 0 auto !important; /* trang ngắn hơn màn hình: không giãn chen khoảng trống vào giữa */
        min-height: 0 !important;
        padding-bottom: 4px !important;
    }
    body.app-shell:not(.page-dashboard):not(.page-shop) .duo-main-container > .duo-stats-col {
        padding-top: 0 !important;
        padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    }
    /* Thanh trên cùng: lá + số điểm kiểu Duolingo */
    body.app-shell .hx-topbar-points {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 8px;
        border: none;
        background: none;
        color: var(--duo-green-border);
        font-size: 17px;
    }
    body.app-shell .hx-topbar-points .material-symbols-outlined {
        font-size: 24px;
        color: var(--duo-green);
    }
    body.app-shell .hx-topbar-logo {
        width: 38px;
        height: 38px;
    }
    body.app-shell:not(.page-dashboard) .duo-map-header h1 { font-size: 19px !important; }
    body.app-shell:not(.page-dashboard) .duo-map-header p { font-size: 13px !important; }
    body.app-shell:not(.page-dashboard) .duo-map-header::after {
        right: 12px;
        width: 92px;
        height: 84px;
    }
    body[data-page="shop"].app-shell .duo-map-header::after { height: 68px; }
    body[data-page="leaderboard"].app-shell .duo-map-header,
    body[data-page="profile"].app-shell .duo-map-header { padding: 16px 18px !important; }
}

/* ============================================================
   HỒ SƠ — huy hiệu hạng (kiểu mục Thành tích)
   ============================================================ */
.hx-rank-badge-list { gap: 0 !important; }
.hx-rank-badge-row {
    gap: 14px !important;
    padding: 12px 0;
}
.hx-rank-badge-row + .hx-rank-badge-row { border-top: 2px solid var(--duo-border-color); }
.hx-rank-badge-row.current {
    margin: 0 -12px;
    padding: 12px;
    border-radius: 16px;
    border-top-color: transparent !important;
    background: var(--duo-green-light);
}
.hx-rank-badge-row.current + .hx-rank-badge-row { border-top-color: transparent; }
.hx-rank-badge-icon {
    position: relative;
    width: 64px !important;
    height: 64px !important;
}
.hx-rank-badge-icon img {
    width: 64px !important;
    height: 64px !important;
    filter: none !important;
}
.hx-rank-badge-row.locked .hx-rank-badge-icon img { filter: grayscale(1) opacity(.35) !important; }
.hx-rank-check {
    position: absolute;
    right: -2px;
    bottom: 0;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--duo-green);
    color: #fff;
    font-size: 15px !important;
    line-height: 18px;
    text-align: center;
    font-variation-settings: 'wght' 700;
}
.hx-rank-badge-text { flex: 1; min-width: 0; }
.hx-rank-badge-name {
    font-size: 15px !important;
    font-weight: 900 !important;
}
.hx-rank-badge-row.locked .hx-rank-badge-name { color: #afafaf; }
.hx-rank-badge-desc { font-size: 12px !important; font-weight: 700; }
.hx-rank-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--duo-green);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .3px;
    text-transform: uppercase;
    vertical-align: middle;
}
.hx-rank-progress {
    position: relative;
    height: 16px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--duo-gray);
    overflow: hidden;
}
.hx-rank-progress span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: var(--duo-yellow);
}
.hx-rank-progress em {
    position: relative;
    display: block;
    text-align: center;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    line-height: 16px;
    color: var(--duo-dark-muted);
}

/* ============================================================
   TẬP TRUNG — cây / thỏ 3D có chuyển động
   ============================================================ */
@keyframes hxSway {
    from { transform: rotate(-2.5deg); }
    to { transform: rotate(2.5deg); }
}
@keyframes hxHop {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    30% { transform: translateY(0) scale(1.06, .94); }
    55% { transform: translateY(-10px) scale(.97, 1.04); }
    75% { transform: translateY(0) scale(1.04, .96); }
}
@keyframes hxBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.035); }
}
@keyframes hxPop {
    0% { transform: scale(.55); opacity: .4; }
    60% { transform: scale(1.14); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes hxSpark {
    0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.1) rotate(45deg); }
}
@keyframes hxWobble {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-4deg); }
    75% { transform: rotate(4deg); }
}

.hx-sway { transform-origin: 50% 92%; animation: hxSway 2.6s ease-in-out infinite alternate; }
.hx-hop { transform-origin: 50% 95%; animation: hxHop 1.8s ease-in-out infinite; }

/* Thẻ chọn chế độ: chỉ chuyển động khi được chọn / rê chuột */
.focus-mode-img {
    display: block;
    width: 112px;
    height: 112px;
    margin: 0 auto 6px;
    object-fit: contain;
    animation-play-state: paused;
}
.focus-mode-card.selected .focus-mode-img,
.focus-mode-card:hover .focus-mode-img { animation-play-state: running; }
.focus-mode-card:not(.selected) .focus-mode-img { filter: saturate(.85); }

/* Khung "đang lớn" */
.focus-live {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
}
.focus-live-stage-wrap {
    position: relative;
    width: 200px;
    height: 200px;
}
.focus-live-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: 50% 90%;
    animation: hxBreathe 3s ease-in-out infinite;
}
.focus-live-img.hx-pop { animation: hxPop .7s cubic-bezier(.34, 1.56, .64, 1), hxBreathe 3s ease-in-out .7s infinite; }
.focus-live-spark {
    position: absolute;
    color: #ffc800;
    font-size: 22px;
    opacity: 0;
    pointer-events: none;
    animation: hxSpark 2.4s ease-in-out infinite;
}
.focus-live-spark.s1 { top: 18%; left: 8%; }
.focus-live-spark.s2 { top: 6%; right: 14%; animation-delay: .8s; font-size: 16px; }
.focus-live-spark.s3 { top: 46%; right: 2%; animation-delay: 1.6s; }
.focus-live-img.hx-pop ~ .focus-live-spark { animation-duration: .8s; animation-iteration-count: 2; font-size: 28px; }
.focus-live.is-paused .focus-live-img { filter: grayscale(.7); animation: none; }
.focus-live.is-paused .focus-live-spark { display: none; }
.focus-live-timer {
    margin-top: 4px;
    font-size: 38px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--duo-dark);
}
.focus-live-stage {
    font-size: 13px;
    font-weight: 800;
    color: var(--duo-green-border);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.focus-live-track {
    width: min(260px, 80%);
    height: 14px;
    margin-top: 10px;
    border-radius: 999px;
    background: var(--duo-gray);
    overflow: hidden;
}
.focus-live-track span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--duo-green);
    transition: width 1s linear;
}

/* Ô hẹn giờ nổi */
#focus-widget-emoji img {
    display: block;
    width: 46px;
    height: 46px;
    object-fit: contain;
    transform-origin: 50% 90%;
    animation: hxBreathe 3s ease-in-out infinite;
}
#focus-widget-emoji img.hx-pop { animation: hxPop .7s cubic-bezier(.34, 1.56, .64, 1); }
#focus-widget-emoji.is-paused img { filter: grayscale(.8); animation: none; }

/* Vườn của bé */
.focus-garden-item {
    background: #fff !important;
    border-color: var(--duo-border-color) !important;
}
.focus-garden-img {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto;
    object-fit: contain;
}

/* Cảnh báo rời app */
.focus-grace-img {
    display: block;
    width: 130px;
    height: 130px;
    margin: 0 auto 6px;
    object-fit: contain;
    animation: hxWobble 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .hx-sway, .hx-hop, .focus-live-img, .focus-live-spark,
    #focus-widget-emoji img, .focus-grace-img { animation: none !important; }
}

/* ============================================================
   GIA ĐÌNH NHIỀU HỒ SƠ
   ============================================================ */
/* Đăng ký: chọn Phụ huynh / Học sinh */
.hx-acct-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.hx-acct-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 2px solid var(--duo-border-color);
    border-bottom-width: 4px;
    border-radius: 16px;
    background: #fff;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
}
.hx-acct-opt img { width: 52px; height: 52px; object-fit: contain; }
.hx-acct-opt b { font-size: 15px; font-weight: 900; color: var(--duo-dark); }
.hx-acct-opt span { font-size: 11px; font-weight: 700; color: var(--duo-dark-muted); line-height: 1.35; }
.hx-acct-opt.selected {
    border-color: #84d8ff;
    background: var(--duo-blue-light);
}
.hx-acct-opt.selected b { color: var(--duo-blue-border); }

/* Màn "Ai đang học nào?" — toàn màn hình, không có menu */
body.app-shell.page-profiles .duo-sidebar,
body.app-shell.page-profiles .hx-navbar,
body.app-shell.page-profiles .hx-topbar,
body.app-shell.page-profiles .hx-tabbar,
body.app-shell.page-profiles #focus-float-widget { display: none !important; }
body.page-profiles { background: #fff; }
body.page-profiles .duo-main-container { justify-content: center; }
.hxp-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 20px calc(40px + env(safe-area-inset-bottom));
    text-align: center;
}
.hxp-logo { width: 84px; height: 84px; object-fit: contain; }
.hxp-title { margin: 10px 0 4px; font-size: 30px; font-weight: 900; color: var(--duo-dark); }
.hxp-sub { margin: 0 0 28px; font-size: 15px; font-weight: 700; color: var(--duo-dark-muted); }
.hxp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    width: 100%;
}
.hxp-loading { grid-column: 1 / -1; color: var(--duo-dark-muted); font-weight: 700; }
.hxp-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 10px 16px;
    border: 2px solid var(--duo-border-color);
    border-bottom-width: 5px;
    border-radius: 20px;
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: transform .1s, border-color .1s;
}
.hxp-tile:hover { border-color: #84d8ff; transform: translateY(-2px); }
.hxp-tile:active { transform: translateY(2px); border-bottom-width: 2px; }
.hxp-avatar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: var(--duo-gray-light);
    overflow: hidden;
}
.hxp-plus { background: var(--duo-green-light); color: var(--duo-green-border); }
.hxp-plus .material-symbols-outlined { font-size: 52px; font-variation-settings: 'wght' 700; }
.hxp-parent-av { background: var(--duo-blue-light); overflow: visible; }
.hxp-parent-av img { width: 76px; height: 76px; object-fit: contain; }
.hxp-lock {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 32px;
    height: 32px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--duo-blue);
    color: #fff;
    font-size: 18px !important;
    line-height: 26px;
}
.hxp-name { font-size: 17px; font-weight: 900; color: var(--duo-dark); }
.hxp-meta { font-size: 12px; font-weight: 700; color: var(--duo-dark-muted); }
.hxp-label { display: block; margin: 8px 0 6px; font-size: 13px; font-weight: 800; color: var(--duo-dark-muted); text-align: left; }
.hxp-logout {
    margin-top: 28px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    color: var(--duo-dark-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
}
.hxp-pin-input {
    display: block;
    width: 200px;
    margin: 6px auto 0;
    padding: 12px;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    font-family: inherit;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 14px;
    text-align: center;
    outline: none;
}
.hxp-pin-input:focus { border-color: #84d8ff; }

/* Góc phụ huynh */
body[data-page="phu-huynh"] { --hx-hero: url('/static/img/hx/char-highfive.png'); }
.ph-kids { display: flex; flex-direction: column; gap: 0; }
.ph-kid-head { display: flex; align-items: center; gap: 14px; }
.ph-kid-av { width: 64px; height: 64px; flex-shrink: 0; }
.ph-kid-name { font-size: 19px; font-weight: 900; color: var(--duo-dark); }
.ph-kid-sub { font-size: 13px; font-weight: 700; color: var(--duo-dark-muted); }
.ph-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 14px 0 10px;
}
.ph-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    border: 2px solid var(--duo-border-color);
    border-radius: 14px;
    text-align: center;
}
.ph-stat b { font-size: 22px; font-weight: 900; color: var(--duo-green-border); }
.ph-stat span { font-size: 11px; font-weight: 800; color: var(--duo-dark-muted); }
.ph-stat.warn { border-color: #ffd36b; background: #fff8e1; }
.ph-stat.warn b { color: #e08600; }
.ph-last {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--duo-dark-muted);
}
.ph-last .material-symbols-outlined { font-size: 18px; color: var(--duo-blue); }
.ph-kid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-kid-actions .duo-btn { height: 46px; font-size: 13px; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.ph-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-actions .duo-btn { height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; font-size: 13px; }
.ph-empty { text-align: center; }
.ph-empty img { width: 160px; height: auto; }
.ph-empty h3 { margin: 8px 0 4px; font-size: 18px; font-weight: 900; }
.ph-empty p { font-size: 14px; color: var(--duo-dark-muted); line-height: 1.5; }
.ph-h3 { margin-bottom: 6px; font-size: 16px; font-weight: 900; }
.ph-note { font-size: 13px; font-weight: 700; color: var(--duo-dark-muted); line-height: 1.5; margin-bottom: 10px; }
.ph-link { margin-top: 8px; border: none; background: none; font-family: inherit; font-weight: 800; color: var(--duo-pink-border); cursor: pointer; padding: 0; }
@media (max-width: 768px) {
    .hxp-wrap { padding-top: calc(28px + env(safe-area-inset-top)); }
    .hxp-title { font-size: 24px; }
    .hxp-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .hxp-avatar { width: 88px; height: 88px; }
    .ph-stats { grid-template-columns: repeat(2, 1fr); }
    .ph-actions, .ph-kid-actions { grid-template-columns: 1fr; }
}

/* Thẻ "Hôm nay con học gì" */
.hx-subj-card { padding: 16px 18px !important; }
.hx-subj-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 900;
    color: var(--duo-dark);
}
.hx-subj-head img { width: 30px; height: 30px; object-fit: contain; }
.hx-subj-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}
.hx-subj-row + .hx-subj-row { border-top: 2px solid var(--duo-border-color); }
.hx-subj-day {
    flex: 0 0 72px;
    font-size: 15px;
    font-weight: 900;
    color: var(--duo-blue-border);
    line-height: 1.2;
}
.hx-subj-day small {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--duo-dark-muted);
    text-transform: uppercase;
}
.hx-subj-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hx-subj-chip {
    display: inline-block;
    padding: 4px 10px;
    border: 2px solid var(--duo-border-color);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    font-weight: 800;
    color: var(--duo-dark);
}
.hx-subj-off { font-size: 13px; font-weight: 700; color: var(--duo-dark-muted); }
.ph-subj {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}
.ph-subj > b { margin-right: 2px; color: var(--duo-blue-border); }
.ph-subj-empty { color: var(--duo-dark-muted); font-weight: 700; line-height: 1.5; }

/* Trạng thái chờ AI (đọc TKB, tách bài) */
.hx-ai-wait {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 2px solid #84d8ff;
    border-radius: 14px;
    background: var(--duo-blue-light);
    color: var(--duo-blue-border);
    font-size: 14px;
    line-height: 1.4;
}
.hx-ai-wait span:not(.hx-ai-spin) { font-size: 12px; font-weight: 700; color: var(--duo-dark-muted); }
.hx-ai-spin {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 4px solid #cdeefe;
    border-top-color: var(--duo-blue);
    border-radius: 50%;
    animation: hxSpin .8s linear infinite;
}
@keyframes hxSpin { to { transform: rotate(360deg); } }

/* ============================================================
   GIA SƯ LYNCO — nút nổi + bảng chat
   ============================================================ */
.hxt-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 100;
    width: 64px;
    height: 64px;
    padding: 6px;
    border: 2px solid var(--duo-border-color);
    border-bottom-width: 5px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .08);
    transition: transform .12s;
    -webkit-tap-highlight-color: transparent;
}
.hxt-fab img { width: 100%; height: 100%; object-fit: contain; }
.hxt-fab:hover { transform: translateY(-2px); }
.hxt-fab:active { transform: translateY(2px); border-bottom-width: 2px; }
body.hxt-open #floating-tutor-btn { display: none !important; }

#tutor-chat-panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
}
.hxt-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
}
#tutor-chat-panel .hxt-sheet {
    position: absolute;
    right: 24px !important;
    left: auto !important;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100% - 48px)) !important;
    height: min(620px, calc(100% - 48px)) !important;
    max-height: none !important;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--duo-border-color);
    border-radius: 24px !important;
    background: #fff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
    animation: hxtIn .2s ease-out;
}
@keyframes hxtIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}
.hxt-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    border-bottom: 2px solid var(--duo-border-color);
    background: #fff;
}
.hxt-head-avatar {
    width: 48px;
    height: 48px;
    padding: 4px;
    border-radius: 50%;
    background: var(--duo-blue-light);
    object-fit: contain;
}
.hxt-head-text { flex: 1; min-width: 0; }
.hxt-name { font-size: 18px; font-weight: 900; color: var(--duo-dark); }
.hxt-sub { font-size: 13px; font-weight: 700; color: var(--duo-dark-muted); }
.hxt-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: none;
    color: #afafaf;
    cursor: pointer;
}
.hxt-close:hover { background: var(--duo-gray-light); color: var(--duo-dark); }
.hxt-close .material-symbols-outlined { font-size: 26px; }

.hxt-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #fff;
}
.hxt-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
}
.hxt-msg-ai { align-self: flex-start; }
.hxt-msg-user { align-self: flex-end; }
.hxt-msg-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
}
.hxt-bubble {
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.hxt-msg-ai .hxt-bubble {
    border: 2px solid var(--duo-border-color);
    border-bottom-left-radius: 6px;
    background: #fff;
    color: var(--duo-dark);
}
.hxt-msg-user .hxt-bubble {
    border-bottom-right-radius: 6px;
    background: var(--duo-blue);
    color: #fff;
}
.hxt-typing {
    display: flex;
    gap: 5px;
    padding: 14px 16px;
}
.hxt-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #afafaf;
    animation: hxtDot 1s infinite ease-in-out;
}
.hxt-typing span:nth-child(2) { animation-delay: .15s; }
.hxt-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hxtDot {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-5px); opacity: 1; }
}

.hxt-quick {
    display: flex;
    gap: 8px;
    padding: 0 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.hxt-quick::-webkit-scrollbar { display: none; }
.hxt-quick button {
    flex-shrink: 0;
    padding: 8px 12px;
    border: 2px solid var(--duo-border-color);
    border-bottom-width: 3px;
    border-radius: 999px;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    color: var(--duo-blue-border);
    cursor: pointer;
    white-space: nowrap;
}
.hxt-quick button:hover { background: var(--duo-blue-light); }
.hxt-quick button:active { transform: translateY(1px); border-bottom-width: 2px; }

.hxt-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 2px solid var(--duo-border-color);
    background: #fff;
}
.hxt-input-row input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 16px;
    border: 2px solid var(--duo-border-color);
    border-radius: 14px;
    background: var(--duo-gray-light);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--duo-dark);
    outline: none;
}
.hxt-input-row input:focus {
    border-color: #84d8ff;
    background: #fff;
}
.hxt-send {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    border-radius: 14px;
    background: var(--duo-blue);
    box-shadow: 0 4px 0 var(--duo-blue-border);
    color: #fff;
    cursor: pointer;
}
.hxt-send:active { transform: translateY(4px); box-shadow: none; }

@media (max-width: 768px) {
    #tutor-chat-panel .hxt-sheet {
        right: 0 !important;
        left: 0 !important;
        bottom: 0;
        width: 100% !important;
        height: min(85%, calc(var(--hx-app-height, 100dvh) - var(--hx-safe-top, 0px))) !important;
        border: none;
        border-radius: 24px 24px 0 0 !important;
        animation-name: hxtUp;
    }
    @keyframes hxtUp {
        from { transform: translateY(100%); }
        to { transform: none; }
    }
    .hxt-input-row { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ===== Quỹ Học Xanh trên trang chính ===== */
.hxd-fund {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 6px 14px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border-color: #ffd9a8 !important;
    background: linear-gradient(135deg, #fff8ec 0%, #ffffff 70%) !important;
    transition: transform .15s ease;
}
.hxd-fund[hidden] { display: none; }
.hxd-fund:hover { transform: translateY(-2px); }
.hxd-fund-icon { width: 56px; height: 56px; object-fit: contain; grid-row: span 2; }
.hxd-fund-label { font-size: 13px; font-weight: 800; color: var(--duo-dark-muted); text-transform: uppercase; letter-spacing: .4px; }
.hxd-fund-total { font-size: 26px; font-weight: 900; color: var(--duo-orange-border, #e08a00); line-height: 1.15; font-variant-numeric: tabular-nums; }
.hxd-fund-meta { font-size: 12px; font-weight: 700; color: var(--duo-green-border, #58a700); margin-top: 2px; }
.hxd-fund-go { grid-column: 2; font-size: 13px; font-weight: 900; color: var(--duo-blue, #1cb0f6); text-transform: uppercase; }
.hxd-fund.bump { animation: hxd-fund-bump .7s ease; }
@keyframes hxd-fund-bump {
    0% { transform: scale(1); }
    35% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(255, 200, 0, .25); }
    100% { transform: scale(1); }
}

.hxd-fund-chip { color: var(--duo-orange-border, #e08a00); text-decoration: none; }
.hxd-fund-chip[hidden],
.duo-stats-col .hxd-fund-chip { display: none !important; }
.hxd-fund-chip img { width: 26px; height: 26px; object-fit: contain; }

/* Thanh menu trái: tự cuộn khi cửa sổ thấp hơn danh sách mục (trước đây bị tràn, không xuống được Quỹ / Đăng xuất) */
.duo-sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;  /* vẫn cuộn bằng chuột/cảm ứng, chỉ ẩn thanh cuộn */
}
.duo-sidebar::-webkit-scrollbar { display: none; }

/* Ẩn thanh cuộn của trang và cột phải (vẫn cuộn bằng chuột/cảm ứng bình thường) */
html, body, .duo-stats-col { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, .duo-stats-col::-webkit-scrollbar { display: none; }

/* Hồ sơ: thẻ cấp Người hùng hiện tại (1 → 100) */
.hx-hero-level {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; margin-bottom: 12px;
    border: 2px solid #ffd900; border-radius: 16px;
    background: linear-gradient(135deg, #fff9d6 0%, #ffffff 80%);
}
.hx-hero-level > img { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
.hx-hero-level-body { flex: 1; min-width: 0; }
.hx-hero-level-name { font-size: 16px; font-weight: 900; color: var(--duo-dark); white-space: nowrap; }
.hx-hero-level-name small { font-size: 12px; font-weight: 800; color: var(--duo-dark-muted); }
.hx-hero-level-hint { margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--duo-dark-muted); }
.hx-hero-level > img { width: 72px; height: 72px; border-radius: 50%; filter: drop-shadow(0 3px 4px rgba(0,0,0,.18)); }
.hx-hero-level-chapter { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; color: var(--duo-green-border, #58a700); }
.hx-hero-level-sub { font-size: 12px; font-weight: 800; color: var(--duo-dark-muted); }
.hx-rank-badge-icon img[src*="/img/hero/"] { border-radius: 50%; }

/* Huy hiệu Người hùng (sticker cấp hiện tại) gắn ở góc dưới phải avatar */
.duo-profile-avatar-wrap, .duo-stats-avatar, .hxd-avatar, .duo-leader-avatar { position: relative; }
.hxd-avatar { overflow: visible; }
.hx-hero-badge {
    position: absolute; right: -5px; bottom: -5px;
    border-radius: 50%; object-fit: contain; pointer-events: none;
    background: #fff; box-shadow: 0 0 0 2px #fff, 0 2px 4px rgba(0,0,0,.25);
}
