/* ============================================================================
   PersonalStudy — Fun Mode (Kids & Teens)
   Vibrant, playful, Duolingo-inspired UI
   ============================================================================ */

/* ---------- Fun Mode Variables ---------- */
:root {
    /* Vibrant palette */
    --fun-primary: #7C4DFF;
    --fun-primary-light: #B388FF;
    --fun-primary-glow: rgba(124, 77, 255, 0.3);
    --fun-secondary: #FF6B9D;
    --fun-accent: #00E5FF;
    --fun-green: #00E676;
    --fun-yellow: #FFEA00;
    --fun-orange: #FF9100;
    --fun-pink: #FF4081;
    
    /* Gradients */
    --grad-primary: linear-gradient(135deg, #7C4DFF 0%, #448AFF 100%);
    --grad-success: linear-gradient(135deg, #00E676 0%, #00BFA5 100%);
    --grad-fire: linear-gradient(135deg, #FF6B35 0%, #FF3D00 100%);
    --grad-magic: linear-gradient(135deg, #E040FB 0%, #7C4DFF 50%, #448AFF 100%);
    --grad-gold: linear-gradient(135deg, #FFD54F 0%, #FF9100 100%);
    --grad-card: linear-gradient(145deg, #ffffff 0%, #f8f5ff 100%);
    
    /* Backgrounds */
    --fun-bg: #F5F0FF;
    --fun-bg-card: #FFFFFF;
    --fun-bg-dark: #1A1035;
    
    /* Borders & Shadows */
    --fun-border: rgba(124, 77, 255, 0.12);
    --fun-shadow: 0 4px 20px rgba(124, 77, 255, 0.15);
    --fun-shadow-hover: 0 8px 32px rgba(124, 77, 255, 0.25);
    --fun-shadow-glow: 0 0 20px rgba(124, 77, 255, 0.4);
    
    /* Radius */
    --fun-radius: 16px;
    --fun-radius-lg: 14px;
    --fun-radius-xl: 32px;
    --fun-radius-pill: 100px;
    
    /* Typography */
    --fun-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --fun-font-display: 'Inter', sans-serif;
    
    /* Animation */
    --fun-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --fun-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark mode overrides ---------- */
body.dark-mode {
    --fun-bg: #0F0A1F;
    --fun-bg-card: #1A1035;
    --fun-border: rgba(124, 77, 255, 0.2);
    --fun-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
/* ---------- Dark mode overrides (data-theme system) ---------- */
[data-theme="dark"] {
    --fun-bg: #0F0A1F;
    --fun-bg-card: #1A1035;
    --fun-border: rgba(124, 77, 255, 0.2);
    --fun-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}


/* ---------- Base Overrides ---------- */
body {
    background: var(--fun-bg) !important;
    font-family: var(--fun-font) !important;
    overflow-x: hidden;
}

/* Animated background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(124, 77, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 157, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.05) rotate(1deg); }
}

/* ============================================================================
   STAT CARDS — Dashboard Stats Row
   Design: Glassmorphism cards with individual accent colors
   Grid: CSS Grid for equal-width cards, responsive breakpoints
   Hierarchy: icon → value → label → sub-info
   ============================================================================ */

/* --- Stats Row Layout --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 1.5rem;
    padding: 0 2px;
}

@media (max-width: 992px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 576px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-row .stat-card:last-child {
        grid-column: span 2;
    }
}

/* --- Base Stat Card --- */
.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px;
    border-radius: 22px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.35s ease,
                border-color 0.3s ease;
    overflow: hidden;
    cursor: default;
}

/* Top accent line (hidden until hover) */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--stat-accent, var(--fun-primary));
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover::before {
    width: 60%;
    left: 20%;
}

/* Subtle shimmer overlay */
.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0%,
        transparent 50%,
        rgba(124, 77, 255, 0.02) 100%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.dark-mode .stat-card::after {
    background: linear-gradient(
        135deg,
        rgba(124, 77, 255, 0.04) 0%,
        transparent 50%,
        rgba(68, 138, 255, 0.03) 100%
    );
}

.stat-card:hover::after {
    opacity: 1;
}

/* Hover lift */
.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
    border-color: rgba(124, 77, 255, 0.2);
}

/* Focus state for accessibility */
.stat-card:focus-within {
    outline: 2px solid var(--fun-primary);
    outline-offset: 2px;
}

/* --- Icon --- */
.stat-card .stat-icon {
    font-size: 1.4rem;
    line-height: 1;
    margin-bottom: 6px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.stat-card:hover .stat-icon {
    transform: scale(1.15) rotate(-3deg);
}

body.dark-mode .stat-card .stat-icon {
    filter: drop-shadow(0 2px 6px rgba(124, 77, 255, 0.25));
}

/* --- Value (primary number) --- */
.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.5px;
    color: var(--stat-accent, var(--fun-primary));
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.stat-card:hover .stat-value {
    transform: scale(1.05);
}

/* --- Label --- */
.stat-card .stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #1f2937;
    line-height: 1.3;
}

/* --- Sub info (XP text) --- */
.stat-card .stat-sub {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.8;
}

/* --- XP Progress Bar --- */
.stat-card .xp-bar {
    width: 100%;
    height: 4px;
    margin-top: 6px;
    background: var(--progress-track);
    border-radius: 4px;
    overflow: hidden;
}

.stat-card .xp-bar .xp-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--fun-primary), var(--fun-accent));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.stat-card .xp-bar .xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
    border-radius: 4px;
    animation: xpPulse 2s ease-in-out infinite;
}

@keyframes xpPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* --- Individual Card Accent Colors --- */
.stat-card.stat-level {
    --stat-accent: #7C4DFF;
}
.stat-card.stat-streak {
    --stat-accent: #FF6B35;
}
.stat-card.stat-hearts {
    --stat-accent: #E040FB;
}
.stat-card.stat-accuracy {
    --stat-accent: #448AFF;
}
.stat-card.stat-mastered {
    --stat-accent: #FFB300;
}

/* Gradient text for mastered count */
.stat-card.stat-mastered .stat-value {
    background: linear-gradient(135deg, #FFD54F, #FF9100);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Streak fire pulse when active */
.stat-card.stat-streak.active .stat-icon {
    animation: firePulse 1.5s ease-in-out infinite;
}

@keyframes firePulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(255, 107, 53, 0.3)); }
    50% { transform: scale(1.12); filter: drop-shadow(0 4px 12px rgba(255, 107, 53, 0.5)); }
}

/* --- Entrance Animation --- */
.stat-card {
    animation: statAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.stat-card:nth-child(1) { animation-delay: 0.0s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.18s; }
.stat-card:nth-child(5) { animation-delay: 0.24s; }

@keyframes statAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Panel Buttons (below stats) --- */
.panel-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.panel-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 650;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.panel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.1);
    border-color: rgba(124, 77, 255, 0.25);
    color: var(--fun-primary);
}

.panel-btn.active {
    background: var(--grad-primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(124, 77, 255, 0.3);
}

.panel-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 77, 255, 0.35);
}

.panel-btn .panel-btn-icon {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.panel-btn:hover .panel-btn-icon {
    transform: scale(1.1);
}

.panel-btn .panel-btn-text {
    line-height: 1;
}

/* Dark mode panel buttons */
body.dark-mode .panel-btn {
    background: var(--panel-bg);
    border-color: var(--card-border);
    color: var(--text-secondary);
}

body.dark-mode .panel-btn:hover {
    color: var(--fun-primary-light);
    border-color: rgba(124, 77, 255, 0.3);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.15);
}

/* Mastered count in header */
.mastered-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

@media (max-width: 576px) {
    .panel-buttons {
        gap: 6px;
    }
    .panel-btn {
        padding: 7px 12px;
        font-size: 0.72rem;
    }
}

/* ---------- Fun Cards (mq-card) ---------- */
.mq-card {
    background: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: var(--fun-radius-lg) !important;
    box-shadow: var(--card-shadow) !important;
    transition: all 0.3s var(--fun-smooth) !important;
    overflow: hidden;
}

.mq-card:hover {
    box-shadow: var(--card-shadow-hover) !important;
}

.mq-card .card-header {
    background: var(--grade-bg) !important;
    border-bottom: 1px solid var(--card-border) !important;
    padding: 1rem 1.25rem !important;
}

/* ---------- Fun Buttons ---------- */
.btn-primary, 
.btn[style*="background:#6C63FF"],
.btn[style*="background: #6C63FF"] {
    background: var(--grad-primary) !important;
    border: none !important;
    border-radius: var(--fun-radius) !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.3) !important;
    transition: all 0.3s var(--fun-bounce) !important;
    padding: 0.6rem 1.5rem !important;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 6px 25px rgba(124, 77, 255, 0.4) !important;
}

.btn-primary:active {
    transform: translateY(0) scale(0.98) !important;
}

/* Panel toggle buttons — see .panel-btn section */

/* ---------- Fun Navbar ---------- */
.ps-navbar {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 2px solid var(--fun-border) !important;
    box-shadow: 0 4px 30px rgba(124, 77, 255, 0.08) !important;
}

body.dark-mode .ps-navbar {
    background: rgba(26, 16, 53, 0.95) !important;
}

.ps-brand-text {
    font-weight: 900 !important;
    font-size: 1.2rem !important;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ps-nav-item {
    border-radius: var(--fun-radius) !important;
    font-weight: 600 !important;
    transition: all 0.3s var(--fun-bounce) !important;
    padding: 8px 16px !important;
}

.ps-nav-item:hover {
    transform: translateY(-2px);
    background: rgba(124, 77, 255, 0.08) !important;
}

.ps-nav-item.active {
    background: var(--grad-primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.3);
}

.ps-nav-item.active i {
    color: #fff !important;
}

/* ---------- Fun Avatar ---------- */
.ps-avatar {
    width: 36px !important;
    height: 36px !important;
    background: var(--grad-magic) !important;
    font-size: 0.8rem !important;
    font-weight: 900 !important;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 10px rgba(124, 77, 255, 0.3);
    animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 2px 10px rgba(124, 77, 255, 0.3); }
    50% { box-shadow: 0 2px 20px rgba(124, 77, 255, 0.5); }
}

/* ---------- Course Badge ---------- */
.ps-course-badge {
    background: var(--grad-primary) !important;
    color: #fff !important;
    font-weight: 700 !important;
    border-radius: var(--fun-radius-pill) !important;
    padding: 6px 14px !important;
    font-size: 0.75rem !important;
    box-shadow: 0 2px 10px rgba(124, 77, 255, 0.2);
}

/* ---------- Skill Tree Nodes ---------- */
.topic-node {
    border-radius: var(--fun-radius-lg) !important;
    border: 3px solid var(--fun-border) !important;
    transition: all 0.4s var(--fun-bounce) !important;
    box-shadow: var(--fun-shadow) !important;
}

.topic-node:hover {
    transform: scale(1.08) !important;
    box-shadow: var(--fun-shadow-glow) !important;
}

.topic-node.mastered {
    border-color: var(--fun-green) !important;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3) !important;
}

.topic-node.mastered::after {
    content: '⭐';
    position: absolute;
    top: -8px; right: -8px;
    font-size: 1.2rem;
    animation: starBounce 2s ease-in-out infinite;
}

@keyframes starBounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); }
}

.topic-node.in-progress {
    border-color: var(--fun-primary) !important;
    animation: nodeGlow 2s ease-in-out infinite;
}

@keyframes nodeGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(124, 77, 255, 0.2); }
    50% { box-shadow: 0 0 25px rgba(124, 77, 255, 0.4); }
}

/* ---------- Fun Toast / Notification ---------- */
.ps-toast, .toast-notification {
    border-radius: var(--fun-radius-lg) !important;
    font-weight: 600 !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    border: 2px solid var(--fun-border) !important;
    animation: toastSlide 0.5s var(--fun-bounce) !important;
}

@keyframes toastSlide {
    from { transform: translateY(-20px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- Fun Training Mode ---------- */
#train-question-area {
    border-radius: var(--fun-radius-xl) !important;
    border: 2px solid var(--fun-border) !important;
    box-shadow: var(--fun-shadow) !important;
}

.train-option-btn {
    border-radius: var(--fun-radius) !important;
    border: 3px solid var(--fun-border) !important;
    transition: all 0.3s var(--fun-bounce) !important;
    font-weight: 600 !important;
    padding: 1rem 1.5rem !important;
}

.train-option-btn:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: var(--fun-primary-light);
    box-shadow: var(--fun-shadow-hover);
}

.train-option-btn.correct {
    border-color: var(--fun-green) !important;
    background: rgba(0, 230, 118, 0.1) !important;
    animation: correctPop 0.5s var(--fun-bounce);
}

.train-option-btn.wrong {
    border-color: var(--fun-pink) !important;
    background: rgba(255, 64, 129, 0.1) !important;
    animation: wrongShake 0.5s ease;
}

@keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ---------- Fun Progress / Review Cards ---------- */
.review-item, .quest-item {
    border-radius: var(--fun-radius) !important;
    border: 2px solid var(--fun-border) !important;
    padding: 1rem !important;
    transition: all 0.3s var(--fun-bounce) !important;
    margin-bottom: 0.5rem;
}

.review-item:hover, .quest-item:hover {
    transform: translateX(4px);
    border-color: var(--fun-primary-light);
}

/* ---------- Fun Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px !important;
}

::-webkit-scrollbar-track {
    background: rgba(124, 77, 255, 0.05) !important;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--grad-primary) !important;
    border-radius: 10px !important;
}

/* ---------- Level Up Animation ---------- */
@keyframes levelUp {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.level-up-anim {
    animation: levelUp 0.8s var(--fun-bounce) forwards;
}

/* ---------- Confetti-like sparkle ---------- */

}

/* ---------- Fun Badge Styles ---------- */
.badge-item {
    border-radius: var(--fun-radius-lg) !important;
    border: 3px solid var(--fun-border);
    padding: 1.25rem;
    text-align: center;
    transition: all 0.4s var(--fun-bounce);
    position: relative;
}

.badge-item:hover {
    transform: rotate(-3deg) scale(1.05);
    box-shadow: var(--fun-shadow-glow);
}

.badge-item .badge-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: badgeFloat 3s ease-in-out infinite;
}

@keyframes badgeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ---------- Fun Walkthrough ---------- */
.walkthrough-container {
    border-radius: var(--fun-radius-xl) !important;
    border: 3px solid var(--fun-border) !important;
    box-shadow: var(--fun-shadow) !important;
    overflow: hidden;
}

.walkthrough-progress-bar {
    height: 8px !important;
    border-radius: var(--fun-radius-pill) !important;
    background: rgba(124, 77, 255, 0.1) !important;
}

.walkthrough-progress-fill {
    background: var(--grad-primary) !important;
    border-radius: var(--fun-radius-pill) !important;
    transition: width 0.6s var(--fun-bounce) !important;
}

/* ---------- Fun Modal ---------- */
.modal-content {
    border-radius: var(--fun-radius-xl) !important;
    border: 2px solid var(--fun-border) !important;
    box-shadow: 0 20px 60px rgba(124, 77, 255, 0.2) !important;
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 768px) {
    .ps-navbar {
        padding: 0 12px !important;
    }
}

/* ---------- Fun Loading Spinner ---------- */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(124, 77, 255, 0.2);
    border-top-color: var(--fun-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Emoji Reactions ---------- */
.emoji-reaction {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    z-index: 9999;
    animation: emojiFloat 2s ease-out forwards;
}

@keyframes emojiFloat {
    0% { transform: translateY(0) scale(0.5); opacity: 1; }
    100% { transform: translateY(-150px) scale(1.5); opacity: 0; }
}

/* ---------- Fun Streak Counter ---------- */
.streak-fire {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--grad-fire);
    border-radius: var(--fun-radius-pill);
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    animation: fireGlow 1.5s ease-in-out infinite;
}

@keyframes fireGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 107, 53, 0.3); }
    50% { box-shadow: 0 0 25px rgba(255, 107, 53, 0.6); }
}

/* ---------- Fun "Correct!" Overlay ---------- */
.correct-overlay {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    background: var(--grad-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: correctBurst 1s var(--fun-bounce) forwards;
    z-index: 9999;
    pointer-events: none;
}

@keyframes correctBurst {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ---------- Particle Effects (CSS-only) ---------- */
.particle {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: particleFly 1.5s ease-out forwards;
}

@keyframes particleFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ==========================================================================
   ENHANCED FUN STYLES — v2
   ========================================================================== */

/* ---------- Skill Tree Section Headers ---------- */
.skill-tree-section h5,
.skill-tree h5,
h5[style*="color"],
.mq-card h5 {
    font-weight: 900 !important;
    font-size: 0.85rem !important;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    background: var(--grad-magic);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    padding-left: 12px;
}

.skill-tree-section h5::before,
.mq-card h5::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--grad-primary);
    border-radius: 4px;
}

/* ---------- Enhanced Topic Nodes (Skill Tree Cards) ---------- */
.topic-node {
    background: var(--node-bg) !important;
    border-radius: 20px !important;
    border: 2px solid var(--card-border) !important;
    padding: 1.2rem 1rem !important;
    box-shadow: 0 4px 16px rgba(124, 77, 255, 0.08) !important;
    transition: all 0.35s var(--fun-bounce) !important;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.topic-node::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 4px;
    border-radius: 4px;
    background: var(--grad-primary);
    transition: all 0.3s var(--fun-bounce);
}

.topic-node:hover {
    transform: translateY(-4px) scale(1.04) !important;
    border-color: var(--fun-primary-light) !important;
    box-shadow: 0 8px 30px rgba(124, 77, 255, 0.2) !important;
}

.topic-node:hover::before {
    width: 90%;
    left: 5%;
    height: 5px;
}

.topic-node.mastered {
    border-color: rgba(0, 230, 118, 0.3) !important;
}

body:not(.dark-mode) .topic-node.mastered {
    background: linear-gradient(145deg, #ffffff, #f0fff4) !important;
}

.topic-node.mastered::before {
    background: var(--grad-success) !important;
}

/* (topic-node dark mode — handled in unified section below) */

/* Topic node title */
.topic-node .topic-name,
.topic-node strong,
.topic-node a {
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    color: var(--node-title-color, #2d2d44) !important;
}

/* (topic-node text dark mode — handled in unified section below) */

/* Topic mastery status text */
.topic-node .topic-status,
.topic-node small {
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Card Header / "Дерево навыков" Title ---------- */
.mq-card .card-header {
    background: var(--grade-bg) !important;
    border-bottom: 1px solid var(--card-border) !important;
    padding: 1rem 1.5rem !important;
    border-radius: var(--fun-radius-lg) var(--fun-radius-lg) 0 0 !important;
}

.mq-card .card-header h4,
.mq-card .card-header h5 {
    font-weight: 800 !important;
    font-size: 1.1rem !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Fun Level Rows ---------- */
.level-section,
.skill-tree-level {
    padding: 1rem 0;
    border-bottom: 1px dashed rgba(124, 77, 255, 0.1);
    position: relative;
}

.level-section:last-child,
.skill-tree-level:last-child {
    border-bottom: none;
}

/* Level label styling */
.level-label,
.level-section > h5:first-child,
.skill-tree-level > h5:first-child {
    font-size: 0.7rem !important;
    font-weight: 800 !important;
    letter-spacing: 2px !important;
    text-transform: uppercase;
    color: var(--text-secondary, #9f8fcc) !important;
    margin-bottom: 12px;
    padding: 4px 12px;
    background: rgba(124, 77, 255, 0.06);
    border-radius: var(--fun-radius-pill);
    display: inline-block;
}

/* ---------- Fun Mascot Spacing Fix (Bottom-Left) ---------- */
.fun-mascot {
    z-index: 9990;
}

/* (dark mode for cards — moved to unified section below) */

/* ---------- Topic nodes staggered entrance ---------- */
.topic-node {
    animation: nodeAppear 0.5s var(--fun-bounce) both;
}

.topic-node:nth-child(1) { animation-delay: 0.1s; }
.topic-node:nth-child(2) { animation-delay: 0.15s; }
.topic-node:nth-child(3) { animation-delay: 0.2s; }
.topic-node:nth-child(4) { animation-delay: 0.25s; }
.topic-node:nth-child(5) { animation-delay: 0.3s; }
.topic-node:nth-child(6) { animation-delay: 0.35s; }

@keyframes nodeAppear {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Floating accent decorations ---------- */
.mq-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(124, 77, 255, 0.08), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* ---------- Progress bar inside topic nodes ---------- */
.topic-node .progress,
.topic-node .progress-bar {
    border-radius: var(--fun-radius-pill) !important;
    height: 6px !important;
}

.topic-node .progress {
    background: rgba(124, 77, 255, 0.1) !important;
}

.topic-node .progress-bar {
    background: var(--grad-primary) !important;
}

.topic-node.mastered .progress-bar {
    background: var(--grad-success) !important;
}

/* ============================================================================
   COMPREHENSIVE DARK MODE + PREMIUM CARD SYSTEM — v3.0
   All elements properly themed for light/dark with no conflicts
   ============================================================================ */

/* ---------- Missing CSS Variables (used by train.js, etc.) ---------- */
:root {
    --bg-card: #ffffff;
    --bg-input: #f8f9ff;
    --border: #e5e7eb;
    --accent: #6C63FF;
    --success: #00C9A7;
    --success-bg: #f0fdf4;
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --card-bg: rgba(255, 255, 255, 0.88);
    --card-border: rgba(124, 77, 255, 0.1);
    --card-shadow: 0 4px 20px rgba(124, 77, 255, 0.06);
    --card-shadow-hover: 0 12px 40px rgba(124, 77, 255, 0.15);
    --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --node-bg: rgba(255, 255, 255, 0.85);
    --node-title-color: #2d2d44;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --panel-color: #475569;
    --label-color: #8b8ba8;
    --grade-color: #7c4dff;
    --grade-bg: linear-gradient(90deg, rgba(124, 77, 255, 0.06), transparent);
    --badge-item-bg: rgba(124, 77, 255, 0.03);
    --badge-item-border: rgba(124, 77, 255, 0.06);
    --progress-track: rgba(124, 77, 255, 0.08);
    --mascot-bg: #ffffff;
    --modal-bg: #ffffff;
    --toast-bg: #ffffff;
    --code-bg: #f0f0f5;
    --error-bg: #fef2f2;
    --warning-bg: #fef3c7;
    --warning-color: #92400E;
}

body.dark-mode {
    --bg-card: #1e1440;
    --bg-input: #241a4a;
    --border: rgba(124, 77, 255, 0.2);
    --accent: #b388ff;
    --success: #00e676;
    --success-bg: rgba(0, 230, 118, 0.08);
    --text-primary: #e8e0ff;
    --text-secondary: #a89cc8;
    --card-bg: rgba(25, 18, 50, 0.88);
    --card-border: rgba(124, 77, 255, 0.18);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 12px 40px rgba(124, 77, 255, 0.2);
    --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --node-bg: rgba(25, 18, 50, 0.88);
    --node-title-color: #e8e0ff;
    --panel-bg: rgba(25, 18, 50, 0.85);
    --panel-color: #c4b8e8;
    --label-color: #9a8fc4;
    --grade-color: #b388ff;
    --grade-bg: linear-gradient(90deg, rgba(124, 77, 255, 0.12), transparent);
    --badge-item-bg: rgba(124, 77, 255, 0.06);
    --badge-item-border: rgba(124, 77, 255, 0.12);
    --progress-track: rgba(124, 77, 255, 0.15);
    --mascot-bg: #1e1440;
    --modal-bg: #1a1035;
    --toast-bg: #1e1440;
    --code-bg: #1e1440;
    --error-bg: rgba(239, 68, 68, 0.08);
    --warning-bg: rgba(245, 158, 11, 0.08);
    --warning-color: #fbbf24;
}

/* ---------- Skill Tree Node Cards (.skill-node from app.js) ---------- */
.skill-node {
    background: var(--node-bg) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 16px !important;
    padding: 1rem 1.2rem !important;
    min-width: 140px;
    max-width: 180px;
    box-shadow: var(--card-shadow), var(--card-inset) !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skill-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #7c4dff, #448aff, #7c4dff);
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.skill-node::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.02), rgba(68, 138, 255, 0.01));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.skill-node:hover {
    transform: translateY(-6px) scale(1.03) !important;
    border-color: rgba(124, 77, 255, 0.3) !important;
    box-shadow: var(--card-shadow-hover), var(--card-inset) !important;
}

.skill-node:hover::before {
    opacity: 1;
    animation: gradientSlide 2s linear infinite;
}

.skill-node:hover::after {
    opacity: 1;
}

@keyframes gradientSlide {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Status-based skill nodes */
.skill-node.node-mastered {
    border-color: rgba(0, 201, 167, 0.25) !important;
}

body:not(.dark-mode) .skill-node.node-mastered {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(224, 255, 240, 0.6)) !important;
}

body.dark-mode .skill-node.node-mastered {
    background: linear-gradient(145deg, rgba(25, 18, 50, 0.88), rgba(0, 60, 35, 0.25)) !important;
    border-color: rgba(0, 201, 167, 0.3) !important;
}

.skill-node.node-mastered::before {
    background: linear-gradient(90deg, #00c9a7, #00e676, #00c9a7) !important;
    background-size: 200% 100%;
    opacity: 1;
}

.skill-node.node-progress {
    border-color: rgba(124, 77, 255, 0.2) !important;
    animation: progressPulse 3s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { box-shadow: var(--card-shadow); }
    50% { box-shadow: 0 4px 16px rgba(124, 77, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.04); }
}

.skill-node.node-available {
    border: 1px dashed rgba(124, 77, 255, 0.2) !important;
}

.skill-node.node-remediation {
    border-color: rgba(255, 152, 0, 0.25) !important;
}

body:not(.dark-mode) .skill-node.node-remediation {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 225, 0.4)) !important;
}

body.dark-mode .skill-node.node-remediation {
    background: linear-gradient(145deg, rgba(25, 18, 50, 0.88), rgba(60, 40, 0, 0.15)) !important;
}

.skill-node.node-remediation::before {
    background: linear-gradient(90deg, #ff9800, #ffb74d, #ff9800) !important;
    background-size: 200% 100%;
    opacity: 1;
}

.skill-node.node-paused {
    opacity: 0.55;
    filter: grayscale(0.3);
}

.skill-node.node-paused:hover {
    opacity: 0.85;
    filter: grayscale(0);
}

/* Skill node inner elements */
.skill-node .node-title {
    font-weight: 700 !important;
    font-size: 0.82rem !important;
    color: var(--node-title-color) !important;
    line-height: 1.3;
}

.skill-node .node-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: auto;
}

.skill-node .node-meta .badge {
    font-size: 0.6rem !important;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.skill-node .node-mastery .progress {
    background: var(--progress-track) !important;
    border-radius: 4px !important;
    height: 4px !important;
    overflow: hidden;
}

/* Staggered entrance for skill nodes */
.skill-node {
    animation: skillNodeAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.skill-node:nth-child(1) { animation-delay: 0.05s; }
.skill-node:nth-child(2) { animation-delay: 0.1s; }
.skill-node:nth-child(3) { animation-delay: 0.15s; }
.skill-node:nth-child(4) { animation-delay: 0.2s; }
.skill-node:nth-child(5) { animation-delay: 0.25s; }
.skill-node:nth-child(6) { animation-delay: 0.3s; }
.skill-node:nth-child(7) { animation-delay: 0.35s; }
.skill-node:nth-child(8) { animation-delay: 0.4s; }

@keyframes skillNodeAppear {
    from { opacity: 0; transform: translateY(16px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- PREMIUM mq-card ---------- */
.mq-card {
    background: var(--card-bg) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 24px !important;
    box-shadow: var(--card-shadow), var(--card-inset) !important;
    overflow: hidden;
    transition: all 0.3s ease !important;
}

.mq-card:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(124, 77, 255, 0.08) !important;
}

body.dark-mode .mq-card:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(124, 77, 255, 0.15) !important;
}

.mq-card .card-header {
    background: var(--grade-bg) !important;
    border-bottom: 1px solid var(--card-border) !important;
    padding: 1.1rem 1.5rem !important;
}

.mq-card .card-header h5 {
    font-weight: 800 !important;
    font-size: 0.95rem !important;
    letter-spacing: 0.3px;
}

.mq-card .card-body {
    padding: 1.5rem !important;
}

/* ---------- Grade/Level Headers ---------- */
.grade-header {
    font-weight: 800 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--grade-color) !important;
    padding: 8px 16px;
    margin-bottom: 12px;
    background: var(--grade-bg) !important;
    border-left: 3px solid var(--grade-color);
    border-radius: 0 8px 8px 0;
    display: inline-block;
}

/* ---------- Expandable Panel Content ---------- */
#panel-quests .card-body,
#panel-reviews .card-body,
#panel-badges .card-body,
#panel-activity .card-body {
    padding: 1.2rem 1.5rem !important;
}

.badge-item, .quest-item, .review-item, .activity-item {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--badge-item-bg);
    border: 1px solid var(--badge-item-border);
    margin-bottom: 8px;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.badge-item:hover, .quest-item:hover, .review-item:hover, .activity-item:hover {
    background: rgba(124, 77, 255, 0.06);
    transform: translateX(4px);
}

body.dark-mode .badge-item:hover,
body.dark-mode .quest-item:hover,
body.dark-mode .review-item:hover,
body.dark-mode .activity-item:hover {
    background: rgba(124, 77, 255, 0.1);
}

/* ---------- DARK MODE: Training Mode ---------- */
body.dark-mode #train-question-area {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .train-option-btn {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .train-option-btn:hover {
    background: rgba(124, 77, 255, 0.08) !important;
    border-color: var(--fun-primary-light) !important;
}

body.dark-mode .train-option-btn.correct {
    background: rgba(0, 230, 118, 0.1) !important;
    border-color: var(--fun-green) !important;
    color: #a7f3d0 !important;
}

body.dark-mode .train-option-btn.wrong {
    background: rgba(255, 64, 129, 0.1) !important;
    border-color: var(--fun-pink) !important;
    color: #fca5a5 !important;
}

/* ---------- DARK MODE: Modal ---------- */
body.dark-mode .modal-content {
    background: var(--modal-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .modal-header {
    border-bottom-color: var(--border) !important;
}

body.dark-mode .modal-footer {
    border-top-color: var(--border) !important;
}

/* ---------- DARK MODE: Toast / Notification ---------- */
body.dark-mode .ps-toast,
body.dark-mode .toast-notification {
    background: var(--toast-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

/* ---------- DARK MODE: Mascot Speech Bubble ---------- */
body.dark-mode #fun-mascot .mascot-speech,
body.dark-mode .mascot-speech {
    background: var(--mascot-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

/* ---------- DARK MODE: Empty State ---------- */
body.dark-mode .empty-state {
    color: var(--text-secondary) !important;
}

body.dark-mode .empty-state p {
    color: var(--text-secondary) !important;
}

/* ---------- DARK MODE: Code Blocks ---------- */
body.dark-mode code,
body.dark-mode pre {
    background: var(--code-bg) !important;
    color: #e8e0ff !important;
    border-color: var(--border) !important;
}

/* ---------- DARK MODE: Inline badges from JS ---------- */
body.dark-mode .skill-node .node-meta .badge,
body.dark-mode .badge:not(.ps-course-badge) {
    border: 1px solid rgba(124, 77, 255, 0.15);
}

/* ---------- DARK MODE: Card text/paragraph ---------- */
body.dark-mode .mq-card,
body.dark-mode .mq-card p,
body.dark-mode .mq-card span,
body.dark-mode .mq-card li {
    color: var(--text-primary) !important;
}

body.dark-mode .mq-card .card-header h4,
body.dark-mode .mq-card .card-header h5 {
    color: #e8e0ff !important;
    -webkit-text-fill-color: unset !important;
    background: none !important;
}

body.dark-mode .mq-card .card-header h5::before {
    background: linear-gradient(135deg, #b388ff, #7c4dff) !important;
}

/* ---------- DARK MODE: General Text ---------- */
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 {
    color: var(--text-primary) !important;
}

body.dark-mode p, body.dark-mode span, body.dark-mode li,
body.dark-mode td, body.dark-mode th, body.dark-mode label {
    color: var(--text-primary);
}

/* ---------- DARK MODE: Links ---------- */
body.dark-mode a:not(.btn):not(.ps-nav-item):not([data-panel]):not(.ps-course-btn) {
    color: var(--fun-primary-light) !important;
}

/* ---------- DARK MODE: Inputs & Forms ---------- */
body.dark-mode input, body.dark-mode textarea, body.dark-mode select {
    background: var(--bg-input) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: var(--text-secondary) !important;
}

/* ---------- DARK MODE: Bootstrap Tables ---------- */
body.dark-mode .table {
    color: var(--text-primary) !important;
}

body.dark-mode .table > :not(caption) > * > * {
    background-color: transparent !important;
    border-bottom-color: var(--border) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .table-hover > tbody > tr:hover > * {
    background-color: rgba(124, 77, 255, 0.05) !important;
}

/* ---------- DARK MODE: Scrollbar ---------- */
body.dark-mode ::-webkit-scrollbar-track {
    background: rgba(124, 77, 255, 0.03) !important;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #5c35cc, #7c4dff) !important;
}

/* ---------- DARK MODE: Various small elements ---------- */
body.dark-mode .stat-card .stat-icon {
    filter: drop-shadow(0 2px 6px rgba(124, 77, 255, 0.3));
}

/* xp-bar dark mode handled via --progress-track variable */

/* ---------- DARK MODE: Walkthrough Cards ---------- */
body.dark-mode .walkthrough-container {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
}

body.dark-mode .wt-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* ---------- DARK MODE: Dropdown/Select Menus ---------- */
body.dark-mode .dropdown-menu {
    background: var(--modal-bg) !important;
    border-color: var(--border) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .dropdown-item {
    color: var(--text-primary) !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
    background: rgba(124, 77, 255, 0.08) !important;
    color: var(--fun-primary-light) !important;
}

/* ---------- DARK MODE: Buttons (general) ---------- */
body.dark-mode .btn-outline-primary {
    color: var(--fun-primary-light) !important;
    border-color: var(--fun-primary-light) !important;
}

body.dark-mode .btn-outline-primary:hover {
    background: rgba(124, 77, 255, 0.15) !important;
    color: #fff !important;
}

body.dark-mode .btn-light {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

/* ---------- DARK MODE: .mastered-count text ---------- */
body.dark-mode #mastered-count {
    color: var(--text-secondary) !important;
}

/* ---------- DARK MODE: Activity list items ---------- */
body.dark-mode #activity-list p,
body.dark-mode #reviews-container p,
body.dark-mode #quests-container p,
body.dark-mode #badges-container p {
    color: var(--text-secondary) !important;
}

/* ---------- DARK MODE: Topic node (.topic-node) overrides ---------- */
body.dark-mode .topic-node {
    background: var(--node-bg) !important;
    border-color: var(--card-border) !important;
    box-shadow: var(--card-shadow) !important;
}

body.dark-mode .topic-node .topic-name,
body.dark-mode .topic-node strong,
body.dark-mode .topic-node a {
    color: var(--node-title-color) !important;
}

body.dark-mode .topic-node .topic-status,
body.dark-mode .topic-node small {
    color: var(--text-secondary) !important;
}

body.dark-mode .topic-node.mastered {
    background: linear-gradient(145deg, rgba(25, 18, 50, 0.88), rgba(0, 60, 35, 0.25)) !important;
    border-color: rgba(0, 201, 167, 0.3) !important;
}

body.dark-mode .topic-node .progress {
    background: var(--progress-track) !important;
}

/* ---------- DARK MODE: Body and general page ---------- */
body.dark-mode {
    color: var(--text-primary) !important;
}

body.dark-mode #app {
    color: var(--text-primary);
}

/* ---------- DARK MODE: Inline style overrides via CSS ---------- */
/* Buttons with inline bg styles (from dashboard.php) */
/* (inline panel button styles removed — using .panel-btn class) */

/* ---------- DARK MODE: PS (PersonalStudy) nav items ---------- */
body.dark-mode .ps-nav-item {
    color: var(--text-secondary) !important;
}

body.dark-mode .ps-nav-item:hover {
    color: var(--fun-primary-light) !important;
    background: rgba(124, 77, 255, 0.08) !important;
}

body.dark-mode .ps-nav-item.active {
    color: #fff !important;
}

/* ---------- DARK MODE: Avatar border ---------- */
body.dark-mode .ps-avatar {
    border-color: rgba(124, 77, 255, 0.4) !important;
}

/* ---------- Mobile Responsiveness ---------- */
@media (max-width: 768px) {
    .skill-node {
        min-width: 120px !important;
        max-width: 160px;
        padding: 0.9rem 1rem !important;
    }

    .mq-card {
        border-radius: 18px !important;
    }
}

/* --- Navbar dark mode border & shadow --- */
body.dark-mode .ps-navbar {
    border-bottom-color: rgba(124, 77, 255, 0.15) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3) !important;
}

/* --- Shimmer visibility in dark mode --- */
body.dark-mode .stat-card::before {
    background: conic-gradient(from 0deg, transparent, rgba(124, 77, 255, 0.12), transparent) !important;
}

/* ============================================================================
   AI PERSONALIZATION INDICATORS
   Subtle cues that the system is adaptive & intelligent
   ============================================================================ */

/* --- AI Status Pill (top-right of dashboard, always visible) --- */

/* --- AI Insight Strip (below stats, shows personalization signals) --- */

@keyframes insightAppear {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

body.dark-mode 

/* --- "For You" / AI-Picked Badge --- */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.08), rgba(68, 138, 255, 0.06));
    border: 1px solid rgba(124, 77, 255, 0.12);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7C4DFF;
    white-space: nowrap;
}

body.dark-mode .ai-badge {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.15), rgba(68, 138, 255, 0.1));
    color: #B388FF;
}

.ai-badge::before {
    content: '✦';
    font-size: 0.55rem;
    animation: sparkle 2s ease-in-out infinite;
}

}

/* --- Adaptive Difficulty Indicator (on skill nodes / lessons) --- */
.adaptive-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.adaptive-indicator.difficulty-easy {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.adaptive-indicator.difficulty-medium {
    background: rgba(255, 152, 0, 0.1);
    color: #FF9800;
    border: 1px solid rgba(255, 152, 0, 0.2);
}

.adaptive-indicator.difficulty-hard {
    background: rgba(244, 67, 54, 0.1);
    color: #F44336;
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.adaptive-indicator .adapt-icon {
    font-size: 0.7rem;
}

/* --- AI Processing Overlay (shows briefly when AI recalculates) --- */
.ai-processing {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid rgba(124, 77, 255, 0.15);
    box-shadow: 0 8px 30px rgba(124, 77, 255, 0.12);
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--text-secondary);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ai-processing.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ai-processing .ai-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(124, 77, 255, 0.2);
    border-top-color: #7C4DFF;
    animation: aiSpin 0.8s linear infinite;
}

@keyframes aiSpin {
    to { transform: rotate(360deg); }
}

/* --- Stat Card AI Sparkle (corner indicator showing adaptive value) --- */
.stat-card .ai-adapted {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.1), rgba(0, 229, 255, 0.08));
    color: #7C4DFF;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover .ai-adapted {
    opacity: 1;
    transform: scale(1);
}

.stat-card .ai-adapted::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 1px solid rgba(124, 77, 255, 0.2);
    animation: aiRing 2s ease-in-out infinite;
}

/* --- Personalized Path Glow (on recommended next step) --- */
.ai-recommended {
    position: relative;
}

.ai-recommended::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: linear-gradient(135deg, #7C4DFF, #00E5FF, #7C4DFF);
    background-size: 200% 200%;
    animation: aiGlow 3s ease-in-out infinite;
    opacity: 0.15;
    z-index: -1;
}

}

/* --- Learning Style Tag --- */

/* ============================================================================
   AI PERSONALIZATION INDICATORS
   Subtle cues that the system is adaptive & intelligent
   ============================================================================ */

/* --- AI Status Pill (top-right of dashboard, always visible) --- */

/* --- AI Insight Strip (below stats, shows personalization signals) --- */

@keyframes insightAppear {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

body.dark-mode 

/* --- "For You" / AI-Picked Badge --- */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.08), rgba(68, 138, 255, 0.06));
    border: 1px solid rgba(124, 77, 255, 0.12);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7C4DFF;
    white-space: nowrap;
}

body.dark-mode .ai-badge {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.15), rgba(68, 138, 255, 0.1));
    color: #B388FF;
}

.ai-badge::before {
    content: '✦';
    font-size: 0.55rem;
    animation: sparkle 2s ease-in-out infinite;
}

}

/* --- Adaptive Difficulty Indicator (on skill nodes / lessons) --- */
.adaptive-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.adaptive-indicator.difficulty-easy {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.adaptive-indicator.difficulty-medium {
    background: rgba(255, 152, 0, 0.1);
    color: #FF9800;
    border: 1px solid rgba(255, 152, 0, 0.2);
}

.adaptive-indicator.difficulty-hard {
    background: rgba(244, 67, 54, 0.1);
    color: #F44336;
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.adaptive-indicator .adapt-icon {
    font-size: 0.7rem;
}

/* --- AI Processing Overlay (shows briefly when AI recalculates) --- */
.ai-processing {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid rgba(124, 77, 255, 0.15);
    box-shadow: 0 8px 30px rgba(124, 77, 255, 0.12);
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--text-secondary);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ai-processing.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ai-processing .ai-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(124, 77, 255, 0.2);
    border-top-color: #7C4DFF;
    animation: aiSpin 0.8s linear infinite;
}

@keyframes aiSpin {
    to { transform: rotate(360deg); }
}

/* --- Stat Card AI Sparkle (corner indicator showing adaptive value) --- */
.stat-card .ai-adapted {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.1), rgba(0, 229, 255, 0.08));
    color: #7C4DFF;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover .ai-adapted {
    opacity: 1;
    transform: scale(1);
}

.stat-card .ai-adapted::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 1px solid rgba(124, 77, 255, 0.2);
    animation: aiRing 2s ease-in-out infinite;
}

/* --- Personalized Path Glow (on recommended next step) --- */
.ai-recommended {
    position: relative;
}

.ai-recommended::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: linear-gradient(135deg, #7C4DFF, #00E5FF, #7C4DFF);
    background-size: 200% 200%;
    animation: aiGlow 3s ease-in-out infinite;
    opacity: 0.15;
    z-index: -1;
}

}

/* --- Learning Style Tag --- */

/* Dark mode text overrides for stat cards */
body.dark-mode .stat-card .stat-label {
    color: #c4b5d0;
}

body.dark-mode 
