/* ============================================================
   public/css/adaptive.css — Glassmorphism, Animations,
   Mobile-First Layout & Skill Profile Styling
   ============================================================ */
:root {
    --lv1-bg: linear-gradient(135deg, rgba(236, 253, 245, 0.92), rgba(209, 250, 229, 0.78));
    --lv1-bd: #34d399;
    --lv1-tx: #065f46;
    --lv1-glow: rgba(16, 185, 129, 0.25);

    --lv2-bg: linear-gradient(135deg, rgba(240, 249, 255, 0.92), rgba(224, 242, 254, 0.78));
    --lv2-bd: #38bdf8;
    --lv2-tx: #075985;
    --lv2-glow: rgba(14, 165, 233, 0.25);

    --lv3-bg: linear-gradient(135deg, rgba(255, 251, 235, 0.92), rgba(254, 243, 199, 0.78));
    --lv3-bd: #fbbf24;
    --lv3-tx: #92400e;
    --lv3-glow: rgba(245, 158, 11, 0.25);

    --lv4-bg: linear-gradient(135deg, rgba(255, 241, 242, 0.92), rgba(255, 228, 230, 0.78));
    --lv4-bd: #fb7185;
    --lv4-tx: #9f1239;
    --lv4-glow: rgba(244, 63, 94, 0.28);

    --surface-glass: rgba(255, 255, 255, 0.86);
    --surface-card: rgba(255, 255, 255, 0.90);
    --surface-subtle: rgba(248, 250, 252, 0.88);
    --border-glass: rgba(226, 232, 240, 0.88);
    --text-main: #0f172a;
    --text-muted-custom: #64748b;
    --shadow-card: 0 12px 32px -8px rgba(15, 23, 42, 0.07), 0 4px 12px -2px rgba(79, 70, 229, 0.04);
    --shadow-hover: 0 20px 38px -10px rgba(79, 70, 229, 0.16), 0 6px 16px -4px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] {
    --lv1-bg: linear-gradient(135deg, rgba(6, 78, 59, 0.55), rgba(4, 120, 87, 0.35));
    --lv1-bd: rgba(52, 211, 153, 0.55);
    --lv1-tx: #6ee7b7;

    --lv2-bg: linear-gradient(135deg, rgba(12, 74, 110, 0.55), rgba(3, 105, 161, 0.35));
    --lv2-bd: rgba(56, 189, 248, 0.55);
    --lv2-tx: #7dd3fc;

    --lv3-bg: linear-gradient(135deg, rgba(120, 53, 15, 0.55), rgba(180, 83, 9, 0.35));
    --lv3-bd: rgba(251, 191, 36, 0.55);
    --lv3-tx: #fde68a;

    --lv4-bg: linear-gradient(135deg, rgba(136, 19, 55, 0.55), rgba(190, 18, 60, 0.35));
    --lv4-bd: rgba(251, 113, 133, 0.55);
    --lv4-tx: #fda4af;

    --surface-glass: rgba(15, 23, 42, 0.84);
    --surface-card: rgba(15, 23, 42, 0.86);
    --surface-subtle: rgba(30, 41, 59, 0.76);
    --border-glass: rgba(51, 65, 85, 0.75);
    --text-main: #f8fafc;
    --text-muted-custom: #94a3b8;
    --shadow-card: 0 16px 40px -10px rgba(0, 0, 0, 0.48), 0 0 1px 1px rgba(99, 102, 241, 0.12);
    --shadow-hover: 0 22px 46px -10px rgba(99, 102, 241, 0.28), 0 0 1px 1px rgba(99, 102, 241, 0.32);
}

/* Interactive Background Canvas */
#sigma-webgl-bg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
}

/* Ẩn khung làm bài khi chưa có nội dung */
#reader-card:not(:has(#quiz-container > *)) {
    display: none;
}

/* ---------- Khung chọn đề sau khi quét ---------- */
.adp-launch {
    border-radius: 18px;
    padding: 14px;
    background: var(--surface-subtle);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-card);
    animation: adpSlideUp 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Nhãn dán 4 mức độ */
.adp-stickers {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.adp-sticker {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1.5px solid transparent;
    text-align: left;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, border-color 0.22s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    will-change: transform;
}
.adp-sticker::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.55s ease;
    pointer-events: none;
}
@media (hover: hover) {
    .adp-sticker:hover::after { transform: translateX(120%); }
    .adp-sticker:hover { transform: translateY(-3px) scale(1.015); }
}
.adp-sticker:active {
    transform: translateY(0) scale(0.98);
}
.adp-sticker[data-level="1"] { background: var(--lv1-bg); border-color: var(--lv1-bd); color: var(--lv1-tx); box-shadow: 0 6px 18px -6px var(--lv1-glow); }
.adp-sticker[data-level="2"] { background: var(--lv2-bg); border-color: var(--lv2-bd); color: var(--lv2-tx); box-shadow: 0 6px 18px -6px var(--lv2-glow); }
.adp-sticker[data-level="3"] { background: var(--lv3-bg); border-color: var(--lv3-bd); color: var(--lv3-tx); box-shadow: 0 6px 18px -6px var(--lv3-glow); }
.adp-sticker[data-level="4"] { background: var(--lv4-bg); border-color: var(--lv4-bd); color: var(--lv4-tx); box-shadow: 0 6px 18px -6px var(--lv4-glow); }

.adp-sticker .st-top { display: flex; align-items: center; justify-content: space-between; width: 100%; font-weight: 800; font-size: .82rem; letter-spacing: -0.01em; }
.adp-sticker .st-name { font-size: .75rem; font-weight: 600; opacity: .92; }
.adp-sticker .st-dot {
    width: 8px; height: 8px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: adpPulseDot 2s infinite ease-in-out;
}

/* Nhãn mức nhỏ gọn */
.adp-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; border: 1px solid transparent;
    transition: transform 0.18s ease;
    white-space: nowrap;
}
.adp-pill[data-level="1"] { background: var(--lv1-bg); border-color: var(--lv1-bd); color: var(--lv1-tx); }
.adp-pill[data-level="2"] { background: var(--lv2-bg); border-color: var(--lv2-bd); color: var(--lv2-tx); }
.adp-pill[data-level="3"] { background: var(--lv3-bg); border-color: var(--lv3-bd); color: var(--lv3-tx); }
.adp-pill[data-level="4"] { background: var(--lv4-bg); border-color: var(--lv4-bd); color: var(--lv4-tx); }

/* ---------- Dòng trạng thái trong bài làm ---------- */
.adp-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border-glass);
    font-size: .82rem; color: var(--text-muted-custom);
}
.adp-steps { display: inline-flex; align-items: center; gap: 6px; }
.adp-step {
    width: 26px; height: 26px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .73rem; font-weight: 800;
    background: var(--surface-subtle); color: var(--text-muted-custom);
    border: 1px solid var(--border-glass);
    transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.adp-step.done {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}
.adp-step.active {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border-color: transparent;
    transform: scale(1.12);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

/* ---------- Màn hình nâng cấp mức độ ---------- */
.adp-upgrade {
    text-align: center; padding: 44px 16px;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1), transparent 70%);
    border-radius: 20px;
    animation: adpZoomIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.adp-upgrade-bar {
    width: 180px; height: 6px; border-radius: 99px;
    background: var(--border-glass); margin: 16px auto 0; overflow: hidden;
}
.adp-upgrade-bar > span {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, #6366f1, #ec4899, #0ea5e9);
    background-size: 200% 100%;
    animation: adpFill 1.45s cubic-bezier(0.22, 1, 0.36, 1) forwards, adpShimmer 1.2s linear infinite;
}

@keyframes adpSlideUp {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes adpZoomIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes adpFill { to { width: 100%; } }
@keyframes adpShimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
@keyframes adpPulseDot {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.35); opacity: 1; }
}

/* ---------- Link "chưa biết làm" ---------- */
.adp-skip-link {
    background: none; border: none; padding: 8px 4px;
    font-size: .82rem; font-weight: 600; color: var(--text-muted-custom);
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
    transition: color 0.18s ease, transform 0.18s ease;
}
.adp-skip-link:hover:not(:disabled) { color: #6366f1; }
.adp-skip-link:disabled { opacity: .4; cursor: default; }

/* ---------- Danh sách bài sai ---------- */
.adp-wrong-item {
    padding: 13px;
    margin-bottom: 10px;
    border-radius: 14px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-glass);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
@media (hover: hover) {
    .adp-wrong-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-card);
        border-color: rgba(99, 102, 241, 0.35);
    }
}

.adp-count-bubble {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #e11d48);
    color: #fff;
    font-size: .62rem; font-weight: 800;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
.adp-count-bubble.zero { display: none; }

/* ---------- Hồ sơ năng lực & Banner Kiểm tra trình độ nhanh (Lũy tiến) ---------- */
.quick-assess-banner {
    border-radius: 18px;
    padding: 16px;
    border: 1px solid rgba(99, 102, 241, 0.28);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.10) 0%, rgba(14, 165, 233, 0.09) 100%);
    box-shadow: 0 10px 26px -10px rgba(79, 70, 229, 0.22);
}
html[data-theme="dark"] .quick-assess-banner {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.22) 0%, rgba(14, 165, 233, 0.16) 100%);
    border-color: rgba(129, 140, 248, 0.35);
}
.quick-grade-chip {
    border: 1px solid var(--border-glass);
    background: var(--surface-card);
    color: var(--text-muted-custom);
    padding: 5px 11px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}
.quick-grade-chip.active {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
    box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.5);
}

.sk-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.sk-kpi {
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 13px;
    background: var(--surface-subtle);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    will-change: transform;
}
@media (hover: hover) {
    .sk-kpi:hover { box-shadow: var(--shadow-hover); }
}
.sk-kpi .v {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}
html[data-theme="dark"] .sk-kpi .v {
    background: linear-gradient(135deg, #818cf8, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sk-kpi .k { font-size: .73rem; color: var(--text-muted-custom); font-weight: 600; margin-top: 2px; }

.sk-box {
    border: 1px solid var(--border-glass);
    border-radius: 18px;
    padding: 14px;
    background: var(--surface-card);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-card);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.sk-box:hover {
    border-color: rgba(99, 102, 241, 0.35);
}
.sk-title {
    font-size: .78rem; font-weight: 800; color: var(--text-main);
    text-transform: uppercase; letter-spacing: .4px; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.sk-bar-row {
    padding: 10px 0; border-bottom: 1px solid var(--border-glass);
    transition: transform 0.18s ease;
}
.sk-bar-row:last-child { border-bottom: none; }
.sk-track {
    height: 9px; border-radius: 99px; background: rgba(148, 163, 184, 0.16); overflow: hidden;
    display: flex;
}
.sk-fill {
    height: 100%; border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* AI Solved Card & Laser Scanner Effect */
.ai-solved-card {
    background: var(--surface-card) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow-card);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease, border-color 0.24s ease;
}
@media (hover: hover) {
    .ai-solved-card:hover {
        box-shadow: var(--shadow-hover);
        border-color: rgba(99, 102, 241, 0.4) !important;
    }
}

.scanner-dropzone {
    position: relative;
    overflow: hidden;
}
.scanner-dropzone.is-scanning::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #6366f1, #38bdf8, transparent);
    box-shadow: 0 0 14px #6366f1;
    animation: laserScan 1.6s ease-in-out infinite;
    z-index: 5;
}
@keyframes laserScan {
    0% { top: 4%; opacity: 0.4; }
    50% { top: 92%; opacity: 1; }
    100% { top: 4%; opacity: 0.4; }
}

/* ============================================================
   BOTTOM SHEET CHUYÊN ĐỀ THÂN THIỆN MOBILE (LIGHT & DARK MODE)
   ============================================================ */
.topics-sheet.offcanvas-bottom {
    height: auto !important;
    max-height: 88vh;
    max-height: 88dvh;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border: 1px solid var(--border-glass);
    border-bottom: none;
    background: var(--surface-card);
    color: var(--text-main);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 -18px 42px -10px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
html[data-theme="dark"] .topics-sheet.offcanvas-bottom {
    background: rgba(15, 23, 42, 0.94);
    box-shadow: 0 -18px 44px -8px rgba(0, 0, 0, 0.65);
}
@media (min-width: 768px) {
    .topics-sheet.offcanvas-bottom {
        left: 50%;
        right: auto;
        transform: translate(-50%, 100%);
        width: min(680px, calc(100vw - 32px));
        bottom: 16px;
        max-height: 82vh;
        border-radius: 24px;
        border-bottom: 1px solid var(--border-glass);
    }
    .topics-sheet.offcanvas-bottom.show,
    .topics-sheet.offcanvas-bottom.showing {
        transform: translate(-50%, 0);
    }
    .topics-sheet.offcanvas-bottom.hiding {
        transform: translate(-50%, 100%);
    }
}

.topics-sheet-handle-wrap {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.topics-sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.45);
}

.topics-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 16px 12px;
    flex-shrink: 0;
}
.topics-sheet-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.16), rgba(14, 165, 233, 0.14));
    color: #4f46e5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
html[data-theme="dark"] .topics-sheet-icon {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(14, 165, 233, 0.2));
    color: #a5b4fc;
}
.topics-sheet-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.01em;
}
.topics-sheet-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted-custom);
    margin-top: 1px;
}
.topics-sheet-close {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: var(--surface-subtle);
    color: var(--text-muted-custom);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
    -webkit-tap-highlight-color: transparent;
}
.topics-sheet-close:active { transform: scale(0.92); }
@media (hover: hover) {
    .topics-sheet-close:hover {
        color: var(--text-main);
        border-color: rgba(99, 102, 241, 0.4);
    }
}

.topics-sheet-controls {
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.topic-grade-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.14);
}
html[data-theme="dark"] .topic-grade-tabs {
    background: rgba(30, 41, 59, 0.85);
}
.topic-grade-tab {
    border: none;
    background: transparent;
    color: var(--text-muted-custom);
    min-height: 42px;
    padding: 6px 8px;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-tap-highlight-color: transparent;
}
.topic-grade-tab.active {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    box-shadow: 0 6px 14px -4px rgba(79, 70, 229, 0.5);
}
.topic-grade-tab:active { transform: scale(0.97); }
.topic-grade-count {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    color: inherit;
}
.topic-grade-tab.active .topic-grade-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.topic-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.topic-search-ico {
    position: absolute;
    left: 13px;
    color: var(--text-muted-custom);
    font-size: 0.86rem;
    pointer-events: none;
}
.topic-search-input {
    width: 100%;
    min-height: 42px;
    padding: 8px 38px 8px 36px;
    border-radius: 13px;
    border: 1px solid var(--border-glass);
    background: var(--surface-subtle);
    color: var(--text-main);
    font-size: 16px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    -webkit-appearance: none;
}
.topic-search-input::placeholder {
    color: var(--text-muted-custom);
    font-size: 0.86rem;
}
.topic-search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.topic-search-clear {
    position: absolute;
    right: 6px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted-custom);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
}

.topic-filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 1px 0;
}
.topic-filter-pills::-webkit-scrollbar { display: none; }
.topic-filter-pill {
    border: 1px solid var(--border-glass);
    background: var(--surface-subtle);
    color: var(--text-muted-custom);
    border-radius: 999px;
    min-height: 34px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}
.topic-filter-pill.active {
    background: rgba(79, 70, 229, 0.12);
    border-color: #6366f1;
    color: #4f46e5;
    font-weight: 700;
}
html[data-theme="dark"] .topic-filter-pill.active {
    background: rgba(99, 102, 241, 0.24);
    border-color: #818cf8;
    color: #c7d2fe;
}

.topics-sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 16px calc(20px + var(--safe-bottom, 0px)) !important;
}
.topics-list-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Topic Card inside Sheet */
.topic-card {
    border-radius: 16px;
    border: 1px solid var(--border-glass);
    background: var(--surface-subtle);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.topic-card.is-active {
    border-color: #6366f1;
    box-shadow: 0 8px 22px -8px rgba(79, 70, 229, 0.32);
}
.topic-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 13px 10px;
}
.topic-card-title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-width: 0;
    flex: 1;
}
.topic-card-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    margin-top: 6px;
    background: #94a3b8;
}
.topic-card.is-active .topic-card-dot {
    background: #4f46e5;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}
.topic-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.38;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.topic-card-grade-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-card);
    border: 1px solid var(--border-glass);
    color: var(--text-muted-custom);
    white-space: nowrap;
    flex-shrink: 0;
}
.topic-card.is-active .topic-card-grade-tag {
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
    color: #4f46e5;
}
html[data-theme="dark"] .topic-card.is-active .topic-card-grade-tag {
    color: #a5b4fc;
}

.topic-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 12px 12px;
}
.topic-action-btn {
    min-height: 48px;
    padding: 8px 11px;
    border-radius: 13px;
    border: 1.5px solid var(--border-glass);
    background: var(--surface-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    -webkit-tap-highlight-color: transparent;
}
.topic-action-btn:active { transform: scale(0.97); }
.topic-action-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    min-width: 0;
}
.topic-action-sub {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.topic-action-btn.is-basic {
    border-color: rgba(16, 185, 129, 0.35);
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.85), rgba(209, 250, 229, 0.5));
    color: #065f46;
}
.topic-action-btn.is-basic .topic-action-sub {
    background: rgba(16, 185, 129, 0.16);
    color: #047857;
}
.topic-action-btn.is-basic.is-selected {
    border-color: #10b981;
    box-shadow: 0 6px 14px -6px rgba(16, 185, 129, 0.45);
}
html[data-theme="dark"] .topic-action-btn.is-basic {
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.45), rgba(4, 120, 87, 0.28));
    border-color: rgba(52, 211, 153, 0.35);
    color: #6ee7b7;
}
html[data-theme="dark"] .topic-action-btn.is-basic .topic-action-sub {
    background: rgba(52, 211, 153, 0.18);
    color: #a7f3d0;
}

.topic-action-btn.is-advanced {
    border-color: rgba(244, 63, 94, 0.35);
    background: linear-gradient(135deg, rgba(255, 241, 242, 0.85), rgba(255, 228, 230, 0.5));
    color: #9f1239;
}
.topic-action-btn.is-advanced .topic-action-sub {
    background: rgba(244, 63, 94, 0.14);
    color: #be123c;
}
.topic-action-btn.is-advanced.is-selected {
    border-color: #f43f5e;
    box-shadow: 0 6px 14px -6px rgba(244, 63, 94, 0.45);
}
html[data-theme="dark"] .topic-action-btn.is-advanced {
    background: linear-gradient(135deg, rgba(136, 19, 55, 0.45), rgba(190, 18, 60, 0.28));
    border-color: rgba(251, 113, 133, 0.35);
    color: #fda4af;
}
html[data-theme="dark"] .topic-action-btn.is-advanced .topic-action-sub {
    background: rgba(251, 113, 133, 0.18);
    color: #fecdd3;
}

.topic-action-btn.is-disabled {
    opacity: 0.45;
    cursor: default;
    background: var(--surface-card);
    border-style: dashed;
    color: var(--text-muted-custom);
}
.topic-action-btn.is-disabled:active { transform: none; }

.topic-card-extras {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 12px 12px;
}
.topic-extra-btn {
    min-height: 42px;
    width: 100%;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: var(--surface-card);
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}
.topic-extra-btn.is-selected {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}
html[data-theme="dark"] .topic-extra-btn.is-selected {
    color: #fde68a;
}

.topics-empty-state {
    border-radius: 18px;
    border: 1px dashed var(--border-glass);
    background: var(--surface-subtle);
    padding: 28px 18px;
    text-align: center;
    color: var(--text-muted-custom);
}

@media (max-width: 379.98px) {
    .topic-card-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .adp-launch { padding: 12px; border-radius: 15px; }
    .adp-stickers { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .adp-sticker { padding: 10px 12px; }
    .sk-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .sk-kpi { padding: 11px 12px; border-radius: 14px; }
    .sk-kpi .v { font-size: 1.15rem; }
    .sk-box { padding: 12px; border-radius: 15px; }
    .quick-assess-banner { padding: 14px; border-radius: 16px; }
}

/* ============================================================
   KHUNG VẼ HÌNH HỌC 3D / 2D & ĐỒ THỊ (BẢO ĐẢM CHIỀU CAO ỔN ĐỊNH)
   ============================================================ */
.geo3d-wrapper {
    display: block;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #090f1d;
    border: 1px solid rgba(56, 189, 248, 0.28);
}
.geo3d-canvas-stage {
    position: relative;
    display: block;
    width: 100%;
    height: 310px;
    min-height: 260px;
    background: #090f1d;
}
.geo3d-canvas-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}
@media (max-width: 575.98px) {
    .geo3d-canvas-stage {
        height: 260px;
        min-height: 230px;
    }
}
