/* ===================================================
   FINLEARN — Premium Financial Learning Platform
   Refined · Layered · Motion-forward
   =================================================== */

/* ── Design Tokens ── */
:root {
    /* Background — deep, layered */
    --bg-primary: #0a0b0f;
    --bg-secondary: #12141a;
    --bg-card: #16181f;
    --bg-card-hover: #1c1f28;
    --bg-sidebar: #0d0e13;
    --bg-overlay: rgba(6, 7, 10, 0.85);
    --bg-glass: rgba(22, 24, 31, 0.7);

    /* Text — cool slate, refined hierarchy */
    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --text-muted: #4a4f60;
    --text-faint: #2a2d38;

    /* Accent — electric amber */
    --accent-primary: #f0a500;
    --accent-secondary: #ff6b35;
    --accent-primary-dim: rgba(240, 165, 0, 0.10);
    --accent-primary-border: rgba(240, 165, 0, 0.25);

    /* Borders — subtle definition */
    --border-color: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(255, 255, 255, 0.10);
    --border-active: rgba(240, 165, 0, 0.4);

    /* Module accent colors — curated */
    --mod-1: #5b8def;
    --mod-2: #4ec9a0;
    --mod-3: #f0a500;
    --mod-4: #b07ce8;
    --mod-5: #e87ca0;
    --mod-6: #e87c7c;
    --mod-7: #4ec9d4;
    --mod-8: #f0a050;
    --mod-9: #c8e04a;
    --mod-10: #4ac9e8;

    /* Tag colors */
    --tag-core-bg: rgba(91, 141, 239, 0.12);
    --tag-core-text: #5b8def;
    --tag-expanded-bg: rgba(78, 201, 160, 0.12);
    --tag-expanded-text: #4ec9a0;
    --tag-practice-bg: rgba(240, 165, 0, 0.12);
    --tag-practice-text: #f0a500;
    --tag-trend-bg: rgba(176, 124, 232, 0.12);
    --tag-trend-text: #b07ce8;
    --tag-futu-bg: rgba(74, 201, 232, 0.12);
    --tag-futu-text: #4ac9e8;

    /* Typography */
    --font-display: 'Newsreader', 'Georgia', serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Menlo', monospace;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;
    --sp-20: 80px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(240, 165, 0, 0.15);

    /* Transitions */
    --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --t-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f5f6fa;
    --bg-secondary: #eceef5;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f6fa;
    --bg-sidebar: #eceef5;
    --text-primary: #0f1117;
    --text-secondary: #5a6070;
    --text-muted: #9098a8;
    --text-faint: #d0d4e0;
    --border-color: rgba(15, 17, 23, 0.08);
    --border-hover: rgba(15, 17, 23, 0.15);
    --border-active: rgba(240, 165, 0, 0.5);
    --accent-primary: #c8860a;
    --accent-primary-dim: rgba(200, 134, 10, 0.08);
    --accent-primary-border: rgba(200, 134, 10, 0.2);
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-overlay: rgba(237, 239, 245, 0.88);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection { background: var(--accent-primary-dim); color: var(--text-primary); }

/* ── App Shell ── */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ══════════════════════════════════════════
   HEADER — Glassy, minimal, commanding
   ══════════════════════════════════════════ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-8);
    height: 64px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
}

/* ── Logo ── */
.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    text-decoration: none;
    transition: opacity var(--t-fast);
}
.logo:hover { opacity: 0.75; }

.logo-mark {
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(240, 165, 0, 0.3));
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.logo-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── Search ── */
.header-center {
    flex: 1;
    max-width: 400px;
    margin: 0 var(--sp-8);
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px var(--sp-3);
    transition: all var(--t-base);
}

.search-box:focus-within {
    border-color: var(--accent-primary-border);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
    background: var(--bg-card);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-body);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    flex-shrink: 0;
}

/* ── Header Buttons ── */
.header-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 7px var(--sp-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-base);
}

.header-btn:hover {
    border-color: var(--accent-primary-border);
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.header-btn-icon {
    padding: 7px 9px;
}

/* ── Progress Compact ── */
.progress-compact {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.progress-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-track {
    width: 100px;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 99px;
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(240, 165, 0, 0.4);
}

.progress-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-primary);
    font-weight: 600;
    min-width: 32px;
}

/* ══════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════ */
.main-layout {
    display: flex;
    flex: 1;
}

/* ── Sidebar ── */
.sidebar {
    width: 256px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    overflow-y: auto;
    flex-shrink: 0;
    padding: var(--sp-5) 0;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--sp-2);
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: all var(--t-fast);
}

.sidebar-toggle:hover { color: var(--accent-primary); }

.sidebar-nav { padding: 0 var(--sp-3); }

.nav-section { margin-bottom: var(--sp-2); }

.nav-section-title {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: var(--sp-3) var(--sp-2) var(--sp-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 9px var(--sp-3);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--t-base);
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0;
    background: var(--accent-primary);
    border-radius: 0 2px 2px 0;
    transition: height var(--t-base);
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    padding-left: calc(var(--sp-3) + 4px);
}

.nav-item.active {
    color: var(--accent-primary);
    font-weight: 600;
    background: var(--accent-primary-dim);
}

.nav-item.active::before { height: 60%; }

.nav-item.completed { color: var(--text-muted); }

.nav-item-icon {
    font-size: 15px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}

.nav-item-check {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
}

.nav-item.completed .nav-item-check { color: var(--accent-primary); }

/* ══════════════════════════════════════════
   CONTENT AREA
   ══════════════════════════════════════════ */
.content {
    flex: 1;
    padding: var(--sp-12) var(--sp-16);
    overflow-y: auto;
    min-width: 0;
}

.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }

.view {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ══════════════════════════════════════════
   HOME VIEW — Editorial, commanding
   ══════════════════════════════════════════ */
.home-intro {
    max-width: 640px;
    margin-bottom: var(--sp-16);
    padding-top: var(--sp-4);
}

.home-intro-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.home-intro-meta::before {
    content: '';
    width: 20px;
    height: 1px;
    background: var(--accent-primary);
}

.home-intro-title {
    font-family: var(--font-display);
    font-size: 52px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: var(--sp-6);
}

.home-intro-title em {
    font-style: italic;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-intro-desc {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
    max-width: 520px;
    margin-bottom: var(--sp-8);
}

.home-meta-row {
    display: flex;
    gap: var(--sp-8);
}

.meta-pill {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all var(--t-base);
}

.meta-pill:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.meta-num {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.meta-lbl {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

/* ── Section Labels ── */
.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ── Learning Path ── */
.learning-path {
    margin-bottom: var(--sp-16);
}

.path-stages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
}

.stage {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: var(--sp-6);
    border-radius: 12px;
    position: relative;
    transition: all var(--t-base);
    overflow: hidden;
}

.stage::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--stage-color, var(--accent-primary)), transparent);
    opacity: 0;
    transition: opacity var(--t-base);
}

.stage[data-stage="1"] { --stage-color: var(--mod-1); }
.stage[data-stage="2"] { --stage-color: var(--mod-3); }
.stage[data-stage="3"] { --stage-color: var(--mod-4); }

.stage:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stage:hover::before { opacity: 1; }

.stage-eyebrow {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: var(--sp-3);
}

.stage-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stage-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: var(--sp-5);
}

.stage-bar {
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 99px;
    overflow: hidden;
}

.stage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--stage-color, var(--accent-primary)), var(--accent-primary));
    border-radius: 99px;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(var(--stage-color), 0.3);
}

.path-connector {
    display: none;
}

/* ── Modules Grid ── */
.modules-section {
    margin-bottom: var(--sp-12);
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--sp-4);
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: var(--sp-6);
    cursor: pointer;
    transition: all var(--t-base);
    position: relative;
    overflow: hidden;
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--accent-primary));
    opacity: 0;
    transition: opacity var(--t-base);
}

.module-card:hover {
    border-color: var(--card-accent, var(--accent-primary));
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3), 0 0 20px color-mix(in srgb, var(--card-accent, var(--accent-primary)) 15%, transparent);
}

.module-card:hover::before { opacity: 1; }

/* Module accent color */
.module-card[data-module="1"] { --card-accent: var(--mod-1); }
.module-card[data-module="2"] { --card-accent: var(--mod-2); }
.module-card[data-module="3"] { --card-accent: var(--mod-3); }
.module-card[data-module="4"] { --card-accent: var(--mod-4); }
.module-card[data-module="5"] { --card-accent: var(--mod-5); }
.module-card[data-module="6"] { --card-accent: var(--mod-6); }
.module-card[data-module="7"] { --card-accent: var(--mod-7); }
.module-card[data-module="8"] { --card-accent: var(--mod-8); }
.module-card[data-module="9"] { --card-accent: var(--mod-9); }
.module-card[data-module="10"] { --card-accent: var(--mod-10); }

.module-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
}

.module-card-icon {
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.module-card-progress {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 3px 8px;
    border-radius: 99px;
    border: 1px solid var(--border-color);
}

.module-card-num {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--card-accent, var(--accent-primary));
    margin-bottom: var(--sp-2);
}

.module-card-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: var(--sp-3);
    letter-spacing: -0.01em;
}

.module-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: var(--sp-5);
}

.module-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border-color);
}

.module-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.topic-tag {
    font-size: 10px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 99px;
    color: var(--text-muted);
    transition: all var(--t-fast);
    border: 1px solid transparent;
}

.topic-tag:hover {
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border-color: var(--accent-primary-border);
}

.module-card-arrow {
    font-size: 16px;
    color: var(--text-faint);
    transition: all var(--t-base);
}

.module-card:hover .module-card-arrow {
    color: var(--card-accent, var(--accent-primary));
    transform: translateX(4px);
}

/* ══════════════════════════════════════════
   MODULE DETAIL VIEW
   ══════════════════════════════════════════ */
.module-header {
    margin-bottom: var(--sp-8);
    padding-bottom: var(--sp-6);
    border-bottom: 1px solid var(--border-color);
}

.module-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: var(--sp-5);
    cursor: pointer;
    transition: color var(--t-fast);
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.module-breadcrumb:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary-border);
    background: var(--accent-primary-dim);
}

.module-hero {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-6);
}

.module-hero-icon {
    font-size: 48px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

.module-hero-info { flex: 1; min-width: 0; }

.module-hero-num {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--sp-2);
}

.module-hero-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: var(--sp-3);
    line-height: 1.2;
}

.module-hero-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.8;
    max-width: 680px;
    margin-bottom: var(--sp-6);
}

.module-hero-progress {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.module-hero-progress-bar {
    flex: 1;
    max-width: 200px;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 99px;
    overflow: hidden;
}

.module-hero-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-hero-progress-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

/* ── Knowledge Sections ── */
.knowledge-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: var(--sp-3);
    overflow: hidden;
    transition: border-color var(--t-base);
}

.knowledge-section:hover {
    border-color: var(--border-hover);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    cursor: pointer;
    transition: background var(--t-fast);
    gap: var(--sp-4);
}

.section-header:hover { background: var(--bg-card-hover); }

.section-header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex: 1;
    min-width: 0;
}

.section-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.section-count {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 99px;
}

.section-toggle {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--t-base);
    flex-shrink: 0;
    display: flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.section-toggle.open {
    transform: rotate(180deg);
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
}

.section-body {
    display: none;
    padding: 0 var(--sp-6) var(--sp-4);
    border-top: 1px solid var(--border-color);
}

.section-body.open {
    display: block;
    animation: sectionOpen 0.3s ease;
}

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

/* ── Knowledge Items ── */
.knowledge-item {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--t-base);
    border-radius: 8px;
    margin: 0 calc(-1 * var(--sp-2));
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
}

.knowledge-item:last-child { border-bottom: none; }

.knowledge-item:hover {
    padding-left: var(--sp-4);
    background: var(--bg-card-hover);
}

.knowledge-item-check {
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--border-hover);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: all var(--t-spring);
    color: transparent;
    background: var(--bg-secondary);
}

.knowledge-item.checked .knowledge-item-check {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
    color: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(240, 165, 0, 0.3);
}

.knowledge-item-content { flex: 1; min-width: 0; }

.knowledge-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.knowledge-item-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.knowledge-item-tag {
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 99px;
    font-weight: 500;
    flex-shrink: 0;
}

.tag-core { background: var(--tag-core-bg); color: var(--tag-core-text); }
.tag-expanded { background: var(--tag-expanded-bg); color: var(--tag-expanded-text); }
.tag-practice { background: var(--tag-practice-bg); color: var(--tag-practice-text); }
.tag-trend { background: var(--tag-trend-bg); color: var(--tag-trend-text); }
.tag-futu { background: var(--tag-futu-bg); color: var(--tag-futu-text); }

/* ══════════════════════════════════════════
   MODAL — Glassy, animated
   ══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8);
}

.modal-overlay.active {
    display: flex;
    animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-6);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all var(--t-fast);
    display: flex;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-6);
    line-height: 1.8;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }

.modal-body h4 {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    margin: var(--sp-5) 0 var(--sp-3);
    letter-spacing: 0.03em;
}

.modal-body h4:first-child { margin-top: 0; }

.modal-body ul {
    padding-left: var(--sp-5);
    margin: var(--sp-2) 0;
}

.modal-body li { margin: var(--sp-2) 0; }

.modal-body p { margin: var(--sp-2) 0; }

.modal-body .highlight-text {
    background: var(--accent-primary-dim);
    padding: var(--sp-4) var(--sp-5);
    border-radius: 10px;
    border-left: 3px solid var(--accent-primary);
    margin: var(--sp-5) 0;
    font-size: 14px;
    color: var(--text-primary);
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--sp-4) 0;
    font-size: 12px;
}

.modal-body th,
.modal-body td {
    padding: 10px var(--sp-4);
    border: 1px solid var(--border-color);
    text-align: left;
}

.modal-body th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.modal-indicator {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
    padding: 8px var(--sp-5);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: var(--font-body);
    transition: all var(--t-base);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(240, 165, 0, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(240, 165, 0, 0.35);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ══════════════════════════════════════════
   SEARCH RESULTS
   ══════════════════════════════════════════ */
.search-results-header {
    margin-bottom: var(--sp-8);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-color);
}

.search-heading {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.search-heading span { color: var(--accent-primary); }

#searchCount {
    font-size: 12px;
    color: var(--text-muted);
}

.search-result-item {
    padding: var(--sp-5) var(--sp-6);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: var(--sp-3);
    cursor: pointer;
    transition: all var(--t-base);
}

.search-result-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.search-result-module {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: var(--sp-2);
}

.search-result-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.search-result-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.search-no-results {
    text-align: center;
    padding: var(--sp-16) 0;
    color: var(--text-muted);
}

.search-no-results .icon {
    font-size: 40px;
    margin-bottom: var(--sp-4);
    opacity: 0.5;
}

/* ══════════════════════════════════════════
   ANIMATIONS — Staggered entrance
   ══════════════════════════════════════════ */
.animate-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
.stagger-children > * {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.10s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.15s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.20s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.25s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.30s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.35s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.40s; }
.stagger-children.visible > *:nth-child(9) { transition-delay: 0.45s; }
.stagger-children.visible > *:nth-child(10) { transition-delay: 0.50s; }
.stagger-children.visible > * { opacity: 1; transform: translateY(0); }

/* Pulse glow for accent elements */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(240, 165, 0, 0.2); }
    50% { box-shadow: 0 0 16px rgba(240, 165, 0, 0.4); }
}

.pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }

/* Float animation for icons */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.float { animation: float 3s ease-in-out infinite; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1200px) {
    .content { padding: var(--sp-10) var(--sp-10); }
    .modules-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 64px;
        z-index: 90;
        height: calc(100vh - 64px);
        width: 260px;
        transition: left var(--t-base);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .content { padding: var(--sp-8) var(--sp-8); }
    .header-center { display: none; }
    .modules-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
    .path-stages { grid-template-columns: 1fr; gap: var(--sp-3); }
}

@media (max-width: 768px) {
    .header { padding: 0 var(--sp-5); height: 56px; }
    .sidebar { top: 56px; height: calc(100vh - 56px); }
    .content { padding: var(--sp-6) var(--sp-5); }
    .home-intro-title { font-size: 36px; }
    .home-meta-row { gap: var(--sp-4); flex-wrap: wrap; }
    .meta-pill { padding: var(--sp-3) var(--sp-4); }
    .meta-num { font-size: 24px; }
    .logo-text { display: none; }
    .progress-compact { display: none; }
    .module-hero { flex-direction: column; }
    .module-hero-icon { font-size: 36px; }
    .module-hero-title { font-size: 26px; }
    .modal { max-height: 92vh; border-radius: 12px; }
    .modal-overlay { padding: var(--sp-4); }
}

@media (max-width: 480px) {
    .home-intro-title { font-size: 28px; }
    .modules-grid { grid-template-columns: 1fr; }
    .path-stages { gap: var(--sp-2); }
}
